OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #ifndef MEDIA_FILTERS_FAKE_VIDEO_DECODER_H_ |
| 6 #define MEDIA_FILTERS_FAKE_VIDEO_DECODER_H_ |
| 7 |
| 8 #include <list> |
| 9 |
| 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" |
| 23 |
| 24 using base::ResetAndReturn; |
| 25 |
| 26 namespace base { |
| 27 class MessageLoopProxy; |
| 28 } |
| 29 |
| 30 namespace media { |
| 31 |
| 32 class MEDIA_EXPORT FakeVideoDecoder : public VideoDecoder { |
| 33 public: |
| 34 // Constructs an object with a decoding delay of |decoding_delay| frames. |
| 35 explicit FakeVideoDecoder(int decoding_delay); |
| 36 virtual ~FakeVideoDecoder(); |
| 37 |
| 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; |
| 45 |
| 46 // Holds the next init/read/reset/stop callback from firing. |
| 47 void HoldNextInit(); |
| 48 void HoldNextRead(); |
| 49 void HoldNextReset(); |
| 50 void HoldNextStop(); |
| 51 |
| 52 // Satisfies the pending init/read/reset/stop callback, which must be ready |
| 53 // to fire when these methods are called. |
| 54 void SatisfyInit(); |
| 55 void SatisfyRead(); |
| 56 void SatisfyReset(); |
| 57 void SatisfyStop(); |
| 58 |
| 59 private: |
| 60 enum State { |
| 61 UNINITIALIZED, |
| 62 NORMAL |
| 63 }; |
| 64 |
| 65 void ReadFromDemuxerStream(); |
| 66 |
| 67 // Callback for DemuxerStream::Read(). |
| 68 void BufferReady(DemuxerStream::Status status, |
| 69 const scoped_refptr<DecoderBuffer>& buffer); |
| 70 |
| 71 void DoReset(); |
| 72 void DoStop(); |
| 73 |
| 74 scoped_refptr<base::MessageLoopProxy> message_loop_; |
| 75 base::WeakPtrFactory<FakeVideoDecoder> weak_factory_; |
| 76 base::WeakPtr<FakeVideoDecoder> weak_this_; |
| 77 |
| 78 const int decoding_delay_; |
| 79 |
| 80 State state_; |
| 81 |
| 82 StatisticsCB statistics_cb_; |
| 83 |
| 84 CallbackHolder<PipelineStatusCB> init_cb_; |
| 85 CallbackHolder<ReadCB> read_cb_; |
| 86 CallbackHolder<base::Closure> reset_cb_; |
| 87 CallbackHolder<base::Closure> stop_cb_; |
| 88 |
| 89 // Pointer to the demuxer stream that will feed us compressed buffers. |
| 90 DemuxerStream* demuxer_stream_; |
| 91 |
| 92 VideoDecoderConfig current_config_; |
| 93 |
| 94 std::list<scoped_refptr<VideoFrame> > decoded_frames_; |
| 95 |
| 96 DISALLOW_COPY_AND_ASSIGN(FakeVideoDecoder); |
| 97 }; |
| 98 |
| 99 } // namespace media |
| 100 |
| 101 #endif // MEDIA_FILTERS_FAKE_VIDEO_DECODER_H_ |
OLD | NEW |