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" |
11 #include "media/audio/audio_manager.h" | 11 #include "media/audio/audio_manager.h" |
12 #include "media/base/filter_collection.h" | 12 #include "media/base/filter_collection.h" |
13 #include "media/base/media_log.h" | 13 #include "media/base/media_log.h" |
14 #include "media/base/message_loop_factory.h" | 14 #include "media/base/message_loop_factory.h" |
15 #include "media/base/pipeline.h" | 15 #include "media/base/pipeline.h" |
16 #include "media/filters/ffmpeg_audio_decoder.h" | 16 #include "media/filters/ffmpeg_audio_decoder.h" |
17 #include "media/filters/ffmpeg_demuxer_factory.h" | 17 #include "media/filters/ffmpeg_demuxer.h" |
18 #include "media/filters/ffmpeg_video_decoder.h" | 18 #include "media/filters/ffmpeg_video_decoder.h" |
19 #include "media/filters/file_data_source.h" | 19 #include "media/filters/file_data_source.h" |
20 #include "media/filters/null_audio_renderer.h" | 20 #include "media/filters/null_audio_renderer.h" |
21 #include "media/filters/video_renderer_base.h" | 21 #include "media/filters/video_renderer_base.h" |
22 | 22 |
23 using media::FFmpegAudioDecoder; | 23 using media::FFmpegAudioDecoder; |
24 using media::FFmpegDemuxerFactory; | 24 using media::FFmpegDemuxer; |
25 using media::FFmpegVideoDecoder; | 25 using media::FFmpegVideoDecoder; |
26 using media::FileDataSource; | 26 using media::FileDataSource; |
27 using media::FilterCollection; | 27 using media::FilterCollection; |
28 using media::Pipeline; | 28 using media::Pipeline; |
29 | 29 |
30 namespace media { | 30 namespace media { |
31 | 31 |
32 Movie::Movie() | 32 Movie::Movie() |
33 : audio_manager_(AudioManager::Create()), | 33 : audio_manager_(AudioManager::Create()), |
34 enable_audio_(false), | 34 enable_audio_(false), |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 | 71 |
72 // Open the file. | 72 // Open the file. |
73 std::string url_utf8 = WideToUTF8(string16(url)); | 73 std::string url_utf8 = WideToUTF8(string16(url)); |
74 scoped_refptr<FileDataSource> data_source = new FileDataSource(); | 74 scoped_refptr<FileDataSource> data_source = new FileDataSource(); |
75 if (data_source->Initialize(url_utf8) != PIPELINE_OK) { | 75 if (data_source->Initialize(url_utf8) != PIPELINE_OK) { |
76 return false; | 76 return false; |
77 } | 77 } |
78 | 78 |
79 // Create filter collection. | 79 // Create filter collection. |
80 scoped_ptr<FilterCollection> collection(new FilterCollection()); | 80 scoped_ptr<FilterCollection> collection(new FilterCollection()); |
81 collection->SetDemuxerFactory(scoped_ptr<DemuxerFactory>( | 81 collection->SetDemuxer(new FFmpegDemuxer( |
82 new FFmpegDemuxerFactory(data_source, pipeline_loop))); | 82 pipeline_loop, data_source, true)); |
83 collection->AddAudioDecoder(new FFmpegAudioDecoder( | 83 collection->AddAudioDecoder(new FFmpegAudioDecoder( |
84 base::Bind(&MessageLoopFactory::GetMessageLoop, | 84 base::Bind(&MessageLoopFactory::GetMessageLoop, |
85 base::Unretained(message_loop_factory_.get()), | 85 base::Unretained(message_loop_factory_.get()), |
86 "AudioDecoderThread"))); | 86 "AudioDecoderThread"))); |
87 collection->AddVideoDecoder(new FFmpegVideoDecoder( | 87 collection->AddVideoDecoder(new FFmpegVideoDecoder( |
88 base::Bind(&MessageLoopFactory::GetMessageLoop, | 88 base::Bind(&MessageLoopFactory::GetMessageLoop, |
89 base::Unretained(message_loop_factory_.get()), | 89 base::Unretained(message_loop_factory_.get()), |
90 "VideoDecoderThread"))); | 90 "VideoDecoderThread"))); |
91 | 91 |
92 // TODO(vrk): Re-enabled audio. (crbug.com/112159) | 92 // TODO(vrk): Re-enabled audio. (crbug.com/112159) |
93 collection->AddAudioRenderer(new media::NullAudioRenderer()); | 93 collection->AddAudioRenderer(new media::NullAudioRenderer()); |
94 collection->AddVideoRenderer(video_renderer); | 94 collection->AddVideoRenderer(video_renderer); |
95 | 95 |
96 // Create and start our pipeline. | 96 // Create and start our pipeline. |
97 media::PipelineStatusNotification note; | 97 media::PipelineStatusNotification note; |
98 pipeline_->Start( | 98 pipeline_->Start( |
99 collection.Pass(), | 99 collection.Pass(), |
100 url_utf8, | |
101 media::PipelineStatusCB(), | 100 media::PipelineStatusCB(), |
102 media::PipelineStatusCB(), | 101 media::PipelineStatusCB(), |
103 media::NetworkEventCB(), | 102 media::NetworkEventCB(), |
104 note.Callback()); | 103 note.Callback()); |
105 | 104 |
106 // Wait until the pipeline is fully initialized. | 105 // Wait until the pipeline is fully initialized. |
107 note.Wait(); | 106 note.Wait(); |
108 if (note.status() != PIPELINE_OK) | 107 if (note.status() != PIPELINE_OK) |
109 return false; | 108 return false; |
110 pipeline_->SetPlaybackRate(play_rate_); | 109 pipeline_->SetPlaybackRate(play_rate_); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 void Movie::Close() { | 186 void Movie::Close() { |
188 if (pipeline_) { | 187 if (pipeline_) { |
189 pipeline_->Stop(base::Closure()); | 188 pipeline_->Stop(base::Closure()); |
190 pipeline_ = NULL; | 189 pipeline_ = NULL; |
191 } | 190 } |
192 | 191 |
193 message_loop_factory_.reset(); | 192 message_loop_factory_.reset(); |
194 } | 193 } |
195 | 194 |
196 } // namespace media | 195 } // namespace media |
OLD | NEW |