浏览代码

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

j8
Yana Stamcheva 11 年前
父节点
当前提交
d3f2532172
共有 6 个文件被更改,包括 222 次插入178 次删除
  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 查看文件

@@ -382,7 +382,8 @@ $(window).bind('beforeunload', function () {
382 382
     }
383 383
 });
384 384
 
385
-function dump(elem, filename){
385
+function dump(elem, filename) {
386
+    console.log("ELEMENT", elem);
386 387
     elem = elem.parentNode;
387 388
     elem.download = filename || 'xmpplog.json';
388 389
     elem.href = 'data:application/json;charset=utf-8,\n';
@@ -487,7 +488,7 @@ function openLockDialog() {
487 488
                      if(v)
488 489
                      {
489 490
                         setSharedKey('');
490
-                        lockRoom();
491
+                        lockRoom(false);
491 492
                      }
492 493
                      }
493 494
                      });
@@ -508,7 +509,6 @@ function openLockDialog() {
508 509
                      
509 510
                      if (lockKey.value)
510 511
                      {
511
-                     console.log("LOCK KEY", lockKey.value);
512 512
                         setSharedKey(lockKey.value);
513 513
                         lockRoom(true);
514 514
                      }
@@ -537,7 +537,11 @@ function openLinkDialog() {
537 537
  * Locks / unlocks the room.
538 538
  */
539 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 546
     updateLockButton();
543 547
 }

+ 9
- 0
css/main.css 查看文件

@@ -326,3 +326,12 @@ form {
326 326
     -moz-transition: height 0.2s;
327 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 查看文件

@@ -2,13 +2,13 @@
2 2
   <head>
3 3
     <title>WebRTC, meet the Jitsi Videobridge</title>
4 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 7
     <script src="muc.js?v=2"></script><!-- simple MUC library -->
8 8
     <script src="estos_log.js?v=1"></script><!-- simple stanza logger -->
9 9
     <script src="app.js?v=2"></script><!-- application logic -->
10 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 12
     <link rel="stylesheet" href="css/jquery-impromptu.css?v=1">
13 13
     <link rel="stylesheet" href="css/modaldialog.css?v=1">
14 14
     <script src="libs/jquery-impromptu.js"></script>
@@ -65,7 +65,7 @@
65 65
         <div id="chatconversation"></div>
66 66
         <textarea id="usermsg" class= "animated" placeholder='Enter text...' autofocus></textarea>
67 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 69
     <script>
70 70
         (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
71 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 查看文件

@@ -59,7 +59,7 @@ function ColibriFocus(connection, bridgejid) {
59 59
 
60 60
 // creates a conferences with an initial set of peers
61 61
 ColibriFocus.prototype.makeConference = function (peers) {
62
-    var ob = this;
62
+    var self = this;
63 63
     if (this.confid !== null) {
64 64
         console.error('makeConference called twice? Ignoring...');
65 65
         // FIXME: just invite peers?
@@ -68,52 +68,53 @@ ColibriFocus.prototype.makeConference = function (peers) {
68 68
     this.confid = 0; // !null
69 69
     this.peers = [];
70 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 75
     this.peerconnection = new TraceablePeerConnection(this.connection.jingle.ice_config, this.connection.jingle.pc_constraints);
76 76
     this.peerconnection.addStream(this.connection.jingle.localStream);
77 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 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 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 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 95
     this.peerconnection.onaddstream = function (event) {
96
-        ob.remoteStream = event.stream;
96
+        self.remoteStream = event.stream;
97 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 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 108
     this.peerconnection.onicecandidate = function (event) {
109
-        ob.sendIceCandidate(event.candidate);
109
+        self.sendIceCandidate(event.candidate);
110 110
     };
111 111
     this.peerconnection.createOffer(
112 112
         function (offer) {
113
-            ob.peerconnection.setLocalDescription(
113
+            self.peerconnection.setLocalDescription(
114 114
                 offer,
115 115
                 function () {
116 116
                     // success
117
+                    $(document).trigger('setLocalDescription.jingle', [self.sid]);
117 118
                     // FIXME: could call _makeConference here and trickle candidates later
118 119
                 },
119 120
                 function (error) {
@@ -126,17 +127,16 @@ ColibriFocus.prototype.makeConference = function (peers) {
126 127
         }
127 128
     );
128 129
     this.peerconnection.onicecandidate = function (event) {
129
-        console.log('candidate', event.candidate);
130 130
         if (!event.candidate) {
131 131
             console.log('end of candidates');
132
-            ob._makeConference();
132
+            self._makeConference();
133 133
             return;
134 134
         }
135 135
     };
136 136
 };
137 137
 
138 138
 ColibriFocus.prototype._makeConference = function () {
139
-    var ob = this;
139
+    var self = this;
140 140
     var elem = $iq({to: this.bridgejid, type: 'get'});
141 141
     elem.c('conference', {xmlns: 'http://jitsi.org/protocol/colibri'});
142 142
 
@@ -157,7 +157,7 @@ ColibriFocus.prototype._makeConference = function () {
157 157
         localSDP.TransportToJingle(channel, elem);
158 158
 
159 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 161
             elem.c('channel', {initiator: 'true', expire:'15' }).up();
162 162
         }
163 163
         elem.up(); // end of content
@@ -165,7 +165,7 @@ ColibriFocus.prototype._makeConference = function () {
165 165
 
166 166
     this.connection.sendIQ(elem,
167 167
         function (result) {
168
-            ob.createdConference(result);
168
+            self.createdConference(result);
169 169
         },
170 170
         function (error) {
171 171
             console.warn(error);
@@ -267,19 +267,21 @@ ColibriFocus.prototype.createdConference = function (result) {
267 267
                 bridgeSDP.media[channel] += 'a=fingerprint:' + tmp.attr('hash') + ' ' + tmp.text() + '\r\n';
268 268
                 if (tmp.attr('setup')) {
269 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 276
     bridgeSDP.raw = bridgeSDP.session + bridgeSDP.media.join('');
275 277
 
276
-    var ob = this;
278
+    var self = this;
277 279
     this.peerconnection.setRemoteDescription(
278 280
         new RTCSessionDescription({type: 'answer', sdp: bridgeSDP.raw}),
279 281
         function () {
280 282
             console.log('setRemoteDescription success');
281 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 287
         function (error) {
@@ -406,12 +408,12 @@ ColibriFocus.prototype.initiate = function (peer, isInitiator) {
406 408
 
407 409
 // pull in a new participant into the conference
408 410
 ColibriFocus.prototype.addNewParticipant = function (peer) {
409
-    var ob = this;
411
+    var self = this;
410 412
     if (this.confid === 0) {
411 413
         // bad state
412 414
         console.log('confid does not exist yet, postponing', peer);
413 415
         window.setTimeout(function () {
414
-            ob.addNewParticipant(peer);
416
+            self.addNewParticipant(peer);
415 417
         }, 250);
416 418
         return;
417 419
     }
@@ -435,9 +437,9 @@ ColibriFocus.prototype.addNewParticipant = function (peer) {
435 437
             var contents = $(result).find('>conference>content').get();
436 438
             for (var i = 0; i < contents.length; i++) {
437 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 444
         function (error) {
443 445
             console.warn(error);
@@ -491,17 +493,17 @@ ColibriFocus.prototype.updateChannel = function (remoteSDP, participant) {
491 493
 // or a leaving participants a=ssrc lines
492 494
 // FIXME: should not take an SDP, but rather the a=ssrc lines and probably a=mid
493 495
 ColibriFocus.prototype.sendSSRCUpdate = function (sdp, jid, isadd) {
494
-    var ob = this;
496
+    var self = this;
495 497
     this.peers.forEach(function (peerjid) {
496 498
         if (peerjid == jid) return;
497 499
         console.log('tell', peerjid, 'about ' + (isadd ? 'new' : 'removed') + ' ssrcs from', jid);
498
-        if (!ob.remotessrc[peerjid]) {
500
+        if (!self.remotessrc[peerjid]) {
499 501
             // FIXME: this should only send to participants that are stable, i.e. who have sent a session-accept
500 502
             // possibly, this.remoteSSRC[session.peerjid] does not exist yet
501 503
             console.warn('do we really want to bother', peerjid, 'with updates yet?');
502 504
         }
503 505
         var channel;
504
-        var peersess = ob.connection.jingle.jid2session[peerjid];
506
+        var peersess = self.connection.jingle.jid2session[peerjid];
505 507
         var modify = $iq({to: peerjid, type: 'set'})
506 508
             .c('jingle', {
507 509
                 xmlns: 'urn:xmpp:jingle:1',
@@ -538,7 +540,7 @@ ColibriFocus.prototype.sendSSRCUpdate = function (sdp, jid, isadd) {
538 540
             modify.up(); // end of content
539 541
         }
540 542
         if (modified) {
541
-            ob.connection.sendIQ(modify,
543
+            self.connection.sendIQ(modify,
542 544
                 function (res) {
543 545
                     console.warn('got modify result');
544 546
                 },
@@ -555,7 +557,7 @@ ColibriFocus.prototype.sendSSRCUpdate = function (sdp, jid, isadd) {
555 557
 ColibriFocus.prototype.setRemoteDescription = function (session, elem, desctype) {
556 558
     var participant = this.peers.indexOf(session.peerjid);
557 559
     console.log('Colibri.setRemoteDescription from', session.peerjid, participant);
558
-    var ob = this;
560
+    var self = this;
559 561
     var remoteSDP = new SDP('');
560 562
     var tmp;
561 563
     var channel;
@@ -585,9 +587,9 @@ ColibriFocus.prototype.setRemoteDescription = function (session, elem, desctype)
585 587
 
586 588
 // relay ice candidates to bridge using trickle
587 589
 ColibriFocus.prototype.addIceCandidate = function (session, elem) {
588
-    var ob = this;
590
+    var self = this;
589 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 593
     var change = $iq({to: this.bridgejid, type: 'set'});
592 594
     change.c('conference', {xmlns: 'http://jitsi.org/protocol/colibri', id: this.confid});
593 595
     $(elem).each(function () {
@@ -595,7 +597,7 @@ ColibriFocus.prototype.addIceCandidate = function (session, elem) {
595 597
         var channel = name == 'audio' ? 0 : 1; // FIXME: search mlineindex in localdesc
596 598
 
597 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 601
         $(this).find('>transport').each(function () {
600 602
             change.c('transport', {
601 603
                 ufrag: $(this).attr('ufrag'),
@@ -702,7 +704,7 @@ ColibriFocus.prototype.terminate = function (session, reason) {
702 704
 };
703 705
 
704 706
 ColibriFocus.prototype.modifySources = function () {
705
-    var ob = this;
707
+    var self = this;
706 708
     if (!(this.addssrc.length || this.removessrc.length)) return;
707 709
     if (this.peerconnection.signalingState == 'closed') return;
708 710
 
@@ -710,12 +712,12 @@ ColibriFocus.prototype.modifySources = function () {
710 712
     // https://code.google.com/p/webrtc/issues/detail?id=2688
711 713
     if (!(this.peerconnection.signalingState == 'stable' && this.peerconnection.iceConnectionState == 'connected')) {
712 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 716
         this.wait = true;
715 717
         return;
716 718
     }
717 719
     if (this.wait) {
718
-        window.setTimeout(function () { ob.modifySources(); }, 2500);
720
+        window.setTimeout(function () { self.modifySources(); }, 2500);
719 721
         this.wait = false;
720 722
         return;
721 723
     }
@@ -738,19 +740,25 @@ ColibriFocus.prototype.modifySources = function () {
738 740
     this.removessrc = [];
739 741
 
740 742
     sdp.raw = sdp.session + sdp.media.join('');
743
+    /*
744
+     * this seems to create a number of problems...
741 745
     this.peerconnection.setRemoteDescription(
742 746
         new RTCSessionDescription({type: 'offer', sdp: sdp.raw }),
743 747
         function () {
744 748
             console.log('setModifiedRemoteDescription ok');
745
-            ob.peerconnection.createAnswer(
749
+            self.peerconnection.createAnswer(
746 750
                 function (modifiedAnswer) {
747
-                    console.log('modifiedAnswer created');
751
+                    console.log('modifiedAnswer created', modifiedAnswer.sdp);
748 752
                     // FIXME: pushing down an answer while ice connection state 
749 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 759
                         function () {
753 760
                             console.log('setModifiedLocalDescription ok');
761
+                            $(document).trigger('setLocalDescription.jingle', [self.sid]);
754 762
                         },
755 763
                         function (error) {
756 764
                             console.log('setModifiedLocalDescription failed');
@@ -766,6 +774,33 @@ ColibriFocus.prototype.modifySources = function () {
766 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 查看文件

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

+ 1
- 0
muc.js 查看文件

@@ -109,6 +109,7 @@ Strophe.addConnectionPlugin('emuc', {
109 109
                     var formsubmit = $iq({to: ob.roomjid, type: 'set'}).c('query', {xmlns: 'http://jabber.org/protocol/muc#owner'});
110 110
                     formsubmit.c('x', {xmlns: 'jabber:x:data', type: 'submit'});
111 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 113
                     formsubmit.c('field', {'var': 'muc#roomconfig_roomsecret'}).c('value').t(key).up().up();
113 114
                     // FIXME: is muc#roomconfig_passwordprotectedroom required?
114 115
                     this.connection.sendIQ(formsubmit,

正在加载...
取消
保存