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

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

Issue 2192823004: Update StreamTextureProxy to accept a base::Closure (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing comments Created 4 years, 5 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 | « content/renderer/media/android/webmediaplayer_android.h ('k') | media/base/android/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 bf5add330c6a6d261843508eb01baff44f78f1ed..8dd8323152f2d7b34a77fd104588652dec137d83 100644
--- a/content/renderer/media/android/webmediaplayer_android.cc
+++ b/content/renderer/media/android/webmediaplayer_android.cc
@@ -1251,10 +1251,8 @@ void WebMediaPlayerAndroid::SetVideoFrameProviderClient(
// Set the callback target when a frame is produced. Need to do this before
// StopUsingProvider to ensure we really stop using the client.
- if (stream_texture_proxy_) {
- stream_texture_proxy_->BindToLoop(stream_id_, client,
- compositor_task_runner_);
- }
+ if (stream_texture_proxy_)
+ UpdateStreamTextureProxyCallback(client);
if (video_frame_provider_client_ && video_frame_provider_client_ != client)
video_frame_provider_client_->StopUsingProvider();
@@ -1310,6 +1308,25 @@ void WebMediaPlayerAndroid::RemoveSurfaceTextureAndProxy() {
(hasVideo() || IsHLSStream());
}
+void WebMediaPlayerAndroid::UpdateStreamTextureProxyCallback(
+ cc::VideoFrameProvider::Client* client) {
+ base::Closure frame_received_cb;
+
+ if (client) {
+ // Unretained is safe here because:
+ // - |client| is valid until we receive a call to
+ // SetVideoFrameProviderClient(nullptr).
+ // - SetVideoFrameProviderClient(nullptr) clears proxy's callback
+ // guaranteeing it will no longer be run.
+ frame_received_cb =
+ base::Bind(&cc::VideoFrameProvider::Client::DidReceiveFrame,
+ base::Unretained(client));
+ }
+
+ stream_texture_proxy_->BindToTaskRunner(stream_id_, frame_received_cb,
+ compositor_task_runner_);
+}
+
void WebMediaPlayerAndroid::TryCreateStreamTextureProxyIfNeeded() {
DCHECK(main_thread_checker_.CalledOnValidThread());
// Already created.
@@ -1328,10 +1345,8 @@ void WebMediaPlayerAndroid::TryCreateStreamTextureProxyIfNeeded() {
if (stream_texture_proxy_) {
DoCreateStreamTexture();
ReallocateVideoFrame();
- if (video_frame_provider_client_) {
- stream_texture_proxy_->BindToLoop(
- stream_id_, video_frame_provider_client_, compositor_task_runner_);
- }
+ if (video_frame_provider_client_)
+ UpdateStreamTextureProxyCallback(video_frame_provider_client_);
}
}
« no previous file with comments | « content/renderer/media/android/webmediaplayer_android.h ('k') | media/base/android/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698