| OLD | NEW |
| 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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 frame_id_(frame_id), | 219 frame_id_(frame_id), |
| 220 enable_texture_copy_(enable_texture_copy), | 220 enable_texture_copy_(enable_texture_copy), |
| 221 suppress_deleting_texture_(false), | 221 suppress_deleting_texture_(false), |
| 222 playback_completed_(false), | 222 playback_completed_(false), |
| 223 volume_(1.0), | 223 volume_(1.0), |
| 224 volume_multiplier_(1.0), | 224 volume_multiplier_(1.0), |
| 225 weak_factory_(this) { | 225 weak_factory_(this) { |
| 226 DCHECK(player_manager_); | 226 DCHECK(player_manager_); |
| 227 | 227 |
| 228 DCHECK(main_thread_checker_.CalledOnValidThread()); | 228 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 229 stream_texture_factory_->AddObserver(this); | |
| 230 | 229 |
| 231 if (delegate_) | 230 if (delegate_) |
| 232 delegate_id_ = delegate_->AddObserver(this); | 231 delegate_id_ = delegate_->AddObserver(this); |
| 233 | 232 |
| 234 player_id_ = player_manager_->RegisterMediaPlayer(this); | 233 player_id_ = player_manager_->RegisterMediaPlayer(this); |
| 235 | 234 |
| 236 #if defined(VIDEO_HOLE) | 235 #if defined(VIDEO_HOLE) |
| 237 const RendererPreferences& prefs = RenderFrameImpl::FromRoutingID(frame_id) | 236 const RendererPreferences& prefs = RenderFrameImpl::FromRoutingID(frame_id) |
| 238 ->render_view() | 237 ->render_view() |
| 239 ->renderer_preferences(); | 238 ->renderer_preferences(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 { | 276 { |
| 278 base::AutoLock auto_lock(current_frame_lock_); | 277 base::AutoLock auto_lock(current_frame_lock_); |
| 279 current_frame_ = NULL; | 278 current_frame_ = NULL; |
| 280 } | 279 } |
| 281 | 280 |
| 282 if (delegate_) { | 281 if (delegate_) { |
| 283 delegate_->PlayerGone(delegate_id_); | 282 delegate_->PlayerGone(delegate_id_); |
| 284 delegate_->RemoveObserver(delegate_id_); | 283 delegate_->RemoveObserver(delegate_id_); |
| 285 } | 284 } |
| 286 | 285 |
| 287 stream_texture_factory_->RemoveObserver(this); | |
| 288 | |
| 289 if (media_source_delegate_) { | 286 if (media_source_delegate_) { |
| 290 // Part of |media_source_delegate_| needs to be stopped on the media thread. | 287 // Part of |media_source_delegate_| needs to be stopped on the media thread. |
| 291 // Wait until |media_source_delegate_| is fully stopped before tearing | 288 // Wait until |media_source_delegate_| is fully stopped before tearing |
| 292 // down other objects. | 289 // down other objects. |
| 293 base::WaitableEvent waiter(false, false); | 290 base::WaitableEvent waiter(false, false); |
| 294 media_source_delegate_->Stop( | 291 media_source_delegate_->Stop( |
| 295 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&waiter))); | 292 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&waiter))); |
| 296 waiter.Wait(); | 293 waiter.Wait(); |
| 297 } | 294 } |
| 298 } | 295 } |
| (...skipping 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1301 base::AutoLock auto_lock(current_frame_lock_); | 1298 base::AutoLock auto_lock(current_frame_lock_); |
| 1302 video_frame = current_frame_; | 1299 video_frame = current_frame_; |
| 1303 } | 1300 } |
| 1304 | 1301 |
| 1305 return video_frame; | 1302 return video_frame; |
| 1306 } | 1303 } |
| 1307 | 1304 |
| 1308 void WebMediaPlayerAndroid::PutCurrentFrame() { | 1305 void WebMediaPlayerAndroid::PutCurrentFrame() { |
| 1309 } | 1306 } |
| 1310 | 1307 |
| 1311 void WebMediaPlayerAndroid::ResetStreamTextureProxy() { | |
| 1312 DCHECK(main_thread_checker_.CalledOnValidThread()); | |
| 1313 // When suppress_deleting_texture_ is true, OnDidExitFullscreen has already | |
| 1314 // re-connected surface texture for embedded playback. There is no need to | |
| 1315 // delete them and create again. In fact, Android gives MediaPlayer erorr | |
| 1316 // code: what == 1, extra == -19 when Android WebView tries to create, delete | |
| 1317 // then create the surface textures for a video in quick succession. | |
| 1318 if (!suppress_deleting_texture_) | |
| 1319 RemoveSurfaceTextureAndProxy(); | |
| 1320 | |
| 1321 TryCreateStreamTextureProxyIfNeeded(); | |
| 1322 if (needs_establish_peer_ && is_playing_) | |
| 1323 EstablishSurfaceTexturePeer(); | |
| 1324 } | |
| 1325 | |
| 1326 void WebMediaPlayerAndroid::RemoveSurfaceTextureAndProxy() { | 1308 void WebMediaPlayerAndroid::RemoveSurfaceTextureAndProxy() { |
| 1327 DCHECK(main_thread_checker_.CalledOnValidThread()); | 1309 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 1328 | 1310 |
| 1329 if (stream_id_) { | 1311 if (stream_id_) { |
| 1330 GLES2Interface* gl = stream_texture_factory_->ContextGL(); | 1312 GLES2Interface* gl = stream_texture_factory_->ContextGL(); |
| 1331 gl->DeleteTextures(1, &texture_id_); | 1313 gl->DeleteTextures(1, &texture_id_); |
| 1332 // Flush to ensure that the stream texture gets deleted in a timely fashion. | 1314 // Flush to ensure that the stream texture gets deleted in a timely fashion. |
| 1333 gl->ShallowFlushCHROMIUM(); | 1315 gl->ShallowFlushCHROMIUM(); |
| 1334 texture_id_ = 0; | 1316 texture_id_ = 0; |
| 1335 texture_mailbox_ = gpu::Mailbox(); | 1317 texture_mailbox_ = gpu::Mailbox(); |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1682 result = PREDICTION_RESULT_PATH_BASED_WAS_BETTER; | 1664 result = PREDICTION_RESULT_PATH_BASED_WAS_BETTER; |
| 1683 } else if (is_hls_url == is_hls) { | 1665 } else if (is_hls_url == is_hls) { |
| 1684 result = PREDICTION_RESULT_URL_BASED_WAS_BETTER; | 1666 result = PREDICTION_RESULT_URL_BASED_WAS_BETTER; |
| 1685 } | 1667 } |
| 1686 UMA_HISTOGRAM_ENUMERATION( | 1668 UMA_HISTOGRAM_ENUMERATION( |
| 1687 "Media.Android.IsHttpLiveStreamingMediaPredictionResult", | 1669 "Media.Android.IsHttpLiveStreamingMediaPredictionResult", |
| 1688 result, PREDICTION_RESULT_MAX); | 1670 result, PREDICTION_RESULT_MAX); |
| 1689 } | 1671 } |
| 1690 | 1672 |
| 1691 } // namespace content | 1673 } // namespace content |
| OLD | NEW |