| 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 "media/tools/player_wtl/movie.h" | 5 #include "media/tools/player_wtl/movie.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/singleton.h" | 8 #include "base/memory/singleton.h" |
| 9 #include "base/threading/platform_thread.h" | 9 #include "base/threading/platform_thread.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 } | 52 } |
| 53 | 53 |
| 54 bool Movie::Open(const wchar_t* url, VideoRendererBase* video_renderer) { | 54 bool Movie::Open(const wchar_t* url, VideoRendererBase* video_renderer) { |
| 55 // Close previous movie. | 55 // Close previous movie. |
| 56 if (pipeline_) { | 56 if (pipeline_) { |
| 57 Close(); | 57 Close(); |
| 58 } | 58 } |
| 59 | 59 |
| 60 message_loop_factory_.reset(new media::MessageLoopFactory()); | 60 message_loop_factory_.reset(new media::MessageLoopFactory()); |
| 61 | 61 |
| 62 MessageLoop* pipeline_loop = | 62 scoped_refptr<base::MessageLoopProxy> pipeline_loop = |
| 63 message_loop_factory_->GetMessageLoop("PipelineThread"); | 63 message_loop_factory_->GetMessageLoop( |
| 64 media::MessageLoopFactory::kPipeline); |
| 64 pipeline_ = new Pipeline(pipeline_loop, new media::MediaLog()); | 65 pipeline_ = new Pipeline(pipeline_loop, new media::MediaLog()); |
| 65 | 66 |
| 66 // Open the file. | 67 // Open the file. |
| 67 std::string url_utf8 = WideToUTF8(string16(url)); | 68 std::string url_utf8 = WideToUTF8(string16(url)); |
| 68 scoped_refptr<FileDataSource> data_source = new FileDataSource(); | 69 scoped_refptr<FileDataSource> data_source = new FileDataSource(); |
| 69 if (!data_source->Initialize(url_utf8)) { | 70 if (!data_source->Initialize(url_utf8)) { |
| 70 return false; | 71 return false; |
| 71 } | 72 } |
| 72 | 73 |
| 73 // Create filter collection. | 74 // Create filter collection. |
| 74 scoped_ptr<FilterCollection> collection(new FilterCollection()); | 75 scoped_ptr<FilterCollection> collection(new FilterCollection()); |
| 75 collection->SetDemuxer(new FFmpegDemuxer(pipeline_loop, data_source)); | 76 collection->SetDemuxer(new FFmpegDemuxer(pipeline_loop, data_source)); |
| 76 collection->AddAudioDecoder(new FFmpegAudioDecoder( | 77 collection->AddAudioDecoder(new FFmpegAudioDecoder( |
| 77 base::Bind(&MessageLoopFactory::GetMessageLoop, | 78 base::Bind(&MessageLoopFactory::GetMessageLoop, |
| 78 base::Unretained(message_loop_factory_.get()), | 79 base::Unretained(message_loop_factory_.get()), |
| 79 "AudioDecoderThread"))); | 80 media::MessageLoopFactory::kAudioDecoder))); |
| 80 collection->AddVideoDecoder(new FFmpegVideoDecoder( | 81 collection->AddVideoDecoder(new FFmpegVideoDecoder( |
| 81 base::Bind(&MessageLoopFactory::GetMessageLoop, | 82 base::Bind(&MessageLoopFactory::GetMessageLoop, |
| 82 base::Unretained(message_loop_factory_.get()), | 83 base::Unretained(message_loop_factory_.get()), |
| 83 "VideoDecoderThread"), | 84 media::MessageLoopFactory::kVideoDecoder), |
| 84 NULL)); | 85 NULL)); |
| 85 | 86 |
| 86 // TODO(vrk): Re-enabled audio. (crbug.com/112159) | 87 // TODO(vrk): Re-enabled audio. (crbug.com/112159) |
| 87 collection->AddAudioRenderer( | 88 collection->AddAudioRenderer( |
| 88 new media::AudioRendererImpl(new media::NullAudioSink())); | 89 new media::AudioRendererImpl(new media::NullAudioSink())); |
| 89 collection->AddVideoRenderer(video_renderer); | 90 collection->AddVideoRenderer(video_renderer); |
| 90 | 91 |
| 91 // Create and start our pipeline. | 92 // Create and start our pipeline. |
| 92 media::PipelineStatusNotification note; | 93 media::PipelineStatusNotification note; |
| 93 pipeline_->Start( | 94 pipeline_->Start( |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 void Movie::Close() { | 181 void Movie::Close() { |
| 181 if (pipeline_) { | 182 if (pipeline_) { |
| 182 pipeline_->Stop(base::Closure()); | 183 pipeline_->Stop(base::Closure()); |
| 183 pipeline_ = NULL; | 184 pipeline_ = NULL; |
| 184 } | 185 } |
| 185 | 186 |
| 186 message_loop_factory_.reset(); | 187 message_loop_factory_.reset(); |
| 187 } | 188 } |
| 188 | 189 |
| 189 } // namespace media | 190 } // namespace media |
| OLD | NEW |