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

Side by Side 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, 4 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/media/android/webmediaplayer_android.h" 5 #include "content/renderer/media/android/webmediaplayer_android.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <limits> 9 #include <limits>
10 10
(...skipping 1233 matching lines...) Expand 10 before | Expand all | Expand 10 after
1244 } 1244 }
1245 } 1245 }
1246 1246
1247 void WebMediaPlayerAndroid::SetVideoFrameProviderClient( 1247 void WebMediaPlayerAndroid::SetVideoFrameProviderClient(
1248 cc::VideoFrameProvider::Client* client) { 1248 cc::VideoFrameProvider::Client* client) {
1249 // This is called from both the main renderer thread and the compositor 1249 // This is called from both the main renderer thread and the compositor
1250 // thread (when the main thread is blocked). 1250 // thread (when the main thread is blocked).
1251 1251
1252 // Set the callback target when a frame is produced. Need to do this before 1252 // Set the callback target when a frame is produced. Need to do this before
1253 // StopUsingProvider to ensure we really stop using the client. 1253 // StopUsingProvider to ensure we really stop using the client.
1254 if (stream_texture_proxy_) { 1254 if (stream_texture_proxy_)
1255 stream_texture_proxy_->BindToLoop(stream_id_, client, 1255 UpdateStreamTextureProxyCallback(client);
1256 compositor_task_runner_);
1257 }
1258 1256
1259 if (video_frame_provider_client_ && video_frame_provider_client_ != client) 1257 if (video_frame_provider_client_ && video_frame_provider_client_ != client)
1260 video_frame_provider_client_->StopUsingProvider(); 1258 video_frame_provider_client_->StopUsingProvider();
1261 video_frame_provider_client_ = client; 1259 video_frame_provider_client_ = client;
1262 } 1260 }
1263 1261
1264 void WebMediaPlayerAndroid::SetCurrentFrameInternal( 1262 void WebMediaPlayerAndroid::SetCurrentFrameInternal(
1265 scoped_refptr<media::VideoFrame>& video_frame) { 1263 scoped_refptr<media::VideoFrame>& video_frame) {
1266 DCHECK(main_thread_checker_.CalledOnValidThread()); 1264 DCHECK(main_thread_checker_.CalledOnValidThread());
1267 base::AutoLock auto_lock(current_frame_lock_); 1265 base::AutoLock auto_lock(current_frame_lock_);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1303 texture_id_ = 0; 1301 texture_id_ = 0;
1304 texture_mailbox_ = gpu::Mailbox(); 1302 texture_mailbox_ = gpu::Mailbox();
1305 stream_id_ = 0; 1303 stream_id_ = 0;
1306 } 1304 }
1307 stream_texture_proxy_.reset(); 1305 stream_texture_proxy_.reset();
1308 needs_establish_peer_ = !needs_external_surface_ && !is_remote_ && 1306 needs_establish_peer_ = !needs_external_surface_ && !is_remote_ &&
1309 !is_fullscreen_ && 1307 !is_fullscreen_ &&
1310 (hasVideo() || IsHLSStream()); 1308 (hasVideo() || IsHLSStream());
1311 } 1309 }
1312 1310
1311 void WebMediaPlayerAndroid::UpdateStreamTextureProxyCallback(
1312 cc::VideoFrameProvider::Client* client) {
1313 base::Closure frame_received_cb;
1314
1315 if (client) {
1316 // Unretained is safe here because:
1317 // - |client| is valid until we receive a call to
1318 // SetVideoFrameProviderClient(nullptr).
1319 // - SetVideoFrameProviderClient(nullptr) clears proxy's callback
1320 // guaranteeing it will no longer be run.
1321 frame_received_cb =
1322 base::Bind(&cc::VideoFrameProvider::Client::DidReceiveFrame,
1323 base::Unretained(client));
1324 }
1325
1326 stream_texture_proxy_->BindToTaskRunner(stream_id_, frame_received_cb,
1327 compositor_task_runner_);
1328 }
1329
1313 void WebMediaPlayerAndroid::TryCreateStreamTextureProxyIfNeeded() { 1330 void WebMediaPlayerAndroid::TryCreateStreamTextureProxyIfNeeded() {
1314 DCHECK(main_thread_checker_.CalledOnValidThread()); 1331 DCHECK(main_thread_checker_.CalledOnValidThread());
1315 // Already created. 1332 // Already created.
1316 if (stream_texture_proxy_) 1333 if (stream_texture_proxy_)
1317 return; 1334 return;
1318 1335
1319 // No factory to create proxy. 1336 // No factory to create proxy.
1320 if (!stream_texture_factory_.get()) 1337 if (!stream_texture_factory_.get())
1321 return; 1338 return;
1322 1339
1323 // Not needed for hole punching. 1340 // Not needed for hole punching.
1324 if (!needs_establish_peer_) 1341 if (!needs_establish_peer_)
1325 return; 1342 return;
1326 1343
1327 stream_texture_proxy_.reset(stream_texture_factory_->CreateProxy()); 1344 stream_texture_proxy_.reset(stream_texture_factory_->CreateProxy());
1328 if (stream_texture_proxy_) { 1345 if (stream_texture_proxy_) {
1329 DoCreateStreamTexture(); 1346 DoCreateStreamTexture();
1330 ReallocateVideoFrame(); 1347 ReallocateVideoFrame();
1331 if (video_frame_provider_client_) { 1348 if (video_frame_provider_client_)
1332 stream_texture_proxy_->BindToLoop( 1349 UpdateStreamTextureProxyCallback(video_frame_provider_client_);
1333 stream_id_, video_frame_provider_client_, compositor_task_runner_);
1334 }
1335 } 1350 }
1336 } 1351 }
1337 1352
1338 void WebMediaPlayerAndroid::EstablishSurfaceTexturePeer() { 1353 void WebMediaPlayerAndroid::EstablishSurfaceTexturePeer() {
1339 DCHECK(main_thread_checker_.CalledOnValidThread()); 1354 DCHECK(main_thread_checker_.CalledOnValidThread());
1340 if (!stream_texture_proxy_) 1355 if (!stream_texture_proxy_)
1341 return; 1356 return;
1342 1357
1343 if (stream_texture_factory_.get() && stream_id_) 1358 if (stream_texture_factory_.get() && stream_id_)
1344 stream_texture_factory_->EstablishPeer(stream_id_, player_id_, frame_id_); 1359 stream_texture_factory_->EstablishPeer(stream_id_, player_id_, frame_id_);
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
1662 result = PREDICTION_RESULT_PATH_BASED_WAS_BETTER; 1677 result = PREDICTION_RESULT_PATH_BASED_WAS_BETTER;
1663 } else if (is_hls_url == is_hls) { 1678 } else if (is_hls_url == is_hls) {
1664 result = PREDICTION_RESULT_URL_BASED_WAS_BETTER; 1679 result = PREDICTION_RESULT_URL_BASED_WAS_BETTER;
1665 } 1680 }
1666 UMA_HISTOGRAM_ENUMERATION( 1681 UMA_HISTOGRAM_ENUMERATION(
1667 "Media.Android.IsHttpLiveStreamingMediaPredictionResult", 1682 "Media.Android.IsHttpLiveStreamingMediaPredictionResult",
1668 result, PREDICTION_RESULT_MAX); 1683 result, PREDICTION_RESULT_MAX);
1669 } 1684 }
1670 1685
1671 } // namespace content 1686 } // namespace content
OLDNEW
« 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