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;
},
/**
* 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) {
return room.addTrack(stream);
}
}).then(() => {
if (stream) {
this.videoMuted = stream.isMuted();
this.isSharingScreen = stream.videoType === 'desktop';
/**
* Start using provided video stream.
* Stops previous video stream.
* @param {JitsiLocalTrack} [stream] new stream to use or null
* @returns {Promise}
*/
useVideoStream (newStream) {
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'
&& APP.UI.setCameraButtonEnabled(true);
} else {
this.videoMuted = false;
this.isSharingScreen = false;
}
APP.UI.setVideoMuted(this.getMyUserId(), this.videoMuted);
APP.UI.updateDesktopSharingButtons();
});
newStream.videoType === 'camera'
&& APP.UI.setCameraButtonEnabled(true);
} else {
this.videoMuted = false;
this.isSharingScreen = false;
}
APP.UI.setVideoMuted(this.getMyUserId(), this.videoMuted);
APP.UI.updateDesktopSharingButtons();
});
},
/**
@ -946,31 +943,27 @@ export default {
* @param {JitsiLocalTrack} [stream] new stream to use or null
* @returns {Promise}
*/
useAudioStream (stream) {
let promise = Promise.resolve();
if (localAudio) {
// this calls room.removeTrack internally
// so we don't need to remove it manually
promise = localAudio.dispose();
}
localAudio = stream;
return promise.then(function () {
if (stream) {
return room.addTrack(stream);
}
}).then(() => {
if (stream) {
this.audioMuted = stream.isMuted();
APP.UI.addLocalStream(stream);
} else {
this.audioMuted = false;
}
APP.UI.setMicrophoneButtonEnabled(true);
APP.UI.setAudioMuted(this.getMyUserId(), this.audioMuted);
});
useAudioStream (newStream) {
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) {
localAudio.dispose();
}
localAudio = newStream;
if (newStream) {
this.audioMuted = newStream.isMuted();
APP.UI.addLocalStream(newStream);
} else {
this.audioMuted = false;
}
APP.UI.setMicrophoneButtonEnabled(true);
APP.UI.setAudioMuted(this.getMyUserId(), this.audioMuted);
});
},
videoSwitchInProgress: false,
@ -1344,11 +1337,13 @@ export default {
this.deviceChangeListener);
// stop local video
if (localVideo)
if (localVideo) {
localVideo.dispose();
}
// stop local audio
if (localAudio)
if (localAudio) {
localAudio.dispose();
}
// show overlay
APP.UI.showSuspendedOverlay();