Bläddra i källkod

Fixes some issues related to xmpp module creation.

j8
hristoterezov 10 år sedan
förälder
incheckning
6347730dc7

+ 7
- 7
index.html Visa fil

@@ -25,19 +25,19 @@
25 25
     <script src="service/RTC/MediaStreamTypes.js?v=1"></script>
26 26
     <script src="service/xmpp/XMPPEvents.js?v=1"></script>
27 27
     <script src="service/desktopsharing/DesktopSharingEventTypes.js?v=1"></script>
28
-    <script src="libs/modules/simulcast.bundle.js?v=3"></script>
29
-    <script src="libs/modules/connectionquality.bundle.js?v=1"></script>
30
-    <script src="libs/modules/UI.bundle.js?v=5"></script>
31
-    <script src="libs/modules/statistics.bundle.js?v=1"></script>
32
-    <script src="libs/modules/RTC.bundle.js?v=4"></script>
28
+    <script src="libs/modules/simulcast.bundle.js?v=4"></script>
29
+    <script src="libs/modules/connectionquality.bundle.js?v=2"></script>
30
+    <script src="libs/modules/UI.bundle.js?v=6"></script>
31
+    <script src="libs/modules/statistics.bundle.js?v=2"></script>
32
+    <script src="libs/modules/RTC.bundle.js?v=5"></script>
33 33
     <script src="libs/modules/desktopsharing.bundle.js?v=3"></script><!-- desktop sharing -->
34 34
     <script src="util.js?v=7"></script><!-- utility functions -->
35 35
     <script src="libs/modules/xmpp.bundle.js?v=1"></script>
36
-    <script src="app.js?v=26"></script><!-- application logic -->
36
+    <script src="app.js?v=27"></script><!-- application logic -->
37 37
     <script src="libs/modules/API.bundle.js?v=1"></script>
38 38
 
39 39
     <script src="analytics.js?v=1"></script><!-- google analytics plugin -->
40
-    <script src="keyboard_shortcut.js?v=4"></script>
40
+    <script src="keyboard_shortcut.js?v=5"></script>
41 41
     <link rel="stylesheet" href="css/font.css?v=6"/>
42 42
     <link rel="stylesheet" href="css/toastr.css?v=1">
43 43
     <link rel="stylesheet" type="text/css" media="screen" href="css/main.css?v=30"/>

+ 18
- 15
libs/modules/RTC.bundle.js Visa fil

@@ -184,9 +184,9 @@ var DataChannels =
184 184
 
185 185
 }
186 186
 
187
-function onSelectedEndpointChanged(userJid)
187
+function onSelectedEndpointChanged(userResource)
188 188
 {
189
-    console.log('selected endpoint changed: ', userJid);
189
+    console.log('selected endpoint changed: ', userResource);
190 190
     if (_dataChannels && _dataChannels.length != 0)
191 191
     {
192 192
         _dataChannels.some(function (dataChannel) {
@@ -194,8 +194,9 @@ function onSelectedEndpointChanged(userJid)
194 194
             {
195 195
                 dataChannel.send(JSON.stringify({
196 196
                     'colibriClass': 'SelectedEndpointChangedEvent',
197
-                    'selectedEndpoint': (!userJid || userJid == null)
198
-                        ? null : userJid
197
+                    'selectedEndpoint':
198
+                        (!userResource || userResource === null)?
199
+                            null : userResource
199 200
                 }));
200 201
 
201 202
                 return true;
@@ -204,13 +205,13 @@ function onSelectedEndpointChanged(userJid)
204 205
     }
205 206
 }
206 207
 
207
-$(document).bind("selectedendpointchanged", function(event, userJid) {
208
-    onSelectedEndpointChanged(userJid);
208
+$(document).bind("selectedendpointchanged", function(event, userResource) {
209
+    onSelectedEndpointChanged(userResource);
209 210
 });
210 211
 
211
-function onPinnedEndpointChanged(userJid)
212
+function onPinnedEndpointChanged(userResource)
212 213
 {
213
-    console.log('pinned endpoint changed: ', userJid);
214
+    console.log('pinned endpoint changed: ', userResource);
214 215
     if (_dataChannels && _dataChannels.length != 0)
215 216
     {
216 217
         _dataChannels.some(function (dataChannel) {
@@ -218,8 +219,9 @@ function onPinnedEndpointChanged(userJid)
218 219
             {
219 220
                 dataChannel.send(JSON.stringify({
220 221
                     'colibriClass': 'PinnedEndpointChangedEvent',
221
-                    'pinnedEndpoint': (!userJid || userJid == null)
222
-                        ? null : Strophe.getResourceFromJid(userJid)
222
+                    'pinnedEndpoint':
223
+                        (!userResource || userResource == null)?
224
+                            null : userResource
223 225
                 }));
224 226
 
225 227
                 return true;
@@ -228,8 +230,8 @@ function onPinnedEndpointChanged(userJid)
228 230
     }
229 231
 }
230 232
 
231
-$(document).bind("pinnedendpointchanged", function(event, userJid) {
232
-    onPinnedEndpointChanged(userJid);
233
+$(document).bind("pinnedendpointchanged", function(event, userResource) {
234
+    onPinnedEndpointChanged(userResource);
233 235
 });
234 236
 
235 237
 module.exports = DataChannels;
@@ -339,7 +341,7 @@ module.exports = LocalStream;
339 341
  *
340 342
  * @constructor
341 343
  */
342
-function MediaStream(data, sid, ssrc, eventEmmiter, browser) {
344
+function MediaStream(data, sid, ssrc, browser) {
343 345
 
344 346
     // XXX(gp) to minimize headaches in the future, we should build our
345 347
     // abstractions around tracks and not streams. ORTC is track based API.
@@ -358,7 +360,6 @@ function MediaStream(data, sid, ssrc, eventEmmiter, browser) {
358 360
     this.type = (this.stream.getVideoTracks().length > 0)?
359 361
         MediaStreamType.VIDEO_TYPE : MediaStreamType.AUDIO_TYPE;
360 362
     this.muted = false;
361
-    eventEmmiter.emit(StreamEventTypes.EVENT_TYPE_REMOTE_CREATED, this);
362 363
     if(browser == RTCBrowserType.RTC_BROWSER_FIREFOX)
363 364
     {
364 365
         if (!this.getVideoTracks)
@@ -442,13 +443,15 @@ var RTC = {
442 443
         }
443 444
     },
444 445
     createRemoteStream: function (data, sid, thessrc) {
445
-        var remoteStream = new MediaStream(data, sid, thessrc, eventEmitter,
446
+        var remoteStream = new MediaStream(data, sid, thessrc,
446 447
             this.getBrowserType());
447 448
         var jid = data.peerjid || xmpp.myJid();
448 449
         if(!this.remoteStreams[jid]) {
449 450
             this.remoteStreams[jid] = {};
450 451
         }
451 452
         this.remoteStreams[jid][remoteStream.type]= remoteStream;
453
+        eventEmitter.emit(StreamEventTypes.EVENT_TYPE_REMOTE_CREATED, remoteStream);
454
+        console.debug("ADD remote stream ", remoteStream.type, " ", jid, " ", thessrc);
452 455
         return remoteStream;
453 456
     },
454 457
     getBrowserType: function () {

+ 1
- 1
libs/modules/UI.bundle.js Visa fil

@@ -6129,7 +6129,7 @@ var VideoLayout = (function (my) {
6129 6129
                     // picked up later by the lastN changed event handler.
6130 6130
 
6131 6131
                     lastNPickupJid = jid;
6132
-                    $(document).trigger("pinnedendpointchanged", [jid]);
6132
+                    $(document).trigger("pinnedendpointchanged", [Strophe.getResourceFromJid(jid)]);
6133 6133
                 }
6134 6134
             } else if (jid == xmpp.myJid()) {
6135 6135
                 $("#localVideoContainer").click();

+ 5
- 1
libs/modules/simulcast.bundle.js Visa fil

@@ -219,7 +219,7 @@ SimulcastReceiver.prototype.getReceivingVideoStreamBySSRC = function (ssrc)
219 219
     var sid, electedStream;
220 220
     var i, j, k;
221 221
     var jid = ssrc2jid[ssrc];
222
-    if(jid)
222
+    if(jid && RTC.remoteStreams[jid])
223 223
     {
224 224
         var remoteStreamObject = RTC.remoteStreams[jid][MediaStreamType.VIDEO_TYPE];
225 225
         var remoteStream = remoteStreamObject.getOriginalStream();
@@ -239,6 +239,10 @@ SimulcastReceiver.prototype.getReceivingVideoStreamBySSRC = function (ssrc)
239 239
         }
240 240
 
241 241
     }
242
+    else
243
+    {
244
+        console.debug(RTC.remoteStreams, jid, ssrc);
245
+    }
242 246
 
243 247
     return {
244 248
         sid: sid,

+ 22
- 22
libs/modules/xmpp.bundle.js Visa fil

@@ -3827,31 +3827,32 @@ module.exports = function(XMPP, eventEmitter) {
3827 3827
 
3828 3828
 var JingleSession = require("./JingleSession");
3829 3829
 
3830
-function CallIncomingJingle(sid, connection) {
3831
-    var sess = connection.jingle.sessions[sid];
3830
+module.exports = function(XMPP)
3831
+{
3832
+    function CallIncomingJingle(sid, connection) {
3833
+        var sess = connection.jingle.sessions[sid];
3832 3834
 
3833
-    // TODO: do we check activecall == null?
3834
-    activecall = sess;
3835
+        // TODO: do we check activecall == null?
3836
+        connection.jingle.activecall = sess;
3835 3837
 
3836
-    statistics.onConferenceCreated(sess);
3837
-    RTC.onConferenceCreated(sess);
3838
+        statistics.onConferenceCreated(sess);
3839
+        RTC.onConferenceCreated(sess);
3838 3840
 
3839
-    // TODO: check affiliation and/or role
3840
-    console.log('emuc data for', sess.peerjid, connection.emuc.members[sess.peerjid]);
3841
-    sess.usedrip = true; // not-so-naive trickle ice
3842
-    sess.sendAnswer();
3843
-    sess.accept();
3841
+        // TODO: check affiliation and/or role
3842
+        console.log('emuc data for', sess.peerjid, connection.emuc.members[sess.peerjid]);
3843
+        sess.usedrip = true; // not-so-naive trickle ice
3844
+        sess.sendAnswer();
3845
+        sess.accept();
3844 3846
 
3845
-};
3847
+    };
3846 3848
 
3847
-module.exports = function(XMPP)
3848
-{
3849 3849
     Strophe.addConnectionPlugin('jingle', {
3850 3850
         connection: null,
3851 3851
         sessions: {},
3852 3852
         jid2session: {},
3853 3853
         ice_config: {iceServers: []},
3854 3854
         pc_constraints: {},
3855
+        activecall: null,
3855 3856
         media_constraints: {
3856 3857
             mandatory: {
3857 3858
                 'OfferToReceiveAudio': true,
@@ -4389,7 +4390,6 @@ var SDP = require("./SDP");
4389 4390
 var eventEmitter = new EventEmitter();
4390 4391
 var connection = null;
4391 4392
 var authenticatedUser = false;
4392
-var activecall = null;
4393 4393
 
4394 4394
 function connect(jid, password, uiCredentials) {
4395 4395
     var bosh
@@ -4576,7 +4576,7 @@ var XMPP = {
4576 4576
     },
4577 4577
     disposeConference: function (onUnload) {
4578 4578
         eventEmitter.emit(XMPPEvents.DISPOSE_CONFERENCE, onUnload);
4579
-        var handler = activecall;
4579
+        var handler = connection.jingle.activecall;
4580 4580
         if (handler && handler.peerconnection) {
4581 4581
             // FIXME: probably removing streams is not required and close() should
4582 4582
             // be enough
@@ -4588,7 +4588,7 @@ var XMPP = {
4588 4588
             }
4589 4589
             handler.peerconnection.close();
4590 4590
         }
4591
-        activecall = null;
4591
+        connection.jingle.activecall = null;
4592 4592
         if(!onUnload)
4593 4593
         {
4594 4594
             this.sessionTerminated = true;
@@ -4615,9 +4615,9 @@ var XMPP = {
4615 4615
         return Moderator.isExternalAuthEnabled();
4616 4616
     },
4617 4617
     switchStreams: function (stream, oldStream, callback) {
4618
-        if (activecall) {
4618
+        if (connection && connection.jingle.activecall) {
4619 4619
             // FIXME: will block switchInProgress on true value in case of exception
4620
-            activecall.switchStreams(stream, oldStream, callback);
4620
+            connection.jingle.activecall.switchStreams(stream, oldStream, callback);
4621 4621
         } else {
4622 4622
             // We are done immediately
4623 4623
             console.error("No conference handler");
@@ -4627,9 +4627,9 @@ var XMPP = {
4627 4627
         }
4628 4628
     },
4629 4629
     setVideoMute: function (mute, callback, options) {
4630
-       if(activecall && connection && RTC.localVideo)
4630
+       if(connection && RTC.localVideo && connection.jingle.activecall)
4631 4631
        {
4632
-           activecall.setVideoMute(mute, callback, options);
4632
+           connection.jingle.activecall.setVideoMute(mute, callback, options);
4633 4633
        }
4634 4634
     },
4635 4635
     setAudioMute: function (mute, callback) {
@@ -4797,7 +4797,7 @@ var XMPP = {
4797 4797
         connection.moderate.eject(jid);
4798 4798
     },
4799 4799
     findJidFromResource: function (resource) {
4800
-        connection.emuc.findJidFromResource(resource);
4800
+        return connection.emuc.findJidFromResource(resource);
4801 4801
     },
4802 4802
     getMembers: function () {
4803 4803
         return connection.emuc.members;

+ 14
- 12
modules/RTC/DataChannels.js Visa fil

@@ -183,9 +183,9 @@ var DataChannels =
183 183
 
184 184
 }
185 185
 
186
-function onSelectedEndpointChanged(userJid)
186
+function onSelectedEndpointChanged(userResource)
187 187
 {
188
-    console.log('selected endpoint changed: ', userJid);
188
+    console.log('selected endpoint changed: ', userResource);
189 189
     if (_dataChannels && _dataChannels.length != 0)
190 190
     {
191 191
         _dataChannels.some(function (dataChannel) {
@@ -193,8 +193,9 @@ function onSelectedEndpointChanged(userJid)
193 193
             {
194 194
                 dataChannel.send(JSON.stringify({
195 195
                     'colibriClass': 'SelectedEndpointChangedEvent',
196
-                    'selectedEndpoint': (!userJid || userJid == null)
197
-                        ? null : userJid
196
+                    'selectedEndpoint':
197
+                        (!userResource || userResource === null)?
198
+                            null : userResource
198 199
                 }));
199 200
 
200 201
                 return true;
@@ -203,13 +204,13 @@ function onSelectedEndpointChanged(userJid)
203 204
     }
204 205
 }
205 206
 
206
-$(document).bind("selectedendpointchanged", function(event, userJid) {
207
-    onSelectedEndpointChanged(userJid);
207
+$(document).bind("selectedendpointchanged", function(event, userResource) {
208
+    onSelectedEndpointChanged(userResource);
208 209
 });
209 210
 
210
-function onPinnedEndpointChanged(userJid)
211
+function onPinnedEndpointChanged(userResource)
211 212
 {
212
-    console.log('pinned endpoint changed: ', userJid);
213
+    console.log('pinned endpoint changed: ', userResource);
213 214
     if (_dataChannels && _dataChannels.length != 0)
214 215
     {
215 216
         _dataChannels.some(function (dataChannel) {
@@ -217,8 +218,9 @@ function onPinnedEndpointChanged(userJid)
217 218
             {
218 219
                 dataChannel.send(JSON.stringify({
219 220
                     'colibriClass': 'PinnedEndpointChangedEvent',
220
-                    'pinnedEndpoint': (!userJid || userJid == null)
221
-                        ? null : Strophe.getResourceFromJid(userJid)
221
+                    'pinnedEndpoint':
222
+                        (!userResource || userResource == null)?
223
+                            null : userResource
222 224
                 }));
223 225
 
224 226
                 return true;
@@ -227,8 +229,8 @@ function onPinnedEndpointChanged(userJid)
227 229
     }
228 230
 }
229 231
 
230
-$(document).bind("pinnedendpointchanged", function(event, userJid) {
231
-    onPinnedEndpointChanged(userJid);
232
+$(document).bind("pinnedendpointchanged", function(event, userResource) {
233
+    onPinnedEndpointChanged(userResource);
232 234
 });
233 235
 
234 236
 module.exports = DataChannels;

+ 1
- 2
modules/RTC/MediaStream.js Visa fil

@@ -14,7 +14,7 @@
14 14
  *
15 15
  * @constructor
16 16
  */
17
-function MediaStream(data, sid, ssrc, eventEmmiter, browser) {
17
+function MediaStream(data, sid, ssrc, browser) {
18 18
 
19 19
     // XXX(gp) to minimize headaches in the future, we should build our
20 20
     // abstractions around tracks and not streams. ORTC is track based API.
@@ -33,7 +33,6 @@ function MediaStream(data, sid, ssrc, eventEmmiter, browser) {
33 33
     this.type = (this.stream.getVideoTracks().length > 0)?
34 34
         MediaStreamType.VIDEO_TYPE : MediaStreamType.AUDIO_TYPE;
35 35
     this.muted = false;
36
-    eventEmmiter.emit(StreamEventTypes.EVENT_TYPE_REMOTE_CREATED, this);
37 36
     if(browser == RTCBrowserType.RTC_BROWSER_FIREFOX)
38 37
     {
39 38
         if (!this.getVideoTracks)

+ 3
- 1
modules/RTC/RTC.js Visa fil

@@ -56,13 +56,15 @@ var RTC = {
56 56
         }
57 57
     },
58 58
     createRemoteStream: function (data, sid, thessrc) {
59
-        var remoteStream = new MediaStream(data, sid, thessrc, eventEmitter,
59
+        var remoteStream = new MediaStream(data, sid, thessrc,
60 60
             this.getBrowserType());
61 61
         var jid = data.peerjid || xmpp.myJid();
62 62
         if(!this.remoteStreams[jid]) {
63 63
             this.remoteStreams[jid] = {};
64 64
         }
65 65
         this.remoteStreams[jid][remoteStream.type]= remoteStream;
66
+        eventEmitter.emit(StreamEventTypes.EVENT_TYPE_REMOTE_CREATED, remoteStream);
67
+        console.debug("ADD remote stream ", remoteStream.type, " ", jid, " ", thessrc);
66 68
         return remoteStream;
67 69
     },
68 70
     getBrowserType: function () {

+ 1
- 1
modules/UI/videolayout/VideoLayout.js Visa fil

@@ -1742,7 +1742,7 @@ var VideoLayout = (function (my) {
1742 1742
                     // picked up later by the lastN changed event handler.
1743 1743
 
1744 1744
                     lastNPickupJid = jid;
1745
-                    $(document).trigger("pinnedendpointchanged", [jid]);
1745
+                    $(document).trigger("pinnedendpointchanged", [Strophe.getResourceFromJid(jid)]);
1746 1746
                 }
1747 1747
             } else if (jid == xmpp.myJid()) {
1748 1748
                 $("#localVideoContainer").click();

+ 5
- 1
modules/simulcast/SimulcastReceiver.js Visa fil

@@ -185,7 +185,7 @@ SimulcastReceiver.prototype.getReceivingVideoStreamBySSRC = function (ssrc)
185 185
     var sid, electedStream;
186 186
     var i, j, k;
187 187
     var jid = ssrc2jid[ssrc];
188
-    if(jid)
188
+    if(jid && RTC.remoteStreams[jid])
189 189
     {
190 190
         var remoteStreamObject = RTC.remoteStreams[jid][MediaStreamType.VIDEO_TYPE];
191 191
         var remoteStream = remoteStreamObject.getOriginalStream();
@@ -205,6 +205,10 @@ SimulcastReceiver.prototype.getReceivingVideoStreamBySSRC = function (ssrc)
205 205
         }
206 206
 
207 207
     }
208
+    else
209
+    {
210
+        console.debug(RTC.remoteStreams, jid, ssrc);
211
+    }
208 212
 
209 213
     return {
210 214
         sid: sid,

+ 15
- 14
modules/xmpp/strophe.jingle.js Visa fil

@@ -2,31 +2,32 @@
2 2
 
3 3
 var JingleSession = require("./JingleSession");
4 4
 
5
-function CallIncomingJingle(sid, connection) {
6
-    var sess = connection.jingle.sessions[sid];
5
+module.exports = function(XMPP)
6
+{
7
+    function CallIncomingJingle(sid, connection) {
8
+        var sess = connection.jingle.sessions[sid];
7 9
 
8
-    // TODO: do we check activecall == null?
9
-    activecall = sess;
10
+        // TODO: do we check activecall == null?
11
+        connection.jingle.activecall = sess;
10 12
 
11
-    statistics.onConferenceCreated(sess);
12
-    RTC.onConferenceCreated(sess);
13
+        statistics.onConferenceCreated(sess);
14
+        RTC.onConferenceCreated(sess);
13 15
 
14
-    // TODO: check affiliation and/or role
15
-    console.log('emuc data for', sess.peerjid, connection.emuc.members[sess.peerjid]);
16
-    sess.usedrip = true; // not-so-naive trickle ice
17
-    sess.sendAnswer();
18
-    sess.accept();
16
+        // TODO: check affiliation and/or role
17
+        console.log('emuc data for', sess.peerjid, connection.emuc.members[sess.peerjid]);
18
+        sess.usedrip = true; // not-so-naive trickle ice
19
+        sess.sendAnswer();
20
+        sess.accept();
19 21
 
20
-};
22
+    };
21 23
 
22
-module.exports = function(XMPP)
23
-{
24 24
     Strophe.addConnectionPlugin('jingle', {
25 25
         connection: null,
26 26
         sessions: {},
27 27
         jid2session: {},
28 28
         ice_config: {iceServers: []},
29 29
         pc_constraints: {},
30
+        activecall: null,
30 31
         media_constraints: {
31 32
             mandatory: {
32 33
                 'OfferToReceiveAudio': true,

+ 7
- 8
modules/xmpp/xmpp.js Visa fil

@@ -6,7 +6,6 @@ var SDP = require("./SDP");
6 6
 var eventEmitter = new EventEmitter();
7 7
 var connection = null;
8 8
 var authenticatedUser = false;
9
-var activecall = null;
10 9
 
11 10
 function connect(jid, password, uiCredentials) {
12 11
     var bosh
@@ -193,7 +192,7 @@ var XMPP = {
193 192
     },
194 193
     disposeConference: function (onUnload) {
195 194
         eventEmitter.emit(XMPPEvents.DISPOSE_CONFERENCE, onUnload);
196
-        var handler = activecall;
195
+        var handler = connection.jingle.activecall;
197 196
         if (handler && handler.peerconnection) {
198 197
             // FIXME: probably removing streams is not required and close() should
199 198
             // be enough
@@ -205,7 +204,7 @@ var XMPP = {
205 204
             }
206 205
             handler.peerconnection.close();
207 206
         }
208
-        activecall = null;
207
+        connection.jingle.activecall = null;
209 208
         if(!onUnload)
210 209
         {
211 210
             this.sessionTerminated = true;
@@ -232,9 +231,9 @@ var XMPP = {
232 231
         return Moderator.isExternalAuthEnabled();
233 232
     },
234 233
     switchStreams: function (stream, oldStream, callback) {
235
-        if (activecall) {
234
+        if (connection && connection.jingle.activecall) {
236 235
             // FIXME: will block switchInProgress on true value in case of exception
237
-            activecall.switchStreams(stream, oldStream, callback);
236
+            connection.jingle.activecall.switchStreams(stream, oldStream, callback);
238 237
         } else {
239 238
             // We are done immediately
240 239
             console.error("No conference handler");
@@ -244,9 +243,9 @@ var XMPP = {
244 243
         }
245 244
     },
246 245
     setVideoMute: function (mute, callback, options) {
247
-       if(activecall && connection && RTC.localVideo)
246
+       if(connection && RTC.localVideo && connection.jingle.activecall)
248 247
        {
249
-           activecall.setVideoMute(mute, callback, options);
248
+           connection.jingle.activecall.setVideoMute(mute, callback, options);
250 249
        }
251 250
     },
252 251
     setAudioMute: function (mute, callback) {
@@ -414,7 +413,7 @@ var XMPP = {
414 413
         connection.moderate.eject(jid);
415 414
     },
416 415
     findJidFromResource: function (resource) {
417
-        connection.emuc.findJidFromResource(resource);
416
+        return connection.emuc.findJidFromResource(resource);
418 417
     },
419 418
     getMembers: function () {
420 419
         return connection.emuc.members;

Laddar…
Avbryt
Spara