| 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 "webkit/renderer/media/webmediaplayer_impl.h" | 5 #include "webkit/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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 ready_state_(WebMediaPlayer::ReadyStateHaveNothing), | 132 ready_state_(WebMediaPlayer::ReadyStateHaveNothing), |
| 133 main_loop_(base::MessageLoopProxy::current()), | 133 main_loop_(base::MessageLoopProxy::current()), |
| 134 media_loop_(params.message_loop_proxy()), | 134 media_loop_(params.message_loop_proxy()), |
| 135 paused_(true), | 135 paused_(true), |
| 136 seeking_(false), | 136 seeking_(false), |
| 137 playback_rate_(0.0f), | 137 playback_rate_(0.0f), |
| 138 pending_seek_(false), | 138 pending_seek_(false), |
| 139 pending_seek_seconds_(0.0f), | 139 pending_seek_seconds_(0.0f), |
| 140 client_(client), | 140 client_(client), |
| 141 delegate_(delegate), | 141 delegate_(delegate), |
| 142 defer_load_cb_(params.defer_load_cb()), |
| 142 media_log_(params.media_log()), | 143 media_log_(params.media_log()), |
| 143 accelerated_compositing_reported_(false), | 144 accelerated_compositing_reported_(false), |
| 144 incremented_externally_allocated_memory_(false), | 145 incremented_externally_allocated_memory_(false), |
| 145 gpu_factories_(params.gpu_factories()), | 146 gpu_factories_(params.gpu_factories()), |
| 146 is_local_source_(false), | 147 is_local_source_(false), |
| 147 supports_save_(true), | 148 supports_save_(true), |
| 148 starting_(false), | 149 starting_(false), |
| 149 chunk_demuxer_(NULL), | 150 chunk_demuxer_(NULL), |
| 150 pending_repaint_(false), | 151 pending_repaint_(false), |
| 151 pending_size_change_(false), | 152 pending_size_change_(false), |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 if (url.SchemeIs("file")) return kFileURLScheme; | 236 if (url.SchemeIs("file")) return kFileURLScheme; |
| 236 if (url.SchemeIs("blob")) return kBlobURLScheme; | 237 if (url.SchemeIs("blob")) return kBlobURLScheme; |
| 237 if (url.SchemeIs("data")) return kDataURLScheme; | 238 if (url.SchemeIs("data")) return kDataURLScheme; |
| 238 if (url.SchemeIs("filesystem")) return kFileSystemScheme; | 239 if (url.SchemeIs("filesystem")) return kFileSystemScheme; |
| 239 return kUnknownURLScheme; | 240 return kUnknownURLScheme; |
| 240 } | 241 } |
| 241 | 242 |
| 242 } // anonymous namespace | 243 } // anonymous namespace |
| 243 | 244 |
| 244 void WebMediaPlayerImpl::load(const WebKit::WebURL& url, CORSMode cors_mode) { | 245 void WebMediaPlayerImpl::load(const WebKit::WebURL& url, CORSMode cors_mode) { |
| 245 DCHECK(main_loop_->BelongsToCurrentThread()); | 246 load(url, NULL, cors_mode); |
| 246 | |
| 247 LoadSetup(url); | |
| 248 | |
| 249 // Otherwise it's a regular request which requires resolving the URL first. | |
| 250 GURL gurl(url); | |
| 251 data_source_.reset(new BufferedDataSource( | |
| 252 main_loop_, | |
| 253 frame_, | |
| 254 media_log_.get(), | |
| 255 base::Bind(&WebMediaPlayerImpl::NotifyDownloading, AsWeakPtr()))); | |
| 256 data_source_->Initialize( | |
| 257 url, static_cast<BufferedResourceLoader::CORSMode>(cors_mode), | |
| 258 base::Bind( | |
| 259 &WebMediaPlayerImpl::DataSourceInitialized, | |
| 260 AsWeakPtr(), gurl)); | |
| 261 | |
| 262 is_local_source_ = !gurl.SchemeIs("http") && !gurl.SchemeIs("https"); | |
| 263 } | 247 } |
| 264 | 248 |
| 265 void WebMediaPlayerImpl::load(const WebKit::WebURL& url, | 249 void WebMediaPlayerImpl::load(const WebKit::WebURL& url, |
| 266 WebKit::WebMediaSource* media_source, | 250 WebKit::WebMediaSource* media_source, |
| 267 CORSMode cors_mode) { | 251 CORSMode cors_mode) { |
| 268 LoadSetup(url); | 252 if (!defer_load_cb_.is_null()) { |
| 269 | 253 defer_load_cb_.Run(base::Bind( |
| 270 // Media source pipelines can start immediately. | 254 &WebMediaPlayerImpl::DoLoad, AsWeakPtr(), url, media_source, |
| 271 supports_save_ = false; | 255 cors_mode)); |
| 272 StartPipeline(media_source); | 256 return; |
| 257 } |
| 258 DoLoad(url, media_source, cors_mode); |
| 273 } | 259 } |
| 274 | 260 |
| 275 void WebMediaPlayerImpl::LoadSetup(const WebKit::WebURL& url) { | 261 void WebMediaPlayerImpl::DoLoad(const WebKit::WebURL& url, |
| 262 WebKit::WebMediaSource* media_source, |
| 263 CORSMode cors_mode) { |
| 264 DCHECK(main_loop_->BelongsToCurrentThread()); |
| 265 |
| 276 GURL gurl(url); | 266 GURL gurl(url); |
| 277 UMA_HISTOGRAM_ENUMERATION("Media.URLScheme", URLScheme(gurl), kMaxURLScheme); | 267 UMA_HISTOGRAM_ENUMERATION("Media.URLScheme", URLScheme(gurl), kMaxURLScheme); |
| 278 | 268 |
| 279 // Set subresource URL for crash reporting. | 269 // Set subresource URL for crash reporting. |
| 280 base::debug::SetCrashKeyValue("subresource_url", gurl.spec()); | 270 base::debug::SetCrashKeyValue("subresource_url", gurl.spec()); |
| 281 | 271 |
| 282 // Handle any volume/preload changes that occurred before load(). | 272 // Handle any volume/preload changes that occurred before load(). |
| 283 setVolume(GetClient()->volume()); | 273 setVolume(GetClient()->volume()); |
| 284 setPreload(GetClient()->preload()); | 274 setPreload(GetClient()->preload()); |
| 285 | 275 |
| 286 SetNetworkState(WebMediaPlayer::NetworkStateLoading); | 276 SetNetworkState(WebMediaPlayer::NetworkStateLoading); |
| 287 SetReadyState(WebMediaPlayer::ReadyStateHaveNothing); | 277 SetReadyState(WebMediaPlayer::ReadyStateHaveNothing); |
| 288 media_log_->AddEvent(media_log_->CreateLoadEvent(url.spec())); | 278 media_log_->AddEvent(media_log_->CreateLoadEvent(url.spec())); |
| 279 |
| 280 // Media source pipelines can start immediately. |
| 281 if (media_source) { |
| 282 supports_save_ = false; |
| 283 StartPipeline(media_source); |
| 284 return; |
| 285 } |
| 286 |
| 287 // Otherwise it's a regular request which requires resolving the URL first. |
| 288 data_source_.reset(new BufferedDataSource( |
| 289 main_loop_, |
| 290 frame_, |
| 291 media_log_.get(), |
| 292 base::Bind(&WebMediaPlayerImpl::NotifyDownloading, AsWeakPtr()))); |
| 293 data_source_->Initialize( |
| 294 url, static_cast<BufferedResourceLoader::CORSMode>(cors_mode), |
| 295 base::Bind( |
| 296 &WebMediaPlayerImpl::DataSourceInitialized, |
| 297 AsWeakPtr(), gurl)); |
| 298 |
| 299 is_local_source_ = !gurl.SchemeIs("http") && !gurl.SchemeIs("https"); |
| 289 } | 300 } |
| 290 | 301 |
| 291 void WebMediaPlayerImpl::play() { | 302 void WebMediaPlayerImpl::play() { |
| 292 DCHECK(main_loop_->BelongsToCurrentThread()); | 303 DCHECK(main_loop_->BelongsToCurrentThread()); |
| 293 | 304 |
| 294 paused_ = false; | 305 paused_ = false; |
| 295 pipeline_->SetPlaybackRate(playback_rate_); | 306 pipeline_->SetPlaybackRate(playback_rate_); |
| 296 | 307 |
| 297 media_log_->AddEvent(media_log_->CreateEvent(media::MediaLogEvent::PLAY)); | 308 media_log_->AddEvent(media_log_->CreateEvent(media::MediaLogEvent::PLAY)); |
| 298 | 309 |
| (...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1224 | 1235 |
| 1225 if (pending_repaint_) | 1236 if (pending_repaint_) |
| 1226 return; | 1237 return; |
| 1227 | 1238 |
| 1228 pending_repaint_ = true; | 1239 pending_repaint_ = true; |
| 1229 main_loop_->PostTask(FROM_HERE, base::Bind( | 1240 main_loop_->PostTask(FROM_HERE, base::Bind( |
| 1230 &WebMediaPlayerImpl::Repaint, AsWeakPtr())); | 1241 &WebMediaPlayerImpl::Repaint, AsWeakPtr())); |
| 1231 } | 1242 } |
| 1232 | 1243 |
| 1233 } // namespace webkit_media | 1244 } // namespace webkit_media |
| OLD | NEW |