| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <limits> | 7 #include <limits> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 // A sophisticated data source that does memory caching. | 188 // A sophisticated data source that does memory caching. |
| 189 scoped_ptr<media::DataSourceFactory> buffered_data_source_factory( | 189 scoped_ptr<media::DataSourceFactory> buffered_data_source_factory( |
| 190 BufferedDataSource::CreateFactory(MessageLoop::current(), frame, | 190 BufferedDataSource::CreateFactory(MessageLoop::current(), frame, |
| 191 media_log_, | 191 media_log_, |
| 192 proxy_->GetBuildObserver())); | 192 proxy_->GetBuildObserver())); |
| 193 | 193 |
| 194 scoped_ptr<media::CompositeDataSourceFactory> data_source_factory( | 194 scoped_ptr<media::CompositeDataSourceFactory> data_source_factory( |
| 195 new media::CompositeDataSourceFactory()); | 195 new media::CompositeDataSourceFactory()); |
| 196 | 196 |
| 197 if (use_simple_data_source) { | 197 if (use_simple_data_source) { |
| 198 data_source_factory->AddFactory(simple_data_source_factory.release()); | 198 data_source_factory->AddFactory(simple_data_source_factory.Pass()); |
| 199 data_source_factory->AddFactory(buffered_data_source_factory.release()); | 199 data_source_factory->AddFactory(buffered_data_source_factory.Pass()); |
| 200 } else { | 200 } else { |
| 201 data_source_factory->AddFactory(buffered_data_source_factory.release()); | 201 data_source_factory->AddFactory(buffered_data_source_factory.Pass()); |
| 202 data_source_factory->AddFactory(simple_data_source_factory.release()); | 202 data_source_factory->AddFactory(simple_data_source_factory.Pass()); |
| 203 } | 203 } |
| 204 | 204 |
| 205 scoped_ptr<media::DemuxerFactory> demuxer_factory( | 205 scoped_ptr<media::DemuxerFactory> demuxer_factory( |
| 206 new media::FFmpegDemuxerFactory(data_source_factory.release(), | 206 // TODO(fischman): replace the extra scoped_ptr+release() with Pass() when |
| 207 pipeline_message_loop)); | 207 // http://crbug.com/109026 is fixed. |
| 208 new media::FFmpegDemuxerFactory(scoped_ptr<media::DataSourceFactory>( |
| 209 data_source_factory.release()), pipeline_message_loop)); |
| 208 | 210 |
| 209 std::string source_url = GetClient()->sourceURL().spec(); | 211 std::string source_url = GetClient()->sourceURL().spec(); |
| 210 | 212 |
| 211 if (!source_url.empty()) { | 213 if (!source_url.empty()) { |
| 212 demuxer_factory.reset( | 214 demuxer_factory.reset( |
| 213 new media::ChunkDemuxerFactory(source_url, | 215 new media::ChunkDemuxerFactory(source_url, |
| 214 demuxer_factory.release(), | 216 demuxer_factory.Pass(), |
| 215 proxy_)); | 217 proxy_)); |
| 216 } | 218 } |
| 217 filter_collection_->SetDemuxerFactory(demuxer_factory.release()); | 219 filter_collection_->SetDemuxerFactory(demuxer_factory.Pass()); |
| 218 | 220 |
| 219 // Add in the default filter factories. | 221 // Add in the default filter factories. |
| 220 filter_collection_->AddAudioDecoder(new media::FFmpegAudioDecoder( | 222 filter_collection_->AddAudioDecoder(new media::FFmpegAudioDecoder( |
| 221 message_loop_factory_->GetMessageLoop("AudioDecoderThread"))); | 223 message_loop_factory_->GetMessageLoop("AudioDecoderThread"))); |
| 222 filter_collection_->AddVideoDecoder(new media::FFmpegVideoDecoder( | 224 filter_collection_->AddVideoDecoder(new media::FFmpegVideoDecoder( |
| 223 message_loop_factory_->GetMessageLoop("VideoDecoderThread"))); | 225 message_loop_factory_->GetMessageLoop("VideoDecoderThread"))); |
| 224 filter_collection_->AddAudioRenderer(new media::NullAudioRenderer()); | 226 filter_collection_->AddAudioRenderer(new media::NullAudioRenderer()); |
| 225 | 227 |
| 226 return true; | 228 return true; |
| 227 } | 229 } |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 filter_collection_->AddVideoDecoder(new_decoder.get()); | 294 filter_collection_->AddVideoDecoder(new_decoder.get()); |
| 293 has_video = true; | 295 has_video = true; |
| 294 } | 296 } |
| 295 | 297 |
| 296 // TODO(wjia): add audio decoder handling when it's available. | 298 // TODO(wjia): add audio decoder handling when it's available. |
| 297 if (has_video || has_audio) { | 299 if (has_video || has_audio) { |
| 298 // TODO(vrk/wjia): Setting true for local_source is under the assumption | 300 // TODO(vrk/wjia): Setting true for local_source is under the assumption |
| 299 // that the MediaStream represents a local webcam. This will need to | 301 // that the MediaStream represents a local webcam. This will need to |
| 300 // change in the future when GetVideoDecoder is no longer hardcoded to | 302 // change in the future when GetVideoDecoder is no longer hardcoded to |
| 301 // only return CaptureVideoDecoders. | 303 // only return CaptureVideoDecoders. |
| 302 filter_collection_->SetDemuxerFactory( | 304 filter_collection_->SetDemuxerFactory(scoped_ptr<media::DemuxerFactory>( |
| 303 new media::DummyDemuxerFactory(has_video, has_audio, true)); | 305 new media::DummyDemuxerFactory(has_video, has_audio, true))); |
| 304 } | 306 } |
| 305 } | 307 } |
| 306 | 308 |
| 307 // Handle any volume changes that occured before load(). | 309 // Handle any volume changes that occured before load(). |
| 308 setVolume(GetClient()->volume()); | 310 setVolume(GetClient()->volume()); |
| 309 // Get the preload value. | 311 // Get the preload value. |
| 310 setPreload(GetClient()->preload()); | 312 setPreload(GetClient()->preload()); |
| 311 | 313 |
| 312 // Initialize the pipeline. | 314 // Initialize the pipeline. |
| 313 SetNetworkState(WebKit::WebMediaPlayer::Loading); | 315 SetNetworkState(WebKit::WebMediaPlayer::Loading); |
| 314 SetReadyState(WebKit::WebMediaPlayer::HaveNothing); | 316 SetReadyState(WebKit::WebMediaPlayer::HaveNothing); |
| 315 pipeline_->Start( | 317 pipeline_->Start( |
| 316 filter_collection_.release(), | 318 filter_collection_.Pass(), |
| 317 url.spec(), | 319 url.spec(), |
| 318 base::Bind(&WebMediaPlayerProxy::PipelineInitializationCallback, | 320 base::Bind(&WebMediaPlayerProxy::PipelineInitializationCallback, |
| 319 proxy_.get())); | 321 proxy_.get())); |
| 320 | 322 |
| 321 media_log_->AddEvent(media_log_->CreateLoadEvent(url.spec())); | 323 media_log_->AddEvent(media_log_->CreateLoadEvent(url.spec())); |
| 322 } | 324 } |
| 323 | 325 |
| 324 void WebMediaPlayerImpl::cancelLoad() { | 326 void WebMediaPlayerImpl::cancelLoad() { |
| 325 DCHECK_EQ(main_loop_, MessageLoop::current()); | 327 DCHECK_EQ(main_loop_, MessageLoop::current()); |
| 326 } | 328 } |
| (...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 934 return client_; | 936 return client_; |
| 935 } | 937 } |
| 936 | 938 |
| 937 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() { | 939 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() { |
| 938 DCHECK_EQ(main_loop_, MessageLoop::current()); | 940 DCHECK_EQ(main_loop_, MessageLoop::current()); |
| 939 incremented_externally_allocated_memory_ = true; | 941 incremented_externally_allocated_memory_ = true; |
| 940 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory); | 942 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory); |
| 941 } | 943 } |
| 942 | 944 |
| 943 } // namespace webkit_media | 945 } // namespace webkit_media |
| OLD | NEW |