Browse Source

Reports ssrc to callstats when screen sharing is started. (#657)

Adds rtc.LOCAL_TRACK_SSRC_UPDATED event to be emitted when ssrc is updated for a local track.
Fixes adding rtc listeners for CREATE_ANSWER_FAILED, CREATE_OFFER_FAILED, SET_LOCAL_DESCRIPTION_FAILED, SET_REMOTE_DESCRIPTION_FAILED.
release-8443
Дамян Минков 7 years ago
parent
commit
defdc1c287

+ 0
- 7
JitsiConference.js View File

892
 
892
 
893
     newTrack._setConference(this);
893
     newTrack._setConference(this);
894
 
894
 
895
-    // send event for starting screen sharing
896
-    // FIXME: we assume we have only one screen sharing track
897
-    // if we change this we need to fix this check
898
-    if (newTrack.isVideoTrack() && newTrack.videoType === VideoType.DESKTOP) {
899
-        this.statistics.sendScreenSharingEvent(true);
900
-    }
901
-
902
     this.eventEmitter.emit(JitsiConferenceEvents.TRACK_ADDED, newTrack);
895
     this.eventEmitter.emit(JitsiConferenceEvents.TRACK_ADDED, newTrack);
903
 };
896
 };
904
 
897
 

+ 28
- 18
JitsiConferenceEventManager.js View File

19
 import * as JitsiConferenceEvents from './JitsiConferenceEvents';
19
 import * as JitsiConferenceEvents from './JitsiConferenceEvents';
20
 import * as MediaType from './service/RTC/MediaType';
20
 import * as MediaType from './service/RTC/MediaType';
21
 import RTCEvents from './service/RTC/RTCEvents';
21
 import RTCEvents from './service/RTC/RTCEvents';
22
+import VideoType from './service/RTC/VideoType';
22
 import Statistics from './modules/statistics/statistics';
23
 import Statistics from './modules/statistics/statistics';
23
 import XMPPEvents from './service/xmpp/XMPPEvents';
24
 import XMPPEvents from './service/xmpp/XMPPEvents';
24
 
25
 
522
             }
523
             }
523
         });
524
         });
524
 
525
 
525
-    if (conference.statistics) {
526
-        rtc.addListener(RTCEvents.CREATE_ANSWER_FAILED,
527
-            (e, tpc) => {
528
-                conference.statistics.sendCreateAnswerFailed(e, tpc);
529
-            });
526
+    rtc.addListener(RTCEvents.CREATE_ANSWER_FAILED,
527
+        (e, tpc) => {
528
+            conference.statistics.sendCreateAnswerFailed(e, tpc);
529
+        });
530
 
530
 
531
-        rtc.addListener(RTCEvents.CREATE_OFFER_FAILED,
532
-            (e, tpc) => {
533
-                conference.statistics.sendCreateOfferFailed(e, tpc);
534
-            });
531
+    rtc.addListener(RTCEvents.CREATE_OFFER_FAILED,
532
+        (e, tpc) => {
533
+            conference.statistics.sendCreateOfferFailed(e, tpc);
534
+        });
535
 
535
 
536
-        rtc.addListener(RTCEvents.SET_LOCAL_DESCRIPTION_FAILED,
537
-            (e, tpc) => {
538
-                conference.statistics.sendSetLocalDescFailed(e, tpc);
539
-            });
536
+    rtc.addListener(RTCEvents.SET_LOCAL_DESCRIPTION_FAILED,
537
+        (e, tpc) => {
538
+            conference.statistics.sendSetLocalDescFailed(e, tpc);
539
+        });
540
 
540
 
541
-        rtc.addListener(RTCEvents.SET_REMOTE_DESCRIPTION_FAILED,
542
-            (e, tpc) => {
543
-                conference.statistics.sendSetRemoteDescFailed(e, tpc);
544
-            });
545
-    }
541
+    rtc.addListener(RTCEvents.SET_REMOTE_DESCRIPTION_FAILED,
542
+        (e, tpc) => {
543
+            conference.statistics.sendSetRemoteDescFailed(e, tpc);
544
+        });
545
+
546
+    rtc.addListener(RTCEvents.LOCAL_TRACK_SSRC_UPDATED,
547
+        (track, ssrc) => {
548
+            // when starting screen sharing, the track is created and when
549
+            // we do set local description and we process the ssrc we
550
+            // will be notified for it and we will report it with the event
551
+            // for screen sharing
552
+            if (track.isVideoTrack() && track.videoType === VideoType.DESKTOP) {
553
+                conference.statistics.sendScreenSharingEvent(true, ssrc);
554
+            }
555
+        });
546
 };
556
 };
547
 
557
 
548
 /**
558
 /**

+ 3
- 0
modules/RTC/TraceablePeerConnection.js View File

2238
                         } with: `, newSSRC);
2238
                         } with: `, newSSRC);
2239
                 }
2239
                 }
2240
                 this.localSSRCs.set(track.rtcId, newSSRC);
2240
                 this.localSSRCs.set(track.rtcId, newSSRC);
2241
+
2242
+                this.eventEmitter.emit(
2243
+                    RTCEvents.LOCAL_TRACK_SSRC_UPDATED, track, newSSRCNum);
2241
             } else {
2244
             } else {
2242
                 logger.debug(
2245
                 logger.debug(
2243
                     `The local SSRC(${newSSRCNum}) for ${track} ${trackMSID}`
2246
                     `The local SSRC(${newSSRCNum}) for ${track} ${trackMSID}`

+ 11
- 2
modules/statistics/CallStats.js View File

689
      * Notifies CallStats for screen sharing events
689
      * Notifies CallStats for screen sharing events
690
      * @param {boolean} start true for starting screen sharing and
690
      * @param {boolean} start true for starting screen sharing and
691
      * false for not stopping
691
      * false for not stopping
692
+     * @param {string|null} ssrc - optional ssrc value, used only when
693
+     * starting screen sharing.
692
      */
694
      */
693
-    sendScreenSharingEvent(start) {
695
+    sendScreenSharingEvent(start, ssrc) {
696
+        let eventData;
697
+
698
+        if (ssrc) {
699
+            eventData = { ssrc };
700
+        }
701
+
694
         CallStats._reportEvent(
702
         CallStats._reportEvent(
695
             this,
703
             this,
696
-            start ? fabricEvent.screenShareStart : fabricEvent.screenShareStop);
704
+            start ? fabricEvent.screenShareStart : fabricEvent.screenShareStop,
705
+            eventData);
697
     }
706
     }
698
 
707
 
699
     /**
708
     /**

+ 8
- 5
modules/statistics/statistics.js View File

488
  * Notifies CallStats for screen sharing events
488
  * Notifies CallStats for screen sharing events
489
  * @param start {boolean} true for starting screen sharing and
489
  * @param start {boolean} true for starting screen sharing and
490
  * false for not stopping
490
  * false for not stopping
491
+ * @param {string|null} ssrc - optional ssrc value, used only when
492
+ * starting screen sharing.
491
  */
493
  */
492
-Statistics.prototype.sendScreenSharingEvent = function(start) {
493
-    for (const cs of this.callsStatsInstances.values()) {
494
-        cs.sendScreenSharingEvent(start);
495
-    }
496
-};
494
+Statistics.prototype.sendScreenSharingEvent
495
+    = function(start, ssrc) {
496
+        for (const cs of this.callsStatsInstances.values()) {
497
+            cs.sendScreenSharingEvent(start, ssrc);
498
+        }
499
+    };
497
 
500
 
498
 /**
501
 /**
499
  * Notifies the statistics module that we are now the dominant speaker of the
502
  * Notifies the statistics module that we are now the dominant speaker of the

+ 9
- 0
service/RTC/RTCEvents.js View File

21
      * The first argument is the value passed to {@link RTC.setLastN}.
21
      * The first argument is the value passed to {@link RTC.setLastN}.
22
      */
22
      */
23
     LASTN_VALUE_CHANGED: 'rtc.lastn_value_changed',
23
     LASTN_VALUE_CHANGED: 'rtc.lastn_value_changed',
24
+
25
+    /**
26
+     * Event emitted when ssrc for a local track is extracted and stored
27
+     * in {@link TraceablePeerConnection}.
28
+     * @param {JitsiLocalTrack} track which ssrc was updated
29
+     * @param {string} ssrc that was stored
30
+     */
31
+    LOCAL_TRACK_SSRC_UPDATED: 'rtc.local_track_ssrc_updated',
32
+
24
     AVAILABLE_DEVICES_CHANGED: 'rtc.available_devices_changed',
33
     AVAILABLE_DEVICES_CHANGED: 'rtc.available_devices_changed',
25
     TRACK_ATTACHED: 'rtc.track_attached',
34
     TRACK_ATTACHED: 'rtc.track_attached',
26
 
35
 

Loading…
Cancel
Save