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

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

Issue 1915443003: Replace scoped_ptr with std::unique_ptr in //media. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scopedptr-media-base
Patch Set: scopedptr-media: rebase Created 4 years, 7 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
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/ptr_util.h"
10 #include "base/memory/scoped_vector.h" 11 #include "base/memory/scoped_vector.h"
11 #include "media/base/cdm_context.h" 12 #include "media/base/cdm_context.h"
12 #include "media/base/media_log.h" 13 #include "media/base/media_log.h"
13 #include "media/base/media_tracks.h" 14 #include "media/base/media_tracks.h"
14 #include "media/base/test_data_util.h" 15 #include "media/base/test_data_util.h"
15 #include "media/filters/chunk_demuxer.h" 16 #include "media/filters/chunk_demuxer.h"
16 #if !defined(MEDIA_DISABLE_FFMPEG) 17 #if !defined(MEDIA_DISABLE_FFMPEG)
17 #include "media/filters/ffmpeg_audio_decoder.h" 18 #include "media/filters/ffmpeg_audio_decoder.h"
18 #include "media/filters/ffmpeg_demuxer.h" 19 #include "media/filters/ffmpeg_demuxer.h"
19 #include "media/filters/ffmpeg_video_decoder.h" 20 #include "media/filters/ffmpeg_video_decoder.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 75
75 void PipelineIntegrationTestBase::DemuxerEncryptedMediaInitDataCB( 76 void PipelineIntegrationTestBase::DemuxerEncryptedMediaInitDataCB(
76 EmeInitDataType type, 77 EmeInitDataType type,
77 const std::vector<uint8_t>& init_data) { 78 const std::vector<uint8_t>& init_data) {
78 DCHECK(!init_data.empty()); 79 DCHECK(!init_data.empty());
79 CHECK(!encrypted_media_init_data_cb_.is_null()); 80 CHECK(!encrypted_media_init_data_cb_.is_null());
80 encrypted_media_init_data_cb_.Run(type, init_data); 81 encrypted_media_init_data_cb_.Run(type, init_data);
81 } 82 }
82 83
83 void PipelineIntegrationTestBase::DemuxerMediaTracksUpdatedCB( 84 void PipelineIntegrationTestBase::DemuxerMediaTracksUpdatedCB(
84 scoped_ptr<MediaTracks> tracks) { 85 std::unique_ptr<MediaTracks> tracks) {
85 CHECK(tracks); 86 CHECK(tracks);
86 } 87 }
87 88
88 void PipelineIntegrationTestBase::OnEnded() { 89 void PipelineIntegrationTestBase::OnEnded() {
89 DCHECK(!ended_); 90 DCHECK(!ended_);
90 ended_ = true; 91 ended_ = true;
91 pipeline_status_ = PIPELINE_OK; 92 pipeline_status_ = PIPELINE_OK;
92 message_loop_.PostTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); 93 message_loop_.PostTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
93 } 94 }
94 95
(...skipping 12 matching lines...) Expand all
107 return pipeline_status_; 108 return pipeline_status_;
108 } 109 }
109 110
110 void PipelineIntegrationTestBase::OnError(PipelineStatus status) { 111 void PipelineIntegrationTestBase::OnError(PipelineStatus status) {
111 DCHECK_NE(status, PIPELINE_OK); 112 DCHECK_NE(status, PIPELINE_OK);
112 pipeline_status_ = status; 113 pipeline_status_ = status;
113 message_loop_.PostTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); 114 message_loop_.PostTask(FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
114 } 115 }
115 116
116 PipelineStatus PipelineIntegrationTestBase::StartInternal( 117 PipelineStatus PipelineIntegrationTestBase::StartInternal(
117 scoped_ptr<DataSource> data_source, 118 std::unique_ptr<DataSource> data_source,
118 CdmContext* cdm_context, 119 CdmContext* cdm_context,
119 uint8_t test_type) { 120 uint8_t test_type) {
120 hashing_enabled_ = test_type & kHashed; 121 hashing_enabled_ = test_type & kHashed;
121 clockless_playback_ = test_type & kClockless; 122 clockless_playback_ = test_type & kClockless;
122 123
123 EXPECT_CALL(*this, OnMetadata(_)) 124 EXPECT_CALL(*this, OnMetadata(_))
124 .Times(AtMost(1)) 125 .Times(AtMost(1))
125 .WillRepeatedly(SaveArg<0>(&metadata_)); 126 .WillRepeatedly(SaveArg<0>(&metadata_));
126 EXPECT_CALL(*this, OnBufferingStateChanged(BUFFERING_HAVE_ENOUGH)) 127 EXPECT_CALL(*this, OnBufferingStateChanged(BUFFERING_HAVE_ENOUGH))
127 .Times(AnyNumber()); 128 .Times(AnyNumber());
(...skipping 27 matching lines...) Expand all
155 base::Bind(&PipelineIntegrationTestBase::OnWaitingForDecryptionKey, 156 base::Bind(&PipelineIntegrationTestBase::OnWaitingForDecryptionKey,
156 base::Unretained(this))); 157 base::Unretained(this)));
157 message_loop_.Run(); 158 message_loop_.Run();
158 return pipeline_status_; 159 return pipeline_status_;
159 } 160 }
160 161
161 PipelineStatus PipelineIntegrationTestBase::StartWithFile( 162 PipelineStatus PipelineIntegrationTestBase::StartWithFile(
162 const std::string& filename, 163 const std::string& filename,
163 CdmContext* cdm_context, 164 CdmContext* cdm_context,
164 uint8_t test_type) { 165 uint8_t test_type) {
165 scoped_ptr<FileDataSource> file_data_source(new FileDataSource()); 166 std::unique_ptr<FileDataSource> file_data_source(new FileDataSource());
166 base::FilePath file_path(GetTestDataFilePath(filename)); 167 base::FilePath file_path(GetTestDataFilePath(filename));
167 CHECK(file_data_source->Initialize(file_path)) << "Is " << file_path.value() 168 CHECK(file_data_source->Initialize(file_path)) << "Is " << file_path.value()
168 << " missing?"; 169 << " missing?";
169 return StartInternal(std::move(file_data_source), cdm_context, test_type); 170 return StartInternal(std::move(file_data_source), cdm_context, test_type);
170 } 171 }
171 172
172 PipelineStatus PipelineIntegrationTestBase::Start(const std::string& filename) { 173 PipelineStatus PipelineIntegrationTestBase::Start(const std::string& filename) {
173 return StartWithFile(filename, nullptr, kNormal); 174 return StartWithFile(filename, nullptr, kNormal);
174 } 175 }
175 176
176 PipelineStatus PipelineIntegrationTestBase::Start(const std::string& filename, 177 PipelineStatus PipelineIntegrationTestBase::Start(const std::string& filename,
177 CdmContext* cdm_context) { 178 CdmContext* cdm_context) {
178 return StartWithFile(filename, cdm_context, kNormal); 179 return StartWithFile(filename, cdm_context, kNormal);
179 } 180 }
180 181
181 PipelineStatus PipelineIntegrationTestBase::Start(const std::string& filename, 182 PipelineStatus PipelineIntegrationTestBase::Start(const std::string& filename,
182 uint8_t test_type) { 183 uint8_t test_type) {
183 return StartWithFile(filename, nullptr, test_type); 184 return StartWithFile(filename, nullptr, test_type);
184 } 185 }
185 186
186 PipelineStatus PipelineIntegrationTestBase::Start(const uint8_t* data, 187 PipelineStatus PipelineIntegrationTestBase::Start(const uint8_t* data,
187 size_t size, 188 size_t size,
188 uint8_t test_type) { 189 uint8_t test_type) {
189 return StartInternal(make_scoped_ptr(new MemoryDataSource(data, size)), 190 return StartInternal(base::WrapUnique(new MemoryDataSource(data, size)),
190 nullptr, test_type); 191 nullptr, test_type);
191 } 192 }
192 193
193 void PipelineIntegrationTestBase::Play() { 194 void PipelineIntegrationTestBase::Play() {
194 pipeline_->SetPlaybackRate(1); 195 pipeline_->SetPlaybackRate(1);
195 } 196 }
196 197
197 void PipelineIntegrationTestBase::Pause() { 198 void PipelineIntegrationTestBase::Pause() {
198 pipeline_->SetPlaybackRate(0); 199 pipeline_->SetPlaybackRate(0);
199 } 200 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 message_loop_.PostDelayedTask( 264 message_loop_.PostDelayedTask(
264 FROM_HERE, 265 FROM_HERE,
265 base::Bind(&PipelineIntegrationTestBase::QuitAfterCurrentTimeTask, 266 base::Bind(&PipelineIntegrationTestBase::QuitAfterCurrentTimeTask,
266 base::Unretained(this), wait_time), 267 base::Unretained(this), wait_time),
267 base::TimeDelta::FromMilliseconds(10)); 268 base::TimeDelta::FromMilliseconds(10));
268 message_loop_.Run(); 269 message_loop_.Run();
269 return (pipeline_status_ == PIPELINE_OK); 270 return (pipeline_status_ == PIPELINE_OK);
270 } 271 }
271 272
272 void PipelineIntegrationTestBase::CreateDemuxer( 273 void PipelineIntegrationTestBase::CreateDemuxer(
273 scoped_ptr<DataSource> data_source) { 274 std::unique_ptr<DataSource> data_source) {
274 data_source_ = std::move(data_source); 275 data_source_ = std::move(data_source);
275 276
276 Demuxer::MediaTracksUpdatedCB tracks_updated_cb = 277 Demuxer::MediaTracksUpdatedCB tracks_updated_cb =
277 base::Bind(&PipelineIntegrationTestBase::DemuxerMediaTracksUpdatedCB, 278 base::Bind(&PipelineIntegrationTestBase::DemuxerMediaTracksUpdatedCB,
278 base::Unretained(this)); 279 base::Unretained(this));
279 280
280 #if !defined(MEDIA_DISABLE_FFMPEG) 281 #if !defined(MEDIA_DISABLE_FFMPEG)
281 demuxer_ = scoped_ptr<Demuxer>(new FFmpegDemuxer( 282 demuxer_ = std::unique_ptr<Demuxer>(new FFmpegDemuxer(
282 message_loop_.task_runner(), data_source_.get(), 283 message_loop_.task_runner(), data_source_.get(),
283 base::Bind(&PipelineIntegrationTestBase::DemuxerEncryptedMediaInitDataCB, 284 base::Bind(&PipelineIntegrationTestBase::DemuxerEncryptedMediaInitDataCB,
284 base::Unretained(this)), 285 base::Unretained(this)),
285 tracks_updated_cb, new MediaLog())); 286 tracks_updated_cb, new MediaLog()));
286 #endif 287 #endif
287 } 288 }
288 289
289 scoped_ptr<Renderer> PipelineIntegrationTestBase::CreateRenderer() { 290 std::unique_ptr<Renderer> PipelineIntegrationTestBase::CreateRenderer() {
290 ScopedVector<VideoDecoder> video_decoders; 291 ScopedVector<VideoDecoder> video_decoders;
291 #if !defined(MEDIA_DISABLE_LIBVPX) 292 #if !defined(MEDIA_DISABLE_LIBVPX)
292 video_decoders.push_back(new VpxVideoDecoder()); 293 video_decoders.push_back(new VpxVideoDecoder());
293 #endif // !defined(MEDIA_DISABLE_LIBVPX) 294 #endif // !defined(MEDIA_DISABLE_LIBVPX)
294 295
295 #if !defined(MEDIA_DISABLE_FFMPEG) 296 #if !defined(MEDIA_DISABLE_FFMPEG)
296 video_decoders.push_back(new FFmpegVideoDecoder()); 297 video_decoders.push_back(new FFmpegVideoDecoder());
297 #endif 298 #endif
298 299
299 // Simulate a 60Hz rendering sink. 300 // Simulate a 60Hz rendering sink.
300 video_sink_.reset(new NullVideoSink( 301 video_sink_.reset(new NullVideoSink(
301 clockless_playback_, base::TimeDelta::FromSecondsD(1.0 / 60), 302 clockless_playback_, base::TimeDelta::FromSecondsD(1.0 / 60),
302 base::Bind(&PipelineIntegrationTestBase::OnVideoFramePaint, 303 base::Bind(&PipelineIntegrationTestBase::OnVideoFramePaint,
303 base::Unretained(this)), 304 base::Unretained(this)),
304 message_loop_.task_runner())); 305 message_loop_.task_runner()));
305 306
306 // Disable frame dropping if hashing is enabled. 307 // Disable frame dropping if hashing is enabled.
307 scoped_ptr<VideoRenderer> video_renderer(new VideoRendererImpl( 308 std::unique_ptr<VideoRenderer> video_renderer(new VideoRendererImpl(
308 message_loop_.task_runner(), message_loop_.task_runner().get(), 309 message_loop_.task_runner(), message_loop_.task_runner().get(),
309 video_sink_.get(), std::move(video_decoders), false, nullptr, 310 video_sink_.get(), std::move(video_decoders), false, nullptr,
310 new MediaLog())); 311 new MediaLog()));
311 312
312 if (!clockless_playback_) { 313 if (!clockless_playback_) {
313 audio_sink_ = new NullAudioSink(message_loop_.task_runner()); 314 audio_sink_ = new NullAudioSink(message_loop_.task_runner());
314 } else { 315 } else {
315 clockless_audio_sink_ = new ClocklessAudioSink(); 316 clockless_audio_sink_ = new ClocklessAudioSink();
316 } 317 }
317 318
318 ScopedVector<AudioDecoder> audio_decoders; 319 ScopedVector<AudioDecoder> audio_decoders;
319 320
320 #if !defined(MEDIA_DISABLE_FFMPEG) 321 #if !defined(MEDIA_DISABLE_FFMPEG)
321 audio_decoders.push_back( 322 audio_decoders.push_back(
322 new FFmpegAudioDecoder(message_loop_.task_runner(), new MediaLog())); 323 new FFmpegAudioDecoder(message_loop_.task_runner(), new MediaLog()));
323 #endif 324 #endif
324 325
325 audio_decoders.push_back(new OpusAudioDecoder(message_loop_.task_runner())); 326 audio_decoders.push_back(new OpusAudioDecoder(message_loop_.task_runner()));
326 327
327 // Don't allow the audio renderer to resample buffers if hashing is enabled. 328 // Don't allow the audio renderer to resample buffers if hashing is enabled.
328 if (!hashing_enabled_) { 329 if (!hashing_enabled_) {
329 AudioParameters out_params(AudioParameters::AUDIO_PCM_LOW_LATENCY, 330 AudioParameters out_params(AudioParameters::AUDIO_PCM_LOW_LATENCY,
330 CHANNEL_LAYOUT_STEREO, 44100, 16, 512); 331 CHANNEL_LAYOUT_STEREO, 44100, 16, 512);
331 hardware_config_.UpdateOutputConfig(out_params); 332 hardware_config_.UpdateOutputConfig(out_params);
332 } 333 }
333 334
334 scoped_ptr<AudioRenderer> audio_renderer(new AudioRendererImpl( 335 std::unique_ptr<AudioRenderer> audio_renderer(new AudioRendererImpl(
335 message_loop_.task_runner(), 336 message_loop_.task_runner(),
336 (clockless_playback_) 337 (clockless_playback_)
337 ? static_cast<AudioRendererSink*>(clockless_audio_sink_.get()) 338 ? static_cast<AudioRendererSink*>(clockless_audio_sink_.get())
338 : audio_sink_.get(), 339 : audio_sink_.get(),
339 std::move(audio_decoders), hardware_config_, new MediaLog())); 340 std::move(audio_decoders), hardware_config_, new MediaLog()));
340 if (hashing_enabled_) { 341 if (hashing_enabled_) {
341 if (clockless_playback_) 342 if (clockless_playback_)
342 clockless_audio_sink_->StartAudioHashForTesting(); 343 clockless_audio_sink_->StartAudioHashForTesting();
343 else 344 else
344 audio_sink_->StartAudioHashForTesting(); 345 audio_sink_->StartAudioHashForTesting();
345 } 346 }
346 347
347 scoped_ptr<RendererImpl> renderer_impl( 348 std::unique_ptr<RendererImpl> renderer_impl(
348 new RendererImpl(message_loop_.task_runner(), std::move(audio_renderer), 349 new RendererImpl(message_loop_.task_runner(), std::move(audio_renderer),
349 std::move(video_renderer))); 350 std::move(video_renderer)));
350 351
351 // Prevent non-deterministic buffering state callbacks from firing (e.g., slow 352 // Prevent non-deterministic buffering state callbacks from firing (e.g., slow
352 // machine, valgrind). 353 // machine, valgrind).
353 renderer_impl->DisableUnderflowForTesting(); 354 renderer_impl->DisableUnderflowForTesting();
354 355
355 if (clockless_playback_) 356 if (clockless_playback_)
356 renderer_impl->EnableClocklessVideoPlaybackForTesting(); 357 renderer_impl->EnableClocklessVideoPlaybackForTesting();
357 358
(...skipping 30 matching lines...) Expand all
388 DCHECK(clockless_playback_); 389 DCHECK(clockless_playback_);
389 return clockless_audio_sink_->render_time(); 390 return clockless_audio_sink_->render_time();
390 } 391 }
391 392
392 base::TimeTicks DummyTickClock::NowTicks() { 393 base::TimeTicks DummyTickClock::NowTicks() {
393 now_ += base::TimeDelta::FromSeconds(60); 394 now_ += base::TimeDelta::FromSeconds(60);
394 return now_; 395 return now_;
395 } 396 }
396 397
397 } // namespace media 398 } // namespace media
OLDNEW
« no previous file with comments | « media/test/pipeline_integration_test_base.h ('k') | media/video/gpu_memory_buffer_video_frame_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698