Chromium Code Reviews| 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 048994912aa7377092e315f14cfd0e39924acb5b..b914240fbb74282197d80b6f0ccb19ff5be958b5 100644 |
| --- a/content/renderer/media/android/webmediaplayer_android.cc |
| +++ b/content/renderer/media/android/webmediaplayer_android.cc |
| @@ -154,6 +154,7 @@ WebMediaPlayerAndroid::WebMediaPlayerAndroid( |
| DCHECK(cdm_manager_); |
| DCHECK(main_thread_checker_.CalledOnValidThread()); |
| + stream_texture_factory_->AddObserver(this); |
| player_id_ = player_manager_->RegisterMediaPlayer(this); |
| @@ -195,6 +196,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, |
| @@ -1195,7 +1198,7 @@ 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; |
| @@ -1234,6 +1237,25 @@ 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_ = |
|
qinmin
2014/09/11 23:26:41
need to check fullscreen status
boliu
2014/09/12 16:38:25
Done using player_manager_->IsInFullscreen(frame_)
|
| + !needs_external_surface_ && !is_remote_ && (hasVideo() || IsHLSStream()); |
|
boliu
2014/09/11 17:08:33
Min, please double check this line. Unfortunately
|
| + stream_texture_proxy_initialized_ = false; |
| + |
| + TryCreateStreamTextureProxyIfNeeded(); |
| + EstablishSurfaceTexturePeer(); |
|
qinmin
2014/09/11 23:26:41
shouldn't this be:
if (needs_establish_peer_ && i
boliu
2014/09/12 16:38:25
Yes done.
If only the refactor wasn't reverted...
|
| +} |
| + |
| void WebMediaPlayerAndroid::TryCreateStreamTextureProxyIfNeeded() { |
| DCHECK(main_thread_checker_.CalledOnValidThread()); |
| // Already created. |
| @@ -1248,10 +1270,24 @@ void WebMediaPlayerAndroid::TryCreateStreamTextureProxyIfNeeded() { |
| if (needs_establish_peer_ && stream_texture_proxy_) { |
| DoCreateStreamTexture(); |
| ReallocateVideoFrame(); |
| + |
| + base::WaitableEvent completion(true, false); |
| + RenderThreadImpl::current()->compositor_message_loop_proxy()->PostTask( |
| + FROM_HERE, |
| + base::Bind( |
| + &WebMediaPlayerAndroid::BindStreamTextureProxyOnCompositorThread, |
| + base::Unretained(this), |
|
no sievers
2014/09/11 22:28:34
Do we need to do this or can we just invalidate an
boliu
2014/09/11 22:30:56
That's fine in m37. But that code doesn't exist an
|
| + &completion)); |
| + completion.Wait(); |
|
qinmin
2014/09/11 23:26:41
blocking the main thread? I don't feel like this i
boliu
2014/09/12 16:38:25
Blink thread blocks on compositor thread all the t
qinmin
2014/09/12 17:01:58
SetVideoFrameProviderClient uses a lock inside, so
boliu
2014/09/12 17:08:07
By render thread, you mean blink main thread, righ
boliu
2014/09/12 17:10:14
Also I'm floating the idea that WMPA should do mor
qinmin
2014/09/12 17:19:48
But why cannot we just use a callback and don't bl
boliu
2014/09/12 17:26:22
Calling SetVideoFrameProviderClient without the ma
qinmin
2014/09/12 17:31:09
I don't see that's a valid reason to block main th
boliu
2014/09/12 17:36:34
That is way too complex, it's a super invasive cha
|
| } |
| +} |
| - if (stream_texture_proxy_ && video_frame_provider_client_) |
| - stream_texture_proxy_->SetClient(video_frame_provider_client_); |
| +void WebMediaPlayerAndroid::BindStreamTextureProxyOnCompositorThread( |
| + base::WaitableEvent* completion) { |
| + if (video_frame_provider_client_) { |
| + SetVideoFrameProviderClient(video_frame_provider_client_); |
|
qinmin
2014/09/11 23:26:41
nit: no {}
boliu
2014/09/12 16:38:25
Done.
|
| + } |
| + completion->Signal(); |
| } |
| void WebMediaPlayerAndroid::EstablishSurfaceTexturePeer() { |