[MSE] Add support for VideoPlaybackMetrics.
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 9 Dec 2013 23:36:56 +0000 (23:36 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 9 Dec 2013 23:36:56 +0000 (23:36 +0000)
commitef3f32aa194244d3f5ae6ed9ec8cd1ba352ff2ea
tree0520d9b4fde57787d8b34e3c128e260d33e2314a
parent2994e539a9b48b3a85ac361df37156b1a6797e10
[MSE] Add support for VideoPlaybackMetrics.
https://bugs.webkit.org/show_bug.cgi?id=125380

Reviewed by Eric Carlson.

Source/WebCore:

Test: media/media-source/media-source-video-playback-quality.html

Add a new object type VideoPlaybackQuality to be returned by
HTMLMediaElement.getVideoPlaybackQuality().

HTMLMediaElements must separately track a droppedVideoFrame count, as
certain operations on SourceBuffer will drop incoming frames, which must
be accounted for. Reset this count when the media engine changes, which is
indicitive of a new media load requset starting.

Add the new VideoPlaybackQuality class:
* Modules/mediasource/VideoPlaybackQuality.cpp: Added.
(WebCore::VideoPlaybackQuality::create):
(WebCore::VideoPlaybackQuality::VideoPlaybackQuality):
* Modules/mediasource/VideoPlaybackQuality.h: Added.
(WebCore::VideoPlaybackQuality::creationTime):
(WebCore::VideoPlaybackQuality::totalVideoFrames):
(WebCore::VideoPlaybackQuality::droppedVideoFrames):
(WebCore::VideoPlaybackQuality::corruptedVideoFrames):
(WebCore::VideoPlaybackQuality::totalFrameDelay):
* Modules/mediasource/VideoPlaybackQuality.idl: Added.

Add support for the new class to HTMLMediaElement:
* html/HTMLMediaElement.cpp:
(HTMLMediaElement::shouldUseVideoPluginProxy):
(HTMLMediaElement::getVideoPlaybackQuality):
* html/HTMLMediaElement.h:
* html/HTMLMediaElement.idl:

Report the video quality metrics from the MediaPlayer:
* platform/graphics/MediaPlayer.cpp:
(WebCore::MediaPlayer::totalVideoFrames):
(WebCore::MediaPlayer::droppedVideoFrames):
(WebCore::MediaPlayer::corruptedVideoFrames):
(WebCore::MediaPlayer::totalFrameDelay):
* platform/graphics/MediaPlayer.h:
* platform/graphics/MediaPlayerPrivate.h:
(WebCore::MediaPlayerPrivateInterface::totalVideoFrames):
(WebCore::MediaPlayerPrivateInterface::droppedVideoFrames):
(WebCore::MediaPlayerPrivateInterface::corruptedVideoFrames):
(WebCore::MediaPlayerPrivateInterface::totalFrameDelay):

Correctly report the dropped frame count:
* Modules/mediasource/SourceBuffer.cpp:
(WebCore::SourceBuffer::TrackBuffer::TrackBuffer): needsRandomAccessFlag defaults to true.
(WebCore::SourceBuffer::sourceBufferPrivateDidReceiveSample): Check the sync status of the incoming sample.
(WebCore::SourceBuffer::didDropSample): Notify the media element of a dropped frame.
* Modules/mediasource/SourceBuffer.h:
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::HTMLMediaElement):
(HTMLMediaElement::mediaPlayerEngineUpdated): Reset m_droppedFrameCount.
(HTMLMediaElement::getVideoPlaybackQuality): Return a new VideoPlaybackQuality object.
* html/HTMLMediaElement.h:
(WebCore::HTMLMediaElement::incrementDroppedFrameCount): Simple incrementer.
* platform/MediaSample.h:
(WebCore::MediaSample::isSync): Convenience function.
(WebCore::MediaSample::isNonDisplaying): Ditto.

Add support in the AVFoundation MediaSource Engine:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::totalVideoFrames):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::droppedVideoFrames):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::corruptedVideoFrames):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::totalFrameDelay):

Add support in the Mock MediaSource Engine:
* platform/mock/mediasource/MockBox.h:
* platform/mock/mediasource/MockMediaPlayerMediaSource.cpp:
(WebCore::MockMediaPlayerMediaSource::totalVideoFrames): Simple accessor.
(WebCore::MockMediaPlayerMediaSource::droppedVideoFrames): Ditto.
(WebCore::MockMediaPlayerMediaSource::corruptedVideoFrames): Ditto.
(WebCore::MockMediaPlayerMediaSource::totalFrameDelay): Ditto.
* platform/mock/mediasource/MockMediaPlayerMediaSource.h:
* platform/mock/mediasource/MockMediaSourcePrivate.cpp:
(WebCore::MockMediaSourcePrivate::MockMediaSourcePrivate):
* platform/mock/mediasource/MockMediaSourcePrivate.h:
* platform/mock/mediasource/MockSourceBufferPrivate.cpp:
(WebCore::MockSourceBufferPrivate::enqueueSample): Increment the frame counts based on
    the incoming sample.
* platform/mock/mediasource/MockSourceBufferPrivate.h:

Add the new files to the project:
* bindings/gobject/GNUmakefile.am:
* DerivedSources.make:
* WebCore.xcodeproj/project.pbxproj:
* GNUMakefile.list.am:
* CMakeLists.txt:

LayoutTests:

* media/media-source/media-source-video-playback-quality-expected.txt: Added.
* media/media-source/media-source-video-playback-quality.html: Added.
* media/media-source/mock-media-source.js:
(var):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@160336 268f45cc-cd09-0410-ab3c-d52691b4dbfc
33 files changed:
LayoutTests/ChangeLog
LayoutTests/media/media-source/media-source-canplaythrough.html
LayoutTests/media/media-source/media-source-play.html
LayoutTests/media/media-source/media-source-video-playback-quality-expected.txt [new file with mode: 0644]
LayoutTests/media/media-source/media-source-video-playback-quality.html [new file with mode: 0644]
LayoutTests/media/media-source/mock-media-source.js
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/DerivedSources.make
Source/WebCore/GNUmakefile.list.am
Source/WebCore/Modules/mediasource/SourceBuffer.cpp
Source/WebCore/Modules/mediasource/SourceBuffer.h
Source/WebCore/Modules/mediasource/VideoPlaybackQuality.cpp [new file with mode: 0644]
Source/WebCore/Modules/mediasource/VideoPlaybackQuality.h [new file with mode: 0644]
Source/WebCore/Modules/mediasource/VideoPlaybackQuality.idl [new file with mode: 0644]
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/gobject/GNUmakefile.am
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/html/HTMLMediaElement.idl
Source/WebCore/platform/MediaSample.h
Source/WebCore/platform/graphics/MediaPlayer.cpp
Source/WebCore/platform/graphics/MediaPlayer.h
Source/WebCore/platform/graphics/MediaPlayerPrivate.h
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm
Source/WebCore/platform/mock/mediasource/MockBox.h
Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.cpp
Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.h
Source/WebCore/platform/mock/mediasource/MockMediaSourcePrivate.cpp
Source/WebCore/platform/mock/mediasource/MockMediaSourcePrivate.h
Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.cpp
Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.h