ソースを参照

Merge pull request #39 from jitsi/better-onicecandidate

Better onicecandidate
dev1
Paweł Domas 9年前
コミット
b4f0b92d20
1個のファイルの変更26行の追加9行の削除
  1. 26
    9
      modules/xmpp/JingleSessionPC.js

+ 26
- 9
modules/xmpp/JingleSessionPC.js ファイルの表示

102
             RTC.getPCConstraints(),
102
             RTC.getPCConstraints(),
103
             this);
103
             this);
104
 
104
 
105
-    this.peerconnection.onicecandidate = function (event) {
106
-        var protocol;
107
-        if (event && event.candidate) {
108
-            protocol = (typeof event.candidate.protocol === 'string')
109
-                ? event.candidate.protocol.toLowerCase() : '';
110
-            if ((self.webrtcIceTcpDisable && protocol == 'tcp') ||
111
-                (self.webrtcIceUdpDisable && protocol == 'udp')) {
112
-                return;
105
+    this.peerconnection.onicecandidate = function (ev) {
106
+        if (!ev) {
107
+            // There was an incomplete check for ev before which left the last
108
+            // line of the function unprotected from a potential throw of an
109
+            // exception. Consequently, it may be argued that the check is
110
+            // unnecessary. Anyway, I'm leaving it and making the check
111
+            // complete.
112
+            return;
113
+        }
114
+        var candidate = ev.candidate;
115
+        if (candidate) {
116
+            // Discard candidates of disabled protocols.
117
+            var protocol = candidate.protocol;
118
+            if (typeof protocol === 'string') {
119
+                protocol = protocol.toLowerCase();
120
+                if (protocol == 'tcp') {
121
+                    if (self.webrtcIceTcpDisable)
122
+                        return;
123
+                } else if (protocol == 'udp') {
124
+                    if (self.webrtcIceUdpDisable)
125
+                        return;
126
+                }
113
             }
127
             }
114
         }
128
         }
115
-        self.sendIceCandidate(event.candidate);
129
+        self.sendIceCandidate(candidate);
116
     };
130
     };
117
     this.peerconnection.onaddstream = function (event) {
131
     this.peerconnection.onaddstream = function (event) {
118
         if (event.stream.id !== 'default') {
132
         if (event.stream.id !== 'default') {
341
                 return;
355
                 return;
342
             } else {
356
             } else {
343
                 self.sendIceCandidates([candidate]);
357
                 self.sendIceCandidates([candidate]);
358
+                // FIXME this.lasticecandidate is going to be set to true
359
+                // bellow and that seems wrong. The execution doesn't come here
360
+                // with the default values at the time of this writing.
344
             }
361
             }
345
         }
362
         }
346
     } else {
363
     } else {

読み込み中…
キャンセル
保存