Selaa lähdekoodia

Passes the info about stream renderer element id to CallStats.

master
paweldomas 9 vuotta sitten
vanhempi
commit
6f6b409951

+ 11
- 0
JitsiConference.js Näytä tiedosto

@@ -1116,6 +1116,17 @@ function setupListeners(conference) {
1116 1116
                 conference.statistics.sendSetupFailedEvent();
1117 1117
             });
1118 1118
 
1119
+        conference.rtc.addListener(RTCEvents.TRACK_ATTACHED,
1120
+            function(track, container) {
1121
+                var ssrc = track.getSSRC();
1122
+                if (!container.id || !ssrc) {
1123
+                    return;
1124
+                }
1125
+                conference.statistics.associateStreamWithVideoTag(
1126
+                    ssrc, track.isLocal(), track.getUsageLabel(), container.id);
1127
+
1128
+            });
1129
+
1119 1130
         conference.on(JitsiConferenceEvents.TRACK_MUTE_CHANGED,
1120 1131
             function (track) {
1121 1132
                 if(!track.isLocal())

+ 16
- 0
modules/RTC/JitsiLocalTrack.js Näytä tiedosto

@@ -163,6 +163,22 @@ JitsiLocalTrack.prototype._setRTC = function (rtc) {
163 163
     this.rtc = rtc;
164 164
 };
165 165
 
166
+/**
167
+ * Gets the SSRC of this local track if it's available already or <tt>null</tt>
168
+ * otherwise. That's because we don't know the SSRC until local description is
169
+ * created.
170
+ * @returns {string} or {null}
171
+ */
172
+JitsiLocalTrack.prototype.getSSRC = function () {
173
+    if (!this.rtc.room.session)
174
+        return null;
175
+    if (this.isAudioTrack()) {
176
+        return this.rtc.room.session.localStreamsSSRC.audio;
177
+    } else {
178
+        return this.rtc.room.session.localStreamsSSRC.video;
179
+    }
180
+};
181
+
166 182
 /**
167 183
  * Return true;
168 184
  */

+ 17
- 0
modules/RTC/JitsiTrack.js Näytä tiedosto

@@ -1,5 +1,6 @@
1 1
 var logger = require("jitsi-meet-logger").getLogger(__filename);
2 2
 var RTCBrowserType = require("./RTCBrowserType");
3
+var RTCEvents = require("../../service/RTC/RTCEvents");
3 4
 var JitsiTrackEvents = require("../../JitsiTrackEvents");
4 5
 var EventEmitter = require("events");
5 6
 var RTC = require("./RTCUtils");
@@ -135,6 +136,19 @@ JitsiTrack.prototype.getOriginalStream = function() {
135 136
     return this.stream;
136 137
 }
137 138
 
139
+/**
140
+ * Return meaningful usage label for this track depending on it's media and
141
+ * eventual video type.
142
+ * @returns {string}
143
+ */
144
+JitsiTrack.prototype.getUsageLabel = function () {
145
+    if (this.type == JitsiTrack.AUDIO) {
146
+        return "mic";
147
+    } else {
148
+        return this.videoType ? this.videoType : "default";
149
+    }
150
+};
151
+
138 152
 /**
139 153
  * Mutes the track.
140 154
  */
@@ -178,6 +192,9 @@ JitsiTrack.prototype.attach = function (container) {
178 192
             = require("./RTCUtils").attachMediaStream(container, this.stream);
179 193
     }
180 194
     this.containers.push(container);
195
+
196
+    this.rtc.eventEmitter.emit(RTCEvents.TRACK_ATTACHED, this, container);
197
+
181 198
     return container;
182 199
 }
183 200
 

+ 43
- 0
modules/statistics/CallStats.js Näytä tiedosto

@@ -147,6 +147,49 @@ CallStats.prototype.pcCallback = _try_catch(function (err, msg) {
147 147
     logger.log("Monitoring status: "+ err + " msg: " + msg);
148 148
 });
149 149
 
150
+/**
151
+ * Lets CallStats module know where is given SSRC rendered by providing renderer
152
+ * tag ID.
153
+ * @param ssrc {number} the SSRC of the stream
154
+ * @param isLocal {boolean} <tt>true<tt> if this stream is local or
155
+ *        <tt>false</tt> otherwise.
156
+ * @param usageLabel {string} meaningful usage label of this stream like
157
+ *        'microphone', 'camera' or 'screen'.
158
+ * @param containerId {string} the id of media 'audio' or 'video' tag which
159
+ *        renders the stream.
160
+ */
161
+CallStats.prototype.associateStreamWithVideoTag =
162
+function (ssrc, isLocal, usageLabel, containerId) {
163
+    if(!callStats) {
164
+        return;
165
+    }
166
+    // 'focus' is default remote user ID for now
167
+    var callStatsId = 'focus';
168
+    if (isLocal) {
169
+        callStatsId = this.userID;
170
+    }
171
+
172
+    _try_catch(function() {
173
+        logger.debug(
174
+            "Calling callStats.associateMstWithUserID with:",
175
+            this.peerconnection,
176
+            callStatsId,
177
+            this.confID,
178
+            ssrc,
179
+            usageLabel,
180
+            containerId
181
+        );
182
+        callStats.associateMstWithUserID(
183
+            this.peerconnection,
184
+            callStatsId,
185
+            this.confID,
186
+            ssrc,
187
+            usageLabel,
188
+            containerId
189
+        );
190
+    }).bind(this)();
191
+};
192
+
150 193
 /**
151 194
  * Notifies CallStats for mute events
152 195
  * @param mute {boolean} true for muted and false for not muted

+ 19
- 0
modules/statistics/statistics.js Näytä tiedosto

@@ -199,6 +199,25 @@ Statistics.prototype.sendMuteEvent = function (muted, type) {
199 199
         CallStats.sendMuteEvent(muted, type, this.callstats);
200 200
 };
201 201
 
202
+/**
203
+ * Lets the underlying statistics module know where is given SSRC rendered by
204
+ * providing renderer tag ID.
205
+ * @param ssrc {number} the SSRC of the stream
206
+ * @param isLocal {boolean} <tt>true<tt> if this stream is local or
207
+ *        <tt>false</tt> otherwise.
208
+ * @param usageLabel {string} meaningful usage label of this stream like
209
+ *        'microphone', 'camera' or 'screen'.
210
+ * @param containerId {string} the id of media 'audio' or 'video' tag which
211
+ *        renders the stream.
212
+ */
213
+Statistics.prototype.associateStreamWithVideoTag =
214
+function (ssrc, isLocal, usageLabel, containerId) {
215
+    if(this.callStatsIntegrationEnabled && this.callstats) {
216
+        this.callstats.associateStreamWithVideoTag(
217
+            ssrc, isLocal, usageLabel, containerId);
218
+    }
219
+};
220
+
202 221
 /**
203 222
  * Notifies CallStats that getUserMedia failed.
204 223
  *

+ 2
- 1
service/RTC/RTCEvents.js Näytä tiedosto

@@ -5,7 +5,8 @@ var RTCEvents = {
5 5
     DOMINANTSPEAKER_CHANGED: "rtc.dominantspeaker_changed",
6 6
     LASTN_ENDPOINT_CHANGED: "rtc.lastn_endpoint_changed",
7 7
     AVAILABLE_DEVICES_CHANGED: "rtc.available_devices_changed",
8
-    FAKE_VIDEO_TRACK_CREATED: "rtc.fake_video_track_created"
8
+    FAKE_VIDEO_TRACK_CREATED: "rtc.fake_video_track_created",
9
+    TRACK_ATTACHED: "rtc.track_attached"
9 10
 };
10 11
 
11 12
 module.exports = RTCEvents;

Loading…
Peruuta
Tallenna