|
|
@@ -35,6 +35,16 @@ function JingleSessionPC(me, sid, peerjid, connection,
|
|
35
|
35
|
this.modifyingLocalStreams = false;
|
|
36
|
36
|
this.modifiedSSRCs = {};
|
|
37
|
37
|
|
|
|
38
|
+ /**
|
|
|
39
|
+ * The local ICE username fragment for this session.
|
|
|
40
|
+ */
|
|
|
41
|
+ this.localUfrag = null;
|
|
|
42
|
+
|
|
|
43
|
+ /**
|
|
|
44
|
+ * The remote ICE username fragment for this session.
|
|
|
45
|
+ */
|
|
|
46
|
+ this.remoteUfrag = null;
|
|
|
47
|
+
|
|
38
|
48
|
/**
|
|
39
|
49
|
* A map that stores SSRCs of remote streams. And is used only locally
|
|
40
|
50
|
* We store the mapping when jingle is received, and later is used
|
|
|
@@ -78,6 +88,7 @@ JingleSessionPC.prototype.doInitialize = function () {
|
|
78
|
88
|
// complete.
|
|
79
|
89
|
return;
|
|
80
|
90
|
}
|
|
|
91
|
+ // XXX this is broken, candidate is not parsed.
|
|
81
|
92
|
var candidate = ev.candidate;
|
|
82
|
93
|
if (candidate) {
|
|
83
|
94
|
// Discard candidates of disabled protocols.
|
|
|
@@ -773,6 +784,14 @@ JingleSessionPC.prototype._modifySources = function (successCallback, queueCallb
|
|
773
|
784
|
GlobalOnErrorHandler.callErrorHandler(new Error(errmsg));
|
|
774
|
785
|
queueCallback(err);
|
|
775
|
786
|
};
|
|
|
787
|
+
|
|
|
788
|
+ var ufrag = getUfrag(sdp.raw);
|
|
|
789
|
+ if (ufrag != self.remoteUfrag) {
|
|
|
790
|
+ self.remoteUfrag = ufrag;
|
|
|
791
|
+ self.room.eventEmitter.emit(
|
|
|
792
|
+ XMPPEvents.REMOTE_UFRAG_CHANGED, ufrag);
|
|
|
793
|
+ }
|
|
|
794
|
+
|
|
776
|
795
|
this.peerconnection.setRemoteDescription(
|
|
777
|
796
|
new RTCSessionDescription({type: 'offer', sdp: sdp.raw}),
|
|
778
|
797
|
function() {
|
|
|
@@ -794,6 +813,12 @@ JingleSessionPC.prototype._modifySources = function (successCallback, queueCallb
|
|
794
|
813
|
answer.sdp = modifiedAnswer.raw;
|
|
795
|
814
|
self.localSDP = new SDP(answer.sdp);
|
|
796
|
815
|
answer.sdp = self.localSDP.raw;
|
|
|
816
|
+ var ufrag = getUfrag(answer.sdp);
|
|
|
817
|
+ if (ufrag != self.localUfrag) {
|
|
|
818
|
+ self.localUfrag = ufrag;
|
|
|
819
|
+ self.room.eventEmitter.emit(
|
|
|
820
|
+ XMPPEvents.LOCAL_UFRAG_CHANGED, ufrag);
|
|
|
821
|
+ }
|
|
797
|
822
|
self.peerconnection.setLocalDescription(answer,
|
|
798
|
823
|
function() {
|
|
799
|
824
|
successCallback && successCallback();
|
|
|
@@ -1427,4 +1452,15 @@ function createDescriptionNode(jingle, mtype) {
|
|
1427
|
1452
|
return desc;
|
|
1428
|
1453
|
}
|
|
1429
|
1454
|
|
|
|
1455
|
+/**
|
|
|
1456
|
+ * Extracts the ice username fragment from an SDP string.
|
|
|
1457
|
+ */
|
|
|
1458
|
+function getUfrag(sdp) {
|
|
|
1459
|
+ var ufragLines = sdp.split('\n').filter(function(line) {
|
|
|
1460
|
+ return line.startsWith("a=ice-ufrag:");});
|
|
|
1461
|
+ if (ufragLines.length > 0) {
|
|
|
1462
|
+ return ufragLines[0].substr("a=ice-ufrag:".length)
|
|
|
1463
|
+ }
|
|
|
1464
|
+}
|
|
|
1465
|
+
|
|
1430
|
1466
|
module.exports = JingleSessionPC;
|