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

Side by Side Diff: media/base/android/media_codec_decoder_unittest.cc

Issue 1906423005: Replace scoped_ptr with std::unique_ptr in //media/base. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scopedptr-media-base: android 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
« no previous file with comments | « media/base/android/media_codec_decoder.h ('k') | media/base/android/media_codec_player.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <memory>
5 #include <utility> 6 #include <utility>
6 7
7 #include "base/bind.h" 8 #include "base/bind.h"
8 #include "base/logging.h" 9 #include "base/logging.h"
9 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/ptr_util.h"
10 #include "base/thread_task_runner_handle.h" 12 #include "base/thread_task_runner_handle.h"
11 #include "base/timer/timer.h" 13 #include "base/timer/timer.h"
12 #include "media/base/android/audio_media_codec_decoder.h" 14 #include "media/base/android/audio_media_codec_decoder.h"
13 #include "media/base/android/media_codec_util.h" 15 #include "media/base/android/media_codec_util.h"
14 #include "media/base/android/media_statistics.h" 16 #include "media/base/android/media_statistics.h"
15 #include "media/base/android/sdk_media_codec_bridge.h" 17 #include "media/base/android/sdk_media_codec_bridge.h"
16 #include "media/base/android/test_data_factory.h" 18 #include "media/base/android/test_data_factory.h"
17 #include "media/base/android/test_statistics.h" 19 #include "media/base/android/test_statistics.h"
18 #include "media/base/android/video_media_codec_decoder.h" 20 #include "media/base/android/video_media_codec_decoder.h"
19 #include "media/base/timestamp_constants.h" 21 #include "media/base/timestamp_constants.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 protected: 152 protected:
151 typedef base::Callback<bool()> Predicate; 153 typedef base::Callback<bool()> Predicate;
152 154
153 typedef base::Callback<void(const DemuxerData&)> DataAvailableCallback; 155 typedef base::Callback<void(const DemuxerData&)> DataAvailableCallback;
154 156
155 // Waits for condition to become true or for timeout to expire. 157 // Waits for condition to become true or for timeout to expire.
156 // Returns true if the condition becomes true. 158 // Returns true if the condition becomes true.
157 bool WaitForCondition(const Predicate& condition, 159 bool WaitForCondition(const Predicate& condition,
158 const base::TimeDelta& timeout = kDefaultTimeout); 160 const base::TimeDelta& timeout = kDefaultTimeout);
159 161
160 void SetDataFactory(scoped_ptr<TestDataFactory> factory) { 162 void SetDataFactory(std::unique_ptr<TestDataFactory> factory) {
161 data_factory_ = std::move(factory); 163 data_factory_ = std::move(factory);
162 } 164 }
163 165
164 DemuxerConfigs GetConfigs() const { 166 DemuxerConfigs GetConfigs() const {
165 // ASSERT_NE does not compile here because it expects void return value. 167 // ASSERT_NE does not compile here because it expects void return value.
166 EXPECT_NE(nullptr, data_factory_.get()); 168 EXPECT_NE(nullptr, data_factory_.get());
167 return data_factory_->GetConfigs(); 169 return data_factory_->GetConfigs();
168 } 170 }
169 171
170 void CreateAudioDecoder(); 172 void CreateAudioDecoder();
(...skipping 27 matching lines...) Expand all
198 decoder_->RequestToStop(); 200 decoder_->RequestToStop();
199 } 201 }
200 } 202 }
201 203
202 void OnVideoSizeChanged(const gfx::Size& video_size) { 204 void OnVideoSizeChanged(const gfx::Size& video_size) {
203 video_size_ = video_size; 205 video_size_ = video_size;
204 } 206 }
205 207
206 void OnVideoCodecCreated() {} 208 void OnVideoCodecCreated() {}
207 209
208 scoped_ptr<MediaCodecDecoder> decoder_; 210 std::unique_ptr<MediaCodecDecoder> decoder_;
209 scoped_ptr<TestDataFactory> data_factory_; 211 std::unique_ptr<TestDataFactory> data_factory_;
210 Minimax<base::TimeDelta> pts_stat_; 212 Minimax<base::TimeDelta> pts_stat_;
211 gfx::Size video_size_; 213 gfx::Size video_size_;
212 214
213 private: 215 private:
214 bool is_timeout_expired() const { return is_timeout_expired_; } 216 bool is_timeout_expired() const { return is_timeout_expired_; }
215 void SetTimeoutExpired(bool value) { is_timeout_expired_ = value; } 217 void SetTimeoutExpired(bool value) { is_timeout_expired_ = value; }
216 218
217 base::MessageLoop message_loop_; 219 base::MessageLoop message_loop_;
218 bool is_timeout_expired_; 220 bool is_timeout_expired_;
219 221
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 return true; 261 return true;
260 } 262 }
261 message_loop_.RunUntilIdle(); 263 message_loop_.RunUntilIdle();
262 } while (!is_timeout_expired()); 264 } while (!is_timeout_expired());
263 265
264 DCHECK(!timer.IsRunning()); 266 DCHECK(!timer.IsRunning());
265 return false; 267 return false;
266 } 268 }
267 269
268 void MediaCodecDecoderTest::CreateAudioDecoder() { 270 void MediaCodecDecoderTest::CreateAudioDecoder() {
269 decoder_ = scoped_ptr<MediaCodecDecoder>(new AudioMediaCodecDecoder( 271 decoder_ = base::WrapUnique(new AudioMediaCodecDecoder(
270 task_runner_, &frame_statistics_, 272 task_runner_, &frame_statistics_,
271 base::Bind(&MediaCodecDecoderTest::OnDataRequested, 273 base::Bind(&MediaCodecDecoderTest::OnDataRequested,
272 base::Unretained(this)), 274 base::Unretained(this)),
273 base::Bind(&MediaCodecDecoderTest::OnStarvation, base::Unretained(this)), 275 base::Bind(&MediaCodecDecoderTest::OnStarvation, base::Unretained(this)),
274 base::Bind(&MediaCodecDecoderTest::OnDecoderDrained, 276 base::Bind(&MediaCodecDecoderTest::OnDecoderDrained,
275 base::Unretained(this)), 277 base::Unretained(this)),
276 base::Bind(&MediaCodecDecoderTest::OnStopDone, base::Unretained(this)), 278 base::Bind(&MediaCodecDecoderTest::OnStopDone, base::Unretained(this)),
277 base::Bind(&MediaCodecDecoderTest::OnKeyRequired, base::Unretained(this)), 279 base::Bind(&MediaCodecDecoderTest::OnKeyRequired, base::Unretained(this)),
278 base::Bind(&MediaCodecDecoderTest::OnError, base::Unretained(this)), 280 base::Bind(&MediaCodecDecoderTest::OnError, base::Unretained(this)),
279 base::Bind(&MediaCodecDecoderTest::OnUpdateCurrentTime, 281 base::Bind(&MediaCodecDecoderTest::OnUpdateCurrentTime,
280 base::Unretained(this)))); 282 base::Unretained(this))));
281 283
282 data_available_cb_ = base::Bind(&MediaCodecDecoder::OnDemuxerDataAvailable, 284 data_available_cb_ = base::Bind(&MediaCodecDecoder::OnDemuxerDataAvailable,
283 base::Unretained(decoder_.get())); 285 base::Unretained(decoder_.get()));
284 } 286 }
285 287
286 void MediaCodecDecoderTest::CreateVideoDecoder() { 288 void MediaCodecDecoderTest::CreateVideoDecoder() {
287 decoder_ = scoped_ptr<MediaCodecDecoder>(new VideoMediaCodecDecoder( 289 decoder_ = base::WrapUnique(new VideoMediaCodecDecoder(
288 task_runner_, &frame_statistics_, 290 task_runner_, &frame_statistics_,
289 base::Bind(&MediaCodecDecoderTest::OnDataRequested, 291 base::Bind(&MediaCodecDecoderTest::OnDataRequested,
290 base::Unretained(this)), 292 base::Unretained(this)),
291 base::Bind(&MediaCodecDecoderTest::OnStarvation, base::Unretained(this)), 293 base::Bind(&MediaCodecDecoderTest::OnStarvation, base::Unretained(this)),
292 base::Bind(&MediaCodecDecoderTest::OnDecoderDrained, 294 base::Bind(&MediaCodecDecoderTest::OnDecoderDrained,
293 base::Unretained(this)), 295 base::Unretained(this)),
294 base::Bind(&MediaCodecDecoderTest::OnStopDone, base::Unretained(this)), 296 base::Bind(&MediaCodecDecoderTest::OnStopDone, base::Unretained(this)),
295 base::Bind(&MediaCodecDecoderTest::OnKeyRequired, base::Unretained(this)), 297 base::Bind(&MediaCodecDecoderTest::OnKeyRequired, base::Unretained(this)),
296 base::Bind(&MediaCodecDecoderTest::OnError, base::Unretained(this)), 298 base::Bind(&MediaCodecDecoderTest::OnError, base::Unretained(this)),
297 base::Bind(&MediaCodecDecoderTest::OnUpdateCurrentTime, 299 base::Bind(&MediaCodecDecoderTest::OnUpdateCurrentTime,
(...skipping 24 matching lines...) Expand all
322 ASSERT_NE(nullptr, decoder_.get()); 324 ASSERT_NE(nullptr, decoder_.get());
323 VideoMediaCodecDecoder* video_decoder = 325 VideoMediaCodecDecoder* video_decoder =
324 static_cast<VideoMediaCodecDecoder*>(decoder_.get()); 326 static_cast<VideoMediaCodecDecoder*>(decoder_.get());
325 video_decoder->SetVideoSurface(std::move(surface)); 327 video_decoder->SetVideoSurface(std::move(surface));
326 } 328 }
327 329
328 TEST_F(MediaCodecDecoderTest, AudioPrefetch) { 330 TEST_F(MediaCodecDecoderTest, AudioPrefetch) {
329 CreateAudioDecoder(); 331 CreateAudioDecoder();
330 332
331 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(500); 333 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(500);
332 SetDataFactory(scoped_ptr<TestDataFactory>(new AudioFactory(duration))); 334 SetDataFactory(base::WrapUnique(new AudioFactory(duration)));
333 335
334 decoder_->Prefetch(base::Bind(&MediaCodecDecoderTest::SetPrefetched, 336 decoder_->Prefetch(base::Bind(&MediaCodecDecoderTest::SetPrefetched,
335 base::Unretained(this), true)); 337 base::Unretained(this), true));
336 338
337 EXPECT_TRUE(WaitForCondition(base::Bind(&MediaCodecDecoderTest::is_prefetched, 339 EXPECT_TRUE(WaitForCondition(base::Bind(&MediaCodecDecoderTest::is_prefetched,
338 base::Unretained(this)))); 340 base::Unretained(this))));
339 } 341 }
340 342
341 TEST_F(MediaCodecDecoderTest, VideoPrefetch) { 343 TEST_F(MediaCodecDecoderTest, VideoPrefetch) {
342 CreateVideoDecoder(); 344 CreateVideoDecoder();
343 345
344 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(500); 346 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(500);
345 SetDataFactory(scoped_ptr<VideoFactory>(new VideoFactory(duration))); 347 SetDataFactory(base::WrapUnique(new VideoFactory(duration)));
346 348
347 decoder_->Prefetch(base::Bind(&MediaCodecDecoderTest::SetPrefetched, 349 decoder_->Prefetch(base::Bind(&MediaCodecDecoderTest::SetPrefetched,
348 base::Unretained(this), true)); 350 base::Unretained(this), true));
349 351
350 EXPECT_TRUE(WaitForCondition(base::Bind(&MediaCodecDecoderTest::is_prefetched, 352 EXPECT_TRUE(WaitForCondition(base::Bind(&MediaCodecDecoderTest::is_prefetched,
351 base::Unretained(this)))); 353 base::Unretained(this))));
352 } 354 }
353 355
354 TEST_F(MediaCodecDecoderTest, AudioConfigureNoParams) { 356 TEST_F(MediaCodecDecoderTest, AudioConfigureNoParams) {
355 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 357 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
356 358
357 CreateAudioDecoder(); 359 CreateAudioDecoder();
358 360
359 // Cannot configure without config parameters. 361 // Cannot configure without config parameters.
360 EXPECT_EQ(MediaCodecDecoder::kConfigFailure, decoder_->Configure(nullptr)); 362 EXPECT_EQ(MediaCodecDecoder::kConfigFailure, decoder_->Configure(nullptr));
361 } 363 }
362 364
363 TEST_F(MediaCodecDecoderTest, AudioConfigureValidParams) { 365 TEST_F(MediaCodecDecoderTest, AudioConfigureValidParams) {
364 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 366 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
365 367
366 CreateAudioDecoder(); 368 CreateAudioDecoder();
367 369
368 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(500); 370 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(500);
369 scoped_ptr<AudioFactory> factory(new AudioFactory(duration)); 371 std::unique_ptr<AudioFactory> factory(new AudioFactory(duration));
370 decoder_->SetDemuxerConfigs(factory->GetConfigs()); 372 decoder_->SetDemuxerConfigs(factory->GetConfigs());
371 373
372 EXPECT_EQ(MediaCodecDecoder::kConfigOk, decoder_->Configure(nullptr)); 374 EXPECT_EQ(MediaCodecDecoder::kConfigOk, decoder_->Configure(nullptr));
373 } 375 }
374 376
375 TEST_F(MediaCodecDecoderTest, VideoConfigureNoParams) { 377 TEST_F(MediaCodecDecoderTest, VideoConfigureNoParams) {
376 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 378 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
377 379
378 CreateVideoDecoder(); 380 CreateVideoDecoder();
379 381
380 // decoder_->Configure() searches back for the key frame. 382 // decoder_->Configure() searches back for the key frame.
381 // We have to prefetch decoder. 383 // We have to prefetch decoder.
382 384
383 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(500); 385 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(500);
384 SetDataFactory(scoped_ptr<VideoFactory>(new VideoFactory(duration))); 386 SetDataFactory(base::WrapUnique(new VideoFactory(duration)));
385 387
386 decoder_->Prefetch(base::Bind(&MediaCodecDecoderTest::SetPrefetched, 388 decoder_->Prefetch(base::Bind(&MediaCodecDecoderTest::SetPrefetched,
387 base::Unretained(this), true)); 389 base::Unretained(this), true));
388 390
389 EXPECT_TRUE(WaitForCondition(base::Bind(&MediaCodecDecoderTest::is_prefetched, 391 EXPECT_TRUE(WaitForCondition(base::Bind(&MediaCodecDecoderTest::is_prefetched,
390 base::Unretained(this)))); 392 base::Unretained(this))));
391 393
392 SetVideoSurface(); 394 SetVideoSurface();
393 395
394 // Cannot configure without config parameters. 396 // Cannot configure without config parameters.
395 EXPECT_EQ(MediaCodecDecoder::kConfigFailure, decoder_->Configure(nullptr)); 397 EXPECT_EQ(MediaCodecDecoder::kConfigFailure, decoder_->Configure(nullptr));
396 } 398 }
397 399
398 TEST_F(MediaCodecDecoderTest, VideoConfigureNoSurface) { 400 TEST_F(MediaCodecDecoderTest, VideoConfigureNoSurface) {
399 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 401 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
400 402
401 CreateVideoDecoder(); 403 CreateVideoDecoder();
402 404
403 // decoder_->Configure() searches back for the key frame. 405 // decoder_->Configure() searches back for the key frame.
404 // We have to prefetch decoder. 406 // We have to prefetch decoder.
405 407
406 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(500); 408 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(500);
407 SetDataFactory(scoped_ptr<VideoFactory>(new VideoFactory(duration))); 409 SetDataFactory(base::WrapUnique(new VideoFactory(duration)));
408 410
409 decoder_->Prefetch(base::Bind(&MediaCodecDecoderTest::SetPrefetched, 411 decoder_->Prefetch(base::Bind(&MediaCodecDecoderTest::SetPrefetched,
410 base::Unretained(this), true)); 412 base::Unretained(this), true));
411 413
412 EXPECT_TRUE(WaitForCondition(base::Bind(&MediaCodecDecoderTest::is_prefetched, 414 EXPECT_TRUE(WaitForCondition(base::Bind(&MediaCodecDecoderTest::is_prefetched,
413 base::Unretained(this)))); 415 base::Unretained(this))));
414 416
415 decoder_->SetDemuxerConfigs(GetConfigs()); 417 decoder_->SetDemuxerConfigs(GetConfigs());
416 418
417 // Surface is not set, Configure() should fail. 419 // Surface is not set, Configure() should fail.
418 420
419 EXPECT_EQ(MediaCodecDecoder::kConfigFailure, decoder_->Configure(nullptr)); 421 EXPECT_EQ(MediaCodecDecoder::kConfigFailure, decoder_->Configure(nullptr));
420 } 422 }
421 423
422 TEST_F(MediaCodecDecoderTest, VideoConfigureInvalidSurface) { 424 TEST_F(MediaCodecDecoderTest, VideoConfigureInvalidSurface) {
423 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 425 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
424 426
425 CreateVideoDecoder(); 427 CreateVideoDecoder();
426 428
427 // decoder_->Configure() searches back for the key frame. 429 // decoder_->Configure() searches back for the key frame.
428 // We have to prefetch decoder. 430 // We have to prefetch decoder.
429 431
430 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(500); 432 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(500);
431 SetDataFactory(scoped_ptr<VideoFactory>(new VideoFactory(duration))); 433 SetDataFactory(base::WrapUnique(new VideoFactory(duration)));
432 434
433 decoder_->Prefetch(base::Bind(&MediaCodecDecoderTest::SetPrefetched, 435 decoder_->Prefetch(base::Bind(&MediaCodecDecoderTest::SetPrefetched,
434 base::Unretained(this), true)); 436 base::Unretained(this), true));
435 437
436 EXPECT_TRUE(WaitForCondition(base::Bind(&MediaCodecDecoderTest::is_prefetched, 438 EXPECT_TRUE(WaitForCondition(base::Bind(&MediaCodecDecoderTest::is_prefetched,
437 base::Unretained(this)))); 439 base::Unretained(this))));
438 440
439 decoder_->SetDemuxerConfigs(GetConfigs()); 441 decoder_->SetDemuxerConfigs(GetConfigs());
440 442
441 // Prepare the surface. 443 // Prepare the surface.
(...skipping 13 matching lines...) Expand all
455 457
456 TEST_F(MediaCodecDecoderTest, VideoConfigureValidParams) { 458 TEST_F(MediaCodecDecoderTest, VideoConfigureValidParams) {
457 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 459 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
458 460
459 CreateVideoDecoder(); 461 CreateVideoDecoder();
460 462
461 // decoder_->Configure() searches back for the key frame. 463 // decoder_->Configure() searches back for the key frame.
462 // We have to prefetch decoder. 464 // We have to prefetch decoder.
463 465
464 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(500); 466 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(500);
465 SetDataFactory(scoped_ptr<VideoFactory>(new VideoFactory(duration))); 467 SetDataFactory(base::WrapUnique(new VideoFactory(duration)));
466 468
467 decoder_->Prefetch(base::Bind(&MediaCodecDecoderTest::SetPrefetched, 469 decoder_->Prefetch(base::Bind(&MediaCodecDecoderTest::SetPrefetched,
468 base::Unretained(this), true)); 470 base::Unretained(this), true));
469 471
470 EXPECT_TRUE(WaitForCondition(base::Bind(&MediaCodecDecoderTest::is_prefetched, 472 EXPECT_TRUE(WaitForCondition(base::Bind(&MediaCodecDecoderTest::is_prefetched,
471 base::Unretained(this)))); 473 base::Unretained(this))));
472 474
473 decoder_->SetDemuxerConfigs(GetConfigs()); 475 decoder_->SetDemuxerConfigs(GetConfigs());
474 476
475 SetVideoSurface(); 477 SetVideoSurface();
476 478
477 // Now we can expect Configure() to succeed. 479 // Now we can expect Configure() to succeed.
478 480
479 EXPECT_EQ(MediaCodecDecoder::kConfigOk, decoder_->Configure(nullptr)); 481 EXPECT_EQ(MediaCodecDecoder::kConfigOk, decoder_->Configure(nullptr));
480 } 482 }
481 483
482 TEST_F(MediaCodecDecoderTest, AudioStartWithoutConfigure) { 484 TEST_F(MediaCodecDecoderTest, AudioStartWithoutConfigure) {
483 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 485 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
484 486
485 CreateAudioDecoder(); 487 CreateAudioDecoder();
486 488
487 // Decoder has to be prefetched and configured before the start. 489 // Decoder has to be prefetched and configured before the start.
488 490
489 // Wrong state: not prefetched 491 // Wrong state: not prefetched
490 EXPECT_FALSE(decoder_->Start(base::TimeDelta::FromMilliseconds(0))); 492 EXPECT_FALSE(decoder_->Start(base::TimeDelta::FromMilliseconds(0)));
491 493
492 // Do the prefetch. 494 // Do the prefetch.
493 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(500); 495 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(500);
494 SetDataFactory(scoped_ptr<AudioFactory>(new AudioFactory(duration))); 496 SetDataFactory(base::WrapUnique(new AudioFactory(duration)));
495 497
496 // Prefetch to avoid starvation at the beginning of playback. 498 // Prefetch to avoid starvation at the beginning of playback.
497 decoder_->Prefetch(base::Bind(&MediaCodecDecoderTest::SetPrefetched, 499 decoder_->Prefetch(base::Bind(&MediaCodecDecoderTest::SetPrefetched,
498 base::Unretained(this), true)); 500 base::Unretained(this), true));
499 501
500 EXPECT_TRUE(WaitForCondition(base::Bind(&MediaCodecDecoderTest::is_prefetched, 502 EXPECT_TRUE(WaitForCondition(base::Bind(&MediaCodecDecoderTest::is_prefetched,
501 base::Unretained(this)))); 503 base::Unretained(this))));
502 504
503 // Still, decoder is not configured. 505 // Still, decoder is not configured.
504 EXPECT_FALSE(decoder_->Start(base::TimeDelta::FromMilliseconds(0))); 506 EXPECT_FALSE(decoder_->Start(base::TimeDelta::FromMilliseconds(0)));
505 } 507 }
506 508
507 // http://crbug.com/518900 509 // http://crbug.com/518900
508 TEST_F(MediaCodecDecoderTest, DISABLED_AudioPlayTillCompletion) { 510 TEST_F(MediaCodecDecoderTest, DISABLED_AudioPlayTillCompletion) {
509 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 511 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
510 512
511 DVLOG(0) << "AudioPlayTillCompletion started"; 513 DVLOG(0) << "AudioPlayTillCompletion started";
512 514
513 CreateAudioDecoder(); 515 CreateAudioDecoder();
514 516
515 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(500); 517 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(500);
516 base::TimeDelta timeout = base::TimeDelta::FromMilliseconds(1500); 518 base::TimeDelta timeout = base::TimeDelta::FromMilliseconds(1500);
517 519
518 SetDataFactory(scoped_ptr<AudioFactory>(new AudioFactory(duration))); 520 SetDataFactory(base::WrapUnique(new AudioFactory(duration)));
519 521
520 // Prefetch to avoid starvation at the beginning of playback. 522 // Prefetch to avoid starvation at the beginning of playback.
521 decoder_->Prefetch(base::Bind(&MediaCodecDecoderTest::SetPrefetched, 523 decoder_->Prefetch(base::Bind(&MediaCodecDecoderTest::SetPrefetched,
522 base::Unretained(this), true)); 524 base::Unretained(this), true));
523 525
524 EXPECT_TRUE(WaitForCondition(base::Bind(&MediaCodecDecoderTest::is_prefetched, 526 EXPECT_TRUE(WaitForCondition(base::Bind(&MediaCodecDecoderTest::is_prefetched,
525 base::Unretained(this)))); 527 base::Unretained(this))));
526 528
527 decoder_->SetDemuxerConfigs(GetConfigs()); 529 decoder_->SetDemuxerConfigs(GetConfigs());
528 530
(...skipping 21 matching lines...) Expand all
550 TEST_F(MediaCodecDecoderTest, VideoPlayTillCompletion) { 552 TEST_F(MediaCodecDecoderTest, VideoPlayTillCompletion) {
551 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 553 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
552 554
553 CreateVideoDecoder(); 555 CreateVideoDecoder();
554 556
555 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(500); 557 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(500);
556 // The first output frame might come out with significant delay. Apparently 558 // The first output frame might come out with significant delay. Apparently
557 // the codec does initial configuration at this time. We increase the timeout 559 // the codec does initial configuration at this time. We increase the timeout
558 // to leave a room of 1 second for this initial configuration. 560 // to leave a room of 1 second for this initial configuration.
559 base::TimeDelta timeout = base::TimeDelta::FromMilliseconds(1500); 561 base::TimeDelta timeout = base::TimeDelta::FromMilliseconds(1500);
560 SetDataFactory(scoped_ptr<VideoFactory>(new VideoFactory(duration))); 562 SetDataFactory(base::WrapUnique(new VideoFactory(duration)));
561 563
562 // Prefetch 564 // Prefetch
563 decoder_->Prefetch(base::Bind(&MediaCodecDecoderTest::SetPrefetched, 565 decoder_->Prefetch(base::Bind(&MediaCodecDecoderTest::SetPrefetched,
564 base::Unretained(this), true)); 566 base::Unretained(this), true));
565 567
566 EXPECT_TRUE(WaitForCondition(base::Bind(&MediaCodecDecoderTest::is_prefetched, 568 EXPECT_TRUE(WaitForCondition(base::Bind(&MediaCodecDecoderTest::is_prefetched,
567 base::Unretained(this)))); 569 base::Unretained(this))));
568 570
569 decoder_->SetDemuxerConfigs(GetConfigs()); 571 decoder_->SetDemuxerConfigs(GetConfigs());
570 572
(...skipping 17 matching lines...) Expand all
588 590
589 TEST_F(MediaCodecDecoderTest, VideoStopAndResume) { 591 TEST_F(MediaCodecDecoderTest, VideoStopAndResume) {
590 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 592 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
591 593
592 CreateVideoDecoder(); 594 CreateVideoDecoder();
593 595
594 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(500); 596 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(500);
595 base::TimeDelta stop_request_time = base::TimeDelta::FromMilliseconds(200); 597 base::TimeDelta stop_request_time = base::TimeDelta::FromMilliseconds(200);
596 base::TimeDelta timeout = base::TimeDelta::FromMilliseconds(1000); 598 base::TimeDelta timeout = base::TimeDelta::FromMilliseconds(1000);
597 599
598 SetDataFactory(scoped_ptr<VideoFactory>(new VideoFactory(duration))); 600 SetDataFactory(base::WrapUnique(new VideoFactory(duration)));
599 601
600 // Prefetch 602 // Prefetch
601 decoder_->Prefetch(base::Bind(&MediaCodecDecoderTest::SetPrefetched, 603 decoder_->Prefetch(base::Bind(&MediaCodecDecoderTest::SetPrefetched,
602 base::Unretained(this), true)); 604 base::Unretained(this), true));
603 605
604 EXPECT_TRUE(WaitForCondition(base::Bind(&MediaCodecDecoderTest::is_prefetched, 606 EXPECT_TRUE(WaitForCondition(base::Bind(&MediaCodecDecoderTest::is_prefetched,
605 base::Unretained(this)))); 607 base::Unretained(this))));
606 608
607 decoder_->SetDemuxerConfigs(GetConfigs()); 609 decoder_->SetDemuxerConfigs(GetConfigs());
608 610
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 TEST_F(MediaCodecDecoderTest, DISABLED_AudioStarvationAndStop) { 661 TEST_F(MediaCodecDecoderTest, DISABLED_AudioStarvationAndStop) {
660 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 662 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
661 663
662 CreateAudioDecoder(); 664 CreateAudioDecoder();
663 665
664 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(200); 666 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(200);
665 base::TimeDelta timeout = base::TimeDelta::FromMilliseconds(400); 667 base::TimeDelta timeout = base::TimeDelta::FromMilliseconds(400);
666 668
667 AudioFactory* factory = new AudioFactory(duration); 669 AudioFactory* factory = new AudioFactory(duration);
668 factory->SetStarvationMode(true); 670 factory->SetStarvationMode(true);
669 SetDataFactory(scoped_ptr<AudioFactory>(factory)); 671 SetDataFactory(base::WrapUnique(factory));
670 672
671 // Prefetch. 673 // Prefetch.
672 decoder_->Prefetch(base::Bind(&MediaCodecDecoderTest::SetPrefetched, 674 decoder_->Prefetch(base::Bind(&MediaCodecDecoderTest::SetPrefetched,
673 base::Unretained(this), true)); 675 base::Unretained(this), true));
674 676
675 EXPECT_TRUE(WaitForCondition(base::Bind(&MediaCodecDecoderTest::is_prefetched, 677 EXPECT_TRUE(WaitForCondition(base::Bind(&MediaCodecDecoderTest::is_prefetched,
676 base::Unretained(this)))); 678 base::Unretained(this))));
677 679
678 // Configure. 680 // Configure.
679 decoder_->SetDemuxerConfigs(GetConfigs()); 681 decoder_->SetDemuxerConfigs(GetConfigs());
(...skipping 26 matching lines...) Expand all
706 TEST_F(MediaCodecDecoderTest, VideoFirstUnitIsReconfig) { 708 TEST_F(MediaCodecDecoderTest, VideoFirstUnitIsReconfig) {
707 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE(); 709 SKIP_TEST_IF_MEDIA_CODEC_BRIDGE_IS_NOT_AVAILABLE();
708 710
709 // Test that the kConfigChanged unit that comes before the first data unit 711 // Test that the kConfigChanged unit that comes before the first data unit
710 // gets processed, i.e. is not lost. 712 // gets processed, i.e. is not lost.
711 713
712 CreateVideoDecoder(); 714 CreateVideoDecoder();
713 715
714 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(200); 716 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(200);
715 base::TimeDelta timeout = base::TimeDelta::FromMilliseconds(1000); 717 base::TimeDelta timeout = base::TimeDelta::FromMilliseconds(1000);
716 SetDataFactory(scoped_ptr<VideoFactory>(new VideoFactory(duration))); 718 SetDataFactory(base::WrapUnique(new VideoFactory(duration)));
717 719
718 // Ask factory to produce initial configuration unit. The configuraton will 720 // Ask factory to produce initial configuration unit. The configuraton will
719 // be factory.GetConfigs(). 721 // be factory.GetConfigs().
720 data_factory_->RequestInitialConfigs(); 722 data_factory_->RequestInitialConfigs();
721 723
722 // Create am alternative configuration (we just alter video size). 724 // Create am alternative configuration (we just alter video size).
723 DemuxerConfigs alt_configs = data_factory_->GetConfigs(); 725 DemuxerConfigs alt_configs = data_factory_->GetConfigs();
724 alt_configs.video_size = gfx::Size(100, 100); 726 alt_configs.video_size = gfx::Size(100, 100);
725 727
726 // Pass the alternative configuration to decoder. 728 // Pass the alternative configuration to decoder.
(...skipping 25 matching lines...) Expand all
752 754
753 EXPECT_TRUE(decoder_->IsStopped()); 755 EXPECT_TRUE(decoder_->IsStopped());
754 EXPECT_TRUE(decoder_->IsCompleted()); 756 EXPECT_TRUE(decoder_->IsCompleted());
755 EXPECT_EQ(data_factory_->last_pts(), pts_stat_.max()); 757 EXPECT_EQ(data_factory_->last_pts(), pts_stat_.max());
756 758
757 // Check that the reported video size is the one from the in-stream configs. 759 // Check that the reported video size is the one from the in-stream configs.
758 EXPECT_EQ(data_factory_->GetConfigs().video_size, video_size_); 760 EXPECT_EQ(data_factory_->GetConfigs().video_size, video_size_);
759 } 761 }
760 762
761 } // namespace media 763 } // namespace media
OLDNEW
« no previous file with comments | « media/base/android/media_codec_decoder.h ('k') | media/base/android/media_codec_player.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698