瀏覽代碼

Notifies the focus about newly allocated channel SSRCs on add/remove source.

j8
George Politis 10 年之前
父節點
當前提交
ad1772178d
共有 1 個檔案被更改,包括 37 行新增2 行删除
  1. 37
    2
      modules/xmpp/JingleSession.js

+ 37
- 2
modules/xmpp/JingleSession.js 查看文件

54
      */
54
      */
55
     this.videoMuteByUser = false;
55
     this.videoMuteByUser = false;
56
     this.modifySourcesQueue = async.queue(this._modifySources.bind(this), 1);
56
     this.modifySourcesQueue = async.queue(this._modifySources.bind(this), 1);
57
+    // We start with the queue paused. We resume it when the signaling state is
58
+    // stable and the ice connection state is connected.
59
+    this.modifySourcesQueue.pause();
57
 }
60
 }
58
 
61
 
62
+JingleSession.prototype.updateModifySourcesQueue = function() {
63
+    var signalingState = this.peerconnection.signalingState;
64
+    var iceConnectionState = this.peerconnection.iceConnectionState;
65
+    if (signalingState === 'stable' && iceConnectionState === 'connected') {
66
+        this.modifySourcesQueue.resume();
67
+    } else {
68
+        this.modifySourcesQueue.pause();
69
+    }
70
+};
71
+
59
 //TODO: this array must be removed when firefox implement multistream support
72
 //TODO: this array must be removed when firefox implement multistream support
60
 JingleSession.notReceivedSSRCs = [];
73
 JingleSession.notReceivedSSRCs = [];
61
 
74
 
94
     };
107
     };
95
     this.peerconnection.onsignalingstatechange = function (event) {
108
     this.peerconnection.onsignalingstatechange = function (event) {
96
         if (!(self && self.peerconnection)) return;
109
         if (!(self && self.peerconnection)) return;
110
+        self.updateModifySourcesQueue();
97
     };
111
     };
98
     this.peerconnection.oniceconnectionstatechange = function (event) {
112
     this.peerconnection.oniceconnectionstatechange = function (event) {
99
         if (!(self && self.peerconnection)) return;
113
         if (!(self && self.peerconnection)) return;
114
+        self.updateModifySourcesQueue();
100
         switch (self.peerconnection.iceConnectionState) {
115
         switch (self.peerconnection.iceConnectionState) {
101
             case 'connected':
116
             case 'connected':
102
                 this.startTime = new Date();
117
                 this.startTime = new Date();
776
         });
791
         });
777
         sdp.raw = sdp.session + sdp.media.join('');
792
         sdp.raw = sdp.session + sdp.media.join('');
778
     });
793
     });
779
-    this.modifySourcesQueue.push();
794
+
795
+    this.modifySourcesQueue.push(function() {
796
+        // When a source is added and if this is FF, a new channel is allocated
797
+        // for receiving the added source. We need to diffuse the SSRC of this
798
+        // new recvonly channel to the rest of the peers.
799
+        console.log('modify sources done');
800
+
801
+        var newSdp = new SDP(self.peerconnection.localDescription.sdp);
802
+        console.log("SDPs", mySdp, newSdp);
803
+        self.notifyMySSRCUpdate(mySdp, newSdp);
804
+    });
780
 };
805
 };
781
 
806
 
782
 JingleSession.prototype.removeSource = function (elem, fromJid) {
807
 JingleSession.prototype.removeSource = function (elem, fromJid) {
837
         });
862
         });
838
         sdp.raw = sdp.session + sdp.media.join('');
863
         sdp.raw = sdp.session + sdp.media.join('');
839
     });
864
     });
840
-    this.modifySourcesQueue.push();
865
+
866
+    this.modifySourcesQueue.push(function() {
867
+        // When a source is removed and if this is FF, the recvonly channel that
868
+        // receives the remote stream is deactivated . We need to diffuse the
869
+        // recvonly SSRC removal to the rest of the peers.
870
+        console.log('modify sources done');
871
+
872
+        var newSdp = new SDP(self.peerconnection.localDescription.sdp);
873
+        console.log("SDPs", mySdp, newSdp);
874
+        self.notifyMySSRCUpdate(mySdp, newSdp);
875
+    });
841
 };
876
 };
842
 
877
 
843
 JingleSession.prototype._modifySources = function (successCallback, queueCallback) {
878
 JingleSession.prototype._modifySources = function (successCallback, queueCallback) {

Loading…
取消
儲存