| 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): hopefully the extra scoped_ptr<m::DSF>() will be |
| 207 pipeline_message_loop)); | 207 // unnecessary once http://codereview.chromium.org/8968032/ lands |
| 208 // properly. |
| 209 new media::FFmpegDemuxerFactory(scoped_ptr<media::DataSourceFactory>( |
| 210 data_source_factory.Pass()), pipeline_message_loop)); |
| 208 | 211 |
| 209 std::string source_url = GetClient()->sourceURL().spec(); | 212 std::string source_url = GetClient()->sourceURL().spec(); |
| 210 | 213 |
| 211 if (!source_url.empty()) { | 214 if (!source_url.empty()) { |
| 212 demuxer_factory.reset( | 215 demuxer_factory.reset( |
| 213 new media::ChunkDemuxerFactory(source_url, | 216 new media::ChunkDemuxerFactory(source_url, |
| 214 demuxer_factory.release(), | 217 demuxer_factory.Pass(), |
| 215 proxy_)); | 218 proxy_)); |
| 216 } | 219 } |
| 217 filter_collection_->SetDemuxerFactory(demuxer_factory.release()); | 220 filter_collection_->SetDemuxerFactory(demuxer_factory.Pass()); |
| 218 | 221 |
| 219 // Add in the default filter factories. | 222 // Add in the default filter factories. |
| 220 filter_collection_->AddAudioDecoder(new media::FFmpegAudioDecoder( | 223 filter_collection_->AddAudioDecoder(new media::FFmpegAudioDecoder( |
| 221 message_loop_factory_->GetMessageLoop("AudioDecoderThread"))); | 224 message_loop_factory_->GetMessageLoop("AudioDecoderThread"))); |
| 222 filter_collection_->AddVideoDecoder(new media::FFmpegVideoDecoder( | 225 filter_collection_->AddVideoDecoder(new media::FFmpegVideoDecoder( |
| 223 message_loop_factory_->GetMessageLoop("VideoDecoderThread"))); | 226 message_loop_factory_->GetMessageLoop("VideoDecoderThread"))); |
| 224 filter_collection_->AddAudioRenderer(new media::NullAudioRenderer()); | 227 filter_collection_->AddAudioRenderer(new media::NullAudioRenderer()); |
| 225 | 228 |
| 226 return true; | 229 return true; |
| 227 } | 230 } |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 filter_collection_->AddVideoDecoder(new_decoder.get()); | 295 filter_collection_->AddVideoDecoder(new_decoder.get()); |
| 293 has_video = true; | 296 has_video = true; |
| 294 } | 297 } |
| 295 | 298 |
| 296 // TODO(wjia): add audio decoder handling when it's available. | 299 // TODO(wjia): add audio decoder handling when it's available. |
| 297 if (has_video || has_audio) { | 300 if (has_video || has_audio) { |
| 298 // TODO(vrk/wjia): Setting true for local_source is under the assumption | 301 // TODO(vrk/wjia): Setting true for local_source is under the assumption |
| 299 // that the MediaStream represents a local webcam. This will need to | 302 // that the MediaStream represents a local webcam. This will need to |
| 300 // change in the future when GetVideoDecoder is no longer hardcoded to | 303 // change in the future when GetVideoDecoder is no longer hardcoded to |
| 301 // only return CaptureVideoDecoders. | 304 // only return CaptureVideoDecoders. |
| 302 filter_collection_->SetDemuxerFactory( | 305 filter_collection_->SetDemuxerFactory(scoped_ptr<media::DemuxerFactory>( |
| 303 new media::DummyDemuxerFactory(has_video, has_audio, true)); | 306 new media::DummyDemuxerFactory(has_video, has_audio, true))); |
| 304 } | 307 } |
| 305 } | 308 } |
| 306 | 309 |
| 307 // Handle any volume changes that occured before load(). | 310 // Handle any volume changes that occured before load(). |
| 308 setVolume(GetClient()->volume()); | 311 setVolume(GetClient()->volume()); |
| 309 // Get the preload value. | 312 // Get the preload value. |
| 310 setPreload(GetClient()->preload()); | 313 setPreload(GetClient()->preload()); |
| 311 | 314 |
| 312 // Initialize the pipeline. | 315 // Initialize the pipeline. |
| 313 SetNetworkState(WebKit::WebMediaPlayer::Loading); | 316 SetNetworkState(WebKit::WebMediaPlayer::Loading); |
| 314 SetReadyState(WebKit::WebMediaPlayer::HaveNothing); | 317 SetReadyState(WebKit::WebMediaPlayer::HaveNothing); |
| 315 pipeline_->Start( | 318 pipeline_->Start( |
| 316 filter_collection_.release(), | 319 filter_collection_.Pass(), |
| 317 url.spec(), | 320 url.spec(), |
| 318 base::Bind(&WebMediaPlayerProxy::PipelineInitializationCallback, | 321 base::Bind(&WebMediaPlayerProxy::PipelineInitializationCallback, |
| 319 proxy_.get())); | 322 proxy_.get())); |
| 320 | 323 |
| 321 media_log_->AddEvent(media_log_->CreateLoadEvent(url.spec())); | 324 media_log_->AddEvent(media_log_->CreateLoadEvent(url.spec())); |
| 322 } | 325 } |
| 323 | 326 |
| 324 void WebMediaPlayerImpl::cancelLoad() { | 327 void WebMediaPlayerImpl::cancelLoad() { |
| 325 DCHECK_EQ(main_loop_, MessageLoop::current()); | 328 DCHECK_EQ(main_loop_, MessageLoop::current()); |
| 326 } | 329 } |
| (...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 934 return client_; | 937 return client_; |
| 935 } | 938 } |
| 936 | 939 |
| 937 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() { | 940 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() { |
| 938 DCHECK_EQ(main_loop_, MessageLoop::current()); | 941 DCHECK_EQ(main_loop_, MessageLoop::current()); |
| 939 incremented_externally_allocated_memory_ = true; | 942 incremented_externally_allocated_memory_ = true; |
| 940 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory); | 943 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory); |
| 941 } | 944 } |
| 942 | 945 |
| 943 } // namespace webkit_media | 946 } // namespace webkit_media |
| OLD | NEW |