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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 } | 164 } |
165 | 165 |
166 WebMediaPlayerImpl::WebMediaPlayerImpl( | 166 WebMediaPlayerImpl::WebMediaPlayerImpl( |
167 blink::WebLocalFrame* frame, | 167 blink::WebLocalFrame* frame, |
168 blink::WebMediaPlayerClient* client, | 168 blink::WebMediaPlayerClient* client, |
169 base::WeakPtr<WebMediaPlayerDelegate> delegate, | 169 base::WeakPtr<WebMediaPlayerDelegate> delegate, |
170 const WebMediaPlayerParams& params) | 170 const WebMediaPlayerParams& params) |
171 : frame_(frame), | 171 : frame_(frame), |
172 network_state_(WebMediaPlayer::NetworkStateEmpty), | 172 network_state_(WebMediaPlayer::NetworkStateEmpty), |
173 ready_state_(WebMediaPlayer::ReadyStateHaveNothing), | 173 ready_state_(WebMediaPlayer::ReadyStateHaveNothing), |
| 174 preload_(AUTO), |
174 main_loop_(base::MessageLoopProxy::current()), | 175 main_loop_(base::MessageLoopProxy::current()), |
175 media_loop_( | 176 media_loop_( |
176 RenderThreadImpl::current()->GetMediaThreadMessageLoopProxy()), | 177 RenderThreadImpl::current()->GetMediaThreadMessageLoopProxy()), |
177 media_log_(new RenderMediaLog()), | 178 media_log_(new RenderMediaLog()), |
178 pipeline_(media_loop_, media_log_.get()), | 179 pipeline_(media_loop_, media_log_.get()), |
179 load_type_(LoadTypeURL), | 180 load_type_(LoadTypeURL), |
180 opaque_(false), | 181 opaque_(false), |
181 paused_(true), | 182 paused_(true), |
182 seeking_(false), | 183 seeking_(false), |
183 playback_rate_(0.0f), | 184 playback_rate_(0.0f), |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 DCHECK(main_loop_->BelongsToCurrentThread()); | 283 DCHECK(main_loop_->BelongsToCurrentThread()); |
283 | 284 |
284 GURL gurl(url); | 285 GURL gurl(url); |
285 ReportMediaSchemeUma(gurl); | 286 ReportMediaSchemeUma(gurl); |
286 | 287 |
287 // Set subresource URL for crash reporting. | 288 // Set subresource URL for crash reporting. |
288 base::debug::SetCrashKeyValue("subresource_url", gurl.spec()); | 289 base::debug::SetCrashKeyValue("subresource_url", gurl.spec()); |
289 | 290 |
290 load_type_ = load_type; | 291 load_type_ = load_type; |
291 | 292 |
292 // Handle any volume/preload changes that occurred before load(). | |
293 setVolume(client_->volume()); | |
294 setPreload(client_->preload()); | |
295 | |
296 SetNetworkState(WebMediaPlayer::NetworkStateLoading); | 293 SetNetworkState(WebMediaPlayer::NetworkStateLoading); |
297 SetReadyState(WebMediaPlayer::ReadyStateHaveNothing); | 294 SetReadyState(WebMediaPlayer::ReadyStateHaveNothing); |
298 media_log_->AddEvent(media_log_->CreateLoadEvent(url.spec())); | 295 media_log_->AddEvent(media_log_->CreateLoadEvent(url.spec())); |
299 | 296 |
300 // Media source pipelines can start immediately. | 297 // Media source pipelines can start immediately. |
301 if (load_type == LoadTypeMediaSource) { | 298 if (load_type == LoadTypeMediaSource) { |
302 supports_save_ = false; | 299 supports_save_ = false; |
303 StartPipeline(); | 300 StartPipeline(); |
304 return; | 301 return; |
305 } | 302 } |
306 | 303 |
307 // Otherwise it's a regular request which requires resolving the URL first. | 304 // Otherwise it's a regular request which requires resolving the URL first. |
308 data_source_.reset(new BufferedDataSource( | 305 data_source_.reset(new BufferedDataSource( |
309 url, | 306 url, |
310 static_cast<BufferedResourceLoader::CORSMode>(cors_mode), | 307 static_cast<BufferedResourceLoader::CORSMode>(cors_mode), |
311 main_loop_, | 308 main_loop_, |
312 frame_, | 309 frame_, |
313 media_log_.get(), | 310 media_log_.get(), |
314 &buffered_data_source_host_, | 311 &buffered_data_source_host_, |
315 base::Bind(&WebMediaPlayerImpl::NotifyDownloading, AsWeakPtr()))); | 312 base::Bind(&WebMediaPlayerImpl::NotifyDownloading, AsWeakPtr()))); |
316 data_source_->Initialize( | 313 data_source_->Initialize( |
317 base::Bind(&WebMediaPlayerImpl::DataSourceInitialized, AsWeakPtr())); | 314 base::Bind(&WebMediaPlayerImpl::DataSourceInitialized, AsWeakPtr())); |
| 315 data_source_->SetPreload(preload_); |
318 } | 316 } |
319 | 317 |
320 void WebMediaPlayerImpl::play() { | 318 void WebMediaPlayerImpl::play() { |
321 DVLOG(1) << __FUNCTION__; | 319 DVLOG(1) << __FUNCTION__; |
322 DCHECK(main_loop_->BelongsToCurrentThread()); | 320 DCHECK(main_loop_->BelongsToCurrentThread()); |
323 | 321 |
324 paused_ = false; | 322 paused_ = false; |
325 pipeline_.SetPlaybackRate(playback_rate_); | 323 pipeline_.SetPlaybackRate(playback_rate_); |
326 if (data_source_) | 324 if (data_source_) |
327 data_source_->MediaIsPlaying(); | 325 data_source_->MediaIsPlaying(); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 mismatching_enums) | 423 mismatching_enums) |
426 COMPILE_ASSERT_MATCHING_ENUM(PreloadNone, NONE); | 424 COMPILE_ASSERT_MATCHING_ENUM(PreloadNone, NONE); |
427 COMPILE_ASSERT_MATCHING_ENUM(PreloadMetaData, METADATA); | 425 COMPILE_ASSERT_MATCHING_ENUM(PreloadMetaData, METADATA); |
428 COMPILE_ASSERT_MATCHING_ENUM(PreloadAuto, AUTO); | 426 COMPILE_ASSERT_MATCHING_ENUM(PreloadAuto, AUTO); |
429 #undef COMPILE_ASSERT_MATCHING_ENUM | 427 #undef COMPILE_ASSERT_MATCHING_ENUM |
430 | 428 |
431 void WebMediaPlayerImpl::setPreload(WebMediaPlayer::Preload preload) { | 429 void WebMediaPlayerImpl::setPreload(WebMediaPlayer::Preload preload) { |
432 DVLOG(1) << __FUNCTION__ << "(" << preload << ")"; | 430 DVLOG(1) << __FUNCTION__ << "(" << preload << ")"; |
433 DCHECK(main_loop_->BelongsToCurrentThread()); | 431 DCHECK(main_loop_->BelongsToCurrentThread()); |
434 | 432 |
| 433 preload_ = static_cast<content::Preload>(preload); |
435 if (data_source_) | 434 if (data_source_) |
436 data_source_->SetPreload(static_cast<content::Preload>(preload)); | 435 data_source_->SetPreload(preload_); |
437 } | 436 } |
438 | 437 |
439 bool WebMediaPlayerImpl::hasVideo() const { | 438 bool WebMediaPlayerImpl::hasVideo() const { |
440 DCHECK(main_loop_->BelongsToCurrentThread()); | 439 DCHECK(main_loop_->BelongsToCurrentThread()); |
441 | 440 |
442 return pipeline_metadata_.has_video; | 441 return pipeline_metadata_.has_video; |
443 } | 442 } |
444 | 443 |
445 bool WebMediaPlayerImpl::hasAudio() const { | 444 bool WebMediaPlayerImpl::hasAudio() const { |
446 DCHECK(main_loop_->BelongsToCurrentThread()); | 445 DCHECK(main_loop_->BelongsToCurrentThread()); |
(...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1325 compositor_task_runner_->PostTask(FROM_HERE, | 1324 compositor_task_runner_->PostTask(FROM_HERE, |
1326 base::Bind(&GetCurrentFrameAndSignal, | 1325 base::Bind(&GetCurrentFrameAndSignal, |
1327 base::Unretained(compositor_), | 1326 base::Unretained(compositor_), |
1328 &video_frame, | 1327 &video_frame, |
1329 &event)); | 1328 &event)); |
1330 event.Wait(); | 1329 event.Wait(); |
1331 return video_frame; | 1330 return video_frame; |
1332 } | 1331 } |
1333 | 1332 |
1334 } // namespace content | 1333 } // namespace content |
OLD | NEW |