Browse Source

Fixes some issues related to xmpp module creation.

j8
hristoterezov 10 years ago
parent
commit
6347730dc7

+ 7
- 7
index.html View File

25
     <script src="service/RTC/MediaStreamTypes.js?v=1"></script>
25
     <script src="service/RTC/MediaStreamTypes.js?v=1"></script>
26
     <script src="service/xmpp/XMPPEvents.js?v=1"></script>
26
     <script src="service/xmpp/XMPPEvents.js?v=1"></script>
27
     <script src="service/desktopsharing/DesktopSharingEventTypes.js?v=1"></script>
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
     <script src="libs/modules/desktopsharing.bundle.js?v=3"></script><!-- desktop sharing -->
33
     <script src="libs/modules/desktopsharing.bundle.js?v=3"></script><!-- desktop sharing -->
34
     <script src="util.js?v=7"></script><!-- utility functions -->
34
     <script src="util.js?v=7"></script><!-- utility functions -->
35
     <script src="libs/modules/xmpp.bundle.js?v=1"></script>
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
     <script src="libs/modules/API.bundle.js?v=1"></script>
37
     <script src="libs/modules/API.bundle.js?v=1"></script>
38
 
38
 
39
     <script src="analytics.js?v=1"></script><!-- google analytics plugin -->
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
     <link rel="stylesheet" href="css/font.css?v=6"/>
41
     <link rel="stylesheet" href="css/font.css?v=6"/>
42
     <link rel="stylesheet" href="css/toastr.css?v=1">
42
     <link rel="stylesheet" href="css/toastr.css?v=1">
43
     <link rel="stylesheet" type="text/css" media="screen" href="css/main.css?v=30"/>
43
     <link rel="stylesheet" type="text/css" media="screen" href="css/main.css?v=30"/>

+ 18
- 15
libs/modules/RTC.bundle.js View File

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
     if (_dataChannels && _dataChannels.length != 0)
190
     if (_dataChannels && _dataChannels.length != 0)
191
     {
191
     {
192
         _dataChannels.some(function (dataChannel) {
192
         _dataChannels.some(function (dataChannel) {
194
             {
194
             {
195
                 dataChannel.send(JSON.stringify({
195
                 dataChannel.send(JSON.stringify({
196
                     'colibriClass': 'SelectedEndpointChangedEvent',
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
                 return true;
202
                 return true;
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
     if (_dataChannels && _dataChannels.length != 0)
215
     if (_dataChannels && _dataChannels.length != 0)
215
     {
216
     {
216
         _dataChannels.some(function (dataChannel) {
217
         _dataChannels.some(function (dataChannel) {
218
             {
219
             {
219
                 dataChannel.send(JSON.stringify({
220
                 dataChannel.send(JSON.stringify({
220
                     'colibriClass': 'PinnedEndpointChangedEvent',
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
                 return true;
227
                 return true;
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
 module.exports = DataChannels;
237
 module.exports = DataChannels;
339
  *
341
  *
340
  * @constructor
342
  * @constructor
341
  */
343
  */
342
-function MediaStream(data, sid, ssrc, eventEmmiter, browser) {
344
+function MediaStream(data, sid, ssrc, browser) {
343
 
345
 
344
     // XXX(gp) to minimize headaches in the future, we should build our
346
     // XXX(gp) to minimize headaches in the future, we should build our
345
     // abstractions around tracks and not streams. ORTC is track based API.
347
     // abstractions around tracks and not streams. ORTC is track based API.
358
     this.type = (this.stream.getVideoTracks().length > 0)?
360
     this.type = (this.stream.getVideoTracks().length > 0)?
359
         MediaStreamType.VIDEO_TYPE : MediaStreamType.AUDIO_TYPE;
361
         MediaStreamType.VIDEO_TYPE : MediaStreamType.AUDIO_TYPE;
360
     this.muted = false;
362
     this.muted = false;
361
-    eventEmmiter.emit(StreamEventTypes.EVENT_TYPE_REMOTE_CREATED, this);
362
     if(browser == RTCBrowserType.RTC_BROWSER_FIREFOX)
363
     if(browser == RTCBrowserType.RTC_BROWSER_FIREFOX)
363
     {
364
     {
364
         if (!this.getVideoTracks)
365
         if (!this.getVideoTracks)
442
         }
443
         }
443
     },
444
     },
444
     createRemoteStream: function (data, sid, thessrc) {
445
     createRemoteStream: function (data, sid, thessrc) {
445
-        var remoteStream = new MediaStream(data, sid, thessrc, eventEmitter,
446
+        var remoteStream = new MediaStream(data, sid, thessrc,
446
             this.getBrowserType());
447
             this.getBrowserType());
447
         var jid = data.peerjid || xmpp.myJid();
448
         var jid = data.peerjid || xmpp.myJid();
448
         if(!this.remoteStreams[jid]) {
449
         if(!this.remoteStreams[jid]) {
449
             this.remoteStreams[jid] = {};
450
             this.remoteStreams[jid] = {};
450
         }
451
         }
451
         this.remoteStreams[jid][remoteStream.type]= remoteStream;
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
         return remoteStream;
455
         return remoteStream;
453
     },
456
     },
454
     getBrowserType: function () {
457
     getBrowserType: function () {

+ 1
- 1
libs/modules/UI.bundle.js View File

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

+ 5
- 1
libs/modules/simulcast.bundle.js View File

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

+ 22
- 22
libs/modules/xmpp.bundle.js View File

3827
 
3827
 
3828
 var JingleSession = require("./JingleSession");
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
     Strophe.addConnectionPlugin('jingle', {
3849
     Strophe.addConnectionPlugin('jingle', {
3850
         connection: null,
3850
         connection: null,
3851
         sessions: {},
3851
         sessions: {},
3852
         jid2session: {},
3852
         jid2session: {},
3853
         ice_config: {iceServers: []},
3853
         ice_config: {iceServers: []},
3854
         pc_constraints: {},
3854
         pc_constraints: {},
3855
+        activecall: null,
3855
         media_constraints: {
3856
         media_constraints: {
3856
             mandatory: {
3857
             mandatory: {
3857
                 'OfferToReceiveAudio': true,
3858
                 'OfferToReceiveAudio': true,
4389
 var eventEmitter = new EventEmitter();
4390
 var eventEmitter = new EventEmitter();
4390
 var connection = null;
4391
 var connection = null;
4391
 var authenticatedUser = false;
4392
 var authenticatedUser = false;
4392
-var activecall = null;
4393
 
4393
 
4394
 function connect(jid, password, uiCredentials) {
4394
 function connect(jid, password, uiCredentials) {
4395
     var bosh
4395
     var bosh
4576
     },
4576
     },
4577
     disposeConference: function (onUnload) {
4577
     disposeConference: function (onUnload) {
4578
         eventEmitter.emit(XMPPEvents.DISPOSE_CONFERENCE, onUnload);
4578
         eventEmitter.emit(XMPPEvents.DISPOSE_CONFERENCE, onUnload);
4579
-        var handler = activecall;
4579
+        var handler = connection.jingle.activecall;
4580
         if (handler && handler.peerconnection) {
4580
         if (handler && handler.peerconnection) {
4581
             // FIXME: probably removing streams is not required and close() should
4581
             // FIXME: probably removing streams is not required and close() should
4582
             // be enough
4582
             // be enough
4588
             }
4588
             }
4589
             handler.peerconnection.close();
4589
             handler.peerconnection.close();
4590
         }
4590
         }
4591
-        activecall = null;
4591
+        connection.jingle.activecall = null;
4592
         if(!onUnload)
4592
         if(!onUnload)
4593
         {
4593
         {
4594
             this.sessionTerminated = true;
4594
             this.sessionTerminated = true;
4615
         return Moderator.isExternalAuthEnabled();
4615
         return Moderator.isExternalAuthEnabled();
4616
     },
4616
     },
4617
     switchStreams: function (stream, oldStream, callback) {
4617
     switchStreams: function (stream, oldStream, callback) {
4618
-        if (activecall) {
4618
+        if (connection && connection.jingle.activecall) {
4619
             // FIXME: will block switchInProgress on true value in case of exception
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
         } else {
4621
         } else {
4622
             // We are done immediately
4622
             // We are done immediately
4623
             console.error("No conference handler");
4623
             console.error("No conference handler");
4627
         }
4627
         }
4628
     },
4628
     },
4629
     setVideoMute: function (mute, callback, options) {
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
     setAudioMute: function (mute, callback) {
4635
     setAudioMute: function (mute, callback) {
4797
         connection.moderate.eject(jid);
4797
         connection.moderate.eject(jid);
4798
     },
4798
     },
4799
     findJidFromResource: function (resource) {
4799
     findJidFromResource: function (resource) {
4800
-        connection.emuc.findJidFromResource(resource);
4800
+        return connection.emuc.findJidFromResource(resource);
4801
     },
4801
     },
4802
     getMembers: function () {
4802
     getMembers: function () {
4803
         return connection.emuc.members;
4803
         return connection.emuc.members;

+ 14
- 12
modules/RTC/DataChannels.js View File

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
     if (_dataChannels && _dataChannels.length != 0)
189
     if (_dataChannels && _dataChannels.length != 0)
190
     {
190
     {
191
         _dataChannels.some(function (dataChannel) {
191
         _dataChannels.some(function (dataChannel) {
193
             {
193
             {
194
                 dataChannel.send(JSON.stringify({
194
                 dataChannel.send(JSON.stringify({
195
                     'colibriClass': 'SelectedEndpointChangedEvent',
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
                 return true;
201
                 return true;
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
     if (_dataChannels && _dataChannels.length != 0)
214
     if (_dataChannels && _dataChannels.length != 0)
214
     {
215
     {
215
         _dataChannels.some(function (dataChannel) {
216
         _dataChannels.some(function (dataChannel) {
217
             {
218
             {
218
                 dataChannel.send(JSON.stringify({
219
                 dataChannel.send(JSON.stringify({
219
                     'colibriClass': 'PinnedEndpointChangedEvent',
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
                 return true;
226
                 return true;
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
 module.exports = DataChannels;
236
 module.exports = DataChannels;

+ 1
- 2
modules/RTC/MediaStream.js View File

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

+ 3
- 1
modules/RTC/RTC.js View File

56
         }
56
         }
57
     },
57
     },
58
     createRemoteStream: function (data, sid, thessrc) {
58
     createRemoteStream: function (data, sid, thessrc) {
59
-        var remoteStream = new MediaStream(data, sid, thessrc, eventEmitter,
59
+        var remoteStream = new MediaStream(data, sid, thessrc,
60
             this.getBrowserType());
60
             this.getBrowserType());
61
         var jid = data.peerjid || xmpp.myJid();
61
         var jid = data.peerjid || xmpp.myJid();
62
         if(!this.remoteStreams[jid]) {
62
         if(!this.remoteStreams[jid]) {
63
             this.remoteStreams[jid] = {};
63
             this.remoteStreams[jid] = {};
64
         }
64
         }
65
         this.remoteStreams[jid][remoteStream.type]= remoteStream;
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
         return remoteStream;
68
         return remoteStream;
67
     },
69
     },
68
     getBrowserType: function () {
70
     getBrowserType: function () {

+ 1
- 1
modules/UI/videolayout/VideoLayout.js View File

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

+ 5
- 1
modules/simulcast/SimulcastReceiver.js View File

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

+ 15
- 14
modules/xmpp/strophe.jingle.js View File

2
 
2
 
3
 var JingleSession = require("./JingleSession");
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
     Strophe.addConnectionPlugin('jingle', {
24
     Strophe.addConnectionPlugin('jingle', {
25
         connection: null,
25
         connection: null,
26
         sessions: {},
26
         sessions: {},
27
         jid2session: {},
27
         jid2session: {},
28
         ice_config: {iceServers: []},
28
         ice_config: {iceServers: []},
29
         pc_constraints: {},
29
         pc_constraints: {},
30
+        activecall: null,
30
         media_constraints: {
31
         media_constraints: {
31
             mandatory: {
32
             mandatory: {
32
                 'OfferToReceiveAudio': true,
33
                 'OfferToReceiveAudio': true,

+ 7
- 8
modules/xmpp/xmpp.js View File

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

Loading…
Cancel
Save