Chromium Code Reviews| 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 <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/android/build_info.h" | 9 #include "base/android/build_info.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 146 is_remote_(false), | 146 is_remote_(false), |
| 147 media_log_(media_log), | 147 media_log_(media_log), |
| 148 web_cdm_(NULL), | 148 web_cdm_(NULL), |
| 149 allow_stored_credentials_(false), | 149 allow_stored_credentials_(false), |
| 150 is_local_resource_(false), | 150 is_local_resource_(false), |
| 151 weak_factory_(this) { | 151 weak_factory_(this) { |
| 152 DCHECK(player_manager_); | 152 DCHECK(player_manager_); |
| 153 DCHECK(cdm_manager_); | 153 DCHECK(cdm_manager_); |
| 154 | 154 |
| 155 DCHECK(main_thread_checker_.CalledOnValidThread()); | 155 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 156 stream_texture_factory_->AddObserver(this); | |
| 156 | 157 |
| 157 player_id_ = player_manager_->RegisterMediaPlayer(this); | 158 player_id_ = player_manager_->RegisterMediaPlayer(this); |
| 158 | 159 |
| 159 #if defined(VIDEO_HOLE) | 160 #if defined(VIDEO_HOLE) |
| 160 force_use_overlay_embedded_video_ = CommandLine::ForCurrentProcess()-> | 161 force_use_overlay_embedded_video_ = CommandLine::ForCurrentProcess()-> |
| 161 HasSwitch(switches::kForceUseOverlayEmbeddedVideo); | 162 HasSwitch(switches::kForceUseOverlayEmbeddedVideo); |
| 162 if (force_use_overlay_embedded_video_ || | 163 if (force_use_overlay_embedded_video_ || |
| 163 player_manager_->ShouldUseVideoOverlayForEmbeddedEncryptedVideo()) { | 164 player_manager_->ShouldUseVideoOverlayForEmbeddedEncryptedVideo()) { |
| 164 // Defer stream texture creation until we are sure it's necessary. | 165 // Defer stream texture creation until we are sure it's necessary. |
| 165 needs_establish_peer_ = false; | 166 needs_establish_peer_ = false; |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 187 stream_id_ = 0; | 188 stream_id_ = 0; |
| 188 } | 189 } |
| 189 | 190 |
| 190 { | 191 { |
| 191 base::AutoLock auto_lock(current_frame_lock_); | 192 base::AutoLock auto_lock(current_frame_lock_); |
| 192 current_frame_ = NULL; | 193 current_frame_ = NULL; |
| 193 } | 194 } |
| 194 | 195 |
| 195 if (player_type_ == MEDIA_PLAYER_TYPE_MEDIA_SOURCE && delegate_) | 196 if (player_type_ == MEDIA_PLAYER_TYPE_MEDIA_SOURCE && delegate_) |
| 196 delegate_->PlayerGone(this); | 197 delegate_->PlayerGone(this); |
| 198 | |
| 199 stream_texture_factory_->AddObserver(this); | |
|
boliu
2014/09/03 01:00:07
don't judge...
| |
| 197 } | 200 } |
| 198 | 201 |
| 199 void WebMediaPlayerAndroid::load(LoadType load_type, | 202 void WebMediaPlayerAndroid::load(LoadType load_type, |
| 200 const blink::WebURL& url, | 203 const blink::WebURL& url, |
| 201 CORSMode cors_mode) { | 204 CORSMode cors_mode) { |
| 202 DCHECK(main_thread_checker_.CalledOnValidThread()); | 205 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 203 ReportMediaSchemeUma(GURL(url)); | 206 ReportMediaSchemeUma(GURL(url)); |
| 204 | 207 |
| 205 switch (load_type) { | 208 switch (load_type) { |
| 206 case LoadTypeURL: | 209 case LoadTypeURL: |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 315 !player_manager_->IsInFullscreen(frame_)) { | 318 !player_manager_->IsInFullscreen(frame_)) { |
| 316 EstablishSurfaceTexturePeer(); | 319 EstablishSurfaceTexturePeer(); |
| 317 } | 320 } |
| 318 | 321 |
| 319 if (paused()) | 322 if (paused()) |
| 320 player_manager_->Start(player_id_); | 323 player_manager_->Start(player_id_); |
| 321 UpdatePlayingState(true); | 324 UpdatePlayingState(true); |
| 322 UpdateNetworkState(WebMediaPlayer::NetworkStateLoading); | 325 UpdateNetworkState(WebMediaPlayer::NetworkStateLoading); |
| 323 } | 326 } |
| 324 | 327 |
| 328 void WebMediaPlayerAndroid::OnContextLost() { | |
| 329 if (stream_id_) { | |
| 330 GLES2Interface* gl = stream_texture_factory_->ContextGL(); | |
| 331 gl->DeleteTextures(1, &texture_id_); | |
| 332 texture_id_ = 0; | |
| 333 texture_mailbox_ = gpu::Mailbox(); | |
| 334 stream_id_ = 0; | |
| 335 } | |
| 336 stream_texture_proxy_.reset(); | |
| 337 SetNeedsEstablishPeer(true); | |
| 338 | |
| 339 { | |
| 340 base::AutoLock auto_lock(current_frame_lock_); | |
| 341 current_frame_ = NULL; | |
| 342 } | |
| 343 // TODO(boliu): Inform |video_frame_provider_client_|. | |
| 344 } | |
| 345 | |
| 346 void WebMediaPlayerAndroid::OnContextRestored() { | |
| 347 TryCreateStreamTextureProxyIfNeeded(); | |
| 348 if (hasVideo() && needs_establish_peer_ && | |
| 349 !player_manager_->IsInFullscreen(frame_)) { | |
| 350 EstablishSurfaceTexturePeer(); | |
| 351 } | |
| 352 } | |
| 353 | |
| 325 void WebMediaPlayerAndroid::pause() { | 354 void WebMediaPlayerAndroid::pause() { |
| 326 DCHECK(main_thread_checker_.CalledOnValidThread()); | 355 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 327 Pause(true); | 356 Pause(true); |
| 328 } | 357 } |
| 329 | 358 |
| 330 void WebMediaPlayerAndroid::seek(double seconds) { | 359 void WebMediaPlayerAndroid::seek(double seconds) { |
| 331 DCHECK(main_thread_checker_.CalledOnValidThread()); | 360 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 332 DVLOG(1) << __FUNCTION__ << "(" << seconds << ")"; | 361 DVLOG(1) << __FUNCTION__ << "(" << seconds << ")"; |
| 333 | 362 |
| 334 base::TimeDelta new_seek_time = ConvertSecondsToTimestamp(seconds); | 363 base::TimeDelta new_seek_time = ConvertSecondsToTimestamp(seconds); |
| (...skipping 1429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1764 | 1793 |
| 1765 bool WebMediaPlayerAndroid::IsHLSStream() const { | 1794 bool WebMediaPlayerAndroid::IsHLSStream() const { |
| 1766 std::string mime; | 1795 std::string mime; |
| 1767 GURL url = redirected_url_.is_empty() ? url_ : redirected_url_; | 1796 GURL url = redirected_url_.is_empty() ? url_ : redirected_url_; |
| 1768 if (!net::GetMimeTypeFromFile(base::FilePath(url.path()), &mime)) | 1797 if (!net::GetMimeTypeFromFile(base::FilePath(url.path()), &mime)) |
| 1769 return false; | 1798 return false; |
| 1770 return !mime.compare("application/x-mpegurl"); | 1799 return !mime.compare("application/x-mpegurl"); |
| 1771 } | 1800 } |
| 1772 | 1801 |
| 1773 } // namespace content | 1802 } // namespace content |
| OLD | NEW |