Sdp overhaul (#1234)

* M1: device change now uses new flow.  fundamentally "works" but may be corner cases/side effects to other flows. haven't touched ffox yet

* M2: change toggle screenshare flows to use the new video replacement chain

* remove the old 'useVideoStream' and replace it with the new one

* use the new (and renamed back from the shim) 'dispose' method

* tweaks to work with the sdp overhaul changes in lib-jitsi-meet

* change the order in which we call dispose (to handle dispose being reverted back to how it is currently on master)

* move useAudioStream over to new flow

* restore useVideoStream doc

* handle rename JitsiConference::replaceStream -> JitsiConference::replaceTrack

* fix useAudioStream and useVideoStream to return a promise again
This commit is contained in:
bbaldino 2017-01-19 12:46:11 -06:00 committed by hristoterezov
parent 343d17d19a
commit 5baa167a08
1 changed files with 56 additions and 61 deletions

View File

@ -901,43 +901,40 @@ export default {
return options; return options;
}, },
/**
* Start using provided video stream.
* Stops previous video stream.
* @param {JitsiLocalTrack} [stream] new stream to use or null
* @returns {Promise}
*/
useVideoStream (stream) {
let promise = Promise.resolve();
if (localVideo) {
// this calls room.removeTrack internally
// so we don't need to remove it manually
promise = localVideo.dispose();
}
localVideo = stream;
return promise.then(function () { /**
if (stream) { * Start using provided video stream.
return room.addTrack(stream); * Stops previous video stream.
} * @param {JitsiLocalTrack} [stream] new stream to use or null
}).then(() => { * @returns {Promise}
if (stream) { */
this.videoMuted = stream.isMuted(); useVideoStream (newStream) {
this.isSharingScreen = stream.videoType === 'desktop'; return room.replaceTrack(localVideo, newStream)
.then(() => {
// We call dispose after doing the replace because
// dispose will try and do a new o/a after the
// track removes itself. Doing it after means
// the JitsiLocalTrack::conference member is already
// cleared, so it won't try and do the o/a
if (localVideo) {
localVideo.dispose();
}
localVideo = newStream;
if (newStream) {
this.videoMuted = newStream.isMuted();
this.isSharingScreen = newStream.videoType === 'desktop';
APP.UI.addLocalStream(stream); APP.UI.addLocalStream(newStream);
stream.videoType === 'camera' newStream.videoType === 'camera'
&& APP.UI.setCameraButtonEnabled(true); && APP.UI.setCameraButtonEnabled(true);
} else { } else {
this.videoMuted = false; this.videoMuted = false;
this.isSharingScreen = false; this.isSharingScreen = false;
} }
APP.UI.setVideoMuted(this.getMyUserId(), this.videoMuted);
APP.UI.setVideoMuted(this.getMyUserId(), this.videoMuted); APP.UI.updateDesktopSharingButtons();
});
APP.UI.updateDesktopSharingButtons();
});
}, },
/** /**
@ -946,31 +943,27 @@ export default {
* @param {JitsiLocalTrack} [stream] new stream to use or null * @param {JitsiLocalTrack} [stream] new stream to use or null
* @returns {Promise} * @returns {Promise}
*/ */
useAudioStream (stream) { useAudioStream (newStream) {
let promise = Promise.resolve(); return room.replaceTrack(localAudio, newStream)
if (localAudio) { .then(() => {
// this calls room.removeTrack internally // We call dispose after doing the replace because
// so we don't need to remove it manually // dispose will try and do a new o/a after the
promise = localAudio.dispose(); // track removes itself. Doing it after means
} // the JitsiLocalTrack::conference member is already
localAudio = stream; // cleared, so it won't try and do the o/a
if (localAudio) {
return promise.then(function () { localAudio.dispose();
if (stream) { }
return room.addTrack(stream); localAudio = newStream;
} if (newStream) {
}).then(() => { this.audioMuted = newStream.isMuted();
if (stream) { APP.UI.addLocalStream(newStream);
this.audioMuted = stream.isMuted(); } else {
this.audioMuted = false;
APP.UI.addLocalStream(stream); }
} else { APP.UI.setMicrophoneButtonEnabled(true);
this.audioMuted = false; APP.UI.setAudioMuted(this.getMyUserId(), this.audioMuted);
} });
APP.UI.setMicrophoneButtonEnabled(true);
APP.UI.setAudioMuted(this.getMyUserId(), this.audioMuted);
});
}, },
videoSwitchInProgress: false, videoSwitchInProgress: false,
@ -1344,11 +1337,13 @@ export default {
this.deviceChangeListener); this.deviceChangeListener);
// stop local video // stop local video
if (localVideo) if (localVideo) {
localVideo.dispose(); localVideo.dispose();
}
// stop local audio // stop local audio
if (localAudio) if (localAudio) {
localAudio.dispose(); localAudio.dispose();
}
// show overlay // show overlay
APP.UI.showSuspendedOverlay(); APP.UI.showSuspendedOverlay();