From a6e4fdd971fe857bb5bb8e935f273f499e149b3f Mon Sep 17 00:00:00 2001 From: Garrett Date: Thu, 27 Apr 2017 08:07:15 -0700 Subject: [PATCH] Add getVideoPlaybackQuality API (#225) --- CHANGELOG.md | 2 +- src/VideoJS.as | 3 +++ src/com/videojs/VideoJSModel.as | 7 +++++++ src/com/videojs/providers/HTTPAudioProvider.as | 5 +++++ src/com/videojs/providers/HTTPVideoProvider.as | 12 ++++++++++++ src/com/videojs/providers/IProvider.as | 6 ++++++ src/com/videojs/providers/RTMPVideoProvider.as | 12 ++++++++++++ 7 files changed, 46 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ffea64de..0d816bf0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ CHANGELOG ========= ## HEAD (Unreleased) -_(none)_ +* Add getVideoPlaybackQuality API -------------------- diff --git a/src/VideoJS.as b/src/VideoJS.as index 17ecbbc6..0b18b81f 100644 --- a/src/VideoJS.as +++ b/src/VideoJS.as @@ -313,6 +313,9 @@ package{ case "rtmpStream": return _app.model.rtmpStream; break; + case "getVideoPlaybackQuality": + return _app.model.videoPlaybackQuality; + break; } return null; } diff --git a/src/com/videojs/VideoJSModel.as b/src/com/videojs/VideoJSModel.as index 45f02a52..42801f21 100644 --- a/src/com/videojs/VideoJSModel.as +++ b/src/com/videojs/VideoJSModel.as @@ -407,6 +407,13 @@ package com.videojs{ return true; } + public function get videoPlaybackQuality():Object{ + if(_provider){ + return _provider.videoPlaybackQuality; + } + return {}; + } + /** * Allows this model to act as a centralized event bus to which other classes can subscribe. * diff --git a/src/com/videojs/providers/HTTPAudioProvider.as b/src/com/videojs/providers/HTTPAudioProvider.as index 929c5911..38541497 100644 --- a/src/com/videojs/providers/HTTPAudioProvider.as +++ b/src/com/videojs/providers/HTTPAudioProvider.as @@ -170,6 +170,11 @@ package com.videojs.providers{ return _metadata; } + public function get videoPlaybackQuality():Object{ + // only meant for video + return {}; + } + public function get srcAsString():String{ if(_src != null && _src.path != undefined){ return _src.path; diff --git a/src/com/videojs/providers/HTTPVideoProvider.as b/src/com/videojs/providers/HTTPVideoProvider.as index 0943be9c..069012b9 100644 --- a/src/com/videojs/providers/HTTPVideoProvider.as +++ b/src/com/videojs/providers/HTTPVideoProvider.as @@ -271,6 +271,18 @@ package com.videojs.providers{ return _metadata; } + public function get videoPlaybackQuality():Object{ + if (_ns != null && + _ns.hasOwnProperty('decodedFrames') && + _ns.info.hasOwnProperty('droppedFrames')) { + return { + droppedVideoFrames: _ns.info.droppedFrames, + totalVideoFrames: _ns.decodedFrames + _ns.info.droppedFrames + }; + } + return {}; + } + public function set src(pSrc:Object):void{ init(pSrc, false); } diff --git a/src/com/videojs/providers/IProvider.as b/src/com/videojs/providers/IProvider.as index cce9b335..c3a3033c 100644 --- a/src/com/videojs/providers/IProvider.as +++ b/src/com/videojs/providers/IProvider.as @@ -124,6 +124,12 @@ package com.videojs.providers{ */ function get metadata():Object; + /** + * Should return an object that contains playback quality details, following the + * form of https://w3c.github.io/media-source/#VideoPlaybackQuality + */ + function get videoPlaybackQuality():Object; + /** * Should return the most reasonable string representation of the current assets source location. */ diff --git a/src/com/videojs/providers/RTMPVideoProvider.as b/src/com/videojs/providers/RTMPVideoProvider.as index 77237e5b..01ab7d7e 100644 --- a/src/com/videojs/providers/RTMPVideoProvider.as +++ b/src/com/videojs/providers/RTMPVideoProvider.as @@ -202,6 +202,18 @@ package com.videojs.providers{ return _metadata; } + public function get videoPlaybackQuality():Object{ + if (_ns != null && + _ns.hasOwnProperty('decodedFrames') && + _ns.info.hasOwnProperty('droppedFrames')) { + return { + droppedVideoFrames: _ns.info.droppedFrames, + totalVideoFrames: _ns.decodedFrames + _ns.info.droppedFrames + }; + } + return {}; + } + public function set src(pSrc:Object):void{ _hasDuration = false; if(_isPlaying){