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.
5 #ifndef CHROMECAST_MEDIA_CMA_TEST_DUMMY_DEMUXER_STREAM_H_
6 #define CHROMECAST_MEDIA_CMA_TEST_DUMMY_DEMUXER_STREAM_H_
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"
16 namespace chromecast
{
19 class DemuxerStreamForTest
: public ::media::DemuxerStream
{
21 // Creates a demuxer stream which provides frames either with a delay
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|
29 // - then provides |delayed_frame_count| frames with a delay,
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
,
38 int delayed_frame_count
,
39 const std::list
<int>& config_idx
);
40 ~DemuxerStreamForTest() override
;
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
;
50 bool has_pending_read() const { return has_pending_read_
; }
53 static const int kDemuxerStreamForTestFrameDuration
= 40;
56 void DoRead(const ReadCB
& read_cb
);
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_
;
64 // Number of frames sent so far.
67 bool has_pending_read_
;
69 DISALLOW_COPY_AND_ASSIGN(DemuxerStreamForTest
);
73 } // namespace chromecast