Sfoglia il codice sorgente

Logs the ICE ufrags to callstats.

master
Boris Grozev 9 anni fa
parent
commit
68b1eb7912
3 ha cambiato i file con 50 aggiunte e 1 eliminazioni
  1. 7
    0
      JitsiConference.js
  2. 36
    0
      modules/xmpp/JingleSessionPC.js
  3. 7
    1
      service/xmpp/XMPPEvents.js

+ 7
- 0
JitsiConference.js Vedi File

@@ -1053,6 +1053,13 @@ function setupListeners(conference) {
1053 1053
         conference.rtc.closeAllDataChannels();
1054 1054
     });
1055 1055
 
1056
+    conference.room.addListener(XMPPEvents.LOCAL_UFRAG_CHANGED, function (ufrag) {
1057
+        Statistics.sendLog("Local ufrag: " + ufrag);
1058
+    });
1059
+    conference.room.addListener(XMPPEvents.REMOTE_UFRAG_CHANGED, function (ufrag) {
1060
+        Statistics.sendLog("Remote ufrag: " + ufrag);
1061
+    });
1062
+
1056 1063
     conference.room.addListener(XMPPEvents.REMOTE_TRACK_ADDED,
1057 1064
         function (data) {
1058 1065
             var track = conference.rtc.createRemoteTrack(data);

+ 36
- 0
modules/xmpp/JingleSessionPC.js Vedi File

@@ -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;

+ 7
- 1
service/xmpp/XMPPEvents.js Vedi File

@@ -157,6 +157,12 @@ var XMPPEvents = {
157 157
     START_MUTED_FROM_FOCUS: "xmpp.start_muted_from_focus",
158 158
     // Designates an event indicating that the subject of the XMPP MUC has
159 159
     // changed.
160
-    SUBJECT_CHANGED: "xmpp.subject_changed"
160
+    SUBJECT_CHANGED: "xmpp.subject_changed",
161
+    // Designates an event indicating that the local ICE username fragment of
162
+    // the jingle session has changed.
163
+    LOCAL_UFRAG_CHANGED: "xmpp.local_ufrag_changed",
164
+    // Designates an event indicating that the local ICE username fragment of
165
+    // the jingle session has changed.
166
+    REMOTE_UFRAG_CHANGED: "xmpp.remote_ufrag_changed"
161 167
 };
162 168
 module.exports = XMPPEvents;

Loading…
Annulla
Salva