Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e2ee: also enable on p2p connections #1107

Merged
merged 2 commits into from
Apr 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
47 changes: 31 additions & 16 deletions JitsiConference.js
Original file line number Diff line number Diff line change
Expand Up @@ -1113,8 +1113,6 @@ JitsiConference.prototype._setupNewTrack = function(newTrack) {
newTrack._setConference(this);

this.eventEmitter.emit(JitsiConferenceEvents.TRACK_ADDED, newTrack);

this._setupSenderE2EEForTrack(newTrack);
};

/**
Expand Down Expand Up @@ -1694,6 +1692,14 @@ JitsiConference.prototype.onRemoteTrackAdded = function(track) {
JitsiConference.prototype.onCallAccepted = function(session, answer) {
if (this.p2pJingleSession === session) {
logger.info('P2P setAnswer');

// Setup E2EE.
const localTracks = this.getLocalTracks();

for (const track of localTracks) {
this._setupSenderE2EEForTrack(session, track);
}

this.p2pJingleSession.setAnswer(answer);
}
};
Expand Down Expand Up @@ -1873,7 +1879,7 @@ JitsiConference.prototype._acceptJvbIncomingCall = function(

// Setup E2EE.
for (const track of localTracks) {
this._setupSenderE2EEForTrack(track);
this._setupSenderE2EEForTrack(jingleSession, track);
}
},
error => {
Expand Down Expand Up @@ -2633,6 +2639,11 @@ JitsiConference.prototype._acceptP2PIncomingCall = function(
jingleOffer,
() => {
logger.debug('Got RESULT for P2P "session-accept"');

// Setup E2EE.
for (const track of localTracks) {
this._setupSenderE2EEForTrack(jingleSession, track);
}
},
error => {
logger.error(
Expand Down Expand Up @@ -3320,17 +3331,17 @@ JitsiConference.prototype.setE2EEKey = function(key) {
*
* @returns {void}
*/
JitsiConference.prototype._setupSenderE2EEForTrack = function(track) {
const jvbPc = this.jvbJingleSession ? this.jvbJingleSession.peerconnection : null;

if (jvbPc && this._e2eeCtx) {
const sender = jvbPc.findSenderForTrack(track.track);
JitsiConference.prototype._setupSenderE2EEForTrack = function(session, track) {
if (!this._e2eeCtx) {
return;
}
const pc = session.peerconnection;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We ccould use geetActiveTPC` here as well instead of passsing the session around.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but I want the peerconnection the track is received on, no matter what the current establishment status of the p2p ice connection is?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is taken care of by caller function already, isn't it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, this is called from JitsiConference.prototype.onCallAccepted (line 1701) for p2p and JitsiConference.prototype._acceptJvbIncomingCall for the sfu call. In both cases we know exactly where this is originating

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, gotcha.

const sender = pc.findSenderForTrack(track.track);

if (sender) {
this._e2eeCtx.handleSender(sender, track.getType());
} else {
logger.warn(`Could not handle E2EE for local ${track.getType()} track: sender not found`);
}
if (sender) {
this._e2eeCtx.handleSender(sender, track.getType());
} else {
logger.warn(`Could not handle E2EE for local ${track.getType()} track: sender not found`);
}
};

Expand All @@ -3341,10 +3352,14 @@ JitsiConference.prototype._setupSenderE2EEForTrack = function(track) {
* @returns {void}
*/
JitsiConference.prototype._setupReceiverE2EEForTrack = function(track) {
const jvbPc = this.jvbJingleSession ? this.jvbJingleSession.peerconnection : null;
if (!this._e2eeCtx) {
return;
}
const session = track.isP2P ? this.p2pJingleSession : this.jvbJingleSession;
const pc = session && session.peerconnection;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use getActiveTPC instead


if (jvbPc && this._e2eeCtx) {
const receiver = jvbPc.findReceiverForTrack(track.track);
if (pc) {
const receiver = pc.findReceiverForTrack(track.track);

if (receiver) {
this._e2eeCtx.handleReceiver(receiver, track.getType());
Expand Down
2 changes: 1 addition & 1 deletion modules/RTC/RTC.js
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ export default class RTC extends Listenable {

// FIXME: We should rename iceConfig to pcConfig.

if (!isP2P && browser.supportsInsertableStreams()) {
if (browser.supportsInsertableStreams()) {
logger.debug('E2EE - setting insertable streams constraints');
iceConfig.forceEncodedAudioInsertableStreams = true;
iceConfig.forceEncodedVideoInsertableStreams = true;
Expand Down