Upstream version 11.40.271.0
[platform/framework/web/crosswalk.git] / src / chromecast / media / cma / test / media_component_device_feeder_for_test.h
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_TEST_MEDIA_COMPONENT_DEVICE_FEEDER_FOR_TEST_H_
6 #define CHROMECAST_MEDIA_CMA_TEST_MEDIA_COMPONENT_DEVICE_FEEDER_FOR_TEST_H_
7
8 #include <list>
9 #include <vector>
10
11 #include "base/basictypes.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/time/time.h"
15 #include "chromecast/media/cma/backend/audio_pipeline_device.h"
16 #include "chromecast/media/cma/backend/media_clock_device.h"
17 #include "chromecast/media/cma/backend/media_pipeline_device.h"
18 #include "chromecast/media/cma/backend/video_pipeline_device.h"
19 #include "chromecast/media/cma/base/decoder_buffer_base.h"
20
21 namespace chromecast {
22 namespace media {
23
24 typedef std::list<scoped_refptr<DecoderBufferBase> > BufferList;
25
26 class MediaComponentDeviceFeederForTest {
27  public:
28   MediaComponentDeviceFeederForTest(
29       MediaComponentDevice *device,
30       const BufferList& frames);
31
32   virtual ~MediaComponentDeviceFeederForTest();
33
34   void Initialize(const base::Closure& eos_cb);
35
36   // Feeds one frame into the pipeline.
37   void Feed();
38
39  private:
40   void OnFramePushed(MediaComponentDevice::FrameStatus status);
41
42   void OnEos();
43
44   MediaComponentDevice *media_component_device_;
45   BufferList frames_;
46
47   // Frame index where the audio device is switching to the kStateRunning.
48   int rendering_frame_idx_;
49
50   // Frame index where the clock device is switching to the kStateRunning.
51   int clock_frame_idx_;
52
53   // Timing pattern to feed the pipeline.
54   std::vector<base::TimeDelta> delayed_feed_pattern_;
55   size_t delayed_feed_pattern_idx_;
56
57   base::Closure eos_cb_;
58
59   bool feeding_completed_;
60
61   DISALLOW_COPY_AND_ASSIGN(MediaComponentDeviceFeederForTest);
62 };
63
64 }  // namespace media
65 }  // namespace chromecast
66
67 #endif  // CHROMECAST_MEDIA_CMA_TEST_MEDIA_COMPONENT_DEVICE_FEEDER_FOR_TEST_H_