1 // Copyright (c) 2013 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 MEDIA_FILTERS_FAKE_DEMUXER_STREAM_H_
6 #define MEDIA_FILTERS_FAKE_DEMUXER_STREAM_H_
8 #include "base/basictypes.h"
9 #include "base/memory/ref_counted.h"
10 #include "media/base/audio_decoder_config.h"
11 #include "media/base/demuxer_stream.h"
12 #include "media/base/video_decoder_config.h"
15 class SingleThreadTaskRunner
;
20 class FakeDemuxerStream
: public DemuxerStream
{
22 // Constructs an object that outputs |num_configs| different configs in
23 // sequence with |num_frames_in_one_config| buffers for each config. The
24 // output buffers are encrypted if |is_encrypted| is true.
25 FakeDemuxerStream(int num_configs
,
26 int num_buffers_in_one_config
,
28 ~FakeDemuxerStream() override
;
30 // DemuxerStream implementation.
31 void Read(const ReadCB
& read_cb
) override
;
32 AudioDecoderConfig
audio_decoder_config() override
;
33 VideoDecoderConfig
video_decoder_config() override
;
34 Type
type() const override
;
35 bool SupportsConfigChanges() override
;
36 VideoRotation
video_rotation() override
;
40 int num_buffers_returned() const { return num_buffers_returned_
; }
42 // Upon the next read, holds the read callback until SatisfyRead() or Reset()
46 // Upon the next config change read, holds the read callback until
47 // SatisfyRead() or Reset() is called. If there is no config change any more,
48 // no read will be held.
49 void HoldNextConfigChangeRead();
51 // Satisfies the pending read with the next scheduled status and buffer.
54 // Satisfies pending read request and then holds the following read.
55 void SatisfyReadAndHoldNext();
57 // Satisfies the pending read (if any) with kAborted and NULL. This call
58 // always clears |hold_next_read_|.
61 // Reset() this demuxer stream and set the reading position to the start of
65 // Sets the splice timestamp for all furture buffers returned via Read().
66 void set_splice_timestamp(base::TimeDelta splice_timestamp
) {
67 splice_timestamp_
= splice_timestamp
;
71 void UpdateVideoDecoderConfig();
74 scoped_refptr
<base::SingleThreadTaskRunner
> task_runner_
;
76 const int num_configs_
;
77 const int num_buffers_in_one_config_
;
78 const bool config_changes_
;
79 const bool is_encrypted_
;
81 int num_configs_left_
;
83 // Number of frames left with the current decoder config.
84 int num_buffers_left_in_current_config_
;
86 int num_buffers_returned_
;
88 base::TimeDelta current_timestamp_
;
89 base::TimeDelta duration_
;
90 base::TimeDelta splice_timestamp_
;
92 gfx::Size next_coded_size_
;
93 VideoDecoderConfig video_decoder_config_
;
98 // Zero-based number indicating which read operation should be held. -1 means
99 // no read shall be held.
102 DISALLOW_COPY_AND_ASSIGN(FakeDemuxerStream
);
107 #endif // MEDIA_FILTERS_FAKE_DEMUXER_STREAM_H_