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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
143 base::WeakPtr<WebMediaPlayerDelegate> delegate, | 143 base::WeakPtr<WebMediaPlayerDelegate> delegate, |
144 const WebMediaPlayerParams& params) | 144 const WebMediaPlayerParams& params) |
145 : frame_(frame), | 145 : frame_(frame), |
146 network_state_(WebMediaPlayer::NetworkStateEmpty), | 146 network_state_(WebMediaPlayer::NetworkStateEmpty), |
147 ready_state_(WebMediaPlayer::ReadyStateHaveNothing), | 147 ready_state_(WebMediaPlayer::ReadyStateHaveNothing), |
148 main_loop_(base::MessageLoopProxy::current()), | 148 main_loop_(base::MessageLoopProxy::current()), |
149 media_loop_( | 149 media_loop_( |
150 RenderThreadImpl::current()->GetMediaThreadMessageLoopProxy()), | 150 RenderThreadImpl::current()->GetMediaThreadMessageLoopProxy()), |
151 media_log_(new RenderMediaLog()), | 151 media_log_(new RenderMediaLog()), |
152 pipeline_(media_loop_, media_log_.get()), | 152 pipeline_(media_loop_, media_log_.get()), |
153 has_audio_(false), | |
154 has_video_(false), | |
153 paused_(true), | 155 paused_(true), |
154 seeking_(false), | 156 seeking_(false), |
155 playback_rate_(0.0f), | 157 playback_rate_(0.0f), |
156 pending_seek_(false), | 158 pending_seek_(false), |
157 pending_seek_seconds_(0.0f), | 159 pending_seek_seconds_(0.0f), |
158 client_(client), | 160 client_(client), |
159 delegate_(delegate), | 161 delegate_(delegate), |
160 defer_load_cb_(params.defer_load_cb()), | 162 defer_load_cb_(params.defer_load_cb()), |
161 accelerated_compositing_reported_(false), | 163 accelerated_compositing_reported_(false), |
162 incremented_externally_allocated_memory_(false), | 164 incremented_externally_allocated_memory_(false), |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
429 void WebMediaPlayerImpl::setPreload(WebMediaPlayer::Preload preload) { | 431 void WebMediaPlayerImpl::setPreload(WebMediaPlayer::Preload preload) { |
430 DCHECK(main_loop_->BelongsToCurrentThread()); | 432 DCHECK(main_loop_->BelongsToCurrentThread()); |
431 | 433 |
432 if (data_source_) | 434 if (data_source_) |
433 data_source_->SetPreload(static_cast<content::Preload>(preload)); | 435 data_source_->SetPreload(static_cast<content::Preload>(preload)); |
434 } | 436 } |
435 | 437 |
436 bool WebMediaPlayerImpl::hasVideo() const { | 438 bool WebMediaPlayerImpl::hasVideo() const { |
437 DCHECK(main_loop_->BelongsToCurrentThread()); | 439 DCHECK(main_loop_->BelongsToCurrentThread()); |
438 | 440 |
439 return pipeline_.HasVideo(); | 441 return has_video_; |
440 } | 442 } |
441 | 443 |
442 bool WebMediaPlayerImpl::hasAudio() const { | 444 bool WebMediaPlayerImpl::hasAudio() const { |
443 DCHECK(main_loop_->BelongsToCurrentThread()); | 445 DCHECK(main_loop_->BelongsToCurrentThread()); |
444 | 446 |
445 return pipeline_.HasAudio(); | 447 return has_audio_; |
446 } | 448 } |
447 | 449 |
448 blink::WebSize WebMediaPlayerImpl::naturalSize() const { | 450 blink::WebSize WebMediaPlayerImpl::naturalSize() const { |
449 DCHECK(main_loop_->BelongsToCurrentThread()); | 451 DCHECK(main_loop_->BelongsToCurrentThread()); |
450 | 452 |
451 return blink::WebSize(natural_size_); | 453 return blink::WebSize(natural_size_); |
452 } | 454 } |
453 | 455 |
454 bool WebMediaPlayerImpl::paused() const { | 456 bool WebMediaPlayerImpl::paused() const { |
455 DCHECK(main_loop_->BelongsToCurrentThread()); | 457 DCHECK(main_loop_->BelongsToCurrentThread()); |
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
961 SetNetworkState(PipelineErrorToNetworkState(error)); | 963 SetNetworkState(PipelineErrorToNetworkState(error)); |
962 | 964 |
963 if (error == media::PIPELINE_ERROR_DECRYPT) | 965 if (error == media::PIPELINE_ERROR_DECRYPT) |
964 EmeUMAHistogramCounts(current_key_system_, "DecryptError", 1); | 966 EmeUMAHistogramCounts(current_key_system_, "DecryptError", 1); |
965 | 967 |
966 // TODO(scherkus): This should be handled by HTMLMediaElement and controls | 968 // TODO(scherkus): This should be handled by HTMLMediaElement and controls |
967 // should know when to invalidate themselves http://crbug.com/337015 | 969 // should know when to invalidate themselves http://crbug.com/337015 |
968 InvalidateOnMainThread(); | 970 InvalidateOnMainThread(); |
969 } | 971 } |
970 | 972 |
973 void WebMediaPlayerImpl::OnPipelineHasTrack( | |
974 media::Pipeline::TrackType track) { | |
975 switch (track) { | |
976 case media::Pipeline::AUDIO: | |
977 has_audio_ = true; | |
978 break; | |
979 | |
980 case media::Pipeline::VIDEO: | |
981 has_video_ = true; | |
982 break; | |
983 } | |
984 } | |
985 | |
971 void WebMediaPlayerImpl::OnPipelineBufferingState( | 986 void WebMediaPlayerImpl::OnPipelineBufferingState( |
972 media::Pipeline::BufferingState buffering_state) { | 987 media::Pipeline::BufferingState buffering_state) { |
973 DVLOG(1) << "OnPipelineBufferingState(" << buffering_state << ")"; | 988 DVLOG(1) << "OnPipelineBufferingState(" << buffering_state << ")"; |
974 | 989 |
975 switch (buffering_state) { | 990 switch (buffering_state) { |
976 case media::Pipeline::kHaveMetadata: | 991 case media::Pipeline::kHaveMetadata: |
977 // TODO(scherkus): Would be better to have a metadata changed callback | 992 // TODO(scherkus): Would be better to have a metadata changed callback |
978 // that contained the size information as well whether audio/video is | 993 // that contained the size information as well whether audio/video is |
979 // present. Doing so would let us remove more methods off Pipeline. | 994 // present. Doing so would let us remove more methods off Pipeline. |
980 natural_size_ = pipeline_.GetInitialNaturalSize(); | 995 natural_size_ = pipeline_.GetInitialNaturalSize(); |
scherkus (not reviewing)
2014/03/20 23:16:23
ahh this is the TODO I was looking for!
it seems
sandersd (OOO until July 31)
2014/03/21 19:53:03
Done.
| |
981 | 996 |
982 SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata); | 997 SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata); |
983 | 998 |
984 if (hasVideo() && client_->needsWebLayerForVideo()) { | 999 if (hasVideo() && client_->needsWebLayerForVideo()) { |
985 DCHECK(!video_weblayer_); | 1000 DCHECK(!video_weblayer_); |
986 video_weblayer_.reset( | 1001 video_weblayer_.reset( |
987 new webkit::WebLayerImpl(cc::VideoLayer::Create(this))); | 1002 new webkit::WebLayerImpl(cc::VideoLayer::Create(this))); |
988 client_->setWebLayer(video_weblayer_.get()); | 1003 client_->setWebLayer(video_weblayer_.get()); |
989 } | 1004 } |
990 break; | 1005 break; |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1213 filter_collection->SetTextRenderer(text_renderer.Pass()); | 1228 filter_collection->SetTextRenderer(text_renderer.Pass()); |
1214 } | 1229 } |
1215 | 1230 |
1216 // ... and we're ready to go! | 1231 // ... and we're ready to go! |
1217 starting_ = true; | 1232 starting_ = true; |
1218 pipeline_.Start( | 1233 pipeline_.Start( |
1219 filter_collection.Pass(), | 1234 filter_collection.Pass(), |
1220 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnPipelineEnded), | 1235 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnPipelineEnded), |
1221 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnPipelineError), | 1236 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnPipelineError), |
1222 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnPipelineSeek), | 1237 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnPipelineSeek), |
1238 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnPipelineHasTrack), | |
1223 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnPipelineBufferingState), | 1239 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnPipelineBufferingState), |
1224 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnDurationChange)); | 1240 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnDurationChange)); |
1225 } | 1241 } |
1226 | 1242 |
1227 void WebMediaPlayerImpl::SetNetworkState(WebMediaPlayer::NetworkState state) { | 1243 void WebMediaPlayerImpl::SetNetworkState(WebMediaPlayer::NetworkState state) { |
1228 DCHECK(main_loop_->BelongsToCurrentThread()); | 1244 DCHECK(main_loop_->BelongsToCurrentThread()); |
1229 DVLOG(1) << "SetNetworkState: " << state; | 1245 DVLOG(1) << "SetNetworkState: " << state; |
1230 network_state_ = state; | 1246 network_state_ = state; |
1231 // Always notify to ensure client has the latest value. | 1247 // Always notify to ensure client has the latest value. |
1232 client_->networkStateChanged(); | 1248 client_->networkStateChanged(); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1323 | 1339 |
1324 if (web_cdm_) { | 1340 if (web_cdm_) { |
1325 decryptor_ready_cb.Run(web_cdm_->GetDecryptor()); | 1341 decryptor_ready_cb.Run(web_cdm_->GetDecryptor()); |
1326 return; | 1342 return; |
1327 } | 1343 } |
1328 | 1344 |
1329 decryptor_ready_cb_ = decryptor_ready_cb; | 1345 decryptor_ready_cb_ = decryptor_ready_cb; |
1330 } | 1346 } |
1331 | 1347 |
1332 } // namespace content | 1348 } // namespace content |
OLD | NEW |