浏览代码

Merge pull request #272 from mkeesey/master

Fix stream end/start race condition
master
Paweł Domas 10 年前
父节点
当前提交
29f06829e7
共有 3 个文件被更改,包括 1283 次插入106 次删除
  1. 1266
    85
      libs/app.bundle.js
  2. 15
    20
      modules/xmpp/JingleSession.js
  3. 2
    1
      package.json

+ 1266
- 85
libs/app.bundle.js
文件差异内容过多而无法显示
查看文件


+ 15
- 20
modules/xmpp/JingleSession.js 查看文件

4
 var SDPUtil = require("./SDPUtil");
4
 var SDPUtil = require("./SDPUtil");
5
 var SDP = require("./SDP");
5
 var SDP = require("./SDP");
6
 var RTCBrowserType = require("../../service/RTC/RTCBrowserType");
6
 var RTCBrowserType = require("../../service/RTC/RTCBrowserType");
7
+var async = require("async");
7
 
8
 
8
 // Jingle stuff
9
 // Jingle stuff
9
 function JingleSession(me, sid, connection, service) {
10
 function JingleSession(me, sid, connection, service) {
52
      * by the application logic.
53
      * by the application logic.
53
      */
54
      */
54
     this.videoMuteByUser = false;
55
     this.videoMuteByUser = false;
56
+    this.modifySourcesQueue = async.queue(this._modifySources.bind(this), 1);
55
 }
57
 }
56
 
58
 
57
 //TODO: this array must be removed when firefox implement multistream support
59
 //TODO: this array must be removed when firefox implement multistream support
774
         });
776
         });
775
         sdp.raw = sdp.session + sdp.media.join('');
777
         sdp.raw = sdp.session + sdp.media.join('');
776
     });
778
     });
777
-    this.modifySources();
779
+    this.modifySourcesQueue.push();
778
 };
780
 };
779
 
781
 
780
 JingleSession.prototype.removeSource = function (elem, fromJid) {
782
 JingleSession.prototype.removeSource = function (elem, fromJid) {
835
         });
837
         });
836
         sdp.raw = sdp.session + sdp.media.join('');
838
         sdp.raw = sdp.session + sdp.media.join('');
837
     });
839
     });
838
-    this.modifySources();
840
+    this.modifySourcesQueue.push();
839
 };
841
 };
840
 
842
 
841
-JingleSession.prototype.modifySources = function (successCallback) {
843
+JingleSession.prototype._modifySources = function (successCallback, queueCallback) {
842
     var self = this;
844
     var self = this;
845
+
843
     if (this.peerconnection.signalingState == 'closed') return;
846
     if (this.peerconnection.signalingState == 'closed') return;
844
     if (!(this.addssrc.length || this.removessrc.length || this.pendingop !== null || this.switchstreams)){
847
     if (!(this.addssrc.length || this.removessrc.length || this.pendingop !== null || this.switchstreams)){
845
         // There is nothing to do since scheduled job might have been executed by another succeeding call
848
         // There is nothing to do since scheduled job might have been executed by another succeeding call
847
         if(successCallback){
850
         if(successCallback){
848
             successCallback();
851
             successCallback();
849
         }
852
         }
850
-        return;
851
-    }
852
-
853
-    // FIXME: this is a big hack
854
-    // https://code.google.com/p/webrtc/issues/detail?id=2688
855
-    // ^ has been fixed.
856
-    if (!(this.peerconnection.signalingState == 'stable' && this.peerconnection.iceConnectionState == 'connected')) {
857
-        console.warn('modifySources not yet', this.peerconnection.signalingState, this.peerconnection.iceConnectionState);
858
-        this.wait = true;
859
-        window.setTimeout(function() { self.modifySources(successCallback); }, 250);
860
-        return;
861
-    }
862
-    if (this.wait) {
863
-        window.setTimeout(function() { self.modifySources(successCallback); }, 2500);
864
-        this.wait = false;
853
+        queueCallback();
865
         return;
854
         return;
866
     }
855
     }
867
 
856
 
901
 
890
 
902
             if(self.signalingState == 'closed') {
891
             if(self.signalingState == 'closed') {
903
                 console.error("createAnswer attempt on closed state");
892
                 console.error("createAnswer attempt on closed state");
893
+                queueCallback("createAnswer attempt on closed state");
904
                 return;
894
                 return;
905
             }
895
             }
906
 
896
 
937
                             if(successCallback){
927
                             if(successCallback){
938
                                 successCallback();
928
                                 successCallback();
939
                             }
929
                             }
930
+                            queueCallback();
940
                         },
931
                         },
941
                         function(error) {
932
                         function(error) {
942
                             console.error('modified setLocalDescription failed', error);
933
                             console.error('modified setLocalDescription failed', error);
934
+                            queueCallback(error);
943
                         }
935
                         }
944
                     );
936
                     );
945
                 },
937
                 },
946
                 function(error) {
938
                 function(error) {
947
                     console.error('modified answer failed', error);
939
                     console.error('modified answer failed', error);
940
+                    queueCallback(error);
948
                 }
941
                 }
949
             );
942
             );
950
         },
943
         },
951
         function(error) {
944
         function(error) {
952
             console.error('modify failed', error);
945
             console.error('modify failed', error);
946
+            queueCallback(error);
953
         }
947
         }
954
     );
948
     );
955
 };
949
 };
956
 
950
 
951
+
957
 /**
952
 /**
958
  * Switches video streams.
953
  * Switches video streams.
959
  * @param new_stream new stream that will be used as video of this session.
954
  * @param new_stream new stream that will be used as video of this session.
984
     }
979
     }
985
 
980
 
986
     self.switchstreams = true;
981
     self.switchstreams = true;
987
-    self.modifySources(function() {
982
+    self.modifySourcesQueue.push(function() {
988
         console.log('modify sources done');
983
         console.log('modify sources done');
989
 
984
 
990
         success_callback();
985
         success_callback();
1092
 
1087
 
1093
     this.hardMuteVideo(mute);
1088
     this.hardMuteVideo(mute);
1094
 
1089
 
1095
-    this.modifySources(callback(mute));
1090
+    this.modifySourcesQueue.push(callback(mute));
1096
 };
1091
 };
1097
 
1092
 
1098
 JingleSession.prototype.hardMuteVideo = function (muted) {
1093
 JingleSession.prototype.hardMuteVideo = function (muted) {

+ 2
- 1
package.json 查看文件

19
       "pako": "*",
19
       "pako": "*",
20
       "i18next-client": "1.7.7",
20
       "i18next-client": "1.7.7",
21
       "sdp-interop": "jitsi/sdp-interop#f65fedfe57a",
21
       "sdp-interop": "jitsi/sdp-interop#f65fedfe57a",
22
-      "sdp-transform": "1.3.0"
22
+      "sdp-transform": "1.3.0",
23
+      "async": "0.9.0"
23
   },
24
   },
24
   "devDependencies": {
25
   "devDependencies": {
25
   },
26
   },

正在加载...
取消
保存