Skip to content

Commit

Permalink
Remove DATACHANNEL flag
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeny-nadymov committed Apr 23, 2021
1 parent ce576f1 commit 96b0f6e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 34 deletions.
5 changes: 5 additions & 0 deletions src/Components/Calls/CallPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ class CallPanel extends React.Component {
};

handleClose = () => {
if (this.isFullScreen()) {
this.exitFullscreen();
return;
}

this.handleDiscard(null);
};

Expand Down
7 changes: 4 additions & 3 deletions src/Components/Calls/GroupCallSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,16 @@ class GroupCallSettings extends React.Component {
closeStreams() {
const { inputAudioStream, inputAudioDeviceId, inputVideoStream, inputVideoDeviceId } = this.state;
if (inputAudioStream) {
if (!CallStore.currentGroupCall || !CallStore.currentCall || inputAudioDeviceId === CallStore.getInputAudioDeviceId()) {
if (!CallStore.currentGroupCall && !CallStore.currentCall || inputAudioDeviceId === CallStore.getInputAudioDeviceId()) {
inputAudioStream.getAudioTracks().forEach(x => {
x.stop();
});
}
}

if (inputVideoStream) {
if (!CallStore.currentGroupCall || !CallStore.currentCall || inputVideoDeviceId === CallStore.getInputVideoDeviceId()) {
inputVideoStream.getAudioTracks().forEach(x => {
if (!CallStore.currentGroupCall && !CallStore.currentCall || inputVideoDeviceId === CallStore.getInputVideoDeviceId()) {
inputVideoStream.getVideoTracks().forEach(x => {
x.stop();
});
}
Expand Down
51 changes: 20 additions & 31 deletions src/Stores/CallStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import P2PEncryptor from '../Calls/P2P/P2PEncryptor';
const JOIN_TRACKS = true;
const UNIFY_SDP = true;
const UNIFY_CANDIDATE = true;
const DATACHANNEL = true;
const TG_CALLS = true;
const TG_CALLS_MEDIA_STATE = true;
const TG_CALLS_SDP = true;
Expand Down Expand Up @@ -1725,32 +1724,28 @@ class CallStore extends EventEmitter {
}

p2pCreateChannel(connection) {
if (DATACHANNEL) {
const channel = connection.createDataChannel('data', {
id: 0,
negotiated: true
});
channel.onmessage = e => {
LOG_P2P_CALL('[channel] onmessage', e);
const { data } = e;
this.p2pApplyCallDataChannelData(JSON.parse(data));
};
channel.onopen = () => {
const { currentCall } = this;
if (!currentCall) return;

const { callId } = currentCall;
const channel = connection.createDataChannel('data', {
id: 0,
negotiated: true
});
channel.onmessage = e => {
LOG_P2P_CALL('[channel] onmessage', e);
const { data } = e;
this.p2pApplyCallDataChannelData(JSON.parse(data));
};
channel.onopen = () => {
const { currentCall } = this;
if (!currentCall) return;

const mediaState = this.p2pGetMediaState(callId, 'input');
if (!mediaState) return;
const { callId } = currentCall;

this.p2pSendMediaState(callId, mediaState);
};
const mediaState = this.p2pGetMediaState(callId, 'input');
if (!mediaState) return;

return channel;
}
this.p2pSendMediaState(callId, mediaState);
};

return null;
return channel;
}

async p2pJoinCall(callId) {
Expand Down Expand Up @@ -1933,9 +1928,7 @@ class CallStore extends EventEmitter {
const { connection } = currentCall;
if (!connection) return;

if (DATACHANNEL) {
currentCall.channel = this.p2pCreateChannel(connection);
}
currentCall.channel = this.p2pCreateChannel(connection);

const senders = connection.getSenders();
if (senders.some(x => x.track)) return;
Expand Down Expand Up @@ -2180,11 +2173,7 @@ class CallStore extends EventEmitter {
p2pSendMediaIsMuted(callId, kind, isMuted) {
LOG_P2P_CALL('p2pSendMediaIsMuted', callId, kind, isMuted);

if (DATACHANNEL) {
this.p2pSendDataChannelData(JSON.stringify({ type: 'media', kind, isMuted }));
} else {
this.p2pSendCallSignalingData(callId, JSON.stringify({ type: 'media', kind, isMuted }));
}
this.p2pSendDataChannelData(JSON.stringify({ type: 'media', kind, isMuted }));
}

p2pSendMediaState(callId, mediaState) {
Expand Down

0 comments on commit 96b0f6e

Please sign in to comment.