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

Unified Diff: content/renderer/media/android/webmediaplayer_android.cc

Issue 532993002: work-in-progress patch to fix context lost black video (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: check client Created 6 years, 3 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: content/renderer/media/android/webmediaplayer_android.cc
diff --git a/content/renderer/media/android/webmediaplayer_android.cc b/content/renderer/media/android/webmediaplayer_android.cc
index 35e898e9bac8dba0ea903ec4571ad4eec8ade2cc..994b5d9a4cf48f6f7f6923a482a12659dd837123 100644
--- a/content/renderer/media/android/webmediaplayer_android.cc
+++ b/content/renderer/media/android/webmediaplayer_android.cc
@@ -155,6 +155,7 @@ WebMediaPlayerAndroid::WebMediaPlayerAndroid(
DCHECK(cdm_manager_);
DCHECK(main_thread_checker_.CalledOnValidThread());
+ stream_texture_factory_->AddObserver(this);
player_id_ = player_manager_->RegisterMediaPlayer(this);
@@ -197,6 +198,8 @@ WebMediaPlayerAndroid::~WebMediaPlayerAndroid() {
if (player_type_ == MEDIA_PLAYER_TYPE_MEDIA_SOURCE && delegate_)
delegate_->PlayerGone(this);
+
+ stream_texture_factory_->RemoveObserver(this);
}
void WebMediaPlayerAndroid::load(LoadType load_type,
@@ -1212,21 +1215,14 @@ 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_)
+ if (video_frame_provider_client_ && video_frame_provider_client_ != 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);
- // If client exists, the compositor thread calls it. At that time,
- // stream_id_, needs_external_surface_, is_remote_ can be accessed because
- // the main thread is blocked.
- if (client && !stream_texture_proxy_initialized_ && stream_id_ &&
- !needs_external_surface_ && !is_remote_) {
- stream_texture_proxy_->BindToCurrentThread(stream_id_);
- stream_texture_proxy_initialized_ = true;
- }
+ if (stream_texture_proxy_ && client) {
+ stream_texture_proxy_->BindToLoop(
+ stream_id_, client, base::MessageLoopProxy::current());
}
}
@@ -1251,6 +1247,27 @@ void WebMediaPlayerAndroid::PutCurrentFrame(
const scoped_refptr<media::VideoFrame>& frame) {
}
+void WebMediaPlayerAndroid::ResetStreamTextureProxy() {
+ DCHECK(main_thread_checker_.CalledOnValidThread());
+
+ if (stream_id_) {
+ GLES2Interface* gl = stream_texture_factory_->ContextGL();
+ gl->DeleteTextures(1, &texture_id_);
+ texture_id_ = 0;
+ texture_mailbox_ = gpu::Mailbox();
+ stream_id_ = 0;
+ }
+ stream_texture_proxy_.reset();
+ needs_establish_peer_ = !needs_external_surface_ && !is_remote_ &&
+ !player_manager_->IsInFullscreen(frame_) &&
+ (hasVideo() || IsHLSStream());
+ stream_texture_proxy_initialized_ = false;
+
+ TryCreateStreamTextureProxyIfNeeded();
+ if (needs_establish_peer_ && is_playing_)
+ EstablishSurfaceTexturePeer();
+}
+
void WebMediaPlayerAndroid::TryCreateStreamTextureProxyIfNeeded() {
DCHECK(main_thread_checker_.CalledOnValidThread());
// Already created.
@@ -1262,13 +1279,13 @@ void WebMediaPlayerAndroid::TryCreateStreamTextureProxyIfNeeded() {
return;
stream_texture_proxy_.reset(stream_texture_factory_->CreateProxy());
qinmin 2014/09/15 17:16:26 Please do the following before this to fix the VID
boliu 2014/09/15 17:54:07 Done.
- if (needs_establish_peer_ && stream_texture_proxy_) {
- DoCreateStreamTexture();
- ReallocateVideoFrame();
+ if (needs_establish_peer_ && stream_texture_proxy_ &&
+ video_frame_provider_client_) {
+ stream_texture_proxy_->BindToLoop(
+ stream_id_,
+ video_frame_provider_client_,
+ RenderThreadImpl::current()->compositor_message_loop_proxy());
}
-
- if (stream_texture_proxy_ && video_frame_provider_client_)
- stream_texture_proxy_->SetClient(video_frame_provider_client_);
}
void WebMediaPlayerAndroid::EstablishSurfaceTexturePeer() {

Powered by Google App Engine
This is Rietveld 408576698