| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "webkit/media/webmediaplayer_impl.h" | 5 #include "webkit/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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 filter_collection_(new media::FilterCollection()), | 130 filter_collection_(new media::FilterCollection()), |
| 131 media_thread_("MediaPipeline"), | 131 media_thread_("MediaPipeline"), |
| 132 paused_(true), | 132 paused_(true), |
| 133 seeking_(false), | 133 seeking_(false), |
| 134 playback_rate_(0.0f), | 134 playback_rate_(0.0f), |
| 135 pending_seek_(false), | 135 pending_seek_(false), |
| 136 pending_seek_seconds_(0.0f), | 136 pending_seek_seconds_(0.0f), |
| 137 client_(client), | 137 client_(client), |
| 138 proxy_(new WebMediaPlayerProxy(main_loop_->message_loop_proxy(), this)), | 138 proxy_(new WebMediaPlayerProxy(main_loop_->message_loop_proxy(), this)), |
| 139 delegate_(delegate), | 139 delegate_(delegate), |
| 140 media_stream_client_(params.media_stream_client()), | |
| 141 media_log_(params.media_log()), | 140 media_log_(params.media_log()), |
| 142 accelerated_compositing_reported_(false), | 141 accelerated_compositing_reported_(false), |
| 143 incremented_externally_allocated_memory_(false), | 142 incremented_externally_allocated_memory_(false), |
| 144 is_local_source_(false), | 143 is_local_source_(false), |
| 145 supports_save_(true), | 144 supports_save_(true), |
| 146 starting_(false) { | 145 starting_(false) { |
| 147 media_log_->AddEvent( | 146 media_log_->AddEvent( |
| 148 media_log_->CreateEvent(media::MediaLogEvent::WEBMEDIAPLAYER_CREATED)); | 147 media_log_->CreateEvent(media::MediaLogEvent::WEBMEDIAPLAYER_CREATED)); |
| 149 | 148 |
| 150 CHECK(media_thread_.Start()); | 149 CHECK(media_thread_.Start()); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 UMA_HISTOGRAM_ENUMERATION("Media.URLScheme", URLScheme(gurl), kMaxURLScheme); | 264 UMA_HISTOGRAM_ENUMERATION("Media.URLScheme", URLScheme(gurl), kMaxURLScheme); |
| 266 | 265 |
| 267 // Handle any volume/preload changes that occured before load(). | 266 // Handle any volume/preload changes that occured before load(). |
| 268 setVolume(GetClient()->volume()); | 267 setVolume(GetClient()->volume()); |
| 269 setPreload(GetClient()->preload()); | 268 setPreload(GetClient()->preload()); |
| 270 | 269 |
| 271 SetNetworkState(WebMediaPlayer::NetworkStateLoading); | 270 SetNetworkState(WebMediaPlayer::NetworkStateLoading); |
| 272 SetReadyState(WebMediaPlayer::ReadyStateHaveNothing); | 271 SetReadyState(WebMediaPlayer::ReadyStateHaveNothing); |
| 273 media_log_->AddEvent(media_log_->CreateLoadEvent(url.spec())); | 272 media_log_->AddEvent(media_log_->CreateLoadEvent(url.spec())); |
| 274 | 273 |
| 275 // Media streams pipelines can start immediately. | |
| 276 if (BuildMediaStreamCollection(url, media_stream_client_, | |
| 277 media_thread_.message_loop_proxy(), | |
| 278 filter_collection_.get())) { | |
| 279 supports_save_ = false; | |
| 280 StartPipeline(); | |
| 281 return; | |
| 282 } | |
| 283 | |
| 284 // Media source pipelines can start immediately. | 274 // Media source pipelines can start immediately. |
| 285 if (!url.isEmpty() && url == GetClient()->sourceURL()) { | 275 if (!url.isEmpty() && url == GetClient()->sourceURL()) { |
| 286 chunk_demuxer_ = new media::ChunkDemuxer( | 276 chunk_demuxer_ = new media::ChunkDemuxer( |
| 287 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnDemuxerOpened), | 277 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnDemuxerOpened), |
| 288 BIND_TO_RENDER_LOOP_2(&WebMediaPlayerImpl::OnNeedKey, "", ""), | 278 BIND_TO_RENDER_LOOP_2(&WebMediaPlayerImpl::OnNeedKey, "", ""), |
| 289 base::Bind(&LogMediaSourceError, media_log_)); | 279 base::Bind(&LogMediaSourceError, media_log_)); |
| 290 | 280 |
| 291 BuildMediaSourceCollection(chunk_demuxer_, | 281 BuildMediaSourceCollection(chunk_demuxer_, |
| 292 media_thread_.message_loop_proxy(), | 282 media_thread_.message_loop_proxy(), |
| 293 filter_collection_.get()); | 283 filter_collection_.get()); |
| (...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1228 } | 1218 } |
| 1229 | 1219 |
| 1230 void WebMediaPlayerImpl::OnDurationChange() { | 1220 void WebMediaPlayerImpl::OnDurationChange() { |
| 1231 if (ready_state_ == WebMediaPlayer::ReadyStateHaveNothing) | 1221 if (ready_state_ == WebMediaPlayer::ReadyStateHaveNothing) |
| 1232 return; | 1222 return; |
| 1233 | 1223 |
| 1234 GetClient()->durationChanged(); | 1224 GetClient()->durationChanged(); |
| 1235 } | 1225 } |
| 1236 | 1226 |
| 1237 } // namespace webkit_media | 1227 } // namespace webkit_media |
| OLD | NEW |