Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add corruptedFrames to stats #2328

Merged
merged 3 commits into from
Jan 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions externs/shaka/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ shaka.extern.StateChange;
*
* decodedFrames: number,
* droppedFrames: number,
* corruptedFrames: number,
* estimatedBandwidth: number,
*
* loadLatency: number,
Expand Down Expand Up @@ -97,6 +98,9 @@ shaka.extern.StateChange;
* @property {number} droppedFrames
* The total number of frames dropped by the Player. This may be
* <code>NaN</code> if this is not supported by the browser.
* @property {number} corruptedFrames
* The total number of corrupted frames dropped by the browser. This may be
* <code>NaN</code> if this is not supported by the browser.
* @property {number} estimatedBandwidth
* The current estimated network bandwidth (in bit/sec).
*
Expand Down
1 change: 1 addition & 0 deletions lib/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -3436,6 +3436,7 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
this.stats_.setDroppedFrames(
Number(info.droppedVideoFrames),
Number(info.totalVideoFrames));
this.stats_.setCorruptedFrames(Number(info.corruptedVideoFrames));
}

const licenseSeconds =
Expand Down
14 changes: 14 additions & 0 deletions lib/util/stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ shaka.util.Stats = class {
this.totalDroppedFrames_ = NaN;
/** @private {number} */
this.totalDecodedFrames_ = NaN;
/** @private {number} */
this.totalCorruptedFrames_ = NaN;

/** @private {number} */
this.loadLatencySeconds_ = NaN;
Expand Down Expand Up @@ -57,6 +59,16 @@ shaka.util.Stats = class {
this.totalDecodedFrames_ = decoded;
}


/**
* Update corrupted frames. This will replace the previous values.
*
* @param {number} corrupted
*/
setCorruptedFrames(corrupted) {
this.totalCorruptedFrames_ = corrupted;
}

/**
* Set the width and height of the video we are currently playing.
*
Expand Down Expand Up @@ -128,6 +140,7 @@ shaka.util.Stats = class {
streamBandwidth: this.variantBandwidth_,
decodedFrames: this.totalDecodedFrames_,
droppedFrames: this.totalDroppedFrames_,
corruptedFrames: this.totalCorruptedFrames_,
estimatedBandwidth: this.bandwidthEstimate_,
loadLatency: this.loadLatencySeconds_,
playTime: this.stateHistory_.getTimeSpentIn('playing'),
Expand All @@ -152,6 +165,7 @@ shaka.util.Stats = class {
streamBandwidth: NaN,
decodedFrames: NaN,
droppedFrames: NaN,
corruptedFrames: NaN,
estimatedBandwidth: NaN,
loadLatency: NaN,
playTime: NaN,
Expand Down
1 change: 1 addition & 0 deletions test/player_integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ describe('Player', () => {

decodedFrames: jasmine.any(Number),
droppedFrames: jasmine.any(Number),
corruptedFrames: jasmine.any(Number),
estimatedBandwidth: jasmine.any(Number),

loadLatency: jasmine.any(Number),
Expand Down
4 changes: 3 additions & 1 deletion test/player_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -1937,10 +1937,11 @@ describe('Player', () => {
let stats = player.getStats();
expect(stats.decodedFrames).toBeNaN();
expect(stats.droppedFrames).toBeNaN();
expect(stats.corruptedFrames).toBeNaN();

video.getVideoPlaybackQuality = () => {
return {
corruptedVideoFrames: 0,
corruptedVideoFrames: 10,
creationTime: 0,
totalFrameDelay: 0,
totalVideoFrames: 75,
Expand All @@ -1952,6 +1953,7 @@ describe('Player', () => {
stats = player.getStats();
expect(stats.decodedFrames).toBe(75);
expect(stats.droppedFrames).toBe(125);
expect(stats.corruptedFrames).toBe(10);
});

describe('buffer/play times', () => {
Expand Down