OLD | NEW |
| (Empty) |
1 // Copyright 2015 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_DUMMY_DEMUXER_STREAM_H_ | |
6 #define CHROMECAST_MEDIA_CMA_TEST_DUMMY_DEMUXER_STREAM_H_ | |
7 | |
8 #include <list> | |
9 | |
10 #include "base/bind.h" | |
11 #include "base/thread_task_runner_handle.h" | |
12 #include "chromecast/media/cma/filters/demuxer_stream_adapter.h" | |
13 #include "media/base/decoder_buffer.h" | |
14 #include "media/base/demuxer_stream.h" | |
15 | |
16 namespace chromecast { | |
17 namespace media { | |
18 | |
19 class DemuxerStreamForTest : public ::media::DemuxerStream { | |
20 public: | |
21 // Creates a demuxer stream which provides frames either with a delay | |
22 // or instantly. | |
23 // - |total_frames| is the number of frames to generate before EOS frame. | |
24 // -1 means keep generating frames and never produce EOS. | |
25 // The scheduling pattern is the following: | |
26 // - provides |delayed_frame_count| frames with a delay, | |
27 // - then provides the following |cycle_count| - |delayed_frame_count| | |
28 // instantly, | |
29 // - then provides |delayed_frame_count| frames with a delay, | |
30 // - ... and so on. | |
31 // Special cases: | |
32 // - all frames are delayed: |delayed_frame_count| = |cycle_count| | |
33 // - all frames are provided instantly: |delayed_frame_count| = 0 | |
34 // |config_idx| is a list of frame index before which there is | |
35 // a change of decoder configuration. | |
36 DemuxerStreamForTest(int total_frames, | |
37 int cycle_count, | |
38 int delayed_frame_count, | |
39 const std::list<int>& config_idx); | |
40 ~DemuxerStreamForTest() override; | |
41 | |
42 // ::media::DemuxerStream implementation. | |
43 void Read(const ReadCB& read_cb) override; | |
44 ::media::AudioDecoderConfig audio_decoder_config() override; | |
45 ::media::VideoDecoderConfig video_decoder_config() override; | |
46 Type type() const override; | |
47 bool SupportsConfigChanges() override; | |
48 ::media::VideoRotation video_rotation() override; | |
49 | |
50 bool has_pending_read() const { return has_pending_read_; } | |
51 | |
52 // Frame duration | |
53 static const int kDemuxerStreamForTestFrameDuration = 40; | |
54 | |
55 private: | |
56 void DoRead(const ReadCB& read_cb); | |
57 | |
58 // Demuxer configuration. | |
59 int total_frame_count_; | |
60 const int cycle_count_; | |
61 const int delayed_frame_count_; | |
62 std::list<int> config_idx_; | |
63 | |
64 // Number of frames sent so far. | |
65 int frame_count_; | |
66 | |
67 bool has_pending_read_; | |
68 | |
69 DISALLOW_COPY_AND_ASSIGN(DemuxerStreamForTest); | |
70 }; | |
71 | |
72 } // namespace media | |
73 } // namespace chromecast | |
74 #endif | |
OLD | NEW |