Allows to switch to desktop stream from the very beginning of the conference.
This commit is contained in:
parent
d5a1fe636d
commit
1f51021041
6
app.js
6
app.js
|
@ -221,7 +221,9 @@ $(document).bind('remotestreamadded.jingle', function (event, data, sid) {
|
|||
}
|
||||
} else {
|
||||
if (data.stream.id !== 'mixedmslabel') {
|
||||
console.warn('can not associate stream', data.stream.id, 'with a participant');
|
||||
console.error('can not associate stream', data.stream.id, 'with a participant');
|
||||
// We don't want to add it here since it will cause troubles
|
||||
return;
|
||||
}
|
||||
// FIXME: for the mixed ms we dont need a video -- currently
|
||||
container = document.createElement('span');
|
||||
|
@ -448,6 +450,8 @@ $(document).bind('callactive.jingle', function (event, videoelem, sid) {
|
|||
|
||||
$(document).bind('callterminated.jingle', function (event, sid, reason) {
|
||||
// FIXME
|
||||
focus = null;
|
||||
activecall = null;
|
||||
});
|
||||
|
||||
$(document).bind('setLocalDescription.jingle', function (event, sid) {
|
||||
|
|
|
@ -42,14 +42,17 @@ function setDesktopSharing(method) {
|
|||
if(method == "ext") {
|
||||
if(RTC.browser === 'chrome') {
|
||||
obtainDesktopStream = obtainScreenFromExtension;
|
||||
console.info("Using Chrome extension for desktop sharing");
|
||||
} else {
|
||||
console.log("Chrome is required to use extension method");
|
||||
console.error("Chrome is required to use extension method");
|
||||
obtainDesktopStream = null;
|
||||
}
|
||||
} else if(method == "webrtc") {
|
||||
obtainDesktopStream = obtainWebRTCScreen;
|
||||
console.info("Using WebRTC for desktop sharing");
|
||||
} else {
|
||||
obtainDesktopStream = null;
|
||||
console.info("Desktop sharing disabled");
|
||||
}
|
||||
showDesktopSharingButton();
|
||||
}
|
||||
|
@ -66,11 +69,8 @@ function showDesktopSharingButton() {
|
|||
* Toggles screen sharing.
|
||||
*/
|
||||
function toggleScreenSharing() {
|
||||
if (!(connection && connection.connected
|
||||
&& !switchInProgress
|
||||
&& getConferenceHandler().peerconnection.signalingState == 'stable'
|
||||
&& getConferenceHandler().peerconnection.iceConnectionState == 'connected'
|
||||
&& obtainDesktopStream )) {
|
||||
if (switchInProgress || !obtainDesktopStream) {
|
||||
console.warn("Switch in progress or no method defined");
|
||||
return;
|
||||
}
|
||||
switchInProgress = true;
|
||||
|
@ -85,7 +85,7 @@ function toggleScreenSharing() {
|
|||
// Hook 'ended' event to restore camera when screen stream stops
|
||||
stream.addEventListener('ended',
|
||||
function(e) {
|
||||
if(!switchInProgress) {
|
||||
if(!switchInProgress && isUsingScreenStream) {
|
||||
toggleScreenSharing();
|
||||
}
|
||||
}
|
||||
|
@ -118,13 +118,24 @@ function newStreamCreated(stream) {
|
|||
|
||||
change_local_video(stream, !isUsingScreenStream);
|
||||
|
||||
// FIXME: will block switchInProgress on true value in case of exception
|
||||
getConferenceHandler().switchStreams(
|
||||
stream, oldStream,
|
||||
function() {
|
||||
// Switch operation has finished
|
||||
var conferenceHandler = getConferenceHandler();
|
||||
if(conferenceHandler) {
|
||||
console.info("Conference considered as started");
|
||||
// FIXME: will block switchInProgress on true value in case of exception
|
||||
conferenceHandler.switchStreams(stream, oldStream, streamSwitchDone);
|
||||
} else {
|
||||
// We are done immediately
|
||||
console.error("No conference handler");
|
||||
streamSwitchDone();
|
||||
}
|
||||
}
|
||||
|
||||
function streamSwitchDone() {
|
||||
//window.setTimeout(
|
||||
// function() {
|
||||
switchInProgress = false;
|
||||
});
|
||||
// }, 100
|
||||
//);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -49,7 +49,10 @@ SessionBase.prototype.switchStreams = function (new_stream, oldStream, success_c
|
|||
var self = this;
|
||||
|
||||
// Remember SDP to figure out added/removed SSRCs
|
||||
var oldSdp = new SDP(self.peerconnection.localDescription.sdp);
|
||||
var oldSdp = null;
|
||||
if(self.peerconnection.localDescription) {
|
||||
oldSdp = new SDP(self.peerconnection.localDescription.sdp);
|
||||
}
|
||||
|
||||
// Stop the stream to trigger onended event for old stream
|
||||
oldStream.stop();
|
||||
|
@ -63,6 +66,12 @@ SessionBase.prototype.switchStreams = function (new_stream, oldStream, success_c
|
|||
self.connection.jingle.localStreams.push(self.connection.jingle.localAudio);
|
||||
self.connection.jingle.localStreams.push(self.connection.jingle.localVideo);
|
||||
|
||||
// Conference is not active
|
||||
if(!oldSdp) {
|
||||
success_callback();
|
||||
return;
|
||||
}
|
||||
|
||||
self.peerconnection.switchstreams = true;
|
||||
self.modifySources(function() {
|
||||
console.log('modify sources done');
|
||||
|
|
Loading…
Reference in New Issue