Explorar el Código

Removes wasteful duplicate calls to SDPUtil.find_line().

dev1
Lyubomir Marinov hace 9 años
padre
commit
d77186198e
Se han modificado 1 ficheros con 17 adiciones y 12 borrados
  1. 17
    12
      modules/xmpp/JingleSessionPC.js

+ 17
- 12
modules/xmpp/JingleSessionPC.js Ver fichero

@@ -419,8 +419,9 @@ JingleSessionPC.prototype.sendIceCandidates = function (candidates) {
419 419
                 cand.c('candidate', SDPUtil.candidateToJingle(cands[i].candidate)).up();
420 420
             }
421 421
             // add fingerprint
422
-            if (SDPUtil.find_line(this.localSDP.media[mid], 'a=fingerprint:', this.localSDP.session)) {
423
-                var tmp = SDPUtil.parse_fingerprint(SDPUtil.find_line(this.localSDP.media[mid], 'a=fingerprint:', this.localSDP.session));
422
+            var fingerprint_line = SDPUtil.find_line(this.localSDP.media[mid], 'a=fingerprint:', this.localSDP.session);
423
+            if (fingerprint_line) {
424
+                var tmp = SDPUtil.parse_fingerprint(fingerprint_line);
424 425
                 tmp.required = true;
425 426
                 cand.c(
426 427
                     'fingerprint',
@@ -483,20 +484,23 @@ JingleSessionPC.prototype.setRemoteDescription = function (elem, desctype) {
483 484
 
484 485
     this.remoteSDP.fromJingle(elem);
485 486
     this.readSsrcInfo($(elem).find(">content"));
486
-    if (this.peerconnection.remoteDescription) {
487
-        logger.log('setRemoteDescription when remote description is not null, should be pranswer', this.peerconnection.remoteDescription);
488
-        if (this.peerconnection.remoteDescription.type == 'pranswer') {
489
-            var pranswer = new SDP(this.peerconnection.remoteDescription.sdp);
487
+    var pcremotedesc = this.peerconnection.remoteDescription;
488
+    if (pcremotedesc) {
489
+        logger.log('setRemoteDescription when remote description is not null, should be pranswer', pcremotedesc);
490
+        if (pcremotedesc.type == 'pranswer') {
491
+            var pranswer = new SDP(pcremotedesc.sdp);
490 492
             for (var i = 0; i < pranswer.media.length; i++) {
491 493
                 // make sure we have ice ufrag and pwd
492 494
                 if (!SDPUtil.find_line(this.remoteSDP.media[i], 'a=ice-ufrag:', this.remoteSDP.session)) {
493
-                    if (SDPUtil.find_line(pranswer.media[i], 'a=ice-ufrag:', pranswer.session)) {
494
-                        this.remoteSDP.media[i] += SDPUtil.find_line(pranswer.media[i], 'a=ice-ufrag:', pranswer.session) + '\r\n';
495
+                    var ice_ufrag_line = SDPUtil.find_line(pranswer.media[i], 'a=ice-ufrag:', pranswer.session);
496
+                    if (ice_ufrag_line) {
497
+                        this.remoteSDP.media[i] += ice_ufrag_line + '\r\n';
495 498
                     } else {
496 499
                         logger.warn('no ice ufrag?');
497 500
                     }
498
-                    if (SDPUtil.find_line(pranswer.media[i], 'a=ice-pwd:', pranswer.session)) {
499
-                        this.remoteSDP.media[i] += SDPUtil.find_line(pranswer.media[i], 'a=ice-pwd:', pranswer.session) + '\r\n';
501
+                    var ice_pwd_line = SDPUtil.find_line(pranswer.media[i], 'a=ice-pwd:', pranswer.session);
502
+                    if (ice_pwd_line) {
503
+                        this.remoteSDP.media[i] += ice_pwd_line + '\r\n';
500 504
                     } else {
501 505
                         logger.warn('no ice pwd?');
502 506
                     }
@@ -544,8 +548,9 @@ JingleSessionPC.prototype.addIceCandidate = function (elem) {
544 548
             for (var i = 0; i < this.localSDP.media.length; i++) {
545 549
                 cobbled += SDPUtil.find_line(this.localSDP.media[i], 'm=') + '\r\n';
546 550
                 cobbled += SDPUtil.find_lines(this.localSDP.media[i], 'a=rtpmap:').join('\r\n') + '\r\n';
547
-                if (SDPUtil.find_line(this.localSDP.media[i], 'a=mid:')) {
548
-                    cobbled += SDPUtil.find_line(this.localSDP.media[i], 'a=mid:') + '\r\n';
551
+                var mid_line = SDPUtil.find_line(this.localSDP.media[i], 'a=mid:');
552
+                if (mid_line) {
553
+                    cobbled += mid_line + '\r\n';
549 554
                 }
550 555
                 cobbled += 'a=inactive\r\n';
551 556
             }

Loading…
Cancelar
Guardar