From f48199069e8deff36b2adf6f84ace4884f50f7eb Mon Sep 17 00:00:00 2001 From: Jaya Allamsetty Date: Tue, 20 Aug 2024 11:17:52 -0400 Subject: [PATCH] feat(quality) Send analytics event for video codec changes. --- modules/RTC/TraceablePeerConnection.js | 12 +++++++++++- modules/qualitycontrol/ReceiveVideoController.js | 4 ++-- modules/xmpp/JingleSessionPC.js | 11 ++++++++++- service/statistics/AnalyticsEvents.spec.ts | 2 ++ service/statistics/AnalyticsEvents.ts | 12 +++++++++++- 5 files changed, 36 insertions(+), 5 deletions(-) diff --git a/modules/RTC/TraceablePeerConnection.js b/modules/RTC/TraceablePeerConnection.js index 7aeadc9875..ca46915f79 100644 --- a/modules/RTC/TraceablePeerConnection.js +++ b/modules/RTC/TraceablePeerConnection.js @@ -9,6 +9,7 @@ import RTCEvents from '../../service/RTC/RTCEvents'; import * as SignalingEvents from '../../service/RTC/SignalingEvents'; import { getSourceIndexFromSourceName } from '../../service/RTC/SignalingLayer'; import { VIDEO_QUALITY_LEVELS } from '../../service/RTC/StandardVideoQualitySettings'; +import { VIDEO_CODEC_CHANGED } from '../../service/statistics/AnalyticsEvents'; import { VideoType } from '../../service/RTC/VideoType'; import { SS_DEFAULT_FRAME_RATE } from '../RTC/ScreenObtainer'; import browser from '../browser'; @@ -19,6 +20,7 @@ import SDP from '../sdp/SDP'; import SDPUtil from '../sdp/SDPUtil'; import SdpSimulcast from '../sdp/SdpSimulcast'; import { SdpTransformWrap } from '../sdp/SdpTransformUtil'; +import Statistics from '../statistics/statistics'; import JitsiRemoteTrack from './JitsiRemoteTrack'; import RTCUtils from './RTCUtils'; @@ -2388,7 +2390,8 @@ TraceablePeerConnection.prototype._updateVideoSenderParameters = function(nextFu */ TraceablePeerConnection.prototype._updateVideoSenderEncodings = function(frameHeight, localVideoTrack, preferredCodec) { const videoSender = this.findSenderForTrack(localVideoTrack.getTrack()); - const isScreensharingTrack = localVideoTrack.getVideoType() === VideoType.DESKTOP; + const videoType = localVideoTrack.getVideoType(); + const isScreensharingTrack = videoType === VideoType.DESKTOP; if (!videoSender) { return Promise.resolve(); @@ -2475,6 +2478,13 @@ TraceablePeerConnection.prototype._updateVideoSenderEncodings = function(frameHe parameters.encodings[idx].codec = matchingCodec; needsUpdate = true; + + Statistics.sendAnalytics( + VIDEO_CODEC_CHANGED, + { + value: codec, + videoType + }); } } } diff --git a/modules/qualitycontrol/ReceiveVideoController.js b/modules/qualitycontrol/ReceiveVideoController.js index 27d3f3cfc0..07e3f578a9 100644 --- a/modules/qualitycontrol/ReceiveVideoController.js +++ b/modules/qualitycontrol/ReceiveVideoController.js @@ -167,7 +167,7 @@ export default class ReceiveVideoController { setLastNLimitedByCpu(enabled) { if (this._lastNLimitedByCpu !== enabled) { this._lastNLimitedByCpu = enabled; - logger.info(`ReceiveVideoController - Setting the _lastNLimitedByCpu flag to ${enabled}`); + logger.info(`ReceiveVideoController - Setting the lastNLimitedByCpu flag to ${enabled}`); } } @@ -250,7 +250,7 @@ export default class ReceiveVideoController { setReceiveResolutionLimitedByCpu(enabled) { if (this._receiveResolutionLimitedByCpu !== enabled) { this._receiveResolutionLimitedByCpu = enabled; - logger.info(`ReceiveVideoController - Setting the _receiveResolutionLimitedByCpu flag to ${enabled}`); + logger.info(`ReceiveVideoController - Setting the receiveResolutionLimitedByCpu flag to ${enabled}`); } } } diff --git a/modules/xmpp/JingleSessionPC.js b/modules/xmpp/JingleSessionPC.js index df142dc6e2..b3c149625a 100644 --- a/modules/xmpp/JingleSessionPC.js +++ b/modules/xmpp/JingleSessionPC.js @@ -8,7 +8,8 @@ import { MediaDirection } from '../../service/RTC/MediaDirection'; import { MediaType } from '../../service/RTC/MediaType'; import { ICE_DURATION, - ICE_STATE_CHANGED + ICE_STATE_CHANGED, + VIDEO_CODEC_CHANGED } from '../../service/statistics/AnalyticsEvents'; import { XMPPEvents } from '../../service/xmpp/XMPPEvents'; import { SS_DEFAULT_FRAME_RATE } from '../RTC/ScreenObtainer'; @@ -24,6 +25,7 @@ import JingleSession from './JingleSession'; import * as JingleSessionState from './JingleSessionState'; import MediaSessionEvents from './MediaSessionEvents'; import XmppConnection from './XmppConnection'; +import { VideoType } from '../../service/RTC/VideoType'; const logger = getLogger(__filename); @@ -1200,6 +1202,13 @@ export default class JingleSessionPC extends JingleSession { return; } + Statistics.sendAnalytics( + VIDEO_CODEC_CHANGED, + { + value: codecList[0], + videoType: VideoType.CAMERA + }); + // Initiate a renegotiate for the codec setting to take effect. const workFunction = finishedCallback => { this._renegotiate() diff --git a/service/statistics/AnalyticsEvents.spec.ts b/service/statistics/AnalyticsEvents.spec.ts index 7aa711df9d..feed7b6981 100644 --- a/service/statistics/AnalyticsEvents.spec.ts +++ b/service/statistics/AnalyticsEvents.spec.ts @@ -27,6 +27,7 @@ describe( "/service/statistics/AnalyticsEvents members", () => { ICE_STATE_CHANGED, NO_BYTES_SENT, TRACK_UNMUTED, + VIDEO_CODEC_CHANGED, createBridgeDownEvent, createConnectionFailedEvent, createConferenceEvent, @@ -74,6 +75,7 @@ describe( "/service/statistics/AnalyticsEvents members", () => { expect( ICE_STATE_CHANGED ).toBe( 'ice.state.changed' ); expect( NO_BYTES_SENT ).toBe( 'track.no-bytes-sent' ); expect( TRACK_UNMUTED ).toBe( 'track.unmuted' ); + expect( VIDEO_CODEC_CHANGED ).toBe( 'quality.video-codec-changed' ); expect( AnalyticsEvents ).toBeDefined(); diff --git a/service/statistics/AnalyticsEvents.ts b/service/statistics/AnalyticsEvents.ts index 1f24289add..a0212b31ae 100644 --- a/service/statistics/AnalyticsEvents.ts +++ b/service/statistics/AnalyticsEvents.ts @@ -211,7 +211,16 @@ export enum AnalyticsEvents { * trackType: the type of the track ('local' or 'remote'). * value: TODO: document */ - TRACK_UNMUTED = 'track.unmuted' + TRACK_UNMUTED = 'track.unmuted', + + /** + * Indicates that the video codec changed for a local track. + * + * Properties: + * value: the video codec mimeType. + * videoType: the videoType of local track, whether its 'camera' or 'desktop'. + */ + VIDEO_CODEC_CHANGED = 'quality.video-codec-changed', } // exported for backward compatibility @@ -238,6 +247,7 @@ export const ICE_ESTABLISHMENT_DURATION_DIFF = AnalyticsEvents.ICE_ESTABLISHMENT export const ICE_STATE_CHANGED = AnalyticsEvents.ICE_STATE_CHANGED; export const NO_BYTES_SENT = AnalyticsEvents.NO_BYTES_SENT; export const TRACK_UNMUTED = AnalyticsEvents.TRACK_UNMUTED; +export const VIDEO_CODEC_CHANGED = AnalyticsEvents.VIDEO_CODEC_CHANGED; /** * Creates an operational event which indicates that we have received a