hi, I have a problem with webrtc in android and ios devices. Sometimes I don’t have a voice. Have a different cases. ios: have voice android: no voice or ios: no voice android: have voice or ios: no voice and android: no voice. I don’t no why. Can you can help me please?
Handle invite
`async handleInvite(data) {
let {
local,
callID,
sdp,
conferenceId,
caller_id_name,
caller_id_number,
verto_h_caller_domain
} = data;
if (local) return;
const isDND = await this.dispatch(getDnd());
const pc = getPeerConnection();
global.connections[callID] = pc;
console.log("INCOMMING: ", data);
console.log("WEBRTC_INCOMING_CALL_CALLID: ", callID, AppState.currentState);
if (this.calls) {
console.log(“WEBRTC_INCOMING_CALL_HANGUP”);
global.verto.hangup(callID);
return;
}
this.calls = callID;
if (isDND) {
global.verto.hangup(callID);
return;
}
global.hasCall = callID;
const user = await this.dispatch(
getUserFromState(caller_id_number, verto_h_caller_domain)
);
console.log("USER: ", user);
const domain = await this.dispatch(getDomainFromState());
console.log("DOMAIN: ", domain);
console.log("PC_CONNECTIONS: ", Object.keys(global.connections));
console.log(“WEBRTC_SDP_INVITE: “, sdp);
const sdpArray = sdp.split(”\r\n”);
const mAudio = sdpArray.filter(_ => _.indexOf(“m=audio”) + 1)[0];
sdp = sdp.replace(
mAudio,
a=group:BUNDLE audio\r\n${mAudio}\r\na=mid:audio
);
await pc
.setRemoteDescription(
new RTCSessionDescription({
type: “offer”,
sdp
})
)
.catch(error => {
this.handleCallError({ callID, error });
});
const desc = await pc.createAnswer({
mandatory: {
OfferToReceiveVideo: false,
OfferToReceiveAudio: true
}
});
await pc.setLocalDescription({ type: “pranswer”, sdp: desc.sdp });
RNCallKit.displayIncomingCall(
callID,
${caller_id_number}${ domain !== verto_h_caller_domain && verto_h_caller_domain ?
@{verto_h_caller_domain}`
: ""
}`,
"",
false,
user
? user.name
: `{caller_id_number}{
domain !== verto_h_caller_domain && verto_h_caller_domain
? `@{verto_h_caller_domain}: "" }
);
// setTimeout(() => {
navService.navigate(“Webrtc”, {
callID,
type: “incoming”,
via: caller_id_number.length > 4 ? caller_id_name : “”,
caller_id_name: user ? user.name : “”,
caller_id_number: ${caller_id_number}${ domain !== verto_h_caller_domain && verto_h_caller_domain ?
@${verto_h_caller_domain}: "" }
});
// }, 1500);
// Delete this line on release
// this.answer(callID);
// -------------->
this.dispatch(
receiveCall({
callID,
conferenceId,
caller_id_name,
caller_id_number: ${caller_id_number}${ domain !== verto_h_caller_domain ?
@{verto_h_caller_domain}` : ""
}`,
type: "incomming"
})
);
this.emit(`call.invite.{callID}`, { callID });
pc.ontrack = event => {
const stream = event.streams[0];
this.emit(“call.stream”, { callID, stream });
this.emit(call.stream.${callID}
, { callID, stream });
};
pc.onaddstream = event => {
const stream = event.stream;
this.emit(“call.stream”, { callID, stream });
this.emit(call.stream.${callID}
, { callID, stream });
};
}`
Answer button action
`async answer(
callID,
{
calleeIdName,
calleeIdNumber,
vertoFunc = “answer”,
conferenceId,
caller_id_number
} = {}
) {
console.log("WEBRTC_ANSWER_CALLID: ", callID);
const pc = global.connections[callID];
if (!pc) {
this.hangup(callID);
}
console.log("WEBRTC_VERTO_ANSWER_REQUEST: ", pc.localDescription);
// this.dispatch(setAnsweredCall(callID));
global.androidBgCall = false;
this.dispatch(setAnsweredCall(callID));
const stream = await mediaDevices
.getUserMedia({
audio: true,
video: false
})
.catch(error => {
this.handleCallError({ callID, error });
});
console.log("GETMEDIAUSER: ");
this.dispatch(setStreamToCall({ callID, stream }));
global.stream = stream;
this.emit(“call.localStream”, { callID, stream });
this.emit(call.localStream.${callID}
, { callID, stream });
pc.addStream(stream);
this.once(verto.bye.${callID}
, () => {
stopMediaStream(stream);
});
// await pc.waitForCandidates(1000);
const desc = await pc.createAnswer({
mandatory: {
OfferToReceiveVideo: false,
OfferToReceiveAudio: true
}
});
await pc.setLocalDescription({ type: “answer”, sdp: desc.sdp });
console.log("WEBRTC_ANSWER_SDP: ", pc.localDescription.sdp);
// await pc.setRemoteDescription({ type: “answer”, sdp: desc.sdp });
this.request(verto.${vertoFunc}
, {
sessid: this.sessid,
sdp: pc.localDescription.sdp,
dialogParams: {
callID,
callee_id_name: calleeIdName,
callee_id_number: calleeIdNumber
}
})
.then(res => {
if (vertoFunc === “attach”) {
return;
}
global.voiceCome = true;
console.log("WEBRTC_VERTO_ANSWER_RESPONSE: ", res);
})
.catch(error => {
this.handleCallError({ callID, error });
});
this.emit(call.localSDP
, {
callID,
sdp: pc.localDescription.sdp
});
this.emit(call.localSDP.${callID}
, {
callID,
sdp: pc.localDescription.sdp
});
}`
Makecall action
`async makeCall(destination, { caller_id_name, _uuid } = {}) {
if (this.mySip === destination) return;
global.hasCall = true;
const callID = uuid.v4() || _uuid;
console.log("WEBRTC_OUTGOING_CALLID: ", callID);
let callStream = {};
const pc = getPeerConnection();
const stream = await mediaDevices.getUserMedia({
audio: true,
video: false
});
callStream = stream;
this.emit(“call.localStream”, { callID, stream });
this.emit(call.localStream.${callID}
, { callID, stream });
pc.addStream(stream);
this.once(verto.bye.${callID}
, () => {
stopMediaStream(stream);
});
let offer = await pc.createOffer({
mandatory: {
OfferToReceiveVideo: false,
OfferToReceiveAudio: true
}
});
await pc.setLocalDescription(offer);
// pc.waitForCandidates(1000);
offer = await pc.createOffer({
mandatory: {
OfferToReceiveVideo: false,
OfferToReceiveAudio: true
}
});
// await pc.setRemoteDescription(offer);
console.log(“WEBRTC_SDP_OFFER: “, offer);
const response = await this.request(“verto.invite”, {
sessid: this.sessid,
sdp: offer.sdp,
dialogParams: {
callID,
caller_id_name: caller_id_name,
caller_id_number: this.mySip,
destination_number: destination
}
}).catch(error => {
this.handleCallError({ callID, error });
});
const domain = await this.dispatch(getDomainFromState());
console.log(“DOMAIN: “, domain);
const user = await this.dispatch(
getUserFromState(
destination.split(”@”)[0],
destination.split(”@”)[1] || domain
)
);
console.log(
“USER: “,
user,
destination.split(”@”)[0],
destination.split("@")[1]
);
try {
RNCallKit.startCall(
response.callID,
destination,
“”,
false,
user ? user.name : destination
);
} catch (error) {
console.log(“START CALL ERROR : “, error);
}
this.once(call.sdp.${response.callID}
, async message => {
const sdpArray = message.sdp.split(”\r\n”);
const mAudio = sdpArray.filter(_ => _.indexOf(“m=audio”) + 1)[0];
global.voiceCome = true;
message.sdp = message.sdp.replace(
mAudio,
a=group:BUNDLE audio\r\n${mAudio}\r\na=mid:audio
);
console.log("RESPONSE ANSWER: ", message.sdp);
await pc.setRemoteDescription(
new RTCSessionDescription({ type: “answer”, sdp: message.sdp })
);
});
console.log("RESSSS: ", response);
global.connections[response.callID] = pc;
global.hasCall = response.callID;
navService.navigate(“Webrtc”, {
callID: response.callID,
type: “outgoing”,
caller_id_number: destination
});
// RNCallKit.startCall(response.callID, destination);
this.calls = response.callID;
global.stream = callStream;
if (response.message === “CALL CREATED”) {
this.dispatch(
receiveCall({
callID: response.callID,
caller_id_number: destination,
type: “outgoing”,
stream: callStream
})
);
}
pc.ontrack = event => {
const stream = event.streams[0];
this.emit(“call.stream”, { callID, stream });
this.emit(call.stream.${callID}
, { callID, stream });
};
pc.onaddstream = event => {
const stream = event.stream;
this.emit(“call.stream”, { callID, stream });
this.emit(call.stream.${callID}
, { callID, stream });
};
return callID;
}`
SDP IOS if no voice
"v=0 o=- 1822018477258816126 3 IN IP4 127.0.0.1 s=- t=0 0 a=group:BUNDLE audio a=msid-semantic: WMS C7313A28-13A1-4066-A13D-299B27455E7B m=audio 54940 RTP/SAVPF 0 8 c=IN IP4 212.220.116.80 a=rtcp:9 IN IP4 0.0.0.0 a=candidate:3348172935 1 udp 2122260223 192.168.88.63 54940 typ host generation 0 network-id 1 network-cost 10 a=candidate:2355873909 1 udp 2122194687 169.254.67.228 59328 typ host generation 0 network-id 2 network-cost 10 a=candidate:4245544955 1 udp 2122131711 2a00:1fa2:4297:f8d8:407b:d973:c1bc:7e01 59329 typ host generation 0 network-id 6 network-cost 900 a=candidate:531856355 1 udp 2122063615 10.63.74.82 58229 typ host generation 0 network-id 5 network-cost 900 a=candidate:1188632115 1 udp 1686052607 212.220.116.80 54940 typ srflx raddr 192.168.88.63 rport 54940 generation 0 network-id 1 network-cost 10 a=candidate:2299718775 1 tcp 1518280447 192.168.88.63 53912 typ host tcptype passive generation 0 network-id 1 network-cost 10 a=candidate:3269997701 1 tcp 1518214911 169.254.67.228 53913 typ host tcptype passive generation 0 network-id 2 network-cost 10 a=candidate:3012436747 1 tcp 1518151935 2a00:1fa2:4297:f8d8:407b:d973:c1bc:7e01 53914 typ host tcptype passive generation 0 network-id 6 network-cost 900 a=candidate:1362134803 1 tcp 1518083839 10.63.74.82 53915 typ host tcptype passive generation 0 network-id 5 network-cost 900 a=candidate:3068982326 1 udp 1685855999 213.87.249.202 15257 typ srflx raddr 10.63.74.82 rport 58229 generation 0 network-id 5 network-cost 900 a=ice-ufrag:t3pk a=ice-pwd:oyvFgXDW/+2CZ8pUc+ip32Ig a=ice-options:trickle renomination a=fingerprint:sha-256 7D:54:70:0C:08:CD:71:1D:1C:D9:B7:01:DD:75:80:80:CB:23:73:3A:B1:2F:2D:07:03:46:30:34:FF:E0:11:2E a=setup:active a=mid:audio a=sendrecv a=rtcp-mux a=rtpmap:0 PCMU/8000 a=rtpmap:8 PCMA/8000 a=ssrc:2600604789 cname:zYyYxhkeCOHEuGBW a=ssrc:2600604789 msid:C7313A28-13A1-4066-A13D-299B27455E7B 821D713F-CF85-49C6-B664-3E13117EF15B a=ssrc:2600604789 mslabel:C7313A28-13A1-4066-A13D-299B27455E7B a=ssrc:2600604789 label:821D713F-CF85-49C6-B664-3E13117EF15B "
SDP Android if no voice
"v=0 o=- 4050888940492126763 3 IN IP4 127.0.0.1 s=- t=0 0 a=group:BUNDLE audio a=msid-semantic: WMS e97a9a89-84a7-4baa-82b2-7c63da73b7c5 m=audio 39141 UDP/TLS/RTP/SAVPF 111 103 9 102 0 8 105 13 110 113 126 c=IN IP4 212.220.116.80 a=rtcp:9 IN IP4 0.0.0.0 a=candidate:3838975051 1 udp 2122260223 192.168.88.146 39141 typ host generation 0 network-id 3 network-cost 10 a=candidate:842163049 1 udp 1686052607 212.220.116.80 39141 typ srflx raddr 192.168.88.146 rport 39141 generation 0 network-id 3 network-cost 10 a=ice-ufrag:Up3j a=ice-pwd:mriN9N1bqIpumV8jhV8/pcZA a=ice-options:trickle renomination a=fingerprint:sha-256 C7:FF:DB:95:5F:8E:40:E7:C5:6E:80:F4:EA:F1:0D:12:83:F7:CF:D6:A7:5D:56:97:95:37:DF:C5:D1:9B:78:3F a=setup:actpass a=mid:audio a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level a=sendrecv a=rtcp-mux a=rtpmap:111 opus/48000/2 a=rtcp-fb:111 transport-cc a=fmtp:111 minptime=10;useinbandfec=1 a=rtpmap:103 ISAC/16000 a=rtpmap:9 G722/8000 a=rtpmap:102 ILBC/8000 a=rtpmap:0 PCMU/8000 a=rtpmap:8 PCMA/8000 a=rtpmap:105 CN/16000 a=rtpmap:13 CN/8000 a=rtpmap:110 telephone-event/48000 a=rtpmap:113 telephone-event/16000 a=rtpmap:126 telephone-event/8000 a=ssrc:64865771 cname:zHTQXfcR7e32xtH1 a=ssrc:64865771 msid:e97a9a89-84a7-4baa-82b2-7c63da73b7c5 bfe4be6f-030b-463f-8c8f-b0e3894d7f73 a=ssrc:64865771 mslabel:e97a9a89-84a7-4baa-82b2-7c63da73b7c5 a=ssrc:64865771 label:bfe4be6f-030b-463f-8c8f-b0e3894d7f73 "
React Native version: 0.59
Plugin version: 1.69.1
OS: Ios: 12.2 android: 8.1