OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 | 75 |
76 void SetUp() override { | 76 void SetUp() override { |
77 CastMediaShlib::Initialize( | 77 CastMediaShlib::Initialize( |
78 base::CommandLine::ForCurrentProcess()->argv()); | 78 base::CommandLine::ForCurrentProcess()->argv()); |
79 } | 79 } |
80 | 80 |
81 void TearDown() override { | 81 void TearDown() override { |
82 CastMediaShlib::Finalize(); | 82 CastMediaShlib::Finalize(); |
83 } | 83 } |
84 | 84 |
85 void ConfigureForFile(std::string filename); | 85 void ConfigureForFile(const std::string& filename); |
86 void ConfigureForAudioOnly(std::string filename); | 86 void ConfigureForAudioOnly(const std::string& filename); |
87 void ConfigureForVideoOnly(std::string filename, bool raw_h264); | 87 void ConfigureForVideoOnly(const std::string& filename, bool raw_h264); |
88 | 88 |
89 // Pattern loops, waiting >= pattern[i].delay against media clock between | 89 // Pattern loops, waiting >= pattern[i].delay against media clock between |
90 // pauses, then pausing for >= pattern[i].length against MessageLoop | 90 // pauses, then pausing for >= pattern[i].length against MessageLoop |
91 // A pause with delay <0 signals to stop sequence and do not loop | 91 // A pause with delay <0 signals to stop sequence and do not loop |
92 void SetPausePattern(const std::vector<PauseInfo> pattern); | 92 void SetPausePattern(const std::vector<PauseInfo> pattern); |
93 | 93 |
94 // Adds a pause to the end of pause pattern | 94 // Adds a pause to the end of pause pattern |
95 void AddPause(base::TimeDelta delay, base::TimeDelta length); | 95 void AddPause(base::TimeDelta delay, base::TimeDelta length); |
96 | 96 |
97 void Start(); | 97 void Start(); |
98 | 98 |
99 private: | 99 private: |
100 void Initialize(); | 100 void Initialize(); |
101 | 101 |
102 void LoadAudioStream(std::string filename); | 102 void LoadAudioStream(const std::string& filename); |
103 void LoadVideoStream(std::string filename, bool raw_h264); | 103 void LoadVideoStream(const std::string& filename, bool raw_h264); |
104 | 104 |
105 void MonitorLoop(); | 105 void MonitorLoop(); |
106 | 106 |
107 void OnPauseCompleted(); | 107 void OnPauseCompleted(); |
108 | 108 |
109 void OnEos(MediaComponentDeviceFeederForTest* device_feeder); | 109 void OnEos(MediaComponentDeviceFeederForTest* device_feeder); |
110 | 110 |
111 scoped_ptr<TaskRunnerImpl> task_runner_; | 111 scoped_ptr<TaskRunnerImpl> task_runner_; |
112 scoped_ptr<MediaPipelineBackend> backend_; | 112 scoped_ptr<MediaPipelineBackend> backend_; |
113 MediaClockDevice* media_clock_device_; | 113 MediaClockDevice* media_clock_device_; |
(...skipping 22 matching lines...) Expand all Loading... |
136 void AudioVideoPipelineDeviceTest::AddPause(base::TimeDelta delay, | 136 void AudioVideoPipelineDeviceTest::AddPause(base::TimeDelta delay, |
137 base::TimeDelta length) { | 137 base::TimeDelta length) { |
138 pause_pattern_.push_back(PauseInfo(delay, length)); | 138 pause_pattern_.push_back(PauseInfo(delay, length)); |
139 } | 139 } |
140 | 140 |
141 void AudioVideoPipelineDeviceTest::SetPausePattern( | 141 void AudioVideoPipelineDeviceTest::SetPausePattern( |
142 const std::vector<PauseInfo> pattern) { | 142 const std::vector<PauseInfo> pattern) { |
143 pause_pattern_ = pattern; | 143 pause_pattern_ = pattern; |
144 } | 144 } |
145 | 145 |
146 void AudioVideoPipelineDeviceTest::ConfigureForAudioOnly(std::string filename) { | 146 void AudioVideoPipelineDeviceTest::ConfigureForAudioOnly( |
| 147 const std::string& filename) { |
147 Initialize(); | 148 Initialize(); |
148 LoadAudioStream(filename); | 149 LoadAudioStream(filename); |
149 } | 150 } |
150 | 151 |
151 void AudioVideoPipelineDeviceTest::ConfigureForVideoOnly(std::string filename, | 152 void AudioVideoPipelineDeviceTest::ConfigureForVideoOnly( |
152 bool raw_h264) { | 153 const std::string& filename, |
| 154 bool raw_h264) { |
153 Initialize(); | 155 Initialize(); |
154 LoadVideoStream(filename, raw_h264); | 156 LoadVideoStream(filename, raw_h264); |
155 } | 157 } |
156 | 158 |
157 void AudioVideoPipelineDeviceTest::ConfigureForFile(std::string filename) { | 159 void AudioVideoPipelineDeviceTest::ConfigureForFile( |
| 160 const std::string& filename) { |
158 Initialize(); | 161 Initialize(); |
159 LoadVideoStream(filename, false /* raw_h264 */); | 162 LoadVideoStream(filename, false /* raw_h264 */); |
160 LoadAudioStream(filename); | 163 LoadAudioStream(filename); |
161 } | 164 } |
162 | 165 |
163 void AudioVideoPipelineDeviceTest::LoadAudioStream(std::string filename) { | 166 void AudioVideoPipelineDeviceTest::LoadAudioStream( |
| 167 const std::string& filename) { |
164 base::FilePath file_path = GetTestDataFilePath(filename); | 168 base::FilePath file_path = GetTestDataFilePath(filename); |
165 DemuxResult demux_result = FFmpegDemuxForTest(file_path, true /* audio */); | 169 DemuxResult demux_result = FFmpegDemuxForTest(file_path, true /* audio */); |
166 BufferList frames = demux_result.frames; | 170 BufferList frames = demux_result.frames; |
167 | 171 |
168 AudioPipelineDevice* audio_pipeline_device = backend_->GetAudio(); | 172 AudioPipelineDevice* audio_pipeline_device = backend_->GetAudio(); |
169 | 173 |
170 bool success = audio_pipeline_device->SetConfig( | 174 bool success = audio_pipeline_device->SetConfig( |
171 DecoderConfigAdapter::ToCastAudioConfig(kPrimary, | 175 DecoderConfigAdapter::ToCastAudioConfig(kPrimary, |
172 demux_result.audio_config)); | 176 demux_result.audio_config)); |
173 ASSERT_TRUE(success); | 177 ASSERT_TRUE(success); |
174 | 178 |
175 VLOG(2) << "Got " << frames.size() << " audio input frames"; | 179 VLOG(2) << "Got " << frames.size() << " audio input frames"; |
176 | 180 |
177 frames.push_back( | 181 frames.push_back( |
178 scoped_refptr<DecoderBufferBase>( | 182 scoped_refptr<DecoderBufferBase>( |
179 new DecoderBufferAdapter(::media::DecoderBuffer::CreateEOSBuffer()))); | 183 new DecoderBufferAdapter(::media::DecoderBuffer::CreateEOSBuffer()))); |
180 | 184 |
181 MediaComponentDeviceFeederForTest* device_feeder = | 185 MediaComponentDeviceFeederForTest* device_feeder = |
182 new MediaComponentDeviceFeederForTest(audio_pipeline_device, frames); | 186 new MediaComponentDeviceFeederForTest(audio_pipeline_device, frames); |
183 device_feeder->Initialize(base::Bind(&AudioVideoPipelineDeviceTest::OnEos, | 187 device_feeder->Initialize(base::Bind(&AudioVideoPipelineDeviceTest::OnEos, |
184 base::Unretained(this), | 188 base::Unretained(this), |
185 device_feeder)); | 189 device_feeder)); |
186 component_device_feeders_.push_back(device_feeder); | 190 component_device_feeders_.push_back(device_feeder); |
187 } | 191 } |
188 | 192 |
189 void AudioVideoPipelineDeviceTest::LoadVideoStream(std::string filename, | 193 void AudioVideoPipelineDeviceTest::LoadVideoStream(const std::string& filename, |
190 bool raw_h264) { | 194 bool raw_h264) { |
191 BufferList frames; | 195 BufferList frames; |
192 VideoConfig video_config; | 196 VideoConfig video_config; |
193 | 197 |
194 if (raw_h264) { | 198 if (raw_h264) { |
195 base::FilePath file_path = GetTestDataFilePath(filename); | 199 base::FilePath file_path = GetTestDataFilePath(filename); |
196 base::MemoryMappedFile video_stream; | 200 base::MemoryMappedFile video_stream; |
197 ASSERT_TRUE(video_stream.Initialize(file_path)) | 201 ASSERT_TRUE(video_stream.Initialize(file_path)) |
198 << "Couldn't open stream file: " << file_path.MaybeAsASCII(); | 202 << "Couldn't open stream file: " << file_path.MaybeAsASCII(); |
199 frames = H264SegmenterForTest(video_stream.data(), video_stream.length()); | 203 frames = H264SegmenterForTest(video_stream.data(), video_stream.length()); |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 TEST_F(AudioVideoPipelineDeviceTest, WebmPlayback) { | 387 TEST_F(AudioVideoPipelineDeviceTest, WebmPlayback) { |
384 scoped_ptr<base::MessageLoop> message_loop(new base::MessageLoop()); | 388 scoped_ptr<base::MessageLoop> message_loop(new base::MessageLoop()); |
385 | 389 |
386 ConfigureForFile("bear-640x360.webm"); | 390 ConfigureForFile("bear-640x360.webm"); |
387 Start(); | 391 Start(); |
388 message_loop->Run(); | 392 message_loop->Run(); |
389 } | 393 } |
390 | 394 |
391 } // namespace media | 395 } // namespace media |
392 } // namespace chromecast | 396 } // namespace chromecast |
OLD | NEW |