|
@@ -54,8 +54,21 @@ function JingleSession(me, sid, connection, service) {
|
54
|
54
|
*/
|
55
|
55
|
this.videoMuteByUser = false;
|
56
|
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
|
72
|
//TODO: this array must be removed when firefox implement multistream support
|
60
|
73
|
JingleSession.notReceivedSSRCs = [];
|
61
|
74
|
|
|
@@ -94,9 +107,11 @@ JingleSession.prototype.initiate = function (peerjid, isInitiator) {
|
94
|
107
|
};
|
95
|
108
|
this.peerconnection.onsignalingstatechange = function (event) {
|
96
|
109
|
if (!(self && self.peerconnection)) return;
|
|
110
|
+ self.updateModifySourcesQueue();
|
97
|
111
|
};
|
98
|
112
|
this.peerconnection.oniceconnectionstatechange = function (event) {
|
99
|
113
|
if (!(self && self.peerconnection)) return;
|
|
114
|
+ self.updateModifySourcesQueue();
|
100
|
115
|
switch (self.peerconnection.iceConnectionState) {
|
101
|
116
|
case 'connected':
|
102
|
117
|
this.startTime = new Date();
|
|
@@ -776,7 +791,17 @@ JingleSession.prototype.addSource = function (elem, fromJid) {
|
776
|
791
|
});
|
777
|
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
|
807
|
JingleSession.prototype.removeSource = function (elem, fromJid) {
|
|
@@ -837,7 +862,17 @@ JingleSession.prototype.removeSource = function (elem, fromJid) {
|
837
|
862
|
});
|
838
|
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
|
878
|
JingleSession.prototype._modifySources = function (successCallback, queueCallback) {
|