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/webmediaplayer_impl.h" | 5 #include "content/renderer/media/webmediaplayer_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 seeking_(false), | 160 seeking_(false), |
161 playback_rate_(0.0f), | 161 playback_rate_(0.0f), |
162 pending_seek_(false), | 162 pending_seek_(false), |
163 pending_seek_seconds_(0.0f), | 163 pending_seek_seconds_(0.0f), |
164 client_(client), | 164 client_(client), |
165 delegate_(delegate), | 165 delegate_(delegate), |
166 defer_load_cb_(params.defer_load_cb()), | 166 defer_load_cb_(params.defer_load_cb()), |
167 accelerated_compositing_reported_(false), | 167 accelerated_compositing_reported_(false), |
168 incremented_externally_allocated_memory_(false), | 168 incremented_externally_allocated_memory_(false), |
169 gpu_factories_(RenderThreadImpl::current()->GetGpuFactories()), | 169 gpu_factories_(RenderThreadImpl::current()->GetGpuFactories()), |
170 is_local_source_(false), | |
171 supports_save_(true), | 170 supports_save_(true), |
172 starting_(false), | 171 starting_(false), |
173 chunk_demuxer_(NULL), | 172 chunk_demuxer_(NULL), |
174 // Threaded compositing isn't enabled universally yet. | 173 // Threaded compositing isn't enabled universally yet. |
175 compositor_task_runner_( | 174 compositor_task_runner_( |
176 RenderThreadImpl::current()->compositor_message_loop_proxy() | 175 RenderThreadImpl::current()->compositor_message_loop_proxy() |
177 ? RenderThreadImpl::current()->compositor_message_loop_proxy() | 176 ? RenderThreadImpl::current()->compositor_message_loop_proxy() |
178 : base::MessageLoopProxy::current()), | 177 : base::MessageLoopProxy::current()), |
179 compositor_(new VideoFrameCompositor( | 178 compositor_(new VideoFrameCompositor( |
180 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnNaturalSizeChanged), | 179 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnNaturalSizeChanged), |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 | 310 |
312 // Media source pipelines can start immediately. | 311 // Media source pipelines can start immediately. |
313 if (load_type == LoadTypeMediaSource) { | 312 if (load_type == LoadTypeMediaSource) { |
314 supports_save_ = false; | 313 supports_save_ = false; |
315 StartPipeline(); | 314 StartPipeline(); |
316 return; | 315 return; |
317 } | 316 } |
318 | 317 |
319 // Otherwise it's a regular request which requires resolving the URL first. | 318 // Otherwise it's a regular request which requires resolving the URL first. |
320 data_source_.reset(new BufferedDataSource( | 319 data_source_.reset(new BufferedDataSource( |
| 320 url, |
| 321 static_cast<BufferedResourceLoader::CORSMode>(cors_mode), |
321 main_loop_, | 322 main_loop_, |
322 frame_, | 323 frame_, |
323 media_log_.get(), | 324 media_log_.get(), |
324 &buffered_data_source_host_, | 325 &buffered_data_source_host_, |
325 base::Bind(&WebMediaPlayerImpl::NotifyDownloading, AsWeakPtr()))); | 326 base::Bind(&WebMediaPlayerImpl::NotifyDownloading, AsWeakPtr()))); |
326 data_source_->Initialize( | 327 data_source_->Initialize( |
327 url, static_cast<BufferedResourceLoader::CORSMode>(cors_mode), | 328 base::Bind(&WebMediaPlayerImpl::DataSourceInitialized, AsWeakPtr())); |
328 base::Bind( | |
329 &WebMediaPlayerImpl::DataSourceInitialized, | |
330 AsWeakPtr(), gurl)); | |
331 | |
332 is_local_source_ = !gurl.SchemeIsHTTPOrHTTPS(); | |
333 } | 329 } |
334 | 330 |
335 void WebMediaPlayerImpl::play() { | 331 void WebMediaPlayerImpl::play() { |
336 DCHECK(main_loop_->BelongsToCurrentThread()); | 332 DCHECK(main_loop_->BelongsToCurrentThread()); |
337 | 333 |
338 paused_ = false; | 334 paused_ = false; |
339 pipeline_.SetPlaybackRate(playback_rate_); | 335 pipeline_.SetPlaybackRate(playback_rate_); |
340 if (data_source_) | 336 if (data_source_) |
341 data_source_->MediaIsPlaying(); | 337 data_source_->MediaIsPlaying(); |
342 | 338 |
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1107 << "Invalid URL in default_url: " << default_url; | 1103 << "Invalid URL in default_url: " << default_url; |
1108 | 1104 |
1109 client_->keyMessage( | 1105 client_->keyMessage( |
1110 WebString::fromUTF8(GetPrefixedKeySystemName(current_key_system_)), | 1106 WebString::fromUTF8(GetPrefixedKeySystemName(current_key_system_)), |
1111 WebString::fromUTF8(session_id), | 1107 WebString::fromUTF8(session_id), |
1112 message.empty() ? NULL : &message[0], | 1108 message.empty() ? NULL : &message[0], |
1113 message.size(), | 1109 message.size(), |
1114 default_url_gurl); | 1110 default_url_gurl); |
1115 } | 1111 } |
1116 | 1112 |
1117 void WebMediaPlayerImpl::DataSourceInitialized(const GURL& gurl, bool success) { | 1113 void WebMediaPlayerImpl::DataSourceInitialized(bool success) { |
1118 DCHECK(main_loop_->BelongsToCurrentThread()); | 1114 DCHECK(main_loop_->BelongsToCurrentThread()); |
1119 | 1115 |
1120 if (!success) { | 1116 if (!success) { |
1121 SetNetworkState(WebMediaPlayer::NetworkStateFormatError); | 1117 SetNetworkState(WebMediaPlayer::NetworkStateFormatError); |
1122 | 1118 |
1123 // TODO(scherkus): This should be handled by HTMLMediaElement and controls | 1119 // TODO(scherkus): This should be handled by HTMLMediaElement and controls |
1124 // should know when to invalidate themselves http://crbug.com/337015 | 1120 // should know when to invalidate themselves http://crbug.com/337015 |
1125 InvalidateOnMainThread(); | 1121 InvalidateOnMainThread(); |
1126 return; | 1122 return; |
1127 } | 1123 } |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1243 DVLOG(1) << "SetNetworkState: " << state; | 1239 DVLOG(1) << "SetNetworkState: " << state; |
1244 network_state_ = state; | 1240 network_state_ = state; |
1245 // Always notify to ensure client has the latest value. | 1241 // Always notify to ensure client has the latest value. |
1246 client_->networkStateChanged(); | 1242 client_->networkStateChanged(); |
1247 } | 1243 } |
1248 | 1244 |
1249 void WebMediaPlayerImpl::SetReadyState(WebMediaPlayer::ReadyState state) { | 1245 void WebMediaPlayerImpl::SetReadyState(WebMediaPlayer::ReadyState state) { |
1250 DCHECK(main_loop_->BelongsToCurrentThread()); | 1246 DCHECK(main_loop_->BelongsToCurrentThread()); |
1251 DVLOG(1) << "SetReadyState: " << state; | 1247 DVLOG(1) << "SetReadyState: " << state; |
1252 | 1248 |
1253 if (state == WebMediaPlayer::ReadyStateHaveEnoughData && | 1249 if (state == WebMediaPlayer::ReadyStateHaveEnoughData && data_source_ && |
1254 is_local_source_ && | 1250 data_source_->assume_fully_buffered() && |
1255 network_state_ == WebMediaPlayer::NetworkStateLoading) | 1251 network_state_ == WebMediaPlayer::NetworkStateLoading) |
1256 SetNetworkState(WebMediaPlayer::NetworkStateLoaded); | 1252 SetNetworkState(WebMediaPlayer::NetworkStateLoaded); |
1257 | 1253 |
1258 ready_state_ = state; | 1254 ready_state_ = state; |
1259 // Always notify to ensure client has the latest value. | 1255 // Always notify to ensure client has the latest value. |
1260 client_->readyStateChanged(); | 1256 client_->readyStateChanged(); |
1261 } | 1257 } |
1262 | 1258 |
1263 blink::WebAudioSourceProvider* WebMediaPlayerImpl::audioSourceProvider() { | 1259 blink::WebAudioSourceProvider* WebMediaPlayerImpl::audioSourceProvider() { |
1264 return audio_source_provider_.get(); | 1260 return audio_source_provider_.get(); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1375 compositor_task_runner_->PostTask(FROM_HERE, | 1371 compositor_task_runner_->PostTask(FROM_HERE, |
1376 base::Bind(&GetCurrentFrameAndSignal, | 1372 base::Bind(&GetCurrentFrameAndSignal, |
1377 base::Unretained(compositor_), | 1373 base::Unretained(compositor_), |
1378 &video_frame, | 1374 &video_frame, |
1379 &event)); | 1375 &event)); |
1380 event.Wait(); | 1376 event.Wait(); |
1381 return video_frame; | 1377 return video_frame; |
1382 } | 1378 } |
1383 | 1379 |
1384 } // namespace content | 1380 } // namespace content |
OLD | NEW |