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,41 +901,38 @@ export default {
return options; return options;
}, },
/** /**
* Start using provided video stream. * Start using provided video stream.
* Stops previous video stream. * Stops previous video stream.
* @param {JitsiLocalTrack} [stream] new stream to use or null * @param {JitsiLocalTrack} [stream] new stream to use or null
* @returns {Promise} * @returns {Promise}
*/ */
useVideoStream (stream) { useVideoStream (newStream) {
let promise = Promise.resolve(); 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) { if (localVideo) {
// this calls room.removeTrack internally localVideo.dispose();
// so we don't need to remove it manually
promise = localVideo.dispose();
} }
localVideo = stream; localVideo = newStream;
if (newStream) {
this.videoMuted = newStream.isMuted();
this.isSharingScreen = newStream.videoType === 'desktop';
return promise.then(function () { APP.UI.addLocalStream(newStream);
if (stream) {
return room.addTrack(stream);
}
}).then(() => {
if (stream) {
this.videoMuted = stream.isMuted();
this.isSharingScreen = stream.videoType === 'desktop';
APP.UI.addLocalStream(stream); newStream.videoType === 'camera'
stream.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,28 +943,24 @@ 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)
.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 (localAudio) { if (localAudio) {
// this calls room.removeTrack internally localAudio.dispose();
// so we don't need to remove it manually
promise = localAudio.dispose();
} }
localAudio = stream; localAudio = newStream;
if (newStream) {
return promise.then(function () { this.audioMuted = newStream.isMuted();
if (stream) { APP.UI.addLocalStream(newStream);
return room.addTrack(stream);
}
}).then(() => {
if (stream) {
this.audioMuted = stream.isMuted();
APP.UI.addLocalStream(stream);
} else { } else {
this.audioMuted = false; this.audioMuted = false;
} }
APP.UI.setMicrophoneButtonEnabled(true); APP.UI.setMicrophoneButtonEnabled(true);
APP.UI.setAudioMuted(this.getMyUserId(), this.audioMuted); APP.UI.setAudioMuted(this.getMyUserId(), this.audioMuted);
}); });
@ -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();