Browse Source

Simplifies code.

master
Boris Grozev 11 years ago
parent
commit
ea93bc6f41
1 changed files with 40 additions and 39 deletions
  1. 40
    39
      libs/colibri/colibri.focus.js

+ 40
- 39
libs/colibri/colibri.focus.js View File

@@ -662,51 +662,52 @@ ColibriFocus.prototype.initiate = function (peer, isInitiator) {
662 662
     var participant = this.peers.indexOf(peer);
663 663
     console.log('tell', peer, participant);
664 664
     var sdp;
665
-    if (this.peerconnection !== null && this.peerconnection.signalingState == 'stable') {
666
-        sdp = new SDP(this.peerconnection.remoteDescription.sdp);
667
-        var localSDP = new SDP(this.peerconnection.localDescription.sdp);
668
-        // throw away stuff we don't want
669
-        // not needed with static offer
670
-        if (!config.useBundle) {
671
-            sdp.removeSessionLines('a=group:');
665
+
666
+    if (!(this.peerconnection !== null && this.peerconnection.signalingState == 'stable')) {
667
+        console.error('can not initiate a new session without a stable peerconnection');
668
+        return;
669
+    }
670
+
671
+    sdp = new SDP(this.peerconnection.remoteDescription.sdp);
672
+    var localSDP = new SDP(this.peerconnection.localDescription.sdp);
673
+    // throw away stuff we don't want
674
+    // not needed with static offer
675
+    if (!config.useBundle) {
676
+        sdp.removeSessionLines('a=group:');
677
+    }
678
+    sdp.removeSessionLines('a=msid-semantic:'); // FIXME: not mapped over jingle anyway...
679
+    for (var i = 0; i < sdp.media.length; i++) {
680
+        if (!config.useRtcpMux){
681
+            sdp.removeMediaLines(i, 'a=rtcp-mux');
672 682
         }
673
-        sdp.removeSessionLines('a=msid-semantic:'); // FIXME: not mapped over jingle anyway...
674
-        for (var i = 0; i < sdp.media.length; i++) {
675
-            if (!config.useRtcpMux){
676
-                sdp.removeMediaLines(i, 'a=rtcp-mux');
683
+        sdp.removeMediaLines(i, 'a=ssrc:');
684
+        sdp.removeMediaLines(i, 'a=ssrc-group:');
685
+        sdp.removeMediaLines(i, 'a=crypto:');
686
+        sdp.removeMediaLines(i, 'a=candidate:');
687
+        sdp.removeMediaLines(i, 'a=ice-options:google-ice');
688
+        sdp.removeMediaLines(i, 'a=ice-ufrag:');
689
+        sdp.removeMediaLines(i, 'a=ice-pwd:');
690
+        sdp.removeMediaLines(i, 'a=fingerprint:');
691
+        sdp.removeMediaLines(i, 'a=setup:');
692
+
693
+        if (1) { //i > 0) { // not for audio FIXME: does not work as intended
694
+            // re-add all remote a=ssrcs _and_ a=ssrc-group
695
+            for (var jid in this.remotessrc) {
696
+                if (jid == peer || !this.remotessrc[jid][i])
697
+                    continue;
698
+                sdp.media[i] += this.remotessrc[jid][i];
677 699
             }
678
-            sdp.removeMediaLines(i, 'a=ssrc:');
679
-            sdp.removeMediaLines(i, 'a=ssrc-group:');
680
-            sdp.removeMediaLines(i, 'a=crypto:');
681
-            sdp.removeMediaLines(i, 'a=candidate:');
682
-            sdp.removeMediaLines(i, 'a=ice-options:google-ice');
683
-            sdp.removeMediaLines(i, 'a=ice-ufrag:');
684
-            sdp.removeMediaLines(i, 'a=ice-pwd:');
685
-            sdp.removeMediaLines(i, 'a=fingerprint:');
686
-            sdp.removeMediaLines(i, 'a=setup:');
687
-
688
-            if (1) { //i > 0) { // not for audio FIXME: does not work as intended
689
-                // re-add all remote a=ssrcs _and_ a=ssrc-group
690
-                for (var jid in this.remotessrc) {
691
-                    if (jid == peer || !this.remotessrc[jid][i])
692
-                        continue;
693
-                    sdp.media[i] += this.remotessrc[jid][i];
694
-                }
695 700
 
696
-                // add local a=ssrc-group: lines
697
-                lines = SDPUtil.find_lines(localSDP.media[i], 'a=ssrc-group:');
698
-                if (lines.length != 0)
699
-                    sdp.media[i] += lines.join('\r\n') + '\r\n';
701
+            // add local a=ssrc-group: lines
702
+            lines = SDPUtil.find_lines(localSDP.media[i], 'a=ssrc-group:');
703
+            if (lines.length != 0)
704
+                sdp.media[i] += lines.join('\r\n') + '\r\n';
700 705
 
701
-                // and local a=ssrc: lines
702
-                sdp.media[i] += SDPUtil.find_lines(localSDP.media[i], 'a=ssrc:').join('\r\n') + '\r\n';
703
-            }
706
+            // and local a=ssrc: lines
707
+            sdp.media[i] += SDPUtil.find_lines(localSDP.media[i], 'a=ssrc:').join('\r\n') + '\r\n';
704 708
         }
705
-        sdp.raw = sdp.session + sdp.media.join('');
706
-    } else {
707
-        console.error('can not initiate a new session without a stable peerconnection');
708
-        return;
709 709
     }
710
+    sdp.raw = sdp.session + sdp.media.join('');
710 711
 
711 712
     // add stuff we got from the bridge
712 713
     for (var j = 0; j < sdp.media.length; j++) {

Loading…
Cancel
Save