| 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 "media/base/audio_decoder_config.h" |
| 21 #include "media/base/buffers.h" | 21 #include "media/base/buffers.h" |
| 22 #include "media/base/video_decoder_config.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 virtual ~MediaClockDeviceFake(); | 30 ~MediaClockDeviceFake() override; |
| 31 | 31 |
| 32 // MediaClockDevice implementation. | 32 // MediaClockDevice implementation. |
| 33 virtual State GetState() const override; | 33 State GetState() const override; |
| 34 virtual bool SetState(State new_state) override; | 34 bool SetState(State new_state) override; |
| 35 virtual bool ResetTimeline(base::TimeDelta time) override; | 35 bool ResetTimeline(base::TimeDelta time) override; |
| 36 virtual bool SetRate(float rate) override; | 36 bool SetRate(float rate) override; |
| 37 virtual base::TimeDelta GetTime() override; | 37 base::TimeDelta GetTime() override; |
| 38 | 38 |
| 39 private: | 39 private: |
| 40 State state_; | 40 State state_; |
| 41 | 41 |
| 42 // Media time sampled at STC time |stc_|. | 42 // Media time sampled at STC time |stc_|. |
| 43 base::TimeDelta media_time_; | 43 base::TimeDelta media_time_; |
| 44 base::TimeTicks stc_; | 44 base::TimeTicks stc_; |
| 45 | 45 |
| 46 float rate_; | 46 float rate_; |
| 47 | 47 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 namespace { | 123 namespace { |
| 124 | 124 |
| 125 // Maximum number of frames that can be buffered. | 125 // Maximum number of frames that can be buffered. |
| 126 const size_t kMaxFrameCount = 20; | 126 const size_t kMaxFrameCount = 20; |
| 127 | 127 |
| 128 } // namespace | 128 } // namespace |
| 129 | 129 |
| 130 class MediaComponentDeviceFake : public MediaComponentDevice { | 130 class MediaComponentDeviceFake : public MediaComponentDevice { |
| 131 public: | 131 public: |
| 132 explicit MediaComponentDeviceFake(MediaClockDeviceFake* media_clock_device); | 132 explicit MediaComponentDeviceFake(MediaClockDeviceFake* media_clock_device); |
| 133 virtual ~MediaComponentDeviceFake(); | 133 ~MediaComponentDeviceFake() override; |
| 134 | 134 |
| 135 // MediaComponentDevice implementation. | 135 // MediaComponentDevice implementation. |
| 136 virtual void SetClient(const Client& client) override; | 136 void SetClient(const Client& client) override; |
| 137 virtual State GetState() const override; | 137 State GetState() const override; |
| 138 virtual bool SetState(State new_state) override; | 138 bool SetState(State new_state) override; |
| 139 virtual bool SetStartPts(base::TimeDelta time) override; | 139 bool SetStartPts(base::TimeDelta time) override; |
| 140 virtual FrameStatus PushFrame( | 140 FrameStatus PushFrame( |
| 141 const scoped_refptr<DecryptContext>& decrypt_context, | 141 const scoped_refptr<DecryptContext>& decrypt_context, |
| 142 const scoped_refptr<DecoderBufferBase>& buffer, | 142 const scoped_refptr<DecoderBufferBase>& buffer, |
| 143 const FrameStatusCB& completion_cb) override; | 143 const FrameStatusCB& completion_cb) override; |
| 144 virtual base::TimeDelta GetRenderingTime() const override; | 144 base::TimeDelta GetRenderingTime() const override; |
| 145 virtual base::TimeDelta GetRenderingDelay() const override; | 145 base::TimeDelta GetRenderingDelay() const override; |
| 146 virtual bool GetStatistics(Statistics* stats) const override; | 146 bool GetStatistics(Statistics* stats) const override; |
| 147 | 147 |
| 148 private: | 148 private: |
| 149 struct FakeDecoderBuffer { | 149 struct FakeDecoderBuffer { |
| 150 FakeDecoderBuffer(); | 150 FakeDecoderBuffer(); |
| 151 ~FakeDecoderBuffer(); | 151 ~FakeDecoderBuffer(); |
| 152 | 152 |
| 153 // Buffer size. | 153 // Buffer size. |
| 154 size_t size; | 154 size_t size; |
| 155 | 155 |
| 156 // Presentation timestamp. | 156 // Presentation timestamp. |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 stats->decoded_bytes = decoded_byte_count_; | 351 stats->decoded_bytes = decoded_byte_count_; |
| 352 stats->decoded_samples = decoded_frame_count_; | 352 stats->decoded_samples = decoded_frame_count_; |
| 353 stats->dropped_samples = 0; | 353 stats->dropped_samples = 0; |
| 354 return true; | 354 return true; |
| 355 } | 355 } |
| 356 | 356 |
| 357 | 357 |
| 358 class AudioPipelineDeviceFake : public AudioPipelineDevice { | 358 class AudioPipelineDeviceFake : public AudioPipelineDevice { |
| 359 public: | 359 public: |
| 360 explicit AudioPipelineDeviceFake(MediaClockDeviceFake* media_clock_device); | 360 explicit AudioPipelineDeviceFake(MediaClockDeviceFake* media_clock_device); |
| 361 virtual ~AudioPipelineDeviceFake(); | 361 ~AudioPipelineDeviceFake() override; |
| 362 | 362 |
| 363 // AudioPipelineDevice implementation. | 363 // AudioPipelineDevice implementation. |
| 364 virtual void SetClient(const Client& client) override; | 364 void SetClient(const Client& client) override; |
| 365 virtual State GetState() const override; | 365 State GetState() const override; |
| 366 virtual bool SetState(State new_state) override; | 366 bool SetState(State new_state) override; |
| 367 virtual bool SetStartPts(base::TimeDelta time) override; | 367 bool SetStartPts(base::TimeDelta time) override; |
| 368 virtual 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 virtual base::TimeDelta GetRenderingTime() const override; | 372 base::TimeDelta GetRenderingTime() const override; |
| 373 virtual base::TimeDelta GetRenderingDelay() const override; | 373 base::TimeDelta GetRenderingDelay() const override; |
| 374 virtual bool SetConfig(const ::media::AudioDecoderConfig& config) override; | 374 bool SetConfig(const ::media::AudioDecoderConfig& config) override; |
| 375 virtual void SetStreamVolumeMultiplier(float multiplier) override; | 375 void SetStreamVolumeMultiplier(float multiplier) override; |
| 376 virtual 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 ::media::AudioDecoderConfig 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( |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 } | 447 } |
| 448 | 448 |
| 449 bool AudioPipelineDeviceFake::GetStatistics(Statistics* stats) const { | 449 bool AudioPipelineDeviceFake::GetStatistics(Statistics* stats) const { |
| 450 return fake_pipeline_->GetStatistics(stats); | 450 return fake_pipeline_->GetStatistics(stats); |
| 451 } | 451 } |
| 452 | 452 |
| 453 | 453 |
| 454 class VideoPipelineDeviceFake : public VideoPipelineDevice { | 454 class VideoPipelineDeviceFake : public VideoPipelineDevice { |
| 455 public: | 455 public: |
| 456 explicit VideoPipelineDeviceFake(MediaClockDeviceFake* media_clock_device); | 456 explicit VideoPipelineDeviceFake(MediaClockDeviceFake* media_clock_device); |
| 457 virtual ~VideoPipelineDeviceFake(); | 457 ~VideoPipelineDeviceFake() override; |
| 458 | 458 |
| 459 // VideoPipelineDevice implementation. | 459 // VideoPipelineDevice implementation. |
| 460 virtual void SetClient(const Client& client) override; | 460 void SetClient(const Client& client) override; |
| 461 virtual State GetState() const override; | 461 State GetState() const override; |
| 462 virtual bool SetState(State new_state) override; | 462 bool SetState(State new_state) override; |
| 463 virtual bool SetStartPts(base::TimeDelta time) override; | 463 bool SetStartPts(base::TimeDelta time) override; |
| 464 virtual FrameStatus PushFrame( | 464 FrameStatus PushFrame( |
| 465 const scoped_refptr<DecryptContext>& decrypt_context, | 465 const scoped_refptr<DecryptContext>& decrypt_context, |
| 466 const scoped_refptr<DecoderBufferBase>& buffer, | 466 const scoped_refptr<DecoderBufferBase>& buffer, |
| 467 const FrameStatusCB& completion_cb) override; | 467 const FrameStatusCB& completion_cb) override; |
| 468 virtual base::TimeDelta GetRenderingTime() const override; | 468 base::TimeDelta GetRenderingTime() const override; |
| 469 virtual base::TimeDelta GetRenderingDelay() const override; | 469 base::TimeDelta GetRenderingDelay() const override; |
| 470 virtual void SetVideoClient(const VideoClient& client) override; | 470 void SetVideoClient(const VideoClient& client) override; |
| 471 virtual bool SetConfig(const ::media::VideoDecoderConfig& config) override; | 471 bool SetConfig(const ::media::VideoDecoderConfig& config) override; |
| 472 virtual bool GetStatistics(Statistics* stats) const override; | 472 bool GetStatistics(Statistics* stats) const override; |
| 473 | 473 |
| 474 private: | 474 private: |
| 475 scoped_ptr<MediaComponentDeviceFake> fake_pipeline_; | 475 scoped_ptr<MediaComponentDeviceFake> fake_pipeline_; |
| 476 | 476 |
| 477 ::media::VideoDecoderConfig config_; | 477 ::media::VideoDecoderConfig config_; |
| 478 | 478 |
| 479 DISALLOW_COPY_AND_ASSIGN(VideoPipelineDeviceFake); | 479 DISALLOW_COPY_AND_ASSIGN(VideoPipelineDeviceFake); |
| 480 }; | 480 }; |
| 481 | 481 |
| 482 VideoPipelineDeviceFake::VideoPipelineDeviceFake( | 482 VideoPipelineDeviceFake::VideoPipelineDeviceFake( |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 VideoPipelineDevice* MediaPipelineDeviceFake::GetVideoPipelineDevice() const { | 564 VideoPipelineDevice* MediaPipelineDeviceFake::GetVideoPipelineDevice() const { |
| 565 return video_pipeline_device_.get(); | 565 return video_pipeline_device_.get(); |
| 566 } | 566 } |
| 567 | 567 |
| 568 MediaClockDevice* MediaPipelineDeviceFake::GetMediaClockDevice() const { | 568 MediaClockDevice* MediaPipelineDeviceFake::GetMediaClockDevice() const { |
| 569 return media_clock_device_.get(); | 569 return media_clock_device_.get(); |
| 570 } | 570 } |
| 571 | 571 |
| 572 } // namespace media | 572 } // namespace media |
| 573 } // namespace chromecast | 573 } // namespace chromecast |
| OLD | NEW |