| Index: webkit/media/webmediaplayer_impl.cc
|
| diff --git a/webkit/media/webmediaplayer_impl.cc b/webkit/media/webmediaplayer_impl.cc
|
| index 87d907aa466904e16f0d3f0dbc7d72ac13b57623..71d8f87da89c752b92359e080f33ff7f94b1b4fb 100644
|
| --- a/webkit/media/webmediaplayer_impl.cc
|
| +++ b/webkit/media/webmediaplayer_impl.cc
|
| @@ -15,6 +15,7 @@
|
| #include "base/metrics/histogram.h"
|
| #include "base/string_number_conversions.h"
|
| #include "base/synchronization/waitable_event.h"
|
| +#include "cc/layers/video_layer.h"
|
| #include "gpu/GLES2/gl2extchromium.h"
|
| #include "media/audio/null_audio_sink.h"
|
| #include "media/base/bind_to_loop.h"
|
| @@ -34,6 +35,7 @@
|
| #include "third_party/WebKit/Source/WebKit/chromium/public/WebRuntimeFeatures.h"
|
| #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
|
| #include "v8/include/v8.h"
|
| +#include "webkit/compositor_bindings/web_layer_impl.h"
|
| #include "webkit/media/buffered_data_source.h"
|
| #include "webkit/media/filter_helpers.h"
|
| #include "webkit/media/webaudiosourceprovider_impl.h"
|
| @@ -41,7 +43,6 @@
|
| #include "webkit/media/webmediaplayer_params.h"
|
| #include "webkit/media/webmediaplayer_util.h"
|
| #include "webkit/media/webmediasourceclient_impl.h"
|
| -#include "webkit/media/webvideoframe_impl.h"
|
| #include "webkit/plugins/ppapi/ppapi_webplugin_impl.h"
|
|
|
| using WebKit::WebCanvas;
|
| @@ -145,7 +146,8 @@ WebMediaPlayerImpl::WebMediaPlayerImpl(
|
| is_local_source_(false),
|
| supports_save_(true),
|
| starting_(false),
|
| - pending_repaint_(false) {
|
| + pending_repaint_(false),
|
| + video_frame_provider_client_(NULL) {
|
| media_log_->AddEvent(
|
| media_log_->CreateEvent(media::MediaLogEvent::WEBMEDIAPLAYER_CREATED));
|
|
|
| @@ -211,6 +213,9 @@ WebMediaPlayerImpl::WebMediaPlayerImpl(
|
| }
|
|
|
| WebMediaPlayerImpl::~WebMediaPlayerImpl() {
|
| + SetVideoFrameProviderClient(NULL);
|
| + GetClient()->setWebLayer(NULL);
|
| +
|
| DCHECK(main_loop_->BelongsToCurrentThread());
|
| Destroy();
|
| media_log_->AddEvent(
|
| @@ -656,21 +661,27 @@ unsigned WebMediaPlayerImpl::videoDecodedByteCount() const {
|
| return stats.video_bytes_decoded;
|
| }
|
|
|
| -WebKit::WebVideoFrame* WebMediaPlayerImpl::getCurrentFrame() {
|
| +void WebMediaPlayerImpl::SetVideoFrameProviderClient(
|
| + cc::VideoFrameProvider::Client* client) {
|
| + // This is called from both the main renderer thread and the compositor
|
| + // thread (when the main thread is blocked).
|
| + if (video_frame_provider_client_)
|
| + video_frame_provider_client_->StopUsingProvider();
|
| + video_frame_provider_client_ = client;
|
| +}
|
| +
|
| +scoped_refptr<media::VideoFrame> WebMediaPlayerImpl::GetCurrentFrame() {
|
| base::AutoLock auto_lock(lock_);
|
| - if (current_frame_)
|
| - return new WebVideoFrameImpl(current_frame_);
|
| - return NULL;
|
| + return current_frame_;
|
| }
|
|
|
| -void WebMediaPlayerImpl::putCurrentFrame(
|
| - WebKit::WebVideoFrame* web_video_frame) {
|
| +void WebMediaPlayerImpl::PutCurrentFrame(
|
| + const scoped_refptr<media::VideoFrame>& frame) {
|
| if (!accelerated_compositing_reported_) {
|
| accelerated_compositing_reported_ = true;
|
| DCHECK(frame_->view()->isAcceleratedCompositingActive());
|
| UMA_HISTOGRAM_BOOLEAN("Media.AcceleratedCompositingActive", true);
|
| }
|
| - delete web_video_frame;
|
| }
|
|
|
| bool WebMediaPlayerImpl::copyVideoTextureToPlatformTexture(
|
| @@ -962,6 +973,13 @@ void WebMediaPlayerImpl::OnPipelineBufferingState(
|
| switch (buffering_state) {
|
| case media::Pipeline::kHaveMetadata:
|
| SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata);
|
| +
|
| + if (hasVideo() && GetClient()->needsWebLayer()) {
|
| + DCHECK(!video_weblayer_);
|
| + video_weblayer_.reset(
|
| + new webkit::WebLayerImpl(cc::VideoLayer::Create(this)));
|
| + GetClient()->setWebLayer(video_weblayer_.get());
|
| + }
|
| break;
|
| case media::Pipeline::kPrerollCompleted:
|
| SetReadyState(WebMediaPlayer::ReadyStateHaveEnoughData);
|
| @@ -1114,16 +1132,10 @@ void WebMediaPlayerImpl::SetReadyState(WebMediaPlayer::ReadyState state) {
|
| DCHECK(main_loop_->BelongsToCurrentThread());
|
| DVLOG(1) << "SetReadyState: " << state;
|
|
|
| - if (ready_state_ == WebMediaPlayer::ReadyStateHaveNothing &&
|
| - state >= WebMediaPlayer::ReadyStateHaveMetadata) {
|
| - if (!hasVideo())
|
| - GetClient()->disableAcceleratedCompositing();
|
| - } else if (state == WebMediaPlayer::ReadyStateHaveEnoughData) {
|
| - if (is_local_source_ &&
|
| - network_state_ == WebMediaPlayer::NetworkStateLoading) {
|
| - SetNetworkState(WebMediaPlayer::NetworkStateLoaded);
|
| - }
|
| - }
|
| + if (state == WebMediaPlayer::ReadyStateHaveEnoughData &&
|
| + is_local_source_ &&
|
| + network_state_ == WebMediaPlayer::NetworkStateLoading)
|
| + SetNetworkState(WebMediaPlayer::NetworkStateLoaded);
|
|
|
| ready_state_ = state;
|
| // Always notify to ensure client has the latest value.
|
|
|