Skip to content

Commit

Permalink
fix: add subscriber video stats to analyics
Browse files Browse the repository at this point in the history
  • Loading branch information
eswarclynn committed Feb 22, 2024
1 parent 19450a7 commit 6d34209
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ export abstract class RunningTrackAnalytics {
return latestValue - firstValue;
}

protected calculateDifferenceAverage(key: keyof TempPublishStats, round = true) {
const avg = this.calculateDifferenceForSample(key) / this.tempStats.length;
return round ? Math.round(avg) : avg;
}

protected calculateInstancesOfHigh(key: keyof TempPublishStats, threshold: number) {
const checkStat = this.getLatestStat()[key];
if (typeof checkStat !== 'number') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,15 @@ class RunningRemoteTrackAnalytics extends RunningTrackAnalytics {
};

if (latestStat.kind === 'video') {
return removeUndefinedFromObject<RemoteAudioSample | RemoteVideoSample>(baseSample);
return removeUndefinedFromObject<RemoteAudioSample | RemoteVideoSample>(
Object.assign(baseSample, {
avg_frames_received_per_sec: this.calculateDifferenceAverage('framesReceived'),
avg_frames_dropped_per_sec: this.calculateDifferenceAverage('framesDropped'),
avg_frames_decoded_per_sec: this.calculateDifferenceAverage('framesDecoded'),
frame_width: this.calculateAverage('frameWidth'),
frame_height: this.calculateAverage('frameHeight'),
}),
);
} else {
const audio_concealed_samples =
(latestStat.concealedSamples || 0) -
Expand Down
7 changes: 7 additions & 0 deletions packages/hms-video-store/src/analytics/stats/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,11 @@ export interface RemoteVideoSample extends RemoteBaseSample {
avg_frames_decoded_per_sec?: number;
total_pli_count?: number;
total_nack_count?: number;
frame_width?: number;
frame_height?: number;
pause_count?: number;
pause_duration_seconds?: number;
freeze_count?: number;
freeze_duration_seconds?: number;
avg_jitter_buffer_delay?: number;
}

0 comments on commit 6d34209

Please sign in to comment.