Sfoglia il codice sorgente

Merge pull request #59 from damencho/callstats-screen-share-events

Adds screenShareStart and screenShareStop events to callstats reports.
master
hristoterezov 9 anni fa
parent
commit
a132424c5e
3 ha cambiato i file con 39 aggiunte e 1 eliminazioni
  1. 15
    0
      JitsiConference.js
  2. 14
    1
      modules/statistics/CallStats.js
  3. 10
    0
      modules/statistics/statistics.js

+ 15
- 0
JitsiConference.js Vedi File

@@ -351,6 +351,13 @@ JitsiConference.prototype.addTrack = function (track) {
351 351
                                    track.audioLevelHandler);
352 352
             //FIXME: This dependacy is not necessary. This is quick fix.
353 353
             track._setConference(this);
354
+
355
+            // send event for starting screen sharing
356
+            // FIXME: we assume we have only one screen sharing track
357
+            // if we change this we need to fix this check
358
+            if (track.isVideoTrack() && track.videoType === "desktop")
359
+                this.statistics.sendScreenSharingEvent(true);
360
+
354 361
             this.eventEmitter.emit(JitsiConferenceEvents.TRACK_ADDED, track);
355 362
             resolve(track);
356 363
         }.bind(this));
@@ -391,6 +398,7 @@ JitsiConference.prototype.removeTrack = function (track) {
391 398
     {
392 399
         throw new Error(JitsiTrackErrors.TRACK_IS_DISPOSED);
393 400
     }
401
+
394 402
     if(!this.room){
395 403
         if(this.rtc) {
396 404
             this.rtc.removeLocalStream(track);
@@ -410,6 +418,13 @@ JitsiConference.prototype.removeTrack = function (track) {
410 418
                 track.audioLevelHandler);
411 419
             this.room.removeListener(XMPPEvents.SENDRECV_STREAMS_CHANGED,
412 420
                 track.ssrcHandler);
421
+
422
+            // send event for stopping screen sharing
423
+            // FIXME: we assume we have only one screen sharing track
424
+            // if we change this we need to fix this check
425
+            if (track.isVideoTrack() && track.videoType === "desktop")
426
+                this.statistics.sendScreenSharingEvent(false);
427
+
413 428
             this.eventEmitter.emit(JitsiConferenceEvents.TRACK_REMOVED, track);
414 429
             resolve();
415 430
         }.bind(this), {

+ 14
- 1
modules/statistics/CallStats.js Vedi File

@@ -32,7 +32,9 @@ var fabricEvent = {
32 32
     videoResume:"videoResume",
33 33
     fabricUsageEvent:"fabricUsageEvent",
34 34
     fabricStats:"fabricStats",
35
-    fabricTerminated:"fabricTerminated"
35
+    fabricTerminated:"fabricTerminated",
36
+    screenShareStart:"screenShareStart",
37
+    screenShareStop:"screenShareStop"
36 38
 };
37 39
 
38 40
 var callStats = null;
@@ -209,6 +211,17 @@ CallStats.sendMuteEvent = _try_catch(function (mute, type, cs) {
209 211
     CallStats._reportEvent.call(cs, event);
210 212
 });
211 213
 
214
+/**
215
+ * Notifies CallStats for screen sharing events
216
+ * @param start {boolean} true for starting screen sharing and
217
+ * false for not stopping
218
+ */
219
+CallStats.sendScreenSharingEvent = _try_catch(function (start, cs) {
220
+
221
+    CallStats._reportEvent.call(cs,
222
+        start? fabricEvent.screenShareStart : fabricEvent.screenShareStop);
223
+});
224
+
212 225
 /**
213 226
  * Reports an error to callstats.
214 227
  *

+ 10
- 0
modules/statistics/statistics.js Vedi File

@@ -199,6 +199,16 @@ Statistics.prototype.sendMuteEvent = function (muted, type) {
199 199
         CallStats.sendMuteEvent(muted, type, this.callstats);
200 200
 };
201 201
 
202
+/**
203
+ * Notifies CallStats for screen sharing events
204
+ * @param start {boolean} true for starting screen sharing and
205
+ * false for not stopping
206
+ */
207
+Statistics.prototype.sendScreenSharingEvent = function (start) {
208
+    if(this.callStatsIntegrationEnabled)
209
+        CallStats.sendScreenSharingEvent(start, this.callstats);
210
+};
211
+
202 212
 /**
203 213
  * Lets the underlying statistics module know where is given SSRC rendered by
204 214
  * providing renderer tag ID.

Loading…
Annulla
Salva