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

Unified Diff: webkit/media/android/webmediaplayer_android.cc

Issue 12902002: Remove WebVideoFrame, WebVideoFrameProvider, and WebVideoLayer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: No provider client lock 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
Index: webkit/media/android/webmediaplayer_android.cc
diff --git a/webkit/media/android/webmediaplayer_android.cc b/webkit/media/android/webmediaplayer_android.cc
index 93cdcdc89eb2dd4ebfb03b7cfdbe93448ffb3302..1ee9ac72fb04bd855dc43831f813b91062c6a32e 100644
--- a/webkit/media/android/webmediaplayer_android.cc
+++ b/webkit/media/android/webmediaplayer_android.cc
@@ -6,14 +6,15 @@
#include "base/files/file_path.h"
#include "base/logging.h"
+#include "cc/layers/video_layer.h"
#include "media/base/android/media_player_bridge.h"
#include "media/base/video_frame.h"
#include "net/base/mime_util.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerClient.h"
+#include "webkit/compositor_bindings/web_layer_impl.h"
#include "webkit/media/android/stream_texture_factory_android.h"
#include "webkit/media/android/webmediaplayer_manager_android.h"
#include "webkit/media/webmediaplayer_util.h"
-#include "webkit/media/webvideoframe_impl.h"
static const uint32 kGLTextureExternalOES = 0x8D65;
@@ -22,7 +23,6 @@ using WebKit::WebMediaSource;
using WebKit::WebSize;
using WebKit::WebTimeRanges;
using WebKit::WebURL;
-using WebKit::WebVideoFrame;
using media::MediaPlayerBridge;
using media::VideoFrame;
@@ -44,7 +44,8 @@ WebMediaPlayerAndroid::WebMediaPlayerAndroid(
is_playing_(false),
needs_establish_peer_(true),
has_size_info_(false),
- stream_texture_factory_(factory) {
+ stream_texture_factory_(factory),
+ video_frame_provider_client_(NULL) {
main_loop_->AddDestructionObserver(this);
if (manager_)
player_id_ = manager_->RegisterMediaPlayer(this);
@@ -57,6 +58,9 @@ WebMediaPlayerAndroid::WebMediaPlayerAndroid(
}
WebMediaPlayerAndroid::~WebMediaPlayerAndroid() {
+ SetVideoFrameProviderClient(NULL);
+ client_->setWebLayer(NULL);
+
if (stream_id_)
stream_texture_factory_->DestroyStreamTexture(texture_id_);
@@ -276,10 +280,12 @@ void WebMediaPlayerAndroid::OnMediaPrepared(base::TimeDelta duration) {
if (ready_state_ != WebMediaPlayer::ReadyStateHaveEnoughData) {
UpdateReadyState(WebMediaPlayer::ReadyStateHaveMetadata);
UpdateReadyState(WebMediaPlayer::ReadyStateHaveEnoughData);
- } else {
- // If the status is already set to ReadyStateHaveEnoughData, set it again
- // to make sure that Videolayerchromium will get created.
- UpdateReadyState(WebMediaPlayer::ReadyStateHaveEnoughData);
+ }
+
+ if (hasVideo() && !video_weblayer_) {
+ video_weblayer_.reset(
+ new webkit::WebLayerImpl(cc::VideoLayer::Create(this)));
+ client_->setWebLayer(video_weblayer_.get());
}
// In we have skipped loading, we have to update webkit about the new
@@ -395,40 +401,46 @@ void WebMediaPlayerAndroid::Detach() {
stream_id_ = 0;
}
- web_video_frame_.reset();
+ current_frame_ = NULL;
manager_ = NULL;
}
void WebMediaPlayerAndroid::ReallocateVideoFrame() {
if (texture_id_) {
- web_video_frame_.reset(new WebVideoFrameImpl(VideoFrame::WrapNativeTexture(
+ current_frame_ = VideoFrame::WrapNativeTexture(
texture_id_, kGLTextureExternalOES, natural_size_,
gfx::Rect(natural_size_), natural_size_, base::TimeDelta(),
VideoFrame::ReadPixelsCB(),
- base::Closure())));
+ base::Closure());
}
}
-WebVideoFrame* WebMediaPlayerAndroid::getCurrentFrame() {
- if (stream_texture_proxy_.get() && !stream_texture_proxy_->IsInitialized()
+void WebMediaPlayerAndroid::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;
+
+ // Set the callback target when a frame is produced.
+ if (stream_texture_proxy_)
+ stream_texture_proxy_->SetClient(client);
+}
+
+scoped_refptr<media::VideoFrame> WebMediaPlayerAndroid::GetCurrentFrame() {
+ if (stream_texture_proxy_ && !stream_texture_proxy_->IsInitialized()
&& stream_id_) {
- gfx::Size natural_size = web_video_frame_->video_frame->natural_size();
+ gfx::Size natural_size = current_frame_->natural_size();
stream_texture_proxy_->Initialize(
stream_id_, natural_size.width(), natural_size.height());
}
-
- return web_video_frame_.get();
+ return current_frame_;
}
-void WebMediaPlayerAndroid::putCurrentFrame(
- WebVideoFrame* web_video_frame) {
-}
-
-void WebMediaPlayerAndroid::setStreamTextureClient(
- WebKit::WebStreamTextureClient* client) {
- if (stream_texture_proxy_.get())
- stream_texture_proxy_->SetClient(client);
+void WebMediaPlayerAndroid::PutCurrentFrame(
+ const scoped_refptr<media::VideoFrame>& frame) {
}
void WebMediaPlayerAndroid::EstablishSurfaceTexturePeer() {

Powered by Google App Engine
This is Rietveld 408576698