Report errors from ChromiumEnv::GetChildren in Posix.
[chromium-blink-merge.git] / media / filters / fake_video_decoder.h
blobc1cf1a6a4cf6e5c87b6632c886e2c76a92315c7d
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_
8 #include <list>
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/pipeline_status.h"
17 #include "media/base/video_decoder.h"
18 #include "media/base/video_decoder_config.h"
19 #include "media/base/video_frame.h"
20 #include "ui/gfx/size.h"
22 using base::ResetAndReturn;
24 namespace base {
25 class MessageLoopProxy;
28 namespace media {
30 class FakeVideoDecoder : public VideoDecoder {
31 public:
32 // Constructs an object with a decoding delay of |decoding_delay| frames.
33 explicit FakeVideoDecoder(int decoding_delay);
34 virtual ~FakeVideoDecoder();
36 // VideoDecoder implementation.
37 virtual void Initialize(const VideoDecoderConfig& config,
38 const PipelineStatusCB& status_cb) OVERRIDE;
39 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer,
40 const DecodeCB& decode_cb) OVERRIDE;
41 virtual void Reset(const base::Closure& closure) OVERRIDE;
42 virtual void Stop(const base::Closure& closure) OVERRIDE;
44 // Holds the next init/read/reset/stop callback from firing.
45 void HoldNextInit();
46 void HoldNextRead();
47 void HoldNextReset();
48 void HoldNextStop();
50 // Satisfies the pending init/read/reset/stop callback, which must be ready
51 // to fire when these methods are called.
52 void SatisfyInit();
53 void SatisfyRead();
54 void SatisfyReset();
55 void SatisfyStop();
57 int total_bytes_decoded() const { return total_bytes_decoded_; }
59 private:
60 enum State {
61 UNINITIALIZED,
62 NORMAL
65 // Callback for updating |total_bytes_decoded_|.
66 void OnFrameDecoded(int buffer_size,
67 const DecodeCB& read_cb,
68 Status status,
69 const scoped_refptr<VideoFrame>& video_frame);
71 void DoReset();
72 void DoStop();
74 scoped_refptr<base::MessageLoopProxy> message_loop_;
75 base::WeakPtrFactory<FakeVideoDecoder> weak_factory_;
76 base::WeakPtr<FakeVideoDecoder> weak_this_;
78 const int decoding_delay_;
80 State state_;
82 CallbackHolder<PipelineStatusCB> init_cb_;
83 CallbackHolder<DecodeCB> decode_cb_;
84 CallbackHolder<base::Closure> reset_cb_;
85 CallbackHolder<base::Closure> stop_cb_;
87 VideoDecoderConfig current_config_;
89 std::list<scoped_refptr<VideoFrame> > decoded_frames_;
91 int total_bytes_decoded_;
93 DISALLOW_COPY_AND_ASSIGN(FakeVideoDecoder);
96 } // namespace media
98 #endif // MEDIA_FILTERS_FAKE_VIDEO_DECODER_H_