mirror of
https://github.com/shaka-project/shaka-player.git
synced 2026-06-26 17:46:26 +03:00
64896d70b0
This reflects changes in Google's policy on JavaScript license headers, which should be smaller to avoid increasing the size of the binary unnecessarily. This also updates the company name from "Google, Inc" to "Google LLC". Change-Id: I3f8b9ed3700b6351f43173d50c94d35c333e82b4
58 lines
1.4 KiB
JavaScript
58 lines
1.4 KiB
JavaScript
/** @license
|
|
* Copyright 2016 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
goog.provide('shaka.polyfill.VideoPlaybackQuality');
|
|
|
|
goog.require('shaka.polyfill');
|
|
|
|
|
|
/**
|
|
* @summary A polyfill to provide MSE VideoPlaybackQuality metrics.
|
|
* Many browsers do not yet provide this API, and Chrome currently provides
|
|
* similar data through individual prefixed attributes on HTMLVideoElement.
|
|
*/
|
|
shaka.polyfill.VideoPlaybackQuality = class {
|
|
/**
|
|
* Install the polyfill if needed.
|
|
*/
|
|
static install() {
|
|
if (!window.HTMLVideoElement) {
|
|
// Avoid errors on very old browsers.
|
|
return;
|
|
}
|
|
|
|
// eslint-disable-next-line no-restricted-syntax
|
|
const proto = HTMLVideoElement.prototype;
|
|
if (proto.getVideoPlaybackQuality) {
|
|
// No polyfill needed.
|
|
return;
|
|
}
|
|
|
|
if ('webkitDroppedFrameCount' in proto) {
|
|
proto.getVideoPlaybackQuality =
|
|
shaka.polyfill.VideoPlaybackQuality.webkit_;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @this {HTMLVideoElement}
|
|
* @return {!VideoPlaybackQuality}
|
|
* @private
|
|
*/
|
|
static webkit_() {
|
|
return {
|
|
'droppedVideoFrames': this.webkitDroppedFrameCount,
|
|
'totalVideoFrames': this.webkitDecodedFrameCount,
|
|
// Not provided by this polyfill:
|
|
'corruptedVideoFrames': 0,
|
|
'creationTime': NaN,
|
|
'totalFrameDelay': 0,
|
|
};
|
|
}
|
|
};
|
|
|
|
|
|
shaka.polyfill.register(shaka.polyfill.VideoPlaybackQuality.install);
|