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_->RemoveObserver(this); | |
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::ResetStreamTextureProxy() { | |
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 TryCreateStreamTextureProxyIfNeeded(); | |
340 // TODO(boliu): This is not thread safe. | |
341 stream_texture_proxy_initialized_ = false; | |
342 if (hasVideo() && needs_establish_peer_ && | |
qinmin
2014/09/04 00:14:47
isn't needs_establish_peer_ true since you called
| |
343 !player_manager_->IsInFullscreen(frame_)) { | |
344 EstablishSurfaceTexturePeer(); | |
345 } | |
346 | |
347 // TODO(boliu): Inform |video_frame_provider_client_| on compositor thread. | |
qinmin
2014/09/04 00:14:47
you also need to bind the new stream texture proxy
| |
348 } | |
349 | |
325 void WebMediaPlayerAndroid::pause() { | 350 void WebMediaPlayerAndroid::pause() { |
326 DCHECK(main_thread_checker_.CalledOnValidThread()); | 351 DCHECK(main_thread_checker_.CalledOnValidThread()); |
327 Pause(true); | 352 Pause(true); |
328 } | 353 } |
329 | 354 |
330 void WebMediaPlayerAndroid::seek(double seconds) { | 355 void WebMediaPlayerAndroid::seek(double seconds) { |
331 DCHECK(main_thread_checker_.CalledOnValidThread()); | 356 DCHECK(main_thread_checker_.CalledOnValidThread()); |
332 DVLOG(1) << __FUNCTION__ << "(" << seconds << ")"; | 357 DVLOG(1) << __FUNCTION__ << "(" << seconds << ")"; |
333 | 358 |
334 base::TimeDelta new_seek_time = ConvertSecondsToTimestamp(seconds); | 359 base::TimeDelta new_seek_time = ConvertSecondsToTimestamp(seconds); |
(...skipping 1429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1764 | 1789 |
1765 bool WebMediaPlayerAndroid::IsHLSStream() const { | 1790 bool WebMediaPlayerAndroid::IsHLSStream() const { |
1766 std::string mime; | 1791 std::string mime; |
1767 GURL url = redirected_url_.is_empty() ? url_ : redirected_url_; | 1792 GURL url = redirected_url_.is_empty() ? url_ : redirected_url_; |
1768 if (!net::GetMimeTypeFromFile(base::FilePath(url.path()), &mime)) | 1793 if (!net::GetMimeTypeFromFile(base::FilePath(url.path()), &mime)) |
1769 return false; | 1794 return false; |
1770 return !mime.compare("application/x-mpegurl"); | 1795 return !mime.compare("application/x-mpegurl"); |
1771 } | 1796 } |
1772 | 1797 |
1773 } // namespace content | 1798 } // namespace content |
OLD | NEW |