Ver código fonte

Integrates fippo's work on audio only for firefox and other fixes.

j8
Yana Stamcheva 11 anos atrás
pai
commit
d3f2532172
6 arquivos alterados com 222 adições e 178 exclusões
  1. 8
    4
      app.js
  2. 9
    0
      css/main.css
  3. 4
    4
      index.html
  4. 78
    43
      libs/colibri.js
  5. 122
    127
      libs/strophejingle.bundle.js
  6. 1
    0
      muc.js

+ 8
- 4
app.js Ver arquivo

382
     }
382
     }
383
 });
383
 });
384
 
384
 
385
-function dump(elem, filename){
385
+function dump(elem, filename) {
386
+    console.log("ELEMENT", elem);
386
     elem = elem.parentNode;
387
     elem = elem.parentNode;
387
     elem.download = filename || 'xmpplog.json';
388
     elem.download = filename || 'xmpplog.json';
388
     elem.href = 'data:application/json;charset=utf-8,\n';
389
     elem.href = 'data:application/json;charset=utf-8,\n';
487
                      if(v)
488
                      if(v)
488
                      {
489
                      {
489
                         setSharedKey('');
490
                         setSharedKey('');
490
-                        lockRoom();
491
+                        lockRoom(false);
491
                      }
492
                      }
492
                      }
493
                      }
493
                      });
494
                      });
508
                      
509
                      
509
                      if (lockKey.value)
510
                      if (lockKey.value)
510
                      {
511
                      {
511
-                     console.log("LOCK KEY", lockKey.value);
512
                         setSharedKey(lockKey.value);
512
                         setSharedKey(lockKey.value);
513
                         lockRoom(true);
513
                         lockRoom(true);
514
                      }
514
                      }
537
  * Locks / unlocks the room.
537
  * Locks / unlocks the room.
538
  */
538
  */
539
 function lockRoom(lock) {
539
 function lockRoom(lock) {
540
-    connection.emuc.lockRoom(sharedKey);
540
+    console.log("LOCK", sharedKey);
541
+    if (lock)
542
+        connection.emuc.lockRoom(sharedKey);
543
+    else
544
+        connection.emuc.lockRoom('');
541
     
545
     
542
     updateLockButton();
546
     updateLockButton();
543
 }
547
 }

+ 9
- 0
css/main.css Ver arquivo

326
     -moz-transition: height 0.2s;
326
     -moz-transition: height 0.2s;
327
     transition: height 0.2s;
327
     transition: height 0.2s;
328
 }
328
 }
329
+
330
+#downloadlog {
331
+    position: absolute;
332
+    bottom: 5;
333
+    left: 5;
334
+    overflow: visible;
335
+    z-index: 100;
336
+}
337
+

+ 4
- 4
index.html Ver arquivo

2
   <head>
2
   <head>
3
     <title>WebRTC, meet the Jitsi Videobridge</title>
3
     <title>WebRTC, meet the Jitsi Videobridge</title>
4
     <script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
4
     <script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
5
-    <script src="libs/strophejingle.bundle.js?v=1"></script><!-- strophe.jingle bundle -->
6
-    <script src="libs/colibri.js?v=1"></script><!-- colibri focus implementation -->
5
+    <script src="libs/strophejingle.bundle.js?v=2"></script><!-- strophe.jingle bundle -->
6
+    <script src="libs/colibri.js?v=2"></script><!-- colibri focus implementation -->
7
     <script src="muc.js?v=2"></script><!-- simple MUC library -->
7
     <script src="muc.js?v=2"></script><!-- simple MUC library -->
8
     <script src="estos_log.js?v=1"></script><!-- simple stanza logger -->
8
     <script src="estos_log.js?v=1"></script><!-- simple stanza logger -->
9
     <script src="app.js?v=2"></script><!-- application logic -->
9
     <script src="app.js?v=2"></script><!-- application logic -->
10
     <link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
10
     <link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
11
-    <link rel="stylesheet" type="text/css" media="screen" href="css/main.css?v=1"/>
11
+    <link rel="stylesheet" type="text/css" media="screen" href="css/main.css?v=2"/>
12
     <link rel="stylesheet" href="css/jquery-impromptu.css?v=1">
12
     <link rel="stylesheet" href="css/jquery-impromptu.css?v=1">
13
     <link rel="stylesheet" href="css/modaldialog.css?v=1">
13
     <link rel="stylesheet" href="css/modaldialog.css?v=1">
14
     <script src="libs/jquery-impromptu.js"></script>
14
     <script src="libs/jquery-impromptu.js"></script>
65
         <div id="chatconversation"></div>
65
         <div id="chatconversation"></div>
66
         <textarea id="usermsg" class= "animated" placeholder='Enter text...' autofocus></textarea>
66
         <textarea id="usermsg" class= "animated" placeholder='Enter text...' autofocus></textarea>
67
     </div>
67
     </div>
68
-    <a id="downloadlog" class="fa fa-cloud-download" title="Download logfile for support" onclick="connection.logger.dump(event.target);" style="position: absolute; bottom: 5; left: 5; overflow: visible; z-index: 100;"></a>
68
+    <a id="downloadlog" onclick='dump(event.target);'><i title="Download support information" class="fa fa-cloud-download"></i></a>
69
     <script>
69
     <script>
70
         (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
70
         (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
71
              (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
71
              (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)

+ 78
- 43
libs/colibri.js Ver arquivo

59
 
59
 
60
 // creates a conferences with an initial set of peers
60
 // creates a conferences with an initial set of peers
61
 ColibriFocus.prototype.makeConference = function (peers) {
61
 ColibriFocus.prototype.makeConference = function (peers) {
62
-    var ob = this;
62
+    var self = this;
63
     if (this.confid !== null) {
63
     if (this.confid !== null) {
64
         console.error('makeConference called twice? Ignoring...');
64
         console.error('makeConference called twice? Ignoring...');
65
         // FIXME: just invite peers?
65
         // FIXME: just invite peers?
68
     this.confid = 0; // !null
68
     this.confid = 0; // !null
69
     this.peers = [];
69
     this.peers = [];
70
     peers.forEach(function (peer) {
70
     peers.forEach(function (peer) {
71
-        ob.peers.push(peer);
72
-        ob.channels.push([]);
71
+        self.peers.push(peer);
72
+        self.channels.push([]);
73
     });
73
     });
74
 
74
 
75
     this.peerconnection = new TraceablePeerConnection(this.connection.jingle.ice_config, this.connection.jingle.pc_constraints);
75
     this.peerconnection = new TraceablePeerConnection(this.connection.jingle.ice_config, this.connection.jingle.pc_constraints);
76
     this.peerconnection.addStream(this.connection.jingle.localStream);
76
     this.peerconnection.addStream(this.connection.jingle.localStream);
77
     this.peerconnection.oniceconnectionstatechange = function (event) {
77
     this.peerconnection.oniceconnectionstatechange = function (event) {
78
-        console.warn('ice connection state changed to', ob.peerconnection.iceConnectionState);
78
+        console.warn('ice connection state changed to', self.peerconnection.iceConnectionState);
79
         /*
79
         /*
80
-        if (ob.peerconnection.signalingState == 'stable' && ob.peerconnection.iceConnectionState == 'connected') {
80
+        if (self.peerconnection.signalingState == 'stable' && self.peerconnection.iceConnectionState == 'connected') {
81
             console.log('adding new remote SSRCs from iceconnectionstatechange');
81
             console.log('adding new remote SSRCs from iceconnectionstatechange');
82
-            window.setTimeout(function() { ob.modifySources(); }, 1000);
82
+            window.setTimeout(function() { self.modifySources(); }, 1000);
83
         }
83
         }
84
         */
84
         */
85
     };
85
     };
86
     this.peerconnection.onsignalingstatechange = function (event) {
86
     this.peerconnection.onsignalingstatechange = function (event) {
87
-        console.warn(ob.peerconnection.signalingState);
87
+        console.warn(self.peerconnection.signalingState);
88
         /*
88
         /*
89
-        if (ob.peerconnection.signalingState == 'stable' && ob.peerconnection.iceConnectionState == 'connected') {
89
+        if (self.peerconnection.signalingState == 'stable' && self.peerconnection.iceConnectionState == 'connected') {
90
             console.log('adding new remote SSRCs from signalingstatechange');
90
             console.log('adding new remote SSRCs from signalingstatechange');
91
-            window.setTimeout(function() { ob.modifySources(); }, 1000);
91
+            window.setTimeout(function() { self.modifySources(); }, 1000);
92
         }
92
         }
93
         */
93
         */
94
     };
94
     };
95
     this.peerconnection.onaddstream = function (event) {
95
     this.peerconnection.onaddstream = function (event) {
96
-        ob.remoteStream = event.stream;
96
+        self.remoteStream = event.stream;
97
         // search the jid associated with this stream
97
         // search the jid associated with this stream
98
-        Object.keys(ob.remotessrc).forEach(function (jid) {
99
-            if (ob.remotessrc[jid].join('\r\n').indexOf('mslabel:' + event.stream.id) != -1) {
98
+        Object.keys(self.remotessrc).forEach(function (jid) {
99
+            if (self.remotessrc[jid].join('\r\n').indexOf('mslabel:' + event.stream.id) != -1) {
100
                 event.peerjid = jid;
100
                 event.peerjid = jid;
101
-                if (ob.connection.jingle.jid2session[jid]) {
102
-                    ob.connection.jingle.jid2session[jid].remotestream = event.stream;
101
+                if (self.connection.jingle.jid2session[jid]) {
102
+                    self.connection.jingle.jid2session[jid].remotestream = event.stream;
103
                 }
103
                 }
104
             }
104
             }
105
         });
105
         });
106
-        $(document).trigger('remotestreamadded.jingle', [event, ob.sid]);
106
+        $(document).trigger('remotestreamadded.jingle', [event, self.sid]);
107
     };
107
     };
108
     this.peerconnection.onicecandidate = function (event) {
108
     this.peerconnection.onicecandidate = function (event) {
109
-        ob.sendIceCandidate(event.candidate);
109
+        self.sendIceCandidate(event.candidate);
110
     };
110
     };
111
     this.peerconnection.createOffer(
111
     this.peerconnection.createOffer(
112
         function (offer) {
112
         function (offer) {
113
-            ob.peerconnection.setLocalDescription(
113
+            self.peerconnection.setLocalDescription(
114
                 offer,
114
                 offer,
115
                 function () {
115
                 function () {
116
                     // success
116
                     // success
117
+                    $(document).trigger('setLocalDescription.jingle', [self.sid]);
117
                     // FIXME: could call _makeConference here and trickle candidates later
118
                     // FIXME: could call _makeConference here and trickle candidates later
118
                 },
119
                 },
119
                 function (error) {
120
                 function (error) {
126
         }
127
         }
127
     );
128
     );
128
     this.peerconnection.onicecandidate = function (event) {
129
     this.peerconnection.onicecandidate = function (event) {
129
-        console.log('candidate', event.candidate);
130
         if (!event.candidate) {
130
         if (!event.candidate) {
131
             console.log('end of candidates');
131
             console.log('end of candidates');
132
-            ob._makeConference();
132
+            self._makeConference();
133
             return;
133
             return;
134
         }
134
         }
135
     };
135
     };
136
 };
136
 };
137
 
137
 
138
 ColibriFocus.prototype._makeConference = function () {
138
 ColibriFocus.prototype._makeConference = function () {
139
-    var ob = this;
139
+    var self = this;
140
     var elem = $iq({to: this.bridgejid, type: 'get'});
140
     var elem = $iq({to: this.bridgejid, type: 'get'});
141
     elem.c('conference', {xmlns: 'http://jitsi.org/protocol/colibri'});
141
     elem.c('conference', {xmlns: 'http://jitsi.org/protocol/colibri'});
142
 
142
 
157
         localSDP.TransportToJingle(channel, elem);
157
         localSDP.TransportToJingle(channel, elem);
158
 
158
 
159
         elem.up(); // end of channel
159
         elem.up(); // end of channel
160
-        for (j = 0; j < ob.peers.length; j++) {
160
+        for (j = 0; j < self.peers.length; j++) {
161
             elem.c('channel', {initiator: 'true', expire:'15' }).up();
161
             elem.c('channel', {initiator: 'true', expire:'15' }).up();
162
         }
162
         }
163
         elem.up(); // end of content
163
         elem.up(); // end of content
165
 
165
 
166
     this.connection.sendIQ(elem,
166
     this.connection.sendIQ(elem,
167
         function (result) {
167
         function (result) {
168
-            ob.createdConference(result);
168
+            self.createdConference(result);
169
         },
169
         },
170
         function (error) {
170
         function (error) {
171
             console.warn(error);
171
             console.warn(error);
267
                 bridgeSDP.media[channel] += 'a=fingerprint:' + tmp.attr('hash') + ' ' + tmp.text() + '\r\n';
267
                 bridgeSDP.media[channel] += 'a=fingerprint:' + tmp.attr('hash') + ' ' + tmp.text() + '\r\n';
268
                 if (tmp.attr('setup')) {
268
                 if (tmp.attr('setup')) {
269
                     bridgeSDP.media[channel] += 'a=setup:' + tmp.attr('setup') + '\r\n';
269
                     bridgeSDP.media[channel] += 'a=setup:' + tmp.attr('setup') + '\r\n';
270
+                } else {
271
+                    bridgeSDP.media[channel] += 'a=setup:active\r\n';
270
                 }
272
                 }
271
             }
273
             }
272
         }
274
         }
273
     }
275
     }
274
     bridgeSDP.raw = bridgeSDP.session + bridgeSDP.media.join('');
276
     bridgeSDP.raw = bridgeSDP.session + bridgeSDP.media.join('');
275
 
277
 
276
-    var ob = this;
278
+    var self = this;
277
     this.peerconnection.setRemoteDescription(
279
     this.peerconnection.setRemoteDescription(
278
         new RTCSessionDescription({type: 'answer', sdp: bridgeSDP.raw}),
280
         new RTCSessionDescription({type: 'answer', sdp: bridgeSDP.raw}),
279
         function () {
281
         function () {
280
             console.log('setRemoteDescription success');
282
             console.log('setRemoteDescription success');
281
             for (var i = 0; i < numparticipants; i++) {
283
             for (var i = 0; i < numparticipants; i++) {
282
-                ob.initiate(ob.peers[i], true);
284
+                self.initiate(self.peers[i], true);
283
             }
285
             }
284
         },
286
         },
285
         function (error) {
287
         function (error) {
406
 
408
 
407
 // pull in a new participant into the conference
409
 // pull in a new participant into the conference
408
 ColibriFocus.prototype.addNewParticipant = function (peer) {
410
 ColibriFocus.prototype.addNewParticipant = function (peer) {
409
-    var ob = this;
411
+    var self = this;
410
     if (this.confid === 0) {
412
     if (this.confid === 0) {
411
         // bad state
413
         // bad state
412
         console.log('confid does not exist yet, postponing', peer);
414
         console.log('confid does not exist yet, postponing', peer);
413
         window.setTimeout(function () {
415
         window.setTimeout(function () {
414
-            ob.addNewParticipant(peer);
416
+            self.addNewParticipant(peer);
415
         }, 250);
417
         }, 250);
416
         return;
418
         return;
417
     }
419
     }
435
             var contents = $(result).find('>conference>content').get();
437
             var contents = $(result).find('>conference>content').get();
436
             for (var i = 0; i < contents.length; i++) {
438
             for (var i = 0; i < contents.length; i++) {
437
                 tmp = $(contents[i]).find('>channel').get();
439
                 tmp = $(contents[i]).find('>channel').get();
438
-                ob.channels[index][i] = tmp[0];
440
+                self.channels[index][i] = tmp[0];
439
             }
441
             }
440
-            ob.initiate(peer, true);
442
+            self.initiate(peer, true);
441
         },
443
         },
442
         function (error) {
444
         function (error) {
443
             console.warn(error);
445
             console.warn(error);
491
 // or a leaving participants a=ssrc lines
493
 // or a leaving participants a=ssrc lines
492
 // FIXME: should not take an SDP, but rather the a=ssrc lines and probably a=mid
494
 // FIXME: should not take an SDP, but rather the a=ssrc lines and probably a=mid
493
 ColibriFocus.prototype.sendSSRCUpdate = function (sdp, jid, isadd) {
495
 ColibriFocus.prototype.sendSSRCUpdate = function (sdp, jid, isadd) {
494
-    var ob = this;
496
+    var self = this;
495
     this.peers.forEach(function (peerjid) {
497
     this.peers.forEach(function (peerjid) {
496
         if (peerjid == jid) return;
498
         if (peerjid == jid) return;
497
         console.log('tell', peerjid, 'about ' + (isadd ? 'new' : 'removed') + ' ssrcs from', jid);
499
         console.log('tell', peerjid, 'about ' + (isadd ? 'new' : 'removed') + ' ssrcs from', jid);
498
-        if (!ob.remotessrc[peerjid]) {
500
+        if (!self.remotessrc[peerjid]) {
499
             // FIXME: this should only send to participants that are stable, i.e. who have sent a session-accept
501
             // FIXME: this should only send to participants that are stable, i.e. who have sent a session-accept
500
             // possibly, this.remoteSSRC[session.peerjid] does not exist yet
502
             // possibly, this.remoteSSRC[session.peerjid] does not exist yet
501
             console.warn('do we really want to bother', peerjid, 'with updates yet?');
503
             console.warn('do we really want to bother', peerjid, 'with updates yet?');
502
         }
504
         }
503
         var channel;
505
         var channel;
504
-        var peersess = ob.connection.jingle.jid2session[peerjid];
506
+        var peersess = self.connection.jingle.jid2session[peerjid];
505
         var modify = $iq({to: peerjid, type: 'set'})
507
         var modify = $iq({to: peerjid, type: 'set'})
506
             .c('jingle', {
508
             .c('jingle', {
507
                 xmlns: 'urn:xmpp:jingle:1',
509
                 xmlns: 'urn:xmpp:jingle:1',
538
             modify.up(); // end of content
540
             modify.up(); // end of content
539
         }
541
         }
540
         if (modified) {
542
         if (modified) {
541
-            ob.connection.sendIQ(modify,
543
+            self.connection.sendIQ(modify,
542
                 function (res) {
544
                 function (res) {
543
                     console.warn('got modify result');
545
                     console.warn('got modify result');
544
                 },
546
                 },
555
 ColibriFocus.prototype.setRemoteDescription = function (session, elem, desctype) {
557
 ColibriFocus.prototype.setRemoteDescription = function (session, elem, desctype) {
556
     var participant = this.peers.indexOf(session.peerjid);
558
     var participant = this.peers.indexOf(session.peerjid);
557
     console.log('Colibri.setRemoteDescription from', session.peerjid, participant);
559
     console.log('Colibri.setRemoteDescription from', session.peerjid, participant);
558
-    var ob = this;
560
+    var self = this;
559
     var remoteSDP = new SDP('');
561
     var remoteSDP = new SDP('');
560
     var tmp;
562
     var tmp;
561
     var channel;
563
     var channel;
585
 
587
 
586
 // relay ice candidates to bridge using trickle
588
 // relay ice candidates to bridge using trickle
587
 ColibriFocus.prototype.addIceCandidate = function (session, elem) {
589
 ColibriFocus.prototype.addIceCandidate = function (session, elem) {
588
-    var ob = this;
590
+    var self = this;
589
     var participant = this.peers.indexOf(session.peerjid);
591
     var participant = this.peers.indexOf(session.peerjid);
590
-    console.log('change transport allocation for', this.confid, session.peerjid, participant);
592
+    //console.log('change transport allocation for', this.confid, session.peerjid, participant);
591
     var change = $iq({to: this.bridgejid, type: 'set'});
593
     var change = $iq({to: this.bridgejid, type: 'set'});
592
     change.c('conference', {xmlns: 'http://jitsi.org/protocol/colibri', id: this.confid});
594
     change.c('conference', {xmlns: 'http://jitsi.org/protocol/colibri', id: this.confid});
593
     $(elem).each(function () {
595
     $(elem).each(function () {
595
         var channel = name == 'audio' ? 0 : 1; // FIXME: search mlineindex in localdesc
597
         var channel = name == 'audio' ? 0 : 1; // FIXME: search mlineindex in localdesc
596
 
598
 
597
         change.c('content', {name: name});
599
         change.c('content', {name: name});
598
-        change.c('channel', {id: $(ob.channels[participant][channel]).attr('id')});
600
+        change.c('channel', {id: $(self.channels[participant][channel]).attr('id')});
599
         $(this).find('>transport').each(function () {
601
         $(this).find('>transport').each(function () {
600
             change.c('transport', {
602
             change.c('transport', {
601
                 ufrag: $(this).attr('ufrag'),
603
                 ufrag: $(this).attr('ufrag'),
702
 };
704
 };
703
 
705
 
704
 ColibriFocus.prototype.modifySources = function () {
706
 ColibriFocus.prototype.modifySources = function () {
705
-    var ob = this;
707
+    var self = this;
706
     if (!(this.addssrc.length || this.removessrc.length)) return;
708
     if (!(this.addssrc.length || this.removessrc.length)) return;
707
     if (this.peerconnection.signalingState == 'closed') return;
709
     if (this.peerconnection.signalingState == 'closed') return;
708
 
710
 
710
     // https://code.google.com/p/webrtc/issues/detail?id=2688
712
     // https://code.google.com/p/webrtc/issues/detail?id=2688
711
     if (!(this.peerconnection.signalingState == 'stable' && this.peerconnection.iceConnectionState == 'connected')) {
713
     if (!(this.peerconnection.signalingState == 'stable' && this.peerconnection.iceConnectionState == 'connected')) {
712
         console.warn('modifySources not yet', this.peerconnection.signalingState, this.peerconnection.iceConnectionState);
714
         console.warn('modifySources not yet', this.peerconnection.signalingState, this.peerconnection.iceConnectionState);
713
-        window.setTimeout(function () { ob.modifySources(); }, 250);
715
+        window.setTimeout(function () { self.modifySources(); }, 250);
714
         this.wait = true;
716
         this.wait = true;
715
         return;
717
         return;
716
     }
718
     }
717
     if (this.wait) {
719
     if (this.wait) {
718
-        window.setTimeout(function () { ob.modifySources(); }, 2500);
720
+        window.setTimeout(function () { self.modifySources(); }, 2500);
719
         this.wait = false;
721
         this.wait = false;
720
         return;
722
         return;
721
     }
723
     }
738
     this.removessrc = [];
740
     this.removessrc = [];
739
 
741
 
740
     sdp.raw = sdp.session + sdp.media.join('');
742
     sdp.raw = sdp.session + sdp.media.join('');
743
+    /*
744
+     * this seems to create a number of problems...
741
     this.peerconnection.setRemoteDescription(
745
     this.peerconnection.setRemoteDescription(
742
         new RTCSessionDescription({type: 'offer', sdp: sdp.raw }),
746
         new RTCSessionDescription({type: 'offer', sdp: sdp.raw }),
743
         function () {
747
         function () {
744
             console.log('setModifiedRemoteDescription ok');
748
             console.log('setModifiedRemoteDescription ok');
745
-            ob.peerconnection.createAnswer(
749
+            self.peerconnection.createAnswer(
746
                 function (modifiedAnswer) {
750
                 function (modifiedAnswer) {
747
-                    console.log('modifiedAnswer created');
751
+                    console.log('modifiedAnswer created', modifiedAnswer.sdp);
748
                     // FIXME: pushing down an answer while ice connection state 
752
                     // FIXME: pushing down an answer while ice connection state 
749
                     // is still checking is bad...
753
                     // is still checking is bad...
750
-                    console.log(ob.peerconnection.iceConnectionState);
751
-                    ob.peerconnection.setLocalDescription(modifiedAnswer,
754
+                    console.log(self.peerconnection.iceConnectionState);
755
+
756
+                    // trying to work around another chrome bug
757
+                    //modifiedAnswer.sdp = modifiedAnswer.sdp.replace(/a=setup:active/g, 'a=setup:actpass');
758
+                    self.peerconnection.setLocalDescription(modifiedAnswer,
752
                         function () {
759
                         function () {
753
                             console.log('setModifiedLocalDescription ok');
760
                             console.log('setModifiedLocalDescription ok');
761
+                            $(document).trigger('setLocalDescription.jingle', [self.sid]);
754
                         },
762
                         },
755
                         function (error) {
763
                         function (error) {
756
                             console.log('setModifiedLocalDescription failed');
764
                             console.log('setModifiedLocalDescription failed');
766
             console.log('setModifiedRemoteDescription failed');
774
             console.log('setModifiedRemoteDescription failed');
767
         }
775
         }
768
     );
776
     );
777
+    */
778
+    this.peerconnection.createOffer(
779
+        function (modifiedOffer) {
780
+            console.log('created (un)modified offer');
781
+            self.peerconnection.setLocalDescription(modifiedOffer,
782
+                function () {
783
+                    console.log('setModifiedLocalDescription ok');
784
+                    self.peerconnection.setRemoteDescription(
785
+                        new RTCSessionDescription({type: 'answer', sdp: sdp.raw }),
786
+                        function () {
787
+                            console.log('setModifiedRemoteDescription ok');
788
+                        },
789
+                        function (error) {
790
+                            console.log('setModifiedRemoteDescription failed');
791
+                        }
792
+                    );
793
+                    $(document).trigger('setLocalDescription.jingle', [self.sid]);
794
+                },
795
+                function (error) {
796
+                    console.log('setModifiedLocalDescription failed');
797
+                }
798
+            );
799
+        },
800
+        function (error) {
801
+            console.log('creating (un)modified offerfailed');
802
+        }
803
+    );
769
 };
804
 };
770
 
805
 
771
 
806
 

+ 122
- 127
libs/strophejingle.bundle.js Ver arquivo

607
 
607
 
608
 // remove lines matching prefix from session section
608
 // remove lines matching prefix from session section
609
 SDP.prototype.removeSessionLines = function(prefix) {
609
 SDP.prototype.removeSessionLines = function(prefix) {
610
-    var ob = this;
610
+    var self = this;
611
     var lines = SDPUtil.find_lines(this.session, prefix);
611
     var lines = SDPUtil.find_lines(this.session, prefix);
612
     lines.forEach(function(line) {
612
     lines.forEach(function(line) {
613
-        ob.session = ob.session.replace(line + '\r\n', '');
613
+        self.session = self.session.replace(line + '\r\n', '');
614
     });
614
     });
615
     this.raw = this.session + this.media.join('');
615
     this.raw = this.session + this.media.join('');
616
     return lines;
616
     return lines;
618
 // remove lines matching prefix from a media section specified by mediaindex
618
 // remove lines matching prefix from a media section specified by mediaindex
619
 // TODO: non-numeric mediaindex could match mid
619
 // TODO: non-numeric mediaindex could match mid
620
 SDP.prototype.removeMediaLines = function(mediaindex, prefix) {
620
 SDP.prototype.removeMediaLines = function(mediaindex, prefix) {
621
-    var ob = this;
621
+    var self = this;
622
     var lines = SDPUtil.find_lines(this.media[mediaindex], prefix);
622
     var lines = SDPUtil.find_lines(this.media[mediaindex], prefix);
623
     lines.forEach(function(line) {
623
     lines.forEach(function(line) {
624
-        ob.media[mediaindex] = ob.media[mediaindex].replace(line + '\r\n', '');
624
+        self.media[mediaindex] = self.media[mediaindex].replace(line + '\r\n', '');
625
     });
625
     });
626
     this.raw = this.session + this.media.join('');
626
     this.raw = this.session + this.media.join('');
627
     return lines;
627
     return lines;
630
 // add content's to a jingle element
630
 // add content's to a jingle element
631
 SDP.prototype.toJingle = function (elem, thecreator) {
631
 SDP.prototype.toJingle = function (elem, thecreator) {
632
     var i, j, k, mline, ssrc, rtpmap, tmp, line, lines;
632
     var i, j, k, mline, ssrc, rtpmap, tmp, line, lines;
633
-    var ob = this;
633
+    var self = this;
634
     // new bundle plan
634
     // new bundle plan
635
     if (SDPUtil.find_line(this.session, 'a=group:')) {
635
     if (SDPUtil.find_line(this.session, 'a=group:')) {
636
         lines = SDPUtil.find_lines(this.session, 'a=group:');
636
         lines = SDPUtil.find_lines(this.session, 'a=group:');
806
 SDP.prototype.TransportToJingle = function (mediaindex, elem) {
806
 SDP.prototype.TransportToJingle = function (mediaindex, elem) {
807
     var i = mediaindex;
807
     var i = mediaindex;
808
     var tmp;
808
     var tmp;
809
-    var ob = this;
809
+    var self = this;
810
     elem.c('transport');
810
     elem.c('transport');
811
 
811
 
812
     // XEP-0320
812
     // XEP-0320
817
         // tmp.xmlns = 'urn:xmpp:jingle:apps:dtls:0'; -- FIXME: update receivers first
817
         // tmp.xmlns = 'urn:xmpp:jingle:apps:dtls:0'; -- FIXME: update receivers first
818
         elem.c('fingerprint').t(tmp.fingerprint);
818
         elem.c('fingerprint').t(tmp.fingerprint);
819
         delete tmp.fingerprint;
819
         delete tmp.fingerprint;
820
-        line = SDPUtil.find_line(ob.media[mediaindex], 'a=setup:', ob.session);
820
+        line = SDPUtil.find_line(self.media[mediaindex], 'a=setup:', self.session);
821
         if (line) {
821
         if (line) {
822
             tmp.setup = line.substr(8);
822
             tmp.setup = line.substr(8);
823
         }
823
         }
881
 
881
 
882
 // construct an SDP from a jingle stanza
882
 // construct an SDP from a jingle stanza
883
 SDP.prototype.fromJingle = function (jingle) {
883
 SDP.prototype.fromJingle = function (jingle) {
884
-    var obj = this;
884
+    var self = this;
885
     this.raw = 'v=0\r\n' +
885
     this.raw = 'v=0\r\n' +
886
         'o=- ' + '1923518516' + ' 2 IN IP4 0.0.0.0\r\n' +// FIXME
886
         'o=- ' + '1923518516' + ' 2 IN IP4 0.0.0.0\r\n' +// FIXME
887
         's=-\r\n' +
887
         's=-\r\n' +
893
                 return content.getAttribute('name');
893
                 return content.getAttribute('name');
894
             }).get();
894
             }).get();
895
             if (contents.length > 0) {
895
             if (contents.length > 0) {
896
-                obj.raw += 'a=group:' + (group.getAttribute('semantics') || group.getAttribute('type')) + ' ' + contents.join(' ') + '\r\n';
896
+                self.raw += 'a=group:' + (group.getAttribute('semantics') || group.getAttribute('type')) + ' ' + contents.join(' ') + '\r\n';
897
             }
897
             }
898
         });
898
         });
899
     } else if ($(jingle).find('>group[xmlns="urn:ietf:rfc:5888"]').length) {
899
     } else if ($(jingle).find('>group[xmlns="urn:ietf:rfc:5888"]').length) {
903
                 return content.getAttribute('name');
903
                 return content.getAttribute('name');
904
             }).get();
904
             }).get();
905
             if (group.getAttribute('type') !== null && contents.length > 0) {
905
             if (group.getAttribute('type') !== null && contents.length > 0) {
906
-                obj.raw += 'a=group:' + group.getAttribute('type') + ' ' + contents.join(' ') + '\r\n';
906
+                self.raw += 'a=group:' + group.getAttribute('type') + ' ' + contents.join(' ') + '\r\n';
907
             }
907
             }
908
         });
908
         });
909
     } else {
909
     } else {
922
 
922
 
923
     this.session = this.raw;
923
     this.session = this.raw;
924
     jingle.find('>content').each(function () {
924
     jingle.find('>content').each(function () {
925
-        var m = obj.jingle2media($(this));
926
-        obj.media.push(m);
925
+        var m = self.jingle2media($(this));
926
+        self.media.push(m);
927
     });
927
     });
928
 
928
 
929
     // reconstruct msid-semantic -- apparently not necessary
929
     // reconstruct msid-semantic -- apparently not necessary
1416
 }
1416
 }
1417
 
1417
 
1418
 JingleSession.prototype.initiate = function (peerjid, isInitiator) {
1418
 JingleSession.prototype.initiate = function (peerjid, isInitiator) {
1419
-    var obj = this;
1419
+    var self = this;
1420
     if (this.state !== null) {
1420
     if (this.state !== null) {
1421
         console.error('attempt to initiate on session ' + this.sid +
1421
         console.error('attempt to initiate on session ' + this.sid +
1422
                   'in state ' + this.state);
1422
                   'in state ' + this.state);
1427
     this.initiator = isInitiator ? this.me : peerjid;
1427
     this.initiator = isInitiator ? this.me : peerjid;
1428
     this.responder = !isInitiator ? this.me : peerjid;
1428
     this.responder = !isInitiator ? this.me : peerjid;
1429
     this.peerjid = peerjid;
1429
     this.peerjid = peerjid;
1430
-    console.log('create PeerConnection ' + JSON.stringify(this.ice_config));
1430
+    //console.log('create PeerConnection ' + JSON.stringify(this.ice_config));
1431
     try {
1431
     try {
1432
         this.peerconnection = new RTCPeerconnection(this.ice_config,
1432
         this.peerconnection = new RTCPeerconnection(this.ice_config,
1433
                                                      this.pc_constraints);
1433
                                                      this.pc_constraints);
1434
-        console.log('Created RTCPeerConnnection');
1435
     } catch (e) {
1434
     } catch (e) {
1436
         console.error('Failed to create PeerConnection, exception: ',
1435
         console.error('Failed to create PeerConnection, exception: ',
1437
                       e.message);
1436
                       e.message);
1442
     this.hadturncandidate = false;
1441
     this.hadturncandidate = false;
1443
     this.lasticecandidate = false;
1442
     this.lasticecandidate = false;
1444
     this.peerconnection.onicecandidate = function (event) {
1443
     this.peerconnection.onicecandidate = function (event) {
1445
-        obj.sendIceCandidate(event.candidate);
1444
+        self.sendIceCandidate(event.candidate);
1446
     };
1445
     };
1447
     this.peerconnection.onaddstream = function (event) {
1446
     this.peerconnection.onaddstream = function (event) {
1448
-        obj.remoteStream = event.stream;
1449
-        obj.remoteStreams.push(event.stream);
1450
-        $(document).trigger('remotestreamadded.jingle', [event, obj.sid]);
1447
+        self.remoteStream = event.stream;
1448
+        self.remoteStreams.push(event.stream);
1449
+        $(document).trigger('remotestreamadded.jingle', [event, self.sid]);
1451
     };
1450
     };
1452
     this.peerconnection.onremovestream = function (event) {
1451
     this.peerconnection.onremovestream = function (event) {
1453
-        obj.remoteStream = null;
1452
+        self.remoteStream = null;
1454
         // FIXME: remove from this.remoteStreams
1453
         // FIXME: remove from this.remoteStreams
1455
-        $(document).trigger('remotestreamremoved.jingle', [event, obj.sid]);
1454
+        $(document).trigger('remotestreamremoved.jingle', [event, self.sid]);
1456
     };
1455
     };
1457
     this.peerconnection.onsignalingstatechange = function (event) {
1456
     this.peerconnection.onsignalingstatechange = function (event) {
1458
-        if (!(obj && obj.peerconnection)) return;
1459
-        console.log('signallingstate ', obj.peerconnection.signalingState, event);
1457
+        if (!(self && self.peerconnection)) return;
1460
     };
1458
     };
1461
     this.peerconnection.oniceconnectionstatechange = function (event) {
1459
     this.peerconnection.oniceconnectionstatechange = function (event) {
1462
-        if (!(obj && obj.peerconnection)) return;
1463
-        console.log('iceconnectionstatechange', obj.peerconnection.iceConnectionState, event);
1464
-        switch (obj.peerconnection.iceConnectionState) {
1460
+        if (!(self && self.peerconnection)) return;
1461
+        switch (self.peerconnection.iceConnectionState) {
1465
         case 'connected':
1462
         case 'connected':
1466
             this.startTime = new Date();
1463
             this.startTime = new Date();
1467
             break;
1464
             break;
1469
             this.stopTime = new Date();
1466
             this.stopTime = new Date();
1470
             break;
1467
             break;
1471
         }
1468
         }
1472
-        $(document).trigger('iceconnectionstatechange.jingle', [obj.sid, obj]);
1469
+        $(document).trigger('iceconnectionstatechange.jingle', [self.sid, self]);
1473
     };
1470
     };
1474
     // add any local and relayed stream
1471
     // add any local and relayed stream
1475
     this.localStreams.forEach(function(stream) {
1472
     this.localStreams.forEach(function(stream) {
1476
-        obj.peerconnection.addStream(stream);
1473
+        self.peerconnection.addStream(stream);
1477
     });
1474
     });
1478
     this.relayedStreams.forEach(function(stream) {
1475
     this.relayedStreams.forEach(function(stream) {
1479
-        obj.peerconnection.addStream(stream);
1476
+        self.peerconnection.addStream(stream);
1480
     });
1477
     });
1481
 };
1478
 };
1482
 
1479
 
1483
 JingleSession.prototype.accept = function () {
1480
 JingleSession.prototype.accept = function () {
1484
-    var ob = this;
1481
+    var self = this;
1485
     this.state = 'active';
1482
     this.state = 'active';
1486
 
1483
 
1487
     var pranswer = this.peerconnection.localDescription;
1484
     var pranswer = this.peerconnection.localDescription;
1513
         function () {
1510
         function () {
1514
             var ack = {};
1511
             var ack = {};
1515
             ack.source = 'answer';
1512
             ack.source = 'answer';
1516
-            $(document).trigger('ack.jingle', [ob.sid, ack]);
1513
+            $(document).trigger('ack.jingle', [self.sid, ack]);
1517
         },
1514
         },
1518
         function (stanza) {
1515
         function (stanza) {
1519
             var error = ($(stanza).find('error').length) ? {
1516
             var error = ($(stanza).find('error').length) ? {
1521
                 reason: $(stanza).find('error :first')[0].tagName,
1518
                 reason: $(stanza).find('error :first')[0].tagName,
1522
             }:{};
1519
             }:{};
1523
             error.source = 'answer';
1520
             error.source = 'answer';
1524
-            $(document).trigger('error.jingle', [ob.sid, error]);
1521
+            $(document).trigger('error.jingle', [self.sid, error]);
1525
         },
1522
         },
1526
     10000);
1523
     10000);
1527
 
1524
 
1532
     }
1529
     }
1533
     this.peerconnection.setLocalDescription(new RTCSessionDescription({type: 'answer', sdp: sdp}),
1530
     this.peerconnection.setLocalDescription(new RTCSessionDescription({type: 'answer', sdp: sdp}),
1534
         function () {
1531
         function () {
1535
-            console.log('setLocalDescription success');
1532
+            //console.log('setLocalDescription success');
1536
         },
1533
         },
1537
         function (e) {
1534
         function (e) {
1538
             console.error('setLocalDescription failed', e);
1535
             console.error('setLocalDescription failed', e);
1555
 };
1552
 };
1556
 
1553
 
1557
 JingleSession.prototype.sendIceCandidate = function (candidate) {
1554
 JingleSession.prototype.sendIceCandidate = function (candidate) {
1558
-    var ob = this;
1555
+    var self = this;
1559
     if (candidate && !this.lasticecandidate) {
1556
     if (candidate && !this.lasticecandidate) {
1560
         var ice = SDPUtil.iceparams(this.localSDP.media[candidate.sdpMLineIndex], this.localSDP.session);
1557
         var ice = SDPUtil.iceparams(this.localSDP.media[candidate.sdpMLineIndex], this.localSDP.session);
1561
         var jcand = SDPUtil.candidateToJingle(candidate.candidate);
1558
         var jcand = SDPUtil.candidateToJingle(candidate.candidate);
1576
                 if (this.drip_container.length === 0) {
1573
                 if (this.drip_container.length === 0) {
1577
                     // start 10ms callout
1574
                     // start 10ms callout
1578
                     window.setTimeout(function () {
1575
                     window.setTimeout(function () {
1579
-                        if (ob.drip_container.length === 0) return;
1580
-                        var allcands = ob.drip_container;
1581
-                        ob.drip_container = [];
1582
-                        var cand = $iq({to: ob.peerjid, type: 'set'})
1576
+                        if (self.drip_container.length === 0) return;
1577
+                        var allcands = self.drip_container;
1578
+                        self.drip_container = [];
1579
+                        var cand = $iq({to: self.peerjid, type: 'set'})
1583
                             .c('jingle', {xmlns: 'urn:xmpp:jingle:1',
1580
                             .c('jingle', {xmlns: 'urn:xmpp:jingle:1',
1584
                                action: 'transport-info',
1581
                                action: 'transport-info',
1585
-                               initiator: ob.initiator,
1586
-                               sid: ob.sid});
1587
-                        for (var mid = 0; mid < ob.localSDP.media.length; mid++) {
1582
+                               initiator: self.initiator,
1583
+                               sid: self.sid});
1584
+                        for (var mid = 0; mid < self.localSDP.media.length; mid++) {
1588
                             var cands = allcands.filter(function (el) { return el.sdpMLineIndex == mid; });
1585
                             var cands = allcands.filter(function (el) { return el.sdpMLineIndex == mid; });
1589
                             if (cands.length > 0) {
1586
                             if (cands.length > 0) {
1590
-                                var ice = SDPUtil.iceparams(ob.localSDP.media[mid], ob.localSDP.session);
1587
+                                var ice = SDPUtil.iceparams(self.localSDP.media[mid], self.localSDP.session);
1591
                                 ice.xmlns = 'urn:xmpp:jingle:transports:ice-udp:1';
1588
                                 ice.xmlns = 'urn:xmpp:jingle:transports:ice-udp:1';
1592
-                                cand.c('content', {creator: ob.initiator == ob.me ? 'initiator' : 'responder',
1589
+                                cand.c('content', {creator: self.initiator == self.me ? 'initiator' : 'responder',
1593
                                        name: cands[0].sdpMid
1590
                                        name: cands[0].sdpMid
1594
                                 }).c('transport', ice);
1591
                                 }).c('transport', ice);
1595
                                 for (var i = 0; i < cands.length; i++) {
1592
                                 for (var i = 0; i < cands.length; i++) {
1596
                                     cand.c('candidate', SDPUtil.candidateToJingle(cands[i].candidate)).up();
1593
                                     cand.c('candidate', SDPUtil.candidateToJingle(cands[i].candidate)).up();
1597
                                 }
1594
                                 }
1598
                                 // add fingerprint
1595
                                 // add fingerprint
1599
-                                if (SDPUtil.find_line(ob.localSDP.media[mid], 'a=fingerprint:', ob.localSDP.session)) {
1600
-                                    var tmp = SDPUtil.parse_fingerprint(SDPUtil.find_line(ob.localSDP.media[mid], 'a=fingerprint:', ob.localSDP.session));
1596
+                                if (SDPUtil.find_line(self.localSDP.media[mid], 'a=fingerprint:', self.localSDP.session)) {
1597
+                                    var tmp = SDPUtil.parse_fingerprint(SDPUtil.find_line(self.localSDP.media[mid], 'a=fingerprint:', self.localSDP.session));
1601
                                     tmp.required = true;
1598
                                     tmp.required = true;
1602
                                     cand.c('fingerprint').t(tmp.fingerprint);
1599
                                     cand.c('fingerprint').t(tmp.fingerprint);
1603
                                     delete tmp.fingerprint;
1600
                                     delete tmp.fingerprint;
1609
                             }
1606
                             }
1610
                         }
1607
                         }
1611
                         // might merge last-candidate notification into this, but it is called alot later. See webrtc issue #2340
1608
                         // might merge last-candidate notification into this, but it is called alot later. See webrtc issue #2340
1612
-                        //console.log('was this the last candidate', ob.lasticecandidate);
1613
-                        ob.connection.sendIQ(cand,
1609
+                        //console.log('was this the last candidate', self.lasticecandidate);
1610
+                        self.connection.sendIQ(cand,
1614
                             function () {
1611
                             function () {
1615
                                 var ack = {};
1612
                                 var ack = {};
1616
                                 ack.source = 'transportinfo';
1613
                                 ack.source = 'transportinfo';
1617
-                                $(document).trigger('ack.jingle', [ob.sid, ack]);
1614
+                                $(document).trigger('ack.jingle', [self.sid, ack]);
1618
                             },
1615
                             },
1619
                             function (stanza) {
1616
                             function (stanza) {
1620
                                 var error = ($(stanza).find('error').length) ? {
1617
                                 var error = ($(stanza).find('error').length) ? {
1622
                                     reason: $(stanza).find('error :first')[0].tagName,
1619
                                     reason: $(stanza).find('error :first')[0].tagName,
1623
                                 }:{};
1620
                                 }:{};
1624
                                 error.source = 'transportinfo';
1621
                                 error.source = 'transportinfo';
1625
-                                $(document).trigger('error.jingle', [ob.sid, error]);
1622
+                                $(document).trigger('error.jingle', [self.sid, error]);
1626
                             },
1623
                             },
1627
                         10000);
1624
                         10000);
1628
                     }, 10);
1625
                     }, 10);
1655
                 function () {
1652
                 function () {
1656
                     var ack = {};
1653
                     var ack = {};
1657
                     ack.source = 'transportinfo';
1654
                     ack.source = 'transportinfo';
1658
-                    $(document).trigger('ack.jingle', [ob.sid, ack]);
1655
+                    $(document).trigger('ack.jingle', [self.sid, ack]);
1659
                 },
1656
                 },
1660
                 function (stanza) {
1657
                 function (stanza) {
1661
                     console.error('transport info error');
1658
                     console.error('transport info error');
1664
                         reason: $(stanza).find('error :first')[0].tagName,
1661
                         reason: $(stanza).find('error :first')[0].tagName,
1665
                     }:{};
1662
                     }:{};
1666
                     error.source = 'transportinfo';
1663
                     error.source = 'transportinfo';
1667
-                    $(document).trigger('error.jingle', [ob.sid, error]);
1664
+                    $(document).trigger('error.jingle', [self.sid, error]);
1668
                 },
1665
                 },
1669
             10000);
1666
             10000);
1670
         }
1667
         }
1671
     } else {
1668
     } else {
1672
-        console.log('sendIceCandidate: last candidate.');
1669
+        //console.log('sendIceCandidate: last candidate.');
1673
         if (!this.usetrickle) {
1670
         if (!this.usetrickle) {
1674
-            console.log('should send full offer now...');
1671
+            //console.log('should send full offer now...');
1675
             var init = $iq({to: this.peerjid,
1672
             var init = $iq({to: this.peerjid,
1676
                        type: 'set'})
1673
                        type: 'set'})
1677
                 .c('jingle', {xmlns: 'urn:xmpp:jingle:1',
1674
                 .c('jingle', {xmlns: 'urn:xmpp:jingle:1',
1682
             this.localSDP.toJingle(init, this.initiator == this.me ? 'initiator' : 'responder');
1679
             this.localSDP.toJingle(init, this.initiator == this.me ? 'initiator' : 'responder');
1683
             this.connection.sendIQ(init,
1680
             this.connection.sendIQ(init,
1684
                 function () {
1681
                 function () {
1685
-                    console.log('session initiate ack');
1682
+                    //console.log('session initiate ack');
1686
                     var ack = {};
1683
                     var ack = {};
1687
                     ack.source = 'offer';
1684
                     ack.source = 'offer';
1688
-                    $(document).trigger('ack.jingle', [ob.sid, ack]);
1685
+                    $(document).trigger('ack.jingle', [self.sid, ack]);
1689
                 },
1686
                 },
1690
                 function (stanza) {
1687
                 function (stanza) {
1691
-                    ob.state = 'error';
1692
-                    ob.peerconnection.close();
1688
+                    self.state = 'error';
1689
+                    self.peerconnection.close();
1693
                     var error = ($(stanza).find('error').length) ? {
1690
                     var error = ($(stanza).find('error').length) ? {
1694
                         code: $(stanza).find('error').attr('code'),
1691
                         code: $(stanza).find('error').attr('code'),
1695
                         reason: $(stanza).find('error :first')[0].tagName,
1692
                         reason: $(stanza).find('error :first')[0].tagName,
1696
                     }:{};
1693
                     }:{};
1697
                     error.source = 'offer';
1694
                     error.source = 'offer';
1698
-                    $(document).trigger('error.jingle', [ob.sid, error]);
1695
+                    $(document).trigger('error.jingle', [self.sid, error]);
1699
                 },
1696
                 },
1700
             10000);
1697
             10000);
1701
         }
1698
         }
1710
 };
1707
 };
1711
 
1708
 
1712
 JingleSession.prototype.sendOffer = function () {
1709
 JingleSession.prototype.sendOffer = function () {
1713
-    console.log('sendOffer...');
1714
-    var ob = this;
1710
+    //console.log('sendOffer...');
1711
+    var self = this;
1715
     this.peerconnection.createOffer(function (sdp) {
1712
     this.peerconnection.createOffer(function (sdp) {
1716
-            ob.createdOffer(sdp);
1713
+            self.createdOffer(sdp);
1717
         },
1714
         },
1718
         function (e) {
1715
         function (e) {
1719
             console.error('createOffer failed', e);
1716
             console.error('createOffer failed', e);
1723
 };
1720
 };
1724
 
1721
 
1725
 JingleSession.prototype.createdOffer = function (sdp) {
1722
 JingleSession.prototype.createdOffer = function (sdp) {
1726
-    console.log('createdOffer', sdp);
1727
-    var ob = this;
1723
+    //console.log('createdOffer', sdp);
1724
+    var self = this;
1728
     this.localSDP = new SDP(sdp.sdp);
1725
     this.localSDP = new SDP(sdp.sdp);
1729
     //this.localSDP.mangle();
1726
     //this.localSDP.mangle();
1730
     if (this.usetrickle) {
1727
     if (this.usetrickle) {
1739
             function () {
1736
             function () {
1740
                 var ack = {};
1737
                 var ack = {};
1741
                 ack.source = 'offer';
1738
                 ack.source = 'offer';
1742
-                $(document).trigger('ack.jingle', [ob.sid, ack]);
1739
+                $(document).trigger('ack.jingle', [self.sid, ack]);
1743
             },
1740
             },
1744
             function (stanza) {
1741
             function (stanza) {
1745
-                ob.state = 'error';
1746
-                ob.peerconnection.close();
1742
+                self.state = 'error';
1743
+                self.peerconnection.close();
1747
                 var error = ($(stanza).find('error').length) ? {
1744
                 var error = ($(stanza).find('error').length) ? {
1748
                     code: $(stanza).find('error').attr('code'),
1745
                     code: $(stanza).find('error').attr('code'),
1749
                     reason: $(stanza).find('error :first')[0].tagName,
1746
                     reason: $(stanza).find('error :first')[0].tagName,
1750
                 }:{};
1747
                 }:{};
1751
                 error.source = 'offer';
1748
                 error.source = 'offer';
1752
-                $(document).trigger('error.jingle', [ob.sid, error]);
1749
+                $(document).trigger('error.jingle', [self.sid, error]);
1753
             },
1750
             },
1754
         10000);
1751
         10000);
1755
     }
1752
     }
1756
     sdp.sdp = this.localSDP.raw;
1753
     sdp.sdp = this.localSDP.raw;
1757
-    this.peerconnection.setLocalDescription(sdp, function () {
1758
-            console.log('setLocalDescription success');
1754
+    this.peerconnection.setLocalDescription(sdp, 
1755
+        function () {
1756
+            //console.log('setLocalDescription success');
1759
         },
1757
         },
1760
         function (e) {
1758
         function (e) {
1761
             console.error('setLocalDescription failed', e);
1759
             console.error('setLocalDescription failed', e);
1773
 };
1771
 };
1774
 
1772
 
1775
 JingleSession.prototype.setRemoteDescription = function (elem, desctype) {
1773
 JingleSession.prototype.setRemoteDescription = function (elem, desctype) {
1776
-    console.log('setting remote description... ', desctype);
1774
+    //console.log('setting remote description... ', desctype);
1777
     this.remoteSDP = new SDP('');
1775
     this.remoteSDP = new SDP('');
1778
     this.remoteSDP.fromJingle(elem);
1776
     this.remoteSDP.fromJingle(elem);
1779
     if (this.peerconnection.remoteDescription !== null) {
1777
     if (this.peerconnection.remoteDescription !== null) {
1807
     
1805
     
1808
     this.peerconnection.setRemoteDescription(remotedesc,
1806
     this.peerconnection.setRemoteDescription(remotedesc,
1809
         function () {
1807
         function () {
1810
-            console.log('setRemoteDescription success');
1808
+            //console.log('setRemoteDescription success');
1811
         },
1809
         },
1812
         function (e) {
1810
         function (e) {
1813
             console.error('setRemoteDescription error', e);
1811
             console.error('setRemoteDescription error', e);
1816
 };
1814
 };
1817
 
1815
 
1818
 JingleSession.prototype.addIceCandidate = function (elem) {
1816
 JingleSession.prototype.addIceCandidate = function (elem) {
1819
-    var obj = this;
1817
+    var self = this;
1820
     if (this.peerconnection.signalingState == 'closed') {
1818
     if (this.peerconnection.signalingState == 'closed') {
1821
         return;
1819
         return;
1822
     }
1820
     }
1841
         }
1839
         }
1842
         // then add things like ice and dtls from remote candidate
1840
         // then add things like ice and dtls from remote candidate
1843
         elem.each(function () {
1841
         elem.each(function () {
1844
-            for (var i = 0; i < obj.remoteSDP.media.length; i++) {
1845
-                if (SDPUtil.find_line(obj.remoteSDP.media[i], 'a=mid:' + $(this).attr('name')) ||
1846
-                        obj.remoteSDP.media[i].indexOf('m=' + $(this).attr('name')) === 0) {
1847
-                    if (!SDPUtil.find_line(obj.remoteSDP.media[i], 'a=ice-ufrag:')) {
1842
+            for (var i = 0; i < self.remoteSDP.media.length; i++) {
1843
+                if (SDPUtil.find_line(self.remoteSDP.media[i], 'a=mid:' + $(this).attr('name')) ||
1844
+                        self.remoteSDP.media[i].indexOf('m=' + $(this).attr('name')) === 0) {
1845
+                    if (!SDPUtil.find_line(self.remoteSDP.media[i], 'a=ice-ufrag:')) {
1848
                         var tmp = $(this).find('transport');
1846
                         var tmp = $(this).find('transport');
1849
-                        obj.remoteSDP.media[i] += 'a=ice-ufrag:' + tmp.attr('ufrag') + '\r\n';
1850
-                        obj.remoteSDP.media[i] += 'a=ice-pwd:' + tmp.attr('pwd') + '\r\n';
1847
+                        self.remoteSDP.media[i] += 'a=ice-ufrag:' + tmp.attr('ufrag') + '\r\n';
1848
+                        self.remoteSDP.media[i] += 'a=ice-pwd:' + tmp.attr('pwd') + '\r\n';
1851
                         tmp = $(this).find('transport>fingerprint');
1849
                         tmp = $(this).find('transport>fingerprint');
1852
                         if (tmp.length) {
1850
                         if (tmp.length) {
1853
-                            obj.remoteSDP.media[i] += 'a=fingerprint:' + tmp.attr('hash') + ' ' + tmp.text() + '\r\n';
1851
+                            self.remoteSDP.media[i] += 'a=fingerprint:' + tmp.attr('hash') + ' ' + tmp.text() + '\r\n';
1854
                         } else {
1852
                         } else {
1855
                             console.log('no dtls fingerprint (webrtc issue #1718?)');
1853
                             console.log('no dtls fingerprint (webrtc issue #1718?)');
1856
-                            obj.remoteSDP.media[i] += 'a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:BAADBAADBAADBAADBAADBAADBAADBAADBAADBAAD\r\n';
1854
+                            self.remoteSDP.media[i] += 'a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:BAADBAADBAADBAADBAADBAADBAADBAADBAADBAAD\r\n';
1857
                         }
1855
                         }
1858
                         break;
1856
                         break;
1859
                     }
1857
                     }
1872
         if (iscomplete) {
1870
         if (iscomplete) {
1873
             console.log('setting pranswer');
1871
             console.log('setting pranswer');
1874
             try {
1872
             try {
1875
-                this.peerconnection.setRemoteDescription(new RTCSessionDescription({type: 'pranswer', sdp: this.remoteSDP.raw }));
1873
+                this.peerconnection.setRemoteDescription(new RTCSessionDescription({type: 'pranswer', sdp: this.remoteSDP.raw }),
1874
+                    function() {
1875
+                    },
1876
+                    function(e) {
1877
+                        console.log('setRemoteDescription pranswer failed', e.toString());
1878
+                    });
1876
             } catch (e) {
1879
             } catch (e) {
1877
                 console.error('setting pranswer failed', e);
1880
                 console.error('setting pranswer failed', e);
1878
             }
1881
             }
1879
         } else {
1882
         } else {
1880
-            console.log('not yet setting pranswer');
1883
+            //console.log('not yet setting pranswer');
1881
         }
1884
         }
1882
     }
1885
     }
1883
     // operate on each content element
1886
     // operate on each content element
1885
         // would love to deactivate this, but firefox still requires it
1888
         // would love to deactivate this, but firefox still requires it
1886
         var idx = -1;
1889
         var idx = -1;
1887
         var i;
1890
         var i;
1888
-        for (i = 0; i < obj.remoteSDP.media.length; i++) {
1889
-            if (SDPUtil.find_line(obj.remoteSDP.media[i], 'a=mid:' + $(this).attr('name')) ||
1890
-                obj.remoteSDP.media[i].indexOf('m=' + $(this).attr('name')) === 0) {
1891
+        for (i = 0; i < self.remoteSDP.media.length; i++) {
1892
+            if (SDPUtil.find_line(self.remoteSDP.media[i], 'a=mid:' + $(this).attr('name')) ||
1893
+                self.remoteSDP.media[i].indexOf('m=' + $(this).attr('name')) === 0) {
1891
                 idx = i;
1894
                 idx = i;
1892
                 break;
1895
                 break;
1893
             }
1896
             }
1894
         }
1897
         }
1895
         if (idx == -1) { // fall back to localdescription
1898
         if (idx == -1) { // fall back to localdescription
1896
-            for (i = 0; i < obj.localSDP.media.length; i++) {
1897
-                if (SDPUtil.find_line(obj.localSDP.media[i], 'a=mid:' + $(this).attr('name')) ||
1898
-                    obj.localSDP.media[i].indexOf('m=' + $(this).attr('name')) === 0) {
1899
+            for (i = 0; i < self.localSDP.media.length; i++) {
1900
+                if (SDPUtil.find_line(self.localSDP.media[i], 'a=mid:' + $(this).attr('name')) ||
1901
+                    self.localSDP.media[i].indexOf('m=' + $(this).attr('name')) === 0) {
1899
                     idx = i;
1902
                     idx = i;
1900
                     break;
1903
                     break;
1901
                 }
1904
                 }
1910
                                             sdpMid: name,
1913
                                             sdpMid: name,
1911
                                             candidate: line});
1914
                                             candidate: line});
1912
             try {
1915
             try {
1913
-                obj.peerconnection.addIceCandidate(candidate);
1916
+                self.peerconnection.addIceCandidate(candidate);
1914
             } catch (e) {
1917
             } catch (e) {
1915
                 console.error('addIceCandidate failed', e.toString(), line);
1918
                 console.error('addIceCandidate failed', e.toString(), line);
1916
             }
1919
             }
1919
 };
1922
 };
1920
 
1923
 
1921
 JingleSession.prototype.sendAnswer = function (provisional) {
1924
 JingleSession.prototype.sendAnswer = function (provisional) {
1922
-    console.log('createAnswer', provisional);
1923
-    var ob = this;
1925
+    //console.log('createAnswer', provisional);
1926
+    var self = this;
1924
     this.peerconnection.createAnswer(
1927
     this.peerconnection.createAnswer(
1925
         function (sdp) {
1928
         function (sdp) {
1926
-            ob.createdAnswer(sdp, provisional);
1929
+            self.createdAnswer(sdp, provisional);
1927
         },
1930
         },
1928
         function (e) {
1931
         function (e) {
1929
             console.error('createAnswer failed', e);
1932
             console.error('createAnswer failed', e);
1933
 };
1936
 };
1934
 
1937
 
1935
 JingleSession.prototype.createdAnswer = function (sdp, provisional) {
1938
 JingleSession.prototype.createdAnswer = function (sdp, provisional) {
1936
-    console.log('createAnswer callback');
1939
+    //console.log('createAnswer callback');
1937
     console.log(sdp);
1940
     console.log(sdp);
1938
-    var ob = this;
1941
+    var self = this;
1939
     this.localSDP = new SDP(sdp.sdp);
1942
     this.localSDP = new SDP(sdp.sdp);
1940
     //this.localSDP.mangle();
1943
     //this.localSDP.mangle();
1941
     this.usepranswer = provisional === true;
1944
     this.usepranswer = provisional === true;
1953
                 function () {
1956
                 function () {
1954
                     var ack = {};
1957
                     var ack = {};
1955
                     ack.source = 'answer';
1958
                     ack.source = 'answer';
1956
-                    $(document).trigger('ack.jingle', [ob.sid, ack]);
1959
+                    $(document).trigger('ack.jingle', [self.sid, ack]);
1957
                 },
1960
                 },
1958
                 function (stanza) {
1961
                 function (stanza) {
1959
                     var error = ($(stanza).find('error').length) ? {
1962
                     var error = ($(stanza).find('error').length) ? {
1961
                         reason: $(stanza).find('error :first')[0].tagName,
1964
                         reason: $(stanza).find('error :first')[0].tagName,
1962
                     }:{};
1965
                     }:{};
1963
                     error.source = 'answer';
1966
                     error.source = 'answer';
1964
-                    $(document).trigger('error.jingle', [ob.sid, error]);
1967
+                    $(document).trigger('error.jingle', [self.sid, error]);
1965
                 },
1968
                 },
1966
             10000);
1969
             10000);
1967
         } else {
1970
         } else {
1975
     sdp.sdp = this.localSDP.raw;
1978
     sdp.sdp = this.localSDP.raw;
1976
     this.peerconnection.setLocalDescription(sdp,
1979
     this.peerconnection.setLocalDescription(sdp,
1977
         function () {
1980
         function () {
1978
-            console.log('setLocalDescription success');
1981
+            //console.log('setLocalDescription success');
1979
         },
1982
         },
1980
         function (e) {
1983
         function (e) {
1981
             console.error('setLocalDescription failed', e);
1984
             console.error('setLocalDescription failed', e);
1993
 };
1996
 };
1994
 
1997
 
1995
 JingleSession.prototype.sendTerminate = function (reason, text) {
1998
 JingleSession.prototype.sendTerminate = function (reason, text) {
1996
-    var obj = this,
1999
+    var self = this,
1997
         term = $iq({to: this.peerjid,
2000
         term = $iq({to: this.peerjid,
1998
                type: 'set'})
2001
                type: 'set'})
1999
         .c('jingle', {xmlns: 'urn:xmpp:jingle:1',
2002
         .c('jingle', {xmlns: 'urn:xmpp:jingle:1',
2009
     
2012
     
2010
     this.connection.sendIQ(term,
2013
     this.connection.sendIQ(term,
2011
         function () {
2014
         function () {
2012
-            obj.peerconnection.close();
2013
-            obj.peerconnection = null;
2014
-            obj.terminate();
2015
+            self.peerconnection.close();
2016
+            self.peerconnection = null;
2017
+            self.terminate();
2015
             var ack = {};
2018
             var ack = {};
2016
             ack.source = 'terminate';
2019
             ack.source = 'terminate';
2017
-            $(document).trigger('ack.jingle', [obj.sid, ack]);
2020
+            $(document).trigger('ack.jingle', [self.sid, ack]);
2018
         },
2021
         },
2019
         function (stanza) {
2022
         function (stanza) {
2020
             var error = ($(stanza).find('error').length) ? {
2023
             var error = ($(stanza).find('error').length) ? {
2021
                 code: $(stanza).find('error').attr('code'),
2024
                 code: $(stanza).find('error').attr('code'),
2022
                 reason: $(stanza).find('error :first')[0].tagName,
2025
                 reason: $(stanza).find('error :first')[0].tagName,
2023
             }:{};
2026
             }:{};
2024
-            $(document).trigger('ack.jingle', [obj.sid, error]);
2027
+            $(document).trigger('ack.jingle', [self.sid, error]);
2025
         },
2028
         },
2026
     10000);
2029
     10000);
2027
     if (this.statsinterval !== null) {
2030
     if (this.statsinterval !== null) {
2036
     console.log('ice', this.peerconnection.iceConnectionState);
2039
     console.log('ice', this.peerconnection.iceConnectionState);
2037
     var sdp = new SDP(this.peerconnection.remoteDescription.sdp);
2040
     var sdp = new SDP(this.peerconnection.remoteDescription.sdp);
2038
 
2041
 
2039
-    var ob = this;
2042
+    var self = this;
2040
     $(elem).each(function (idx, content) {
2043
     $(elem).each(function (idx, content) {
2041
         var name = $(content).attr('name');
2044
         var name = $(content).attr('name');
2042
         var lines = '';
2045
         var lines = '';
2050
                 lines += '\r\n';
2053
                 lines += '\r\n';
2051
             });
2054
             });
2052
         });
2055
         });
2053
-        console.log(name, lines);
2054
         sdp.media.forEach(function(media, idx) {
2056
         sdp.media.forEach(function(media, idx) {
2055
             if (!SDPUtil.find_line(media, 'a=mid:' + name))
2057
             if (!SDPUtil.find_line(media, 'a=mid:' + name))
2056
                 return;
2058
                 return;
2057
             sdp.media[idx] += lines;
2059
             sdp.media[idx] += lines;
2058
-            if (!ob.addssrc[idx]) ob.addssrc[idx] = '';
2059
-            ob.addssrc[idx] += lines;
2060
+            if (!self.addssrc[idx]) self.addssrc[idx] = '';
2061
+            self.addssrc[idx] += lines;
2060
         });
2062
         });
2061
         sdp.raw = sdp.session + sdp.media.join('');
2063
         sdp.raw = sdp.session + sdp.media.join('');
2062
     });
2064
     });
2068
     console.log('ice', this.peerconnection.iceConnectionState);
2070
     console.log('ice', this.peerconnection.iceConnectionState);
2069
     var sdp = new SDP(this.peerconnection.remoteDescription.sdp);
2071
     var sdp = new SDP(this.peerconnection.remoteDescription.sdp);
2070
 
2072
 
2071
-    var ob = this;
2073
+    var self = this;
2072
     $(elem).each(function (idx, content) {
2074
     $(elem).each(function (idx, content) {
2073
         var name = $(content).attr('name');
2075
         var name = $(content).attr('name');
2074
         var lines = '';
2076
         var lines = '';
2082
                 lines += '\r\n';
2084
                 lines += '\r\n';
2083
             });
2085
             });
2084
         });
2086
         });
2085
-        console.log(name, lines);
2086
         sdp.media.forEach(function(media, idx) {
2087
         sdp.media.forEach(function(media, idx) {
2087
             if (!SDPUtil.find_line(media, 'a=mid:' + name))
2088
             if (!SDPUtil.find_line(media, 'a=mid:' + name))
2088
                 return;
2089
                 return;
2089
             sdp.media[idx] += lines;
2090
             sdp.media[idx] += lines;
2090
-            if (!ob.addssrc[idx]) ob.removessrc[idx] = '';
2091
-            ob.removessrc[idx] += lines;
2091
+            if (!self.addssrc[idx]) self.removessrc[idx] = '';
2092
+            self.removessrc[idx] += lines;
2092
         });
2093
         });
2093
         sdp.raw = sdp.session + sdp.media.join('');
2094
         sdp.raw = sdp.session + sdp.media.join('');
2094
     });
2095
     });
2095
-    console.log(this.removessrc);
2096
     this.modifySources();
2096
     this.modifySources();
2097
 };
2097
 };
2098
 
2098
 
2099
-
2100
-
2101
 JingleSession.prototype.modifySources = function() {
2099
 JingleSession.prototype.modifySources = function() {
2102
-    var ob = this;
2100
+    var self = this;
2103
     if (!(this.addssrc.length || this.removessrc.length)) return;
2101
     if (!(this.addssrc.length || this.removessrc.length)) return;
2104
     if (this.peerconnection.signalingState == 'closed') return;
2102
     if (this.peerconnection.signalingState == 'closed') return;
2105
     if (!(this.peerconnection.signalingState == 'stable' && this.peerconnection.iceConnectionState == 'connected')) {
2103
     if (!(this.peerconnection.signalingState == 'stable' && this.peerconnection.iceConnectionState == 'connected')) {
2106
         console.warn('modifySources not yet', this.peerconnection.signalingState, this.peerconnection.iceConnectionState);
2104
         console.warn('modifySources not yet', this.peerconnection.signalingState, this.peerconnection.iceConnectionState);
2107
         this.wait = true;
2105
         this.wait = true;
2108
-        window.setTimeout(function() { ob.modifySources(); }, 250);
2106
+        window.setTimeout(function() { self.modifySources(); }, 250);
2109
         return;
2107
         return;
2110
     }
2108
     }
2111
     if (this.wait) {
2109
     if (this.wait) {
2112
-        window.setTimeout(function() { ob.modifySources(); }, 2500);
2110
+        window.setTimeout(function() { self.modifySources(); }, 2500);
2113
         this.wait = false;
2111
         this.wait = false;
2114
         return;
2112
         return;
2115
     }
2113
     }
2116
 
2114
 
2117
-    console.log('ice', this.peerconnection.iceConnectionState);
2118
     var sdp = new SDP(this.peerconnection.remoteDescription.sdp);
2115
     var sdp = new SDP(this.peerconnection.remoteDescription.sdp);
2119
 
2116
 
2120
     // add sources
2117
     // add sources
2136
     sdp.raw = sdp.session + sdp.media.join('');
2133
     sdp.raw = sdp.session + sdp.media.join('');
2137
     this.peerconnection.setRemoteDescription(new RTCSessionDescription({type: 'offer', sdp: sdp.raw}),
2134
     this.peerconnection.setRemoteDescription(new RTCSessionDescription({type: 'offer', sdp: sdp.raw}),
2138
         function() {
2135
         function() {
2139
-            console.log('modify ok');
2140
-            ob.peerconnection.createAnswer(
2136
+            self.peerconnection.createAnswer(
2141
                 function(modifiedAnswer) {
2137
                 function(modifiedAnswer) {
2142
-                    console.log('modified answer...');
2143
-                    ob.peerconnection.setLocalDescription(modifiedAnswer,
2138
+                    self.peerconnection.setLocalDescription(modifiedAnswer,
2144
                         function() {
2139
                         function() {
2145
-                            console.log('modified setLocalDescription ok');
2140
+                            //console.log('modified setLocalDescription ok');
2146
                         },
2141
                         },
2147
                         function(error) {
2142
                         function(error) {
2148
                             console.log('modified setLocalDescription failed');
2143
                             console.log('modified setLocalDescription failed');
2187
 };
2182
 };
2188
 
2183
 
2189
 JingleSession.prototype.getStats = function (interval) {
2184
 JingleSession.prototype.getStats = function (interval) {
2190
-    var ob = this;
2185
+    var self = this;
2191
     var recv = {audio: 0, video: 0};
2186
     var recv = {audio: 0, video: 0};
2192
     var lost = {audio: 0, video: 0};
2187
     var lost = {audio: 0, video: 0};
2193
     var lastrecv = {audio: 0, video: 0};
2188
     var lastrecv = {audio: 0, video: 0};
2195
     var loss = {audio: 0, video: 0};
2190
     var loss = {audio: 0, video: 0};
2196
     var delta = {audio: 0, video: 0};
2191
     var delta = {audio: 0, video: 0};
2197
     this.statsinterval = window.setInterval(function () {
2192
     this.statsinterval = window.setInterval(function () {
2198
-        if (ob && ob.peerconnection && ob.peerconnection.getStats) {
2199
-            ob.peerconnection.getStats(function (stats) {
2193
+        if (self && self.peerconnection && self.peerconnection.getStats) {
2194
+            self.peerconnection.getStats(function (stats) {
2200
                 var results = stats.result();
2195
                 var results = stats.result();
2201
                 // TODO: there are so much statistics you can get from this..
2196
                 // TODO: there are so much statistics you can get from this..
2202
                 for (var i = 0; i < results.length; ++i) {
2197
                 for (var i = 0; i < results.length; ++i) {
2225
                 delta.video = recv.video - lastrecv.video;
2220
                 delta.video = recv.video - lastrecv.video;
2226
                 loss.audio = (delta.audio > 0) ? Math.ceil(100 * (lost.audio - lastlost.audio) / delta.audio) : 0;
2221
                 loss.audio = (delta.audio > 0) ? Math.ceil(100 * (lost.audio - lastlost.audio) / delta.audio) : 0;
2227
                 loss.video = (delta.video > 0) ? Math.ceil(100 * (lost.video - lastlost.video) / delta.video) : 0;
2222
                 loss.video = (delta.video > 0) ? Math.ceil(100 * (lost.video - lastlost.video) / delta.video) : 0;
2228
-                $(document).trigger('packetloss.jingle', [ob.sid, loss]);
2223
+                $(document).trigger('packetloss.jingle', [self.sid, loss]);
2229
             });
2224
             });
2230
         }
2225
         }
2231
     }, interval || 3000);
2226
     }, interval || 3000);

+ 1
- 0
muc.js Ver arquivo

109
                     var formsubmit = $iq({to: ob.roomjid, type: 'set'}).c('query', {xmlns: 'http://jabber.org/protocol/muc#owner'});
109
                     var formsubmit = $iq({to: ob.roomjid, type: 'set'}).c('query', {xmlns: 'http://jabber.org/protocol/muc#owner'});
110
                     formsubmit.c('x', {xmlns: 'jabber:x:data', type: 'submit'});
110
                     formsubmit.c('x', {xmlns: 'jabber:x:data', type: 'submit'});
111
                     formsubmit.c('field', {'var': 'FORM_TYPE'}).c('value').t('http://jabber.org/protocol/muc#roomconfig').up().up();
111
                     formsubmit.c('field', {'var': 'FORM_TYPE'}).c('value').t('http://jabber.org/protocol/muc#roomconfig').up().up();
112
+                    console.log("THE KEY TO SET", key);
112
                     formsubmit.c('field', {'var': 'muc#roomconfig_roomsecret'}).c('value').t(key).up().up();
113
                     formsubmit.c('field', {'var': 'muc#roomconfig_roomsecret'}).c('value').t(key).up().up();
113
                     // FIXME: is muc#roomconfig_passwordprotectedroom required?
114
                     // FIXME: is muc#roomconfig_passwordprotectedroom required?
114
                     this.connection.sendIQ(formsubmit,
115
                     this.connection.sendIQ(formsubmit,

Carregando…
Cancelar
Salvar