|
@@ -42,14 +42,17 @@ function setDesktopSharing(method) {
|
42
|
42
|
if(method == "ext") {
|
43
|
43
|
if(RTC.browser === 'chrome') {
|
44
|
44
|
obtainDesktopStream = obtainScreenFromExtension;
|
|
45
|
+ console.info("Using Chrome extension for desktop sharing");
|
45
|
46
|
} else {
|
46
|
|
- console.log("Chrome is required to use extension method");
|
|
47
|
+ console.error("Chrome is required to use extension method");
|
47
|
48
|
obtainDesktopStream = null;
|
48
|
49
|
}
|
49
|
50
|
} else if(method == "webrtc") {
|
50
|
51
|
obtainDesktopStream = obtainWebRTCScreen;
|
|
52
|
+ console.info("Using WebRTC for desktop sharing");
|
51
|
53
|
} else {
|
52
|
54
|
obtainDesktopStream = null;
|
|
55
|
+ console.info("Desktop sharing disabled");
|
53
|
56
|
}
|
54
|
57
|
showDesktopSharingButton();
|
55
|
58
|
}
|
|
@@ -66,11 +69,8 @@ function showDesktopSharingButton() {
|
66
|
69
|
* Toggles screen sharing.
|
67
|
70
|
*/
|
68
|
71
|
function toggleScreenSharing() {
|
69
|
|
- if (!(connection && connection.connected
|
70
|
|
- && !switchInProgress
|
71
|
|
- && getConferenceHandler().peerconnection.signalingState == 'stable'
|
72
|
|
- && getConferenceHandler().peerconnection.iceConnectionState == 'connected'
|
73
|
|
- && obtainDesktopStream )) {
|
|
72
|
+ if (switchInProgress || !obtainDesktopStream) {
|
|
73
|
+ console.warn("Switch in progress or no method defined");
|
74
|
74
|
return;
|
75
|
75
|
}
|
76
|
76
|
switchInProgress = true;
|
|
@@ -85,7 +85,7 @@ function toggleScreenSharing() {
|
85
|
85
|
// Hook 'ended' event to restore camera when screen stream stops
|
86
|
86
|
stream.addEventListener('ended',
|
87
|
87
|
function(e) {
|
88
|
|
- if(!switchInProgress) {
|
|
88
|
+ if(!switchInProgress && isUsingScreenStream) {
|
89
|
89
|
toggleScreenSharing();
|
90
|
90
|
}
|
91
|
91
|
}
|
|
@@ -118,13 +118,24 @@ function newStreamCreated(stream) {
|
118
|
118
|
|
119
|
119
|
change_local_video(stream, !isUsingScreenStream);
|
120
|
120
|
|
121
|
|
- // FIXME: will block switchInProgress on true value in case of exception
|
122
|
|
- getConferenceHandler().switchStreams(
|
123
|
|
- stream, oldStream,
|
124
|
|
- function() {
|
125
|
|
- // Switch operation has finished
|
|
121
|
+ var conferenceHandler = getConferenceHandler();
|
|
122
|
+ if(conferenceHandler) {
|
|
123
|
+ console.info("Conference considered as started");
|
|
124
|
+ // FIXME: will block switchInProgress on true value in case of exception
|
|
125
|
+ conferenceHandler.switchStreams(stream, oldStream, streamSwitchDone);
|
|
126
|
+ } else {
|
|
127
|
+ // We are done immediately
|
|
128
|
+ console.error("No conference handler");
|
|
129
|
+ streamSwitchDone();
|
|
130
|
+ }
|
|
131
|
+}
|
|
132
|
+
|
|
133
|
+function streamSwitchDone() {
|
|
134
|
+ //window.setTimeout(
|
|
135
|
+ // function() {
|
126
|
136
|
switchInProgress = false;
|
127
|
|
- });
|
|
137
|
+ // }, 100
|
|
138
|
+ //);
|
128
|
139
|
}
|
129
|
140
|
|
130
|
141
|
/**
|