| 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 "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/media/cma/public/audio_config.h" |
| 21 #include "chromecast/media/cma/public/video_config.h" |
| 21 #include "media/base/buffers.h" | 22 #include "media/base/buffers.h" |
| 22 #include "media/base/video_decoder_config.h" | |
| 23 | 23 |
| 24 namespace chromecast { | 24 namespace chromecast { |
| 25 namespace media { | 25 namespace media { |
| 26 | 26 |
| 27 class MediaClockDeviceFake : public MediaClockDevice { | 27 class MediaClockDeviceFake : public MediaClockDevice { |
| 28 public: | 28 public: |
| 29 MediaClockDeviceFake(); | 29 MediaClockDeviceFake(); |
| 30 ~MediaClockDeviceFake() override; | 30 ~MediaClockDeviceFake() override; |
| 31 | 31 |
| 32 // MediaClockDevice implementation. | 32 // MediaClockDevice implementation. |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 void SetClient(const Client& client) override; | 364 void SetClient(const Client& client) override; |
| 365 State GetState() const override; | 365 State GetState() const override; |
| 366 bool SetState(State new_state) override; | 366 bool SetState(State new_state) override; |
| 367 bool SetStartPts(base::TimeDelta time) override; | 367 bool SetStartPts(base::TimeDelta time) override; |
| 368 FrameStatus PushFrame( | 368 FrameStatus PushFrame( |
| 369 const scoped_refptr<DecryptContext>& decrypt_context, | 369 const scoped_refptr<DecryptContext>& decrypt_context, |
| 370 const scoped_refptr<DecoderBufferBase>& buffer, | 370 const scoped_refptr<DecoderBufferBase>& buffer, |
| 371 const FrameStatusCB& completion_cb) override; | 371 const FrameStatusCB& completion_cb) override; |
| 372 base::TimeDelta GetRenderingTime() const override; | 372 base::TimeDelta GetRenderingTime() const override; |
| 373 base::TimeDelta GetRenderingDelay() const override; | 373 base::TimeDelta GetRenderingDelay() const override; |
| 374 bool SetConfig(const ::media::AudioDecoderConfig& config) override; | 374 bool SetConfig(const AudioConfig& config) override; |
| 375 void SetStreamVolumeMultiplier(float multiplier) override; | 375 void SetStreamVolumeMultiplier(float multiplier) override; |
| 376 bool GetStatistics(Statistics* stats) const override; | 376 bool GetStatistics(Statistics* stats) const override; |
| 377 | 377 |
| 378 private: | 378 private: |
| 379 scoped_ptr<MediaComponentDeviceFake> fake_pipeline_; | 379 scoped_ptr<MediaComponentDeviceFake> fake_pipeline_; |
| 380 | 380 |
| 381 ::media::AudioDecoderConfig config_; | 381 AudioConfig config_; |
| 382 | 382 |
| 383 DISALLOW_COPY_AND_ASSIGN(AudioPipelineDeviceFake); | 383 DISALLOW_COPY_AND_ASSIGN(AudioPipelineDeviceFake); |
| 384 }; | 384 }; |
| 385 | 385 |
| 386 AudioPipelineDeviceFake::AudioPipelineDeviceFake( | 386 AudioPipelineDeviceFake::AudioPipelineDeviceFake( |
| 387 MediaClockDeviceFake* media_clock_device) | 387 MediaClockDeviceFake* media_clock_device) |
| 388 : fake_pipeline_(new MediaComponentDeviceFake(media_clock_device)) { | 388 : fake_pipeline_(new MediaComponentDeviceFake(media_clock_device)) { |
| 389 DetachFromThread(); | 389 DetachFromThread(); |
| 390 } | 390 } |
| 391 | 391 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 402 | 402 |
| 403 bool AudioPipelineDeviceFake::SetState(State new_state) { | 403 bool AudioPipelineDeviceFake::SetState(State new_state) { |
| 404 bool success = fake_pipeline_->SetState(new_state); | 404 bool success = fake_pipeline_->SetState(new_state); |
| 405 if (!success) | 405 if (!success) |
| 406 return false; | 406 return false; |
| 407 | 407 |
| 408 if (new_state == kStateIdle) { | 408 if (new_state == kStateIdle) { |
| 409 DCHECK(config_.IsValidConfig()); | 409 DCHECK(config_.IsValidConfig()); |
| 410 } | 410 } |
| 411 if (new_state == kStateUninitialized) { | 411 if (new_state == kStateUninitialized) { |
| 412 config_ = ::media::AudioDecoderConfig(); | 412 config_ = AudioConfig(); |
| 413 } | 413 } |
| 414 return true; | 414 return true; |
| 415 } | 415 } |
| 416 | 416 |
| 417 bool AudioPipelineDeviceFake::SetStartPts(base::TimeDelta time) { | 417 bool AudioPipelineDeviceFake::SetStartPts(base::TimeDelta time) { |
| 418 return fake_pipeline_->SetStartPts(time); | 418 return fake_pipeline_->SetStartPts(time); |
| 419 } | 419 } |
| 420 | 420 |
| 421 MediaComponentDevice::FrameStatus AudioPipelineDeviceFake::PushFrame( | 421 MediaComponentDevice::FrameStatus AudioPipelineDeviceFake::PushFrame( |
| 422 const scoped_refptr<DecryptContext>& decrypt_context, | 422 const scoped_refptr<DecryptContext>& decrypt_context, |
| 423 const scoped_refptr<DecoderBufferBase>& buffer, | 423 const scoped_refptr<DecoderBufferBase>& buffer, |
| 424 const FrameStatusCB& completion_cb) { | 424 const FrameStatusCB& completion_cb) { |
| 425 return fake_pipeline_->PushFrame(decrypt_context, buffer, completion_cb); | 425 return fake_pipeline_->PushFrame(decrypt_context, buffer, completion_cb); |
| 426 } | 426 } |
| 427 | 427 |
| 428 base::TimeDelta AudioPipelineDeviceFake::GetRenderingTime() const { | 428 base::TimeDelta AudioPipelineDeviceFake::GetRenderingTime() const { |
| 429 return fake_pipeline_->GetRenderingTime(); | 429 return fake_pipeline_->GetRenderingTime(); |
| 430 } | 430 } |
| 431 | 431 |
| 432 base::TimeDelta AudioPipelineDeviceFake::GetRenderingDelay() const { | 432 base::TimeDelta AudioPipelineDeviceFake::GetRenderingDelay() const { |
| 433 return fake_pipeline_->GetRenderingDelay(); | 433 return fake_pipeline_->GetRenderingDelay(); |
| 434 } | 434 } |
| 435 | 435 |
| 436 bool AudioPipelineDeviceFake::SetConfig( | 436 bool AudioPipelineDeviceFake::SetConfig(const AudioConfig& config) { |
| 437 const ::media::AudioDecoderConfig& config) { | |
| 438 DCHECK(CalledOnValidThread()); | 437 DCHECK(CalledOnValidThread()); |
| 439 if (!config.IsValidConfig()) | 438 if (!config.IsValidConfig()) |
| 440 return false; | 439 return false; |
| 441 config_ = config; | 440 config_ = config; |
| 442 return true; | 441 return true; |
| 443 } | 442 } |
| 444 | 443 |
| 445 void AudioPipelineDeviceFake::SetStreamVolumeMultiplier(float multiplier) { | 444 void AudioPipelineDeviceFake::SetStreamVolumeMultiplier(float multiplier) { |
| 446 DCHECK(CalledOnValidThread()); | 445 DCHECK(CalledOnValidThread()); |
| 447 } | 446 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 461 State GetState() const override; | 460 State GetState() const override; |
| 462 bool SetState(State new_state) override; | 461 bool SetState(State new_state) override; |
| 463 bool SetStartPts(base::TimeDelta time) override; | 462 bool SetStartPts(base::TimeDelta time) override; |
| 464 FrameStatus PushFrame( | 463 FrameStatus PushFrame( |
| 465 const scoped_refptr<DecryptContext>& decrypt_context, | 464 const scoped_refptr<DecryptContext>& decrypt_context, |
| 466 const scoped_refptr<DecoderBufferBase>& buffer, | 465 const scoped_refptr<DecoderBufferBase>& buffer, |
| 467 const FrameStatusCB& completion_cb) override; | 466 const FrameStatusCB& completion_cb) override; |
| 468 base::TimeDelta GetRenderingTime() const override; | 467 base::TimeDelta GetRenderingTime() const override; |
| 469 base::TimeDelta GetRenderingDelay() const override; | 468 base::TimeDelta GetRenderingDelay() const override; |
| 470 void SetVideoClient(const VideoClient& client) override; | 469 void SetVideoClient(const VideoClient& client) override; |
| 471 bool SetConfig(const ::media::VideoDecoderConfig& config) override; | 470 bool SetConfig(const VideoConfig& config) override; |
| 472 bool GetStatistics(Statistics* stats) const override; | 471 bool GetStatistics(Statistics* stats) const override; |
| 473 | 472 |
| 474 private: | 473 private: |
| 475 scoped_ptr<MediaComponentDeviceFake> fake_pipeline_; | 474 scoped_ptr<MediaComponentDeviceFake> fake_pipeline_; |
| 476 | 475 |
| 477 ::media::VideoDecoderConfig config_; | 476 VideoConfig config_; |
| 478 | 477 |
| 479 DISALLOW_COPY_AND_ASSIGN(VideoPipelineDeviceFake); | 478 DISALLOW_COPY_AND_ASSIGN(VideoPipelineDeviceFake); |
| 480 }; | 479 }; |
| 481 | 480 |
| 482 VideoPipelineDeviceFake::VideoPipelineDeviceFake( | 481 VideoPipelineDeviceFake::VideoPipelineDeviceFake( |
| 483 MediaClockDeviceFake* media_clock_device) | 482 MediaClockDeviceFake* media_clock_device) |
| 484 : fake_pipeline_(new MediaComponentDeviceFake(media_clock_device)) { | 483 : fake_pipeline_(new MediaComponentDeviceFake(media_clock_device)) { |
| 485 DetachFromThread(); | 484 DetachFromThread(); |
| 486 } | 485 } |
| 487 | 486 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 498 | 497 |
| 499 bool VideoPipelineDeviceFake::SetState(State new_state) { | 498 bool VideoPipelineDeviceFake::SetState(State new_state) { |
| 500 bool success = fake_pipeline_->SetState(new_state); | 499 bool success = fake_pipeline_->SetState(new_state); |
| 501 if (!success) | 500 if (!success) |
| 502 return false; | 501 return false; |
| 503 | 502 |
| 504 if (new_state == kStateIdle) { | 503 if (new_state == kStateIdle) { |
| 505 DCHECK(config_.IsValidConfig()); | 504 DCHECK(config_.IsValidConfig()); |
| 506 } | 505 } |
| 507 if (new_state == kStateUninitialized) { | 506 if (new_state == kStateUninitialized) { |
| 508 config_ = ::media::VideoDecoderConfig(); | 507 config_ = VideoConfig(); |
| 509 } | 508 } |
| 510 return true; | 509 return true; |
| 511 } | 510 } |
| 512 | 511 |
| 513 bool VideoPipelineDeviceFake::SetStartPts(base::TimeDelta time) { | 512 bool VideoPipelineDeviceFake::SetStartPts(base::TimeDelta time) { |
| 514 return fake_pipeline_->SetStartPts(time); | 513 return fake_pipeline_->SetStartPts(time); |
| 515 } | 514 } |
| 516 | 515 |
| 517 MediaComponentDevice::FrameStatus VideoPipelineDeviceFake::PushFrame( | 516 MediaComponentDevice::FrameStatus VideoPipelineDeviceFake::PushFrame( |
| 518 const scoped_refptr<DecryptContext>& decrypt_context, | 517 const scoped_refptr<DecryptContext>& decrypt_context, |
| 519 const scoped_refptr<DecoderBufferBase>& buffer, | 518 const scoped_refptr<DecoderBufferBase>& buffer, |
| 520 const FrameStatusCB& completion_cb) { | 519 const FrameStatusCB& completion_cb) { |
| 521 return fake_pipeline_->PushFrame(decrypt_context, buffer, completion_cb); | 520 return fake_pipeline_->PushFrame(decrypt_context, buffer, completion_cb); |
| 522 } | 521 } |
| 523 | 522 |
| 524 base::TimeDelta VideoPipelineDeviceFake::GetRenderingTime() const { | 523 base::TimeDelta VideoPipelineDeviceFake::GetRenderingTime() const { |
| 525 return fake_pipeline_->GetRenderingTime(); | 524 return fake_pipeline_->GetRenderingTime(); |
| 526 } | 525 } |
| 527 | 526 |
| 528 base::TimeDelta VideoPipelineDeviceFake::GetRenderingDelay() const { | 527 base::TimeDelta VideoPipelineDeviceFake::GetRenderingDelay() const { |
| 529 return fake_pipeline_->GetRenderingDelay(); | 528 return fake_pipeline_->GetRenderingDelay(); |
| 530 } | 529 } |
| 531 | 530 |
| 532 void VideoPipelineDeviceFake::SetVideoClient(const VideoClient& client) { | 531 void VideoPipelineDeviceFake::SetVideoClient(const VideoClient& client) { |
| 533 } | 532 } |
| 534 | 533 |
| 535 bool VideoPipelineDeviceFake::SetConfig( | 534 bool VideoPipelineDeviceFake::SetConfig( |
| 536 const ::media::VideoDecoderConfig& config) { | 535 const VideoConfig& config) { |
| 537 DCHECK(CalledOnValidThread()); | 536 DCHECK(CalledOnValidThread()); |
| 538 if (!config.IsValidConfig()) | 537 if (!config.IsValidConfig()) |
| 539 return false; | 538 return false; |
| 540 config_ = config; | 539 config_ = config; |
| 541 return true; | 540 return true; |
| 542 } | 541 } |
| 543 | 542 |
| 544 bool VideoPipelineDeviceFake::GetStatistics(Statistics* stats) const { | 543 bool VideoPipelineDeviceFake::GetStatistics(Statistics* stats) const { |
| 545 return fake_pipeline_->GetStatistics(stats); | 544 return fake_pipeline_->GetStatistics(stats); |
| 546 } | 545 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 564 VideoPipelineDevice* MediaPipelineDeviceFake::GetVideoPipelineDevice() const { | 563 VideoPipelineDevice* MediaPipelineDeviceFake::GetVideoPipelineDevice() const { |
| 565 return video_pipeline_device_.get(); | 564 return video_pipeline_device_.get(); |
| 566 } | 565 } |
| 567 | 566 |
| 568 MediaClockDevice* MediaPipelineDeviceFake::GetMediaClockDevice() const { | 567 MediaClockDevice* MediaPipelineDeviceFake::GetMediaClockDevice() const { |
| 569 return media_clock_device_.get(); | 568 return media_clock_device_.get(); |
| 570 } | 569 } |
| 571 | 570 |
| 572 } // namespace media | 571 } // namespace media |
| 573 } // namespace chromecast | 572 } // namespace chromecast |
| OLD | NEW |