| 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 "media/tools/player_wtl/movie.h" | 5 #include "media/tools/player_wtl/movie.h" |
| 6 | 6 |
| 7 #include "base/memory/singleton.h" | 7 #include "base/memory/singleton.h" |
| 8 #include "base/threading/platform_thread.h" | 8 #include "base/threading/platform_thread.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "media/audio/audio_manager.h" | 10 #include "media/audio/audio_manager.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 } | 65 } |
| 66 | 66 |
| 67 message_loop_factory_.reset(new media::MessageLoopFactoryImpl()); | 67 message_loop_factory_.reset(new media::MessageLoopFactoryImpl()); |
| 68 | 68 |
| 69 MessageLoop* pipeline_loop = | 69 MessageLoop* pipeline_loop = |
| 70 message_loop_factory_->GetMessageLoop("PipelineThread"); | 70 message_loop_factory_->GetMessageLoop("PipelineThread"); |
| 71 pipeline_ = new PipelineImpl(pipeline_loop, new media::MediaLog()); | 71 pipeline_ = new PipelineImpl(pipeline_loop, new media::MediaLog()); |
| 72 | 72 |
| 73 // Create filter collection. | 73 // Create filter collection. |
| 74 scoped_ptr<FilterCollection> collection(new FilterCollection()); | 74 scoped_ptr<FilterCollection> collection(new FilterCollection()); |
| 75 collection->SetDemuxerFactory(new FFmpegDemuxerFactory( | 75 collection->SetDemuxerFactory( |
| 76 new FileDataSourceFactory(), pipeline_loop)); | 76 scoped_ptr<DemuxerFactory>(new FFmpegDemuxerFactory( |
| 77 scoped_ptr<DataSourceFactory>(new FileDataSourceFactory()), |
| 78 pipeline_loop))); |
| 77 collection->AddAudioDecoder(new FFmpegAudioDecoder( | 79 collection->AddAudioDecoder(new FFmpegAudioDecoder( |
| 78 message_loop_factory_->GetMessageLoop("AudioDecoderThread"))); | 80 message_loop_factory_->GetMessageLoop("AudioDecoderThread"))); |
| 79 collection->AddVideoDecoder(new FFmpegVideoDecoder( | 81 collection->AddVideoDecoder(new FFmpegVideoDecoder( |
| 80 message_loop_factory_->GetMessageLoop("VideoDecoderThread"))); | 82 message_loop_factory_->GetMessageLoop("VideoDecoderThread"))); |
| 81 | 83 |
| 82 if (enable_audio_) { | 84 if (enable_audio_) { |
| 83 collection->AddAudioRenderer( | 85 collection->AddAudioRenderer( |
| 84 new ReferenceAudioRenderer(audio_manager_)); | 86 new ReferenceAudioRenderer(audio_manager_)); |
| 85 } else { | 87 } else { |
| 86 collection->AddAudioRenderer(new media::NullAudioRenderer()); | 88 collection->AddAudioRenderer(new media::NullAudioRenderer()); |
| 87 } | 89 } |
| 88 collection->AddVideoRenderer(video_renderer); | 90 collection->AddVideoRenderer(video_renderer); |
| 89 | 91 |
| 90 // Create and start our pipeline. | 92 // Create and start our pipeline. |
| 91 media::PipelineStatusNotification note; | 93 media::PipelineStatusNotification note; |
| 92 pipeline_->Start(collection.release(), WideToUTF8(std::wstring(url)), | 94 pipeline_->Start(collection.Pass(), WideToUTF8(string16(url)), |
| 93 note.Callback()); | 95 note.Callback()); |
| 94 // Wait until the pipeline is fully initialized. | 96 // Wait until the pipeline is fully initialized. |
| 95 note.Wait(); | 97 note.Wait(); |
| 96 if (note.status() != PIPELINE_OK) | 98 if (note.status() != PIPELINE_OK) |
| 97 return false; | 99 return false; |
| 98 pipeline_->SetPlaybackRate(play_rate_); | 100 pipeline_->SetPlaybackRate(play_rate_); |
| 99 return true; | 101 return true; |
| 100 } | 102 } |
| 101 | 103 |
| 102 void Movie::Play(float rate) { | 104 void Movie::Play(float rate) { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 void Movie::Close() { | 178 void Movie::Close() { |
| 177 if (pipeline_) { | 179 if (pipeline_) { |
| 178 pipeline_->Stop(media::PipelineStatusCB()); | 180 pipeline_->Stop(media::PipelineStatusCB()); |
| 179 pipeline_ = NULL; | 181 pipeline_ = NULL; |
| 180 } | 182 } |
| 181 | 183 |
| 182 message_loop_factory_.reset(); | 184 message_loop_factory_.reset(); |
| 183 } | 185 } |
| 184 | 186 |
| 185 } // namespace media | 187 } // namespace media |
| OLD | NEW |