1 // Copyright 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_VIDEO_DECODER_H_
6 #define MEDIA_FILTERS_FAKE_VIDEO_DECODER_H_
10 #include "base/bind.h"
11 #include "base/callback.h"
12 #include "base/callback_helpers.h"
13 #include "base/memory/weak_ptr.h"
14 #include "media/base/callback_holder.h"
15 #include "media/base/decoder_buffer.h"
16 #include "media/base/demuxer_stream.h"
17 #include "media/base/media_export.h"
18 #include "media/base/pipeline_status.h"
19 #include "media/base/video_decoder.h"
20 #include "media/base/video_decoder_config.h"
21 #include "media/base/video_frame.h"
22 #include "ui/gfx/size.h"
24 using base::ResetAndReturn
;
27 class MessageLoopProxy
;
32 class MEDIA_EXPORT FakeVideoDecoder
: public VideoDecoder
{
34 // Constructs an object with a decoding delay of |decoding_delay| frames.
35 explicit FakeVideoDecoder(int decoding_delay
);
36 virtual ~FakeVideoDecoder();
38 // VideoDecoder implementation.
39 virtual void Initialize(DemuxerStream
* stream
,
40 const PipelineStatusCB
& status_cb
,
41 const StatisticsCB
& statistics_cb
) OVERRIDE
;
42 virtual void Read(const ReadCB
& read_cb
) OVERRIDE
;
43 virtual void Reset(const base::Closure
& closure
) OVERRIDE
;
44 virtual void Stop(const base::Closure
& closure
) OVERRIDE
;
46 // Holds the next init/read/reset/stop callback from firing.
52 // Satisfies the pending init/read/reset/stop callback, which must be ready
53 // to fire when these methods are called.
65 void ReadFromDemuxerStream();
67 // Callback for DemuxerStream::Read().
68 void BufferReady(DemuxerStream::Status status
,
69 const scoped_refptr
<DecoderBuffer
>& buffer
);
74 scoped_refptr
<base::MessageLoopProxy
> message_loop_
;
75 base::WeakPtrFactory
<FakeVideoDecoder
> weak_factory_
;
76 base::WeakPtr
<FakeVideoDecoder
> weak_this_
;
78 const int decoding_delay_
;
82 StatisticsCB statistics_cb_
;
84 CallbackHolder
<PipelineStatusCB
> init_cb_
;
85 CallbackHolder
<ReadCB
> read_cb_
;
86 CallbackHolder
<base::Closure
> reset_cb_
;
87 CallbackHolder
<base::Closure
> stop_cb_
;
89 // Pointer to the demuxer stream that will feed us compressed buffers.
90 DemuxerStream
* demuxer_stream_
;
92 VideoDecoderConfig current_config_
;
94 std::list
<scoped_refptr
<VideoFrame
> > decoded_frames_
;
96 DISALLOW_COPY_AND_ASSIGN(FakeVideoDecoder
);
101 #endif // MEDIA_FILTERS_FAKE_VIDEO_DECODER_H_