浏览代码

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 年前
父节点
当前提交
defdc1c287

+ 0
- 7
JitsiConference.js 查看文件

@@ -892,13 +892,6 @@ JitsiConference.prototype._setupNewTrack = function(newTrack) {
892 892
 
893 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 895
     this.eventEmitter.emit(JitsiConferenceEvents.TRACK_ADDED, newTrack);
903 896
 };
904 897
 

+ 28
- 18
JitsiConferenceEventManager.js 查看文件

@@ -19,6 +19,7 @@ import * as JitsiConferenceErrors from './JitsiConferenceErrors';
19 19
 import * as JitsiConferenceEvents from './JitsiConferenceEvents';
20 20
 import * as MediaType from './service/RTC/MediaType';
21 21
 import RTCEvents from './service/RTC/RTCEvents';
22
+import VideoType from './service/RTC/VideoType';
22 23
 import Statistics from './modules/statistics/statistics';
23 24
 import XMPPEvents from './service/xmpp/XMPPEvents';
24 25
 
@@ -522,27 +523,36 @@ JitsiConferenceEventManager.prototype.setupRTCListeners = function() {
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 查看文件

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

+ 11
- 2
modules/statistics/CallStats.js 查看文件

@@ -689,11 +689,20 @@ export default class CallStats {
689 689
      * Notifies CallStats for screen sharing events
690 690
      * @param {boolean} start true for starting screen sharing and
691 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 702
         CallStats._reportEvent(
695 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 查看文件

@@ -488,12 +488,15 @@ Statistics.prototype.sendMuteEvent = function(tpc, muted, type) {
488 488
  * Notifies CallStats for screen sharing events
489 489
  * @param start {boolean} true for starting screen sharing and
490 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 502
  * Notifies the statistics module that we are now the dominant speaker of the

+ 9
- 0
service/RTC/RTCEvents.js 查看文件

@@ -21,6 +21,15 @@ const RTCEvents = {
21 21
      * The first argument is the value passed to {@link RTC.setLastN}.
22 22
      */
23 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 33
     AVAILABLE_DEVICES_CHANGED: 'rtc.available_devices_changed',
25 34
     TRACK_ATTACHED: 'rtc.track_attached',
26 35
 

正在加载...
取消
保存