Procházet zdrojové kódy

Merge pull request #165 from bgrozev/logging

Adds more logs and clean up.
dev1
Дамян Минков před 9 roky
rodič
revize
568475fa07

+ 16
- 2
JitsiConference.js Zobrazit soubor

@@ -526,7 +526,7 @@ JitsiConference.prototype.unlock = function () {
526 526
  */
527 527
 JitsiConference.prototype.selectParticipant = function(participantId) {
528 528
     if (this.rtc) {
529
-        this.rtc.selectedEndpoint(participantId);
529
+        this.rtc.selectEndpoint(participantId);
530 530
     }
531 531
 };
532 532
 
@@ -1002,7 +1002,14 @@ JitsiConference.prototype._reportAudioProblem = function (ssrc) {
1002 1002
         new Error(JSON.stringify(errorContent)));
1003 1003
     logger.error("Audio problem detected. The audio is received but not played",
1004 1004
         errorContent);
1005
-}
1005
+};
1006
+
1007
+/**
1008
+ * Logs an "application log" message
1009
+ */
1010
+JitsiConference.prototype.sendApplicationLog = function(message) {
1011
+    Statistics.sendLog(message);
1012
+};
1006 1013
 
1007 1014
 /**
1008 1015
  * Setups the listeners needed for the conference.
@@ -1053,6 +1060,13 @@ function setupListeners(conference) {
1053 1060
         conference.rtc.closeAllDataChannels();
1054 1061
     });
1055 1062
 
1063
+    conference.room.addListener(XMPPEvents.LOCAL_UFRAG_CHANGED, function (ufrag) {
1064
+        Statistics.sendLog("Local ufrag: " + ufrag);
1065
+    });
1066
+    conference.room.addListener(XMPPEvents.REMOTE_UFRAG_CHANGED, function (ufrag) {
1067
+        Statistics.sendLog("Remote ufrag: " + ufrag);
1068
+    });
1069
+
1056 1070
     conference.room.addListener(XMPPEvents.REMOTE_TRACK_ADDED,
1057 1071
         function (data) {
1058 1072
             var track = conference.rtc.createRemoteTrack(data);

+ 14
- 7
modules/RTC/DataChannels.js Zobrazit soubor

@@ -51,7 +51,7 @@ function DataChannels(peerConnection, emitter) {
51 51
 DataChannels.prototype.onDataChannel = function (event) {
52 52
     var dataChannel = event.channel;
53 53
     var self = this;
54
-    var lastSelectedEndpoint = null;
54
+    var selectedEndpoint = null;
55 55
 
56 56
     dataChannel.onopen = function () {
57 57
         logger.info("Data channel opened by the Videobridge!", dataChannel);
@@ -68,7 +68,8 @@ DataChannels.prototype.onDataChannel = function (event) {
68 68
         // selections so that it can do adaptive simulcast,
69 69
         // we want the notification to trigger even if userJid is undefined,
70 70
         // or null.
71
-        self.handleSelectedEndpointEvent(self.lastSelectedEndpoint);
71
+        // XXX why do we not do the same for pinned endpoints?
72
+        self.sendSelectedEndpointMessage(self.selectedEndpoint);
72 73
     };
73 74
 
74 75
     dataChannel.onerror = function (error) {
@@ -173,13 +174,19 @@ DataChannels.prototype.closeAllChannels = function () {
173 174
     });
174 175
 };
175 176
 
176
-DataChannels.prototype.handleSelectedEndpointEvent = function (userResource) {
177
-    this.lastSelectedEndpoint = userResource;
178
-    this._onXXXEndpointChanged("selected", userResource);
177
+/**
178
+ * Sends a "selected endpoint changed" message via the data channel.
179
+ */
180
+DataChannels.prototype.sendSelectedEndpointMessage = function (endpointId) {
181
+    this.selectedEndpoint = endpointId;
182
+    this._onXXXEndpointChanged("selected", endpointId);
179 183
 };
180 184
 
181
-DataChannels.prototype.handlePinnedEndpointEvent = function (userResource) {
182
-    this._onXXXEndpointChanged("pinnned", userResource);
185
+/**
186
+ * Sends a "pinned endpoint changed" message via the data channel.
187
+ */
188
+DataChannels.prototype.sendPinnedEndpointMessage = function (endpointId) {
189
+    this._onXXXEndpointChanged("pinnned", endpointId);
183 190
 };
184 191
 
185 192
 /**

+ 3
- 3
modules/RTC/RTC.js Zobrazit soubor

@@ -141,14 +141,14 @@ RTC.prototype.onIncommingCall = function(event) {
141 141
     }.bind(this));
142 142
 };
143 143
 
144
-RTC.prototype.selectedEndpoint = function (id) {
144
+RTC.prototype.selectEndpoint = function (id) {
145 145
     if(this.dataChannels)
146
-        this.dataChannels.handleSelectedEndpointEvent(id);
146
+        this.dataChannels.sendSelectedEndpointMessage(id);
147 147
 };
148 148
 
149 149
 RTC.prototype.pinEndpoint = function (id) {
150 150
     if(this.dataChannels)
151
-        this.dataChannels.handlePinnedEndpointEvent(id);
151
+        this.dataChannels.sendPinnedEndpointMessage(id);
152 152
 };
153 153
 
154 154
 RTC.prototype.addListener = function (type, listener) {

+ 36
- 0
modules/xmpp/JingleSessionPC.js Zobrazit soubor

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

+ 1
- 1
package.json Zobrazit soubor

@@ -40,7 +40,7 @@
40 40
   "scripts": {
41 41
     "install": "npm run browserify && npm run version && npm run uglifyjs",
42 42
 
43
-    "browserify": "browserify -d JitsiMeetJS.js -s JitsiMeetJS | exorcist lib-jitsi-meet.js.map > lib-jitsi-meet.js ",
43
+    "browserify": "browserify -d JitsiMeetJS.js -s JitsiMeetJS | exorcist lib-jitsi-meet.js.map > lib-jitsi-meet.js && [ -s lib-jitsi-meet.js ]",
44 44
     "version": "VERSION=`./get-version.sh` && echo lib-jitsi-meet version is:${VERSION} && sed -i'' -e s/{#COMMIT_HASH#}/${VERSION}/g lib-jitsi-meet.js",
45 45
     "uglifyjs": "uglifyjs -p relative lib-jitsi-meet.js -o lib-jitsi-meet.min.js --source-map lib-jitsi-meet.min.map --in-source-map lib-jitsi-meet.js.map",
46 46
     "watch": "watchify JitsiMeetJS.js -s JitsiMeetJS -o lib-jitsi-meet.js -v",

+ 7
- 1
service/xmpp/XMPPEvents.js Zobrazit soubor

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

Načítá se…
Zrušit
Uložit