| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef MEDIA_FILTERS_FAKE_VIDEO_DECODER_H_ | 5 #ifndef MEDIA_FILTERS_FAKE_VIDEO_DECODER_H_ |
| 6 #define MEDIA_FILTERS_FAKE_VIDEO_DECODER_H_ | 6 #define MEDIA_FILTERS_FAKE_VIDEO_DECODER_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 namespace base { | 25 namespace base { |
| 26 class SingleThreadTaskRunner; | 26 class SingleThreadTaskRunner; |
| 27 } | 27 } |
| 28 | 28 |
| 29 namespace media { | 29 namespace media { |
| 30 | 30 |
| 31 class FakeVideoDecoder : public VideoDecoder { | 31 class FakeVideoDecoder : public VideoDecoder { |
| 32 public: | 32 public: |
| 33 // Constructs an object with a decoding delay of |decoding_delay| frames. | 33 // Constructs an object with a decoding delay of |decoding_delay| frames. |
| 34 FakeVideoDecoder(int decoding_delay, | 34 FakeVideoDecoder(int decoding_delay, |
| 35 bool supports_get_decode_output, | |
| 36 int max_parallel_decoding_requests); | 35 int max_parallel_decoding_requests); |
| 37 virtual ~FakeVideoDecoder(); | 36 virtual ~FakeVideoDecoder(); |
| 38 | 37 |
| 39 // VideoDecoder implementation. | 38 // VideoDecoder implementation. |
| 40 virtual void Initialize(const VideoDecoderConfig& config, | 39 virtual void Initialize(const VideoDecoderConfig& config, |
| 41 bool low_delay, | 40 bool low_delay, |
| 42 const PipelineStatusCB& status_cb) OVERRIDE; | 41 const PipelineStatusCB& status_cb, |
| 42 const OutputCB& output_cb) OVERRIDE; |
| 43 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer, | 43 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer, |
| 44 const DecodeCB& decode_cb) OVERRIDE; | 44 const DecodeCB& decode_cb) OVERRIDE; |
| 45 virtual void Reset(const base::Closure& closure) OVERRIDE; | 45 virtual void Reset(const base::Closure& closure) OVERRIDE; |
| 46 virtual void Stop() OVERRIDE; | 46 virtual void Stop() OVERRIDE; |
| 47 virtual scoped_refptr<VideoFrame> GetDecodeOutput() OVERRIDE; | |
| 48 virtual int GetMaxDecodeRequests() const OVERRIDE; | 47 virtual int GetMaxDecodeRequests() const OVERRIDE; |
| 49 | 48 |
| 50 // Holds the next init/decode/reset callback from firing. | 49 // Holds the next init/decode/reset callback from firing. |
| 51 void HoldNextInit(); | 50 void HoldNextInit(); |
| 52 void HoldDecode(); | 51 void HoldDecode(); |
| 53 void HoldNextReset(); | 52 void HoldNextReset(); |
| 54 | 53 |
| 55 // Satisfies the pending init/decode/reset callback, which must be ready to | 54 // Satisfies the pending init/decode/reset callback, which must be ready to |
| 56 // fire when these methods are called. | 55 // fire when these methods are called. |
| 57 void SatisfyInit(); | 56 void SatisfyInit(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 69 enum State { | 68 enum State { |
| 70 STATE_UNINITIALIZED, | 69 STATE_UNINITIALIZED, |
| 71 STATE_NORMAL, | 70 STATE_NORMAL, |
| 72 STATE_END_OF_STREAM, | 71 STATE_END_OF_STREAM, |
| 73 STATE_ERROR, | 72 STATE_ERROR, |
| 74 }; | 73 }; |
| 75 | 74 |
| 76 // Callback for updating |total_bytes_decoded_|. | 75 // Callback for updating |total_bytes_decoded_|. |
| 77 void OnFrameDecoded(int buffer_size, | 76 void OnFrameDecoded(int buffer_size, |
| 78 const DecodeCB& decode_cb, | 77 const DecodeCB& decode_cb, |
| 79 Status status, | 78 Status status); |
| 80 const scoped_refptr<VideoFrame>& video_frame); | |
| 81 | 79 |
| 82 // Runs |decode_cb| or puts it to |held_decode_callbacks_| depending on | 80 // Runs |decode_cb| or puts it to |held_decode_callbacks_| depending on |
| 83 // current value of |hold_decode_|. | 81 // current value of |hold_decode_|. |
| 84 void RunOrHoldDecode(const DecodeCB& decode_cb); | 82 void RunOrHoldDecode(const DecodeCB& decode_cb); |
| 85 | 83 |
| 86 // Runs |decode_cb| with a frame from |decoded_frames_|. | 84 // Runs |decode_cb| with a frame from |decoded_frames_|. |
| 87 void RunDecodeCallback(const DecodeCB& decode_cb); | 85 void RunDecodeCallback(const DecodeCB& decode_cb); |
| 88 | 86 |
| 89 void DoReset(); | 87 void DoReset(); |
| 90 | 88 |
| 91 base::ThreadChecker thread_checker_; | 89 base::ThreadChecker thread_checker_; |
| 92 | 90 |
| 93 const size_t decoding_delay_; | 91 const size_t decoding_delay_; |
| 94 const bool supports_get_decode_output_; | |
| 95 const int max_parallel_decoding_requests_; | 92 const int max_parallel_decoding_requests_; |
| 96 | 93 |
| 97 State state_; | 94 State state_; |
| 98 | 95 |
| 99 CallbackHolder<PipelineStatusCB> init_cb_; | 96 CallbackHolder<PipelineStatusCB> init_cb_; |
| 100 CallbackHolder<base::Closure> reset_cb_; | 97 CallbackHolder<base::Closure> reset_cb_; |
| 101 | 98 |
| 99 OutputCB output_cb_; |
| 100 |
| 102 bool hold_decode_; | 101 bool hold_decode_; |
| 103 std::list<DecodeCB> held_decode_callbacks_; | 102 std::list<DecodeCB> held_decode_callbacks_; |
| 104 | 103 |
| 105 VideoDecoderConfig current_config_; | 104 VideoDecoderConfig current_config_; |
| 106 | 105 |
| 107 std::list<scoped_refptr<VideoFrame> > decoded_frames_; | 106 std::list<scoped_refptr<VideoFrame> > decoded_frames_; |
| 108 | 107 |
| 109 int total_bytes_decoded_; | 108 int total_bytes_decoded_; |
| 110 | 109 |
| 111 // NOTE: Weak pointers must be invalidated before all other member variables. | 110 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 112 base::WeakPtrFactory<FakeVideoDecoder> weak_factory_; | 111 base::WeakPtrFactory<FakeVideoDecoder> weak_factory_; |
| 113 | 112 |
| 114 DISALLOW_COPY_AND_ASSIGN(FakeVideoDecoder); | 113 DISALLOW_COPY_AND_ASSIGN(FakeVideoDecoder); |
| 115 }; | 114 }; |
| 116 | 115 |
| 117 } // namespace media | 116 } // namespace media |
| 118 | 117 |
| 119 #endif // MEDIA_FILTERS_FAKE_VIDEO_DECODER_H_ | 118 #endif // MEDIA_FILTERS_FAKE_VIDEO_DECODER_H_ |
| OLD | NEW |