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

Side by Side Diff: chromecast/media/cma/backend/media_pipeline_device_fake.cc

Issue 1074383002: Introduce VideoConfig/AudioConfig class for CMA backend (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: single DecoderConfig structure for both Audio and Video Created 5 years, 8 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 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 "chromecast/media/cma/backend/media_pipeline_device_fake.h" 5 #include "chromecast/media/cma/backend/media_pipeline_device_fake.h"
6 6
7 #include <list> 7 #include <list>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/message_loop/message_loop_proxy.h" 14 #include "base/message_loop/message_loop_proxy.h"
15 #include "chromecast/media/cma/backend/audio_pipeline_device.h" 15 #include "chromecast/media/cma/backend/audio_pipeline_device.h"
16 #include "chromecast/media/cma/backend/media_clock_device.h" 16 #include "chromecast/media/cma/backend/media_clock_device.h"
17 #include "chromecast/media/cma/backend/media_component_device.h" 17 #include "chromecast/media/cma/backend/media_component_device.h"
18 #include "chromecast/media/cma/backend/video_pipeline_device.h" 18 #include "chromecast/media/cma/backend/video_pipeline_device.h"
19 #include "chromecast/media/cma/base/decoder_buffer_base.h" 19 #include "chromecast/media/cma/base/decoder_buffer_base.h"
20 #include "media/base/audio_decoder_config.h" 20 #include "chromecast/public/media/decoder_config.h"
21 #include "media/base/buffers.h" 21 #include "media/base/buffers.h"
22 #include "media/base/video_decoder_config.h"
23 22
24 namespace chromecast { 23 namespace chromecast {
25 namespace media { 24 namespace media {
26 25
27 class MediaClockDeviceFake : public MediaClockDevice { 26 class MediaClockDeviceFake : public MediaClockDevice {
28 public: 27 public:
29 MediaClockDeviceFake(); 28 MediaClockDeviceFake();
30 ~MediaClockDeviceFake() override; 29 ~MediaClockDeviceFake() override;
31 30
32 // MediaClockDevice implementation. 31 // MediaClockDevice implementation.
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 void SetClient(const Client& client) override; 363 void SetClient(const Client& client) override;
365 State GetState() const override; 364 State GetState() const override;
366 bool SetState(State new_state) override; 365 bool SetState(State new_state) override;
367 bool SetStartPts(base::TimeDelta time) override; 366 bool SetStartPts(base::TimeDelta time) override;
368 FrameStatus PushFrame( 367 FrameStatus PushFrame(
369 const scoped_refptr<DecryptContext>& decrypt_context, 368 const scoped_refptr<DecryptContext>& decrypt_context,
370 const scoped_refptr<DecoderBufferBase>& buffer, 369 const scoped_refptr<DecoderBufferBase>& buffer,
371 const FrameStatusCB& completion_cb) override; 370 const FrameStatusCB& completion_cb) override;
372 base::TimeDelta GetRenderingTime() const override; 371 base::TimeDelta GetRenderingTime() const override;
373 base::TimeDelta GetRenderingDelay() const override; 372 base::TimeDelta GetRenderingDelay() const override;
374 bool SetConfig(const ::media::AudioDecoderConfig& config) override; 373 bool SetConfig(const DecoderConfig& config) override;
375 void SetStreamVolumeMultiplier(float multiplier) override; 374 void SetStreamVolumeMultiplier(float multiplier) override;
376 bool GetStatistics(Statistics* stats) const override; 375 bool GetStatistics(Statistics* stats) const override;
377 376
378 private: 377 private:
379 scoped_ptr<MediaComponentDeviceFake> fake_pipeline_; 378 scoped_ptr<MediaComponentDeviceFake> fake_pipeline_;
380 379
381 ::media::AudioDecoderConfig config_; 380 DecoderConfig config_;
382 381
383 DISALLOW_COPY_AND_ASSIGN(AudioPipelineDeviceFake); 382 DISALLOW_COPY_AND_ASSIGN(AudioPipelineDeviceFake);
384 }; 383 };
385 384
386 AudioPipelineDeviceFake::AudioPipelineDeviceFake( 385 AudioPipelineDeviceFake::AudioPipelineDeviceFake(
387 MediaClockDeviceFake* media_clock_device) 386 MediaClockDeviceFake* media_clock_device)
388 : fake_pipeline_(new MediaComponentDeviceFake(media_clock_device)) { 387 : fake_pipeline_(new MediaComponentDeviceFake(media_clock_device)) {
389 DetachFromThread(); 388 DetachFromThread();
390 } 389 }
391 390
392 AudioPipelineDeviceFake::~AudioPipelineDeviceFake() { 391 AudioPipelineDeviceFake::~AudioPipelineDeviceFake() {
393 } 392 }
394 393
395 void AudioPipelineDeviceFake::SetClient(const Client& client) { 394 void AudioPipelineDeviceFake::SetClient(const Client& client) {
396 fake_pipeline_->SetClient(client); 395 fake_pipeline_->SetClient(client);
397 } 396 }
398 397
399 MediaComponentDevice::State AudioPipelineDeviceFake::GetState() const { 398 MediaComponentDevice::State AudioPipelineDeviceFake::GetState() const {
400 return fake_pipeline_->GetState(); 399 return fake_pipeline_->GetState();
401 } 400 }
402 401
403 bool AudioPipelineDeviceFake::SetState(State new_state) { 402 bool AudioPipelineDeviceFake::SetState(State new_state) {
404 bool success = fake_pipeline_->SetState(new_state); 403 bool success = fake_pipeline_->SetState(new_state);
405 if (!success) 404 if (!success)
406 return false; 405 return false;
407 406
408 if (new_state == kStateIdle) { 407 if (new_state == kStateIdle) {
409 DCHECK(config_.IsValidConfig()); 408 DCHECK(config_.is_valid_config);
410 } 409 }
411 if (new_state == kStateUninitialized) { 410 if (new_state == kStateUninitialized) {
412 config_ = ::media::AudioDecoderConfig(); 411 config_ = DecoderConfig();
413 } 412 }
414 return true; 413 return true;
415 } 414 }
416 415
417 bool AudioPipelineDeviceFake::SetStartPts(base::TimeDelta time) { 416 bool AudioPipelineDeviceFake::SetStartPts(base::TimeDelta time) {
418 return fake_pipeline_->SetStartPts(time); 417 return fake_pipeline_->SetStartPts(time);
419 } 418 }
420 419
421 MediaComponentDevice::FrameStatus AudioPipelineDeviceFake::PushFrame( 420 MediaComponentDevice::FrameStatus AudioPipelineDeviceFake::PushFrame(
422 const scoped_refptr<DecryptContext>& decrypt_context, 421 const scoped_refptr<DecryptContext>& decrypt_context,
423 const scoped_refptr<DecoderBufferBase>& buffer, 422 const scoped_refptr<DecoderBufferBase>& buffer,
424 const FrameStatusCB& completion_cb) { 423 const FrameStatusCB& completion_cb) {
425 return fake_pipeline_->PushFrame(decrypt_context, buffer, completion_cb); 424 return fake_pipeline_->PushFrame(decrypt_context, buffer, completion_cb);
426 } 425 }
427 426
428 base::TimeDelta AudioPipelineDeviceFake::GetRenderingTime() const { 427 base::TimeDelta AudioPipelineDeviceFake::GetRenderingTime() const {
429 return fake_pipeline_->GetRenderingTime(); 428 return fake_pipeline_->GetRenderingTime();
430 } 429 }
431 430
432 base::TimeDelta AudioPipelineDeviceFake::GetRenderingDelay() const { 431 base::TimeDelta AudioPipelineDeviceFake::GetRenderingDelay() const {
433 return fake_pipeline_->GetRenderingDelay(); 432 return fake_pipeline_->GetRenderingDelay();
434 } 433 }
435 434
436 bool AudioPipelineDeviceFake::SetConfig( 435 bool AudioPipelineDeviceFake::SetConfig(const DecoderConfig& config) {
437 const ::media::AudioDecoderConfig& config) {
438 DCHECK(CalledOnValidThread()); 436 DCHECK(CalledOnValidThread());
439 if (!config.IsValidConfig()) 437 if (!config.is_valid_config)
440 return false; 438 return false;
441 config_ = config; 439 config_ = config;
442 return true; 440 return true;
443 } 441 }
444 442
445 void AudioPipelineDeviceFake::SetStreamVolumeMultiplier(float multiplier) { 443 void AudioPipelineDeviceFake::SetStreamVolumeMultiplier(float multiplier) {
446 DCHECK(CalledOnValidThread()); 444 DCHECK(CalledOnValidThread());
447 } 445 }
448 446
449 bool AudioPipelineDeviceFake::GetStatistics(Statistics* stats) const { 447 bool AudioPipelineDeviceFake::GetStatistics(Statistics* stats) const {
(...skipping 11 matching lines...) Expand all
461 State GetState() const override; 459 State GetState() const override;
462 bool SetState(State new_state) override; 460 bool SetState(State new_state) override;
463 bool SetStartPts(base::TimeDelta time) override; 461 bool SetStartPts(base::TimeDelta time) override;
464 FrameStatus PushFrame( 462 FrameStatus PushFrame(
465 const scoped_refptr<DecryptContext>& decrypt_context, 463 const scoped_refptr<DecryptContext>& decrypt_context,
466 const scoped_refptr<DecoderBufferBase>& buffer, 464 const scoped_refptr<DecoderBufferBase>& buffer,
467 const FrameStatusCB& completion_cb) override; 465 const FrameStatusCB& completion_cb) override;
468 base::TimeDelta GetRenderingTime() const override; 466 base::TimeDelta GetRenderingTime() const override;
469 base::TimeDelta GetRenderingDelay() const override; 467 base::TimeDelta GetRenderingDelay() const override;
470 void SetVideoClient(const VideoClient& client) override; 468 void SetVideoClient(const VideoClient& client) override;
471 bool SetConfig(const ::media::VideoDecoderConfig& config) override; 469 bool SetConfig(const DecoderConfig& config) override;
472 bool GetStatistics(Statistics* stats) const override; 470 bool GetStatistics(Statistics* stats) const override;
473 471
474 private: 472 private:
475 scoped_ptr<MediaComponentDeviceFake> fake_pipeline_; 473 scoped_ptr<MediaComponentDeviceFake> fake_pipeline_;
476 474
477 ::media::VideoDecoderConfig config_; 475 DecoderConfig config_;
478 476
479 DISALLOW_COPY_AND_ASSIGN(VideoPipelineDeviceFake); 477 DISALLOW_COPY_AND_ASSIGN(VideoPipelineDeviceFake);
480 }; 478 };
481 479
482 VideoPipelineDeviceFake::VideoPipelineDeviceFake( 480 VideoPipelineDeviceFake::VideoPipelineDeviceFake(
483 MediaClockDeviceFake* media_clock_device) 481 MediaClockDeviceFake* media_clock_device)
484 : fake_pipeline_(new MediaComponentDeviceFake(media_clock_device)) { 482 : fake_pipeline_(new MediaComponentDeviceFake(media_clock_device)) {
485 DetachFromThread(); 483 DetachFromThread();
486 } 484 }
487 485
488 VideoPipelineDeviceFake::~VideoPipelineDeviceFake() { 486 VideoPipelineDeviceFake::~VideoPipelineDeviceFake() {
489 } 487 }
490 488
491 void VideoPipelineDeviceFake::SetClient(const Client& client) { 489 void VideoPipelineDeviceFake::SetClient(const Client& client) {
492 fake_pipeline_->SetClient(client); 490 fake_pipeline_->SetClient(client);
493 } 491 }
494 492
495 MediaComponentDevice::State VideoPipelineDeviceFake::GetState() const { 493 MediaComponentDevice::State VideoPipelineDeviceFake::GetState() const {
496 return fake_pipeline_->GetState(); 494 return fake_pipeline_->GetState();
497 } 495 }
498 496
499 bool VideoPipelineDeviceFake::SetState(State new_state) { 497 bool VideoPipelineDeviceFake::SetState(State new_state) {
500 bool success = fake_pipeline_->SetState(new_state); 498 bool success = fake_pipeline_->SetState(new_state);
501 if (!success) 499 if (!success)
502 return false; 500 return false;
503 501
504 if (new_state == kStateIdle) { 502 if (new_state == kStateIdle) {
505 DCHECK(config_.IsValidConfig()); 503 DCHECK(config_.is_valid_config);
506 } 504 }
507 if (new_state == kStateUninitialized) { 505 if (new_state == kStateUninitialized) {
508 config_ = ::media::VideoDecoderConfig(); 506 config_ = DecoderConfig();
509 } 507 }
510 return true; 508 return true;
511 } 509 }
512 510
513 bool VideoPipelineDeviceFake::SetStartPts(base::TimeDelta time) { 511 bool VideoPipelineDeviceFake::SetStartPts(base::TimeDelta time) {
514 return fake_pipeline_->SetStartPts(time); 512 return fake_pipeline_->SetStartPts(time);
515 } 513 }
516 514
517 MediaComponentDevice::FrameStatus VideoPipelineDeviceFake::PushFrame( 515 MediaComponentDevice::FrameStatus VideoPipelineDeviceFake::PushFrame(
518 const scoped_refptr<DecryptContext>& decrypt_context, 516 const scoped_refptr<DecryptContext>& decrypt_context,
519 const scoped_refptr<DecoderBufferBase>& buffer, 517 const scoped_refptr<DecoderBufferBase>& buffer,
520 const FrameStatusCB& completion_cb) { 518 const FrameStatusCB& completion_cb) {
521 return fake_pipeline_->PushFrame(decrypt_context, buffer, completion_cb); 519 return fake_pipeline_->PushFrame(decrypt_context, buffer, completion_cb);
522 } 520 }
523 521
524 base::TimeDelta VideoPipelineDeviceFake::GetRenderingTime() const { 522 base::TimeDelta VideoPipelineDeviceFake::GetRenderingTime() const {
525 return fake_pipeline_->GetRenderingTime(); 523 return fake_pipeline_->GetRenderingTime();
526 } 524 }
527 525
528 base::TimeDelta VideoPipelineDeviceFake::GetRenderingDelay() const { 526 base::TimeDelta VideoPipelineDeviceFake::GetRenderingDelay() const {
529 return fake_pipeline_->GetRenderingDelay(); 527 return fake_pipeline_->GetRenderingDelay();
530 } 528 }
531 529
532 void VideoPipelineDeviceFake::SetVideoClient(const VideoClient& client) { 530 void VideoPipelineDeviceFake::SetVideoClient(const VideoClient& client) {
533 } 531 }
534 532
535 bool VideoPipelineDeviceFake::SetConfig( 533 bool VideoPipelineDeviceFake::SetConfig(const DecoderConfig& config) {
536 const ::media::VideoDecoderConfig& config) {
537 DCHECK(CalledOnValidThread()); 534 DCHECK(CalledOnValidThread());
538 if (!config.IsValidConfig()) 535 if (!config.is_valid_config)
539 return false; 536 return false;
540 config_ = config; 537 config_ = config;
541 return true; 538 return true;
542 } 539 }
543 540
544 bool VideoPipelineDeviceFake::GetStatistics(Statistics* stats) const { 541 bool VideoPipelineDeviceFake::GetStatistics(Statistics* stats) const {
545 return fake_pipeline_->GetStatistics(stats); 542 return fake_pipeline_->GetStatistics(stats);
546 } 543 }
547 544
548 545
(...skipping 15 matching lines...) Expand all
564 VideoPipelineDevice* MediaPipelineDeviceFake::GetVideoPipelineDevice() const { 561 VideoPipelineDevice* MediaPipelineDeviceFake::GetVideoPipelineDevice() const {
565 return video_pipeline_device_.get(); 562 return video_pipeline_device_.get();
566 } 563 }
567 564
568 MediaClockDevice* MediaPipelineDeviceFake::GetMediaClockDevice() const { 565 MediaClockDevice* MediaPipelineDeviceFake::GetMediaClockDevice() const {
569 return media_clock_device_.get(); 566 return media_clock_device_.get();
570 } 567 }
571 568
572 } // namespace media 569 } // namespace media
573 } // namespace chromecast 570 } // namespace chromecast
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698