Skip to content

Commit

Permalink
Fix double offer for voice chats
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeny-nadymov committed Apr 8, 2021
1 parent 68a8561 commit af281d9
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/Stores/CallStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -464,15 +464,15 @@ class CallStore extends EventEmitter {
description.updateFromServer(data);
const sdp = description.generateSdp();

LOG_CALL(`[conn][updateGroupCallParticipants] setRemoteDescription participantsCount=${participants.length} signaling=${connection.signalingState} ice=${connection.iceConnectionState} gathering=${connection.iceGatheringState} connection=${connection.connectionState}`, sdp);
LOG_CALL(`[conn][updateGroupCallParticipants][sdp] setRemoteDescription participantsCount=${participants.length} signaling=${connection.signalingState} ice=${connection.iceConnectionState} gathering=${connection.iceGatheringState} connection=${connection.connectionState}`, sdp);
await connection.setRemoteDescription({
type: 'offer',
sdp,
});

LOG_CALL(`[conn][updateGroupCallParticipants] createAnswer id=${groupCallId}`, ts);
const answer = await connection.createAnswer();
LOG_CALL(`[conn][updateGroupCallParticipants] setLocalDescription id=${groupCallId}`, ts);
LOG_CALL(`[conn][updateGroupCallParticipants][sdp] createAnswer setLocalDescription id=${groupCallId}`, ts, answer.sdp);
await connection.setLocalDescription(answer);
} finally {
LOG_CALL(`updateGroupCallParticipants id=${groupCallId} updateSdp finish`, ts);
Expand Down Expand Up @@ -759,18 +759,18 @@ class CallStore extends EventEmitter {
offerToReceiveVideo: 0,
};
let offer = await connection.createOffer(offerOptions);
LOG_CALL('[conn][joinGroupCallInternal] setLocalDescription', offer);
LOG_CALL('[conn][joinGroupCallInternal][sdp] setLocalDescription', offer.sdp);
await connection.setLocalDescription(offer);
let clientInfo = parseSdp(offer.sdp);
let { ufrag, pwd, hash, setup, fingerprint, source } = clientInfo;
LOG_CALL('[conn][joinGroupCallInternal] clientInfo', clientInfo);


offer = await connection.createOffer(offerOptions);
LOG_CALL('[conn][joinGroupCallInternal] setLocalDescription', offer);
await connection.setLocalDescription(offer);
clientInfo = parseSdp(offer.sdp);
LOG_CALL('[conn][joinGroupCallInternal] clientInfo', clientInfo);
// offer = await connection.createOffer(offerOptions);
// LOG_CALL('[conn][joinGroupCallInternal][sdp] setLocalDescription', offer.sdp);
// await connection.setLocalDescription(offer);
// clientInfo = parseSdp(offer.sdp);
// LOG_CALL('[conn][joinGroupCallInternal] clientInfo', clientInfo);

currentGroupCall.meSignSource = toTelegramSource(source);

Expand Down Expand Up @@ -887,7 +887,7 @@ class CallStore extends EventEmitter {
description.updateFromServer(data1);
const sdp1 = description.generateSdp(true);

LOG_CALL(`[conn][joinGroupCallInternal] setRemoteDescription signaling=${connection.signalingState} ice=${connection.iceConnectionState} gathering=${connection.iceGatheringState} connection=${connection.connectionState}`, sdp1);
LOG_CALL(`[conn][joinGroupCallInternal][sdp] setRemoteDescription signaling=${connection.signalingState} ice=${connection.iceConnectionState} gathering=${connection.iceGatheringState} connection=${connection.connectionState}`, sdp1);
await connection.setRemoteDescription({
type: 'answer',
sdp: sdp1,
Expand Down Expand Up @@ -1989,6 +1989,7 @@ class CallStore extends EventEmitter {

if (!isAnswer) {
const answer = await connection.createAnswer();
console.log('[sdp] local', answer.sdp);
await connection.setLocalDescription(answer);

// LOG_P2P_CALL('2 try invoke p2pAppendInputStream', inputStream, is_outgoing);
Expand Down

0 comments on commit af281d9

Please sign in to comment.