OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROMECAST_MEDIA_CMA_BACKEND_MEDIA_COMPONENT_DEVICE_FEEDER_FOR_TEST_H_ |
| 6 #define CHROMECAST_MEDIA_CMA_BACKEND_MEDIA_COMPONENT_DEVICE_FEEDER_FOR_TEST_H_ |
| 7 |
| 8 #include <list> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/basictypes.h" |
| 12 #include "base/macros.h" |
| 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/time/time.h" |
| 16 #include "chromecast/media/cma/backend/audio_pipeline_device.h" |
| 17 #include "chromecast/media/cma/backend/media_clock_device.h" |
| 18 #include "chromecast/media/cma/backend/media_pipeline_device.h" |
| 19 #include "chromecast/media/cma/backend/video_pipeline_device.h" |
| 20 #include "chromecast/media/cma/base/decoder_buffer_base.h" |
| 21 |
| 22 namespace chromecast { |
| 23 namespace media { |
| 24 |
| 25 typedef std::list<scoped_refptr<DecoderBufferBase> > FrameList; |
| 26 |
| 27 class MediaComponentDeviceFeeder : |
| 28 public base::RefCounted<MediaComponentDeviceFeeder> { |
| 29 public: |
| 30 MediaComponentDeviceFeeder(MediaComponentDevice *device, |
| 31 MediaClockDevice *clock, |
| 32 const FrameList& frames); |
| 33 |
| 34 void Initialize(); |
| 35 |
| 36 // Feed one frame into the pipeline. |
| 37 void Feed(); |
| 38 void Pause(); |
| 39 |
| 40 void SetEosCB(base::Callback<void()> eos_cb); |
| 41 void SetFrameCountBetweenPause(int frame_count); |
| 42 void SetDelayedFeedPattern(const std::vector<bool>& pattern); |
| 43 |
| 44 protected: |
| 45 friend class base::RefCounted<MediaComponentDeviceFeeder>; |
| 46 virtual ~MediaComponentDeviceFeeder(); |
| 47 |
| 48 private: |
| 49 |
| 50 void OnFramePushed(MediaComponentDevice::FrameStatus status); |
| 51 void OnPauseCompleted(); |
| 52 |
| 53 void OnEos(); |
| 54 |
| 55 MediaClockDevice *media_clock_device_; |
| 56 MediaComponentDevice *media_component_device_; |
| 57 FrameList frames_; |
| 58 |
| 59 // Frame index where the audio device is switching to the kStateRunning. |
| 60 int rendering_frame_idx_; |
| 61 |
| 62 // Frame index where the clock device is switching to the kStateRunning |
| 63 int clock_frame_idx_; |
| 64 |
| 65 // Timing pattern to feed the pipeline. |
| 66 std::vector<bool> delayed_feed_pattern_; |
| 67 size_t delayed_feed_pattern_idx_; |
| 68 |
| 69 // Issue a pause at regular intervals. |
| 70 int frame_count_between_pause_; |
| 71 int frame_count_since_last_pause_; |
| 72 |
| 73 // Set to enable eos callback |
| 74 base::Callback<void()> eos_cb_; |
| 75 |
| 76 // Current media time. |
| 77 base::TimeDelta media_time_; |
| 78 |
| 79 bool feeding_completed_; |
| 80 |
| 81 DISALLOW_COPY_AND_ASSIGN(MediaComponentDeviceFeeder); |
| 82 }; |
| 83 |
| 84 } // namespace media |
| 85 } // namespace chromecast |
| 86 |
| 87 #endif // CHROMECAST_MEDIA_CMA_BACKEND_MEDIA_COMPONENT_DEVICE_FEEDER_FOR_TEST_H
_ |
OLD | NEW |