Skip to content

Commit

Permalink
feat(quality) Send analytics event for video codec changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
jallamsetty1 committed Aug 20, 2024
1 parent 8d1787a commit f481990
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 5 deletions.
12 changes: 11 additions & 1 deletion modules/RTC/TraceablePeerConnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Check failure on line 13 in modules/RTC/TraceablePeerConnection.js

View workflow job for this annotation

GitHub Actions / Build

`../../service/RTC/VideoType` import should occur before import of `../../service/statistics/AnalyticsEvents`
import { SS_DEFAULT_FRAME_RATE } from '../RTC/ScreenObtainer';
import browser from '../browser';
Expand All @@ -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';
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -2475,6 +2478,13 @@ TraceablePeerConnection.prototype._updateVideoSenderEncodings = function(frameHe

parameters.encodings[idx].codec = matchingCodec;
needsUpdate = true;

Statistics.sendAnalytics(
VIDEO_CODEC_CHANGED,
{
value: codec,
videoType
});
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions modules/qualitycontrol/ReceiveVideoController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
}
}

Expand Down Expand Up @@ -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}`);
}
}
}
11 changes: 10 additions & 1 deletion modules/xmpp/JingleSessionPC.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -24,6 +25,7 @@ import JingleSession from './JingleSession';
import * as JingleSessionState from './JingleSessionState';
import MediaSessionEvents from './MediaSessionEvents';
import XmppConnection from './XmppConnection';

Check failure on line 27 in modules/xmpp/JingleSessionPC.js

View workflow job for this annotation

GitHub Actions / Build

There should be at least one empty line between import groups
import { VideoType } from '../../service/RTC/VideoType';

Check failure on line 28 in modules/xmpp/JingleSessionPC.js

View workflow job for this annotation

GitHub Actions / Build

`../../service/RTC/VideoType` import should occur before import of `../../service/statistics/AnalyticsEvents`

const logger = getLogger(__filename);

Expand Down Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions service/statistics/AnalyticsEvents.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ describe( "/service/statistics/AnalyticsEvents members", () => {
ICE_STATE_CHANGED,
NO_BYTES_SENT,
TRACK_UNMUTED,
VIDEO_CODEC_CHANGED,
createBridgeDownEvent,
createConnectionFailedEvent,
createConferenceEvent,
Expand Down Expand Up @@ -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();

Expand Down
12 changes: 11 additions & 1 deletion service/statistics/AnalyticsEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit f481990

Please sign in to comment.