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