瀏覽代碼

Allows to switch to desktop stream from the very beginning of the conference.

master
paweldomas 11 年之前
父節點
當前提交
1f51021041
共有 3 個檔案被更改,包括 39 行新增15 行删除
  1. 5
    1
      app.js
  2. 24
    13
      desktopsharing.js
  3. 10
    1
      libs/strophe/strophe.jingle.sessionbase.js

+ 5
- 1
app.js 查看文件

221
         }
221
         }
222
     } else {
222
     } else {
223
         if (data.stream.id !== 'mixedmslabel') {
223
         if (data.stream.id !== 'mixedmslabel') {
224
-            console.warn('can not associate stream', data.stream.id, 'with a participant');
224
+            console.error('can not associate stream', data.stream.id, 'with a participant');
225
+            // We don't want to add it here since it will cause troubles
226
+            return;
225
         }
227
         }
226
         // FIXME: for the mixed ms we dont need a video -- currently
228
         // FIXME: for the mixed ms we dont need a video -- currently
227
         container = document.createElement('span');
229
         container = document.createElement('span');
448
 
450
 
449
 $(document).bind('callterminated.jingle', function (event, sid, reason) {
451
 $(document).bind('callterminated.jingle', function (event, sid, reason) {
450
     // FIXME
452
     // FIXME
453
+    focus = null;
454
+    activecall = null;
451
 });
455
 });
452
 
456
 
453
 $(document).bind('setLocalDescription.jingle', function (event, sid) {
457
 $(document).bind('setLocalDescription.jingle', function (event, sid) {

+ 24
- 13
desktopsharing.js 查看文件

42
     if(method == "ext") {
42
     if(method == "ext") {
43
         if(RTC.browser === 'chrome') {
43
         if(RTC.browser === 'chrome') {
44
             obtainDesktopStream = obtainScreenFromExtension;
44
             obtainDesktopStream = obtainScreenFromExtension;
45
+            console.info("Using Chrome extension for desktop sharing");
45
         } else {
46
         } else {
46
-            console.log("Chrome is required to use extension method");
47
+            console.error("Chrome is required to use extension method");
47
             obtainDesktopStream = null;
48
             obtainDesktopStream = null;
48
         }
49
         }
49
     } else if(method == "webrtc") {
50
     } else if(method == "webrtc") {
50
         obtainDesktopStream = obtainWebRTCScreen;
51
         obtainDesktopStream = obtainWebRTCScreen;
52
+        console.info("Using WebRTC for desktop sharing");
51
     } else {
53
     } else {
52
         obtainDesktopStream = null;
54
         obtainDesktopStream = null;
55
+        console.info("Desktop sharing disabled");
53
     }
56
     }
54
     showDesktopSharingButton();
57
     showDesktopSharingButton();
55
 }
58
 }
66
  * Toggles screen sharing.
69
  * Toggles screen sharing.
67
  */
70
  */
68
 function toggleScreenSharing() {
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
         return;
74
         return;
75
     }
75
     }
76
     switchInProgress = true;
76
     switchInProgress = true;
85
                 // Hook 'ended' event to restore camera when screen stream stops
85
                 // Hook 'ended' event to restore camera when screen stream stops
86
                 stream.addEventListener('ended',
86
                 stream.addEventListener('ended',
87
                     function(e) {
87
                     function(e) {
88
-                        if(!switchInProgress) {
88
+                        if(!switchInProgress && isUsingScreenStream) {
89
                             toggleScreenSharing();
89
                             toggleScreenSharing();
90
                         }
90
                         }
91
                     }
91
                     }
118
 
118
 
119
     change_local_video(stream, !isUsingScreenStream);
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
             switchInProgress = false;
136
             switchInProgress = false;
127
-        });
137
+    //    }, 100
138
+    //);
128
 }
139
 }
129
 
140
 
130
 /**
141
 /**

+ 10
- 1
libs/strophe/strophe.jingle.sessionbase.js 查看文件

49
     var self = this;
49
     var self = this;
50
 
50
 
51
     // Remember SDP to figure out added/removed SSRCs
51
     // Remember SDP to figure out added/removed SSRCs
52
-    var oldSdp = new SDP(self.peerconnection.localDescription.sdp);
52
+    var oldSdp = null;
53
+    if(self.peerconnection.localDescription) {
54
+        oldSdp = new SDP(self.peerconnection.localDescription.sdp);
55
+    }
53
 
56
 
54
     // Stop the stream to trigger onended event for old stream
57
     // Stop the stream to trigger onended event for old stream
55
     oldStream.stop();
58
     oldStream.stop();
63
     self.connection.jingle.localStreams.push(self.connection.jingle.localAudio);
66
     self.connection.jingle.localStreams.push(self.connection.jingle.localAudio);
64
     self.connection.jingle.localStreams.push(self.connection.jingle.localVideo);
67
     self.connection.jingle.localStreams.push(self.connection.jingle.localVideo);
65
 
68
 
69
+    // Conference is not active
70
+    if(!oldSdp) {
71
+        success_callback();
72
+        return;
73
+    }
74
+
66
     self.peerconnection.switchstreams = true;
75
     self.peerconnection.switchstreams = true;
67
     self.modifySources(function() {
76
     self.modifySources(function() {
68
         console.log('modify sources done');
77
         console.log('modify sources done');

Loading…
取消
儲存