Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(269)

Side by Side Diff: media/test/pipeline_integration_test_base.cc

Issue 1658303002: Create abstract interface for media::Pipeline. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix FakeMediaSource includes. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/test/pipeline_integration_test_base.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/test/pipeline_integration_test_base.h" 5 #include "media/test/pipeline_integration_test_base.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/scoped_vector.h" 10 #include "base/memory/scoped_vector.h"
(...skipping 23 matching lines...) Expand all
34 using ::testing::SaveArg; 34 using ::testing::SaveArg;
35 35
36 namespace media { 36 namespace media {
37 37
38 const char kNullVideoHash[] = "d41d8cd98f00b204e9800998ecf8427e"; 38 const char kNullVideoHash[] = "d41d8cd98f00b204e9800998ecf8427e";
39 const char kNullAudioHash[] = "0.00,0.00,0.00,0.00,0.00,0.00,"; 39 const char kNullAudioHash[] = "0.00,0.00,0.00,0.00,0.00,0.00,";
40 40
41 PipelineIntegrationTestBase::PipelineIntegrationTestBase() 41 PipelineIntegrationTestBase::PipelineIntegrationTestBase()
42 : hashing_enabled_(false), 42 : hashing_enabled_(false),
43 clockless_playback_(false), 43 clockless_playback_(false),
44 pipeline_(new Pipeline(message_loop_.task_runner(), new MediaLog())), 44 pipeline_(new PipelineImpl(message_loop_.task_runner(), new MediaLog())),
45 ended_(false), 45 ended_(false),
46 pipeline_status_(PIPELINE_OK), 46 pipeline_status_(PIPELINE_OK),
47 last_video_frame_format_(PIXEL_FORMAT_UNKNOWN), 47 last_video_frame_format_(PIXEL_FORMAT_UNKNOWN),
48 last_video_frame_color_space_(COLOR_SPACE_UNSPECIFIED), 48 last_video_frame_color_space_(COLOR_SPACE_UNSPECIFIED),
49 hardware_config_(AudioParameters(), AudioParameters()) { 49 hardware_config_(AudioParameters(), AudioParameters()) {
50 base::MD5Init(&md5_context_); 50 base::MD5Init(&md5_context_);
51 } 51 }
52 52
53 PipelineIntegrationTestBase::~PipelineIntegrationTestBase() { 53 PipelineIntegrationTestBase::~PipelineIntegrationTestBase() {
54 if (!pipeline_->IsRunning()) 54 if (!pipeline_->IsRunning())
55 return; 55 return;
56 56
57 Stop(); 57 Stop();
58 } 58 }
59 59
60 void PipelineIntegrationTestBase::OnSeeked(base::TimeDelta seek_time, 60 void PipelineIntegrationTestBase::OnSeeked(base::TimeDelta seek_time,
61 PipelineStatus status) { 61 PipelineStatus status) {
62 EXPECT_EQ(seek_time, pipeline_->GetMediaTime()); 62 EXPECT_EQ(seek_time, pipeline_->GetMediaTime());
63 pipeline_status_ = status; 63 pipeline_status_ = status;
64 } 64 }
65 65
66 void PipelineIntegrationTestBase::OnStatusCallback( 66 void PipelineIntegrationTestBase::OnStatusCallback(PipelineStatus status) {
67 PipelineStatus status) {
68 pipeline_status_ = status; 67 pipeline_status_ = status;
69 message_loop_.PostTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); 68 message_loop_.PostTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
70 } 69 }
71 70
72 void PipelineIntegrationTestBase::DemuxerEncryptedMediaInitDataCB( 71 void PipelineIntegrationTestBase::DemuxerEncryptedMediaInitDataCB(
73 EmeInitDataType type, 72 EmeInitDataType type,
74 const std::vector<uint8_t>& init_data) { 73 const std::vector<uint8_t>& init_data) {
75 DCHECK(!init_data.empty()); 74 DCHECK(!init_data.empty());
76 CHECK(!encrypted_media_init_data_cb_.is_null()); 75 CHECK(!encrypted_media_init_data_cb_.is_null());
77 encrypted_media_init_data_cb_.Run(type, init_data); 76 encrypted_media_init_data_cb_.Run(type, init_data);
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 216
218 bool PipelineIntegrationTestBase::WaitUntilCurrentTimeIsAfter( 217 bool PipelineIntegrationTestBase::WaitUntilCurrentTimeIsAfter(
219 const base::TimeDelta& wait_time) { 218 const base::TimeDelta& wait_time) {
220 DCHECK(pipeline_->IsRunning()); 219 DCHECK(pipeline_->IsRunning());
221 DCHECK_GT(pipeline_->GetPlaybackRate(), 0); 220 DCHECK_GT(pipeline_->GetPlaybackRate(), 0);
222 DCHECK(wait_time <= pipeline_->GetMediaDuration()); 221 DCHECK(wait_time <= pipeline_->GetMediaDuration());
223 222
224 message_loop_.PostDelayedTask( 223 message_loop_.PostDelayedTask(
225 FROM_HERE, 224 FROM_HERE,
226 base::Bind(&PipelineIntegrationTestBase::QuitAfterCurrentTimeTask, 225 base::Bind(&PipelineIntegrationTestBase::QuitAfterCurrentTimeTask,
227 base::Unretained(this), 226 base::Unretained(this), wait_time),
228 wait_time),
229 base::TimeDelta::FromMilliseconds(10)); 227 base::TimeDelta::FromMilliseconds(10));
230 message_loop_.Run(); 228 message_loop_.Run();
231 return (pipeline_status_ == PIPELINE_OK); 229 return (pipeline_status_ == PIPELINE_OK);
232 } 230 }
233 231
234 void PipelineIntegrationTestBase::CreateDemuxer(const std::string& filename) { 232 void PipelineIntegrationTestBase::CreateDemuxer(const std::string& filename) {
235 FileDataSource* file_data_source = new FileDataSource(); 233 FileDataSource* file_data_source = new FileDataSource();
236 base::FilePath file_path(GetTestDataFilePath(filename)); 234 base::FilePath file_path(GetTestDataFilePath(filename));
237 CHECK(file_data_source->Initialize(file_path)) << "Is " << file_path.value() 235 CHECK(file_data_source->Initialize(file_path)) << "Is " << file_path.value()
238 << " missing?"; 236 << " missing?";
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 clockless_audio_sink_ = new ClocklessAudioSink(); 276 clockless_audio_sink_ = new ClocklessAudioSink();
279 } 277 }
280 278
281 ScopedVector<AudioDecoder> audio_decoders; 279 ScopedVector<AudioDecoder> audio_decoders;
282 280
283 #if !defined(MEDIA_DISABLE_FFMPEG) 281 #if !defined(MEDIA_DISABLE_FFMPEG)
284 audio_decoders.push_back( 282 audio_decoders.push_back(
285 new FFmpegAudioDecoder(message_loop_.task_runner(), new MediaLog())); 283 new FFmpegAudioDecoder(message_loop_.task_runner(), new MediaLog()));
286 #endif 284 #endif
287 285
288 audio_decoders.push_back( 286 audio_decoders.push_back(new OpusAudioDecoder(message_loop_.task_runner()));
289 new OpusAudioDecoder(message_loop_.task_runner()));
290 287
291 // Don't allow the audio renderer to resample buffers if hashing is enabled. 288 // Don't allow the audio renderer to resample buffers if hashing is enabled.
292 if (!hashing_enabled_) { 289 if (!hashing_enabled_) {
293 AudioParameters out_params(AudioParameters::AUDIO_PCM_LOW_LATENCY, 290 AudioParameters out_params(AudioParameters::AUDIO_PCM_LOW_LATENCY,
294 CHANNEL_LAYOUT_STEREO, 291 CHANNEL_LAYOUT_STEREO, 44100, 16, 512);
295 44100,
296 16,
297 512);
298 hardware_config_.UpdateOutputConfig(out_params); 292 hardware_config_.UpdateOutputConfig(out_params);
299 } 293 }
300 294
301 scoped_ptr<AudioRenderer> audio_renderer(new AudioRendererImpl( 295 scoped_ptr<AudioRenderer> audio_renderer(new AudioRendererImpl(
302 message_loop_.task_runner(), 296 message_loop_.task_runner(),
303 (clockless_playback_) 297 (clockless_playback_)
304 ? static_cast<AudioRendererSink*>(clockless_audio_sink_.get()) 298 ? static_cast<AudioRendererSink*>(clockless_audio_sink_.get())
305 : audio_sink_.get(), 299 : audio_sink_.get(),
306 std::move(audio_decoders), hardware_config_, new MediaLog())); 300 std::move(audio_decoders), hardware_config_, new MediaLog()));
307 if (hashing_enabled_) { 301 if (hashing_enabled_) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 DCHECK(clockless_playback_); 349 DCHECK(clockless_playback_);
356 return clockless_audio_sink_->render_time(); 350 return clockless_audio_sink_->render_time();
357 } 351 }
358 352
359 base::TimeTicks DummyTickClock::NowTicks() { 353 base::TimeTicks DummyTickClock::NowTicks() {
360 now_ += base::TimeDelta::FromSeconds(60); 354 now_ += base::TimeDelta::FromSeconds(60);
361 return now_; 355 return now_;
362 } 356 }
363 357
364 } // namespace media 358 } // namespace media
OLDNEW
« no previous file with comments | « media/test/pipeline_integration_test_base.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698