Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(170)

Unified Diff: webkit/media/webmediaplayer_impl.cc

Issue 12676004: Move ownership of cc:VideoLayer to webkit/media (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/media/webmediaplayer_impl.h ('k') | webkit/media/webmediaplayer_ms.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/media/webmediaplayer_impl.cc
diff --git a/webkit/media/webmediaplayer_impl.cc b/webkit/media/webmediaplayer_impl.cc
index 87d907aa466904e16f0d3f0dbc7d72ac13b57623..e01e9aa6ab6df7033bbf0cbfe2fd2714c6e09b8c 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"
@@ -145,7 +147,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 +214,11 @@ WebMediaPlayerImpl::WebMediaPlayerImpl(
}
WebMediaPlayerImpl::~WebMediaPlayerImpl() {
+#ifdef REMOVE_WEBVIDEOFRAME
+ SetVideoFrameProviderClient(NULL);
+ GetClient()->setWebLayer(NULL);
+#endif
+
DCHECK(main_loop_->BelongsToCurrentThread());
Destroy();
media_log_->AddEvent(
@@ -656,6 +664,7 @@ unsigned WebMediaPlayerImpl::videoDecodedByteCount() const {
return stats.video_bytes_decoded;
}
+#ifndef REMOVE_WEBVIDEOFRAME
WebKit::WebVideoFrame* WebMediaPlayerImpl::getCurrentFrame() {
base::AutoLock auto_lock(lock_);
if (current_frame_)
@@ -672,6 +681,30 @@ void WebMediaPlayerImpl::putCurrentFrame(
}
delete web_video_frame;
}
+#else
+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_);
+ return current_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);
+ }
+}
+#endif
bool WebMediaPlayerImpl::copyVideoTextureToPlatformTexture(
WebKit::WebGraphicsContext3D* web_graphics_context,
@@ -962,6 +995,15 @@ void WebMediaPlayerImpl::OnPipelineBufferingState(
switch (buffering_state) {
case media::Pipeline::kHaveMetadata:
SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata);
+
+#ifdef REMOVE_WEBVIDEOFRAME
+ if (hasVideo() && GetClient()->needsWebLayerForVideo()) {
+ DCHECK(!video_weblayer_);
+ video_weblayer_.reset(
+ new webkit::WebLayerImpl(cc::VideoLayer::Create(this)));
+ GetClient()->setWebLayer(video_weblayer_.get());
+ }
+#endif
break;
case media::Pipeline::kPrerollCompleted:
SetReadyState(WebMediaPlayer::ReadyStateHaveEnoughData);
@@ -1114,16 +1156,17 @@ void WebMediaPlayerImpl::SetReadyState(WebMediaPlayer::ReadyState state) {
DCHECK(main_loop_->BelongsToCurrentThread());
DVLOG(1) << "SetReadyState: " << state;
+#ifndef REMOVE_WEBVIDEOFRAME
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);
- }
- }
+ } else
+#endif
+ 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.
« no previous file with comments | « webkit/media/webmediaplayer_impl.h ('k') | webkit/media/webmediaplayer_ms.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698