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 MessageLoopProxy
;
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 virtual ~FakeDemuxerStream();
30 // DemuxerStream implementation.
31 virtual void Read(const ReadCB
& read_cb
) OVERRIDE
;
32 virtual AudioDecoderConfig
audio_decoder_config() OVERRIDE
;
33 virtual VideoDecoderConfig
video_decoder_config() OVERRIDE
;
34 virtual Type
type() OVERRIDE
;
35 virtual void EnableBitstreamConverter() OVERRIDE
;
37 int num_buffers_returned() const { return num_buffers_returned_
; }
39 // Upon the next read, holds the read callback until SatisfyRead() or Reset()
43 // Upon the next config change read, holds the read callback until
44 // SatisfyRead() or Reset() is called. If there is no config change any more,
45 // no read will be held.
46 void HoldNextConfigChangeRead();
48 // Satisfies the pending read with the next scheduled status and buffer.
51 // Satisfies the pending read (if any) with kAborted and NULL. This call
52 // always clears |hold_next_read_|.
56 void UpdateVideoDecoderConfig();
59 scoped_refptr
<base::MessageLoopProxy
> message_loop_
;
61 int num_configs_left_
;
62 int num_buffers_in_one_config_
;
65 // Number of frames left with the current decoder config.
66 int num_buffers_left_in_current_config_
;
68 int num_buffers_returned_
;
70 base::TimeDelta current_timestamp_
;
71 base::TimeDelta duration_
;
73 gfx::Size next_coded_size_
;
74 VideoDecoderConfig video_decoder_config_
;
79 // Zero-based number indicating which read operation should be held. -1 means
80 // no read shall be held.
83 DISALLOW_COPY_AND_ASSIGN(FakeDemuxerStream
);
88 #endif // MEDIA_FILTERS_FAKE_DEMUXER_STREAM_H_