| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 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_VPX_VIDEO_DECODER_H_ | |
| 6 #define MEDIA_FILTERS_VPX_VIDEO_DECODER_H_ | |
| 7 | |
| 8 #include "base/callback.h" | |
| 9 #include "base/memory/ref_counted.h" | |
| 10 #include "media/base/demuxer_stream.h" | |
| 11 #include "media/base/video_decoder.h" | |
| 12 | |
| 13 struct vpx_codec_ctx; | |
| 14 struct vpx_image; | |
| 15 | |
| 16 namespace base { | |
| 17 class MessageLoopProxy; | |
| 18 } | |
| 19 | |
| 20 namespace media { | |
| 21 | |
| 22 class MEDIA_EXPORT VpxVideoDecoder : public VideoDecoder { | |
| 23 public: | |
| 24 explicit VpxVideoDecoder( | |
| 25 const scoped_refptr<base::MessageLoopProxy>& message_loop); | |
| 26 | |
| 27 // VideoDecoder implementation. | |
| 28 virtual void Initialize(const scoped_refptr<DemuxerStream>& stream, | |
| 29 const PipelineStatusCB& status_cb, | |
| 30 const StatisticsCB& statistics_cb) OVERRIDE; | |
| 31 virtual void Read(const ReadCB& read_cb) OVERRIDE; | |
| 32 virtual void Reset(const base::Closure& closure) OVERRIDE; | |
| 33 virtual void Stop(const base::Closure& closure) OVERRIDE; | |
| 34 | |
| 35 protected: | |
| 36 virtual ~VpxVideoDecoder(); | |
| 37 | |
| 38 private: | |
| 39 enum DecoderState { | |
| 40 kUninitialized, | |
| 41 kNormal, | |
| 42 kFlushCodec, | |
| 43 kDecodeFinished | |
| 44 }; | |
| 45 | |
| 46 // Handles (re-)initializing the decoder with a (new) config. | |
| 47 // Returns true when initialization was successful. | |
| 48 bool ConfigureDecoder(); | |
| 49 | |
| 50 void CloseDecoder(); | |
| 51 void ReadFromDemuxerStream(); | |
| 52 | |
| 53 // Carries out the buffer processing operation scheduled by | |
| 54 // DecryptOrDecodeBuffer(). | |
| 55 void DoDecryptOrDecodeBuffer(DemuxerStream::Status status, | |
| 56 const scoped_refptr<DecoderBuffer>& buffer); | |
| 57 | |
| 58 void DecodeBuffer(const scoped_refptr<DecoderBuffer>& buffer); | |
| 59 bool Decode(const scoped_refptr<DecoderBuffer>& buffer, | |
| 60 scoped_refptr<VideoFrame>* video_frame); | |
| 61 | |
| 62 // Reset decoder and call |reset_cb_|. | |
| 63 void DoReset(); | |
| 64 | |
| 65 void CopyVpxImageTo(const vpx_image* vpx_image, | |
| 66 scoped_refptr<VideoFrame>* video_frame); | |
| 67 | |
| 68 scoped_refptr<base::MessageLoopProxy> message_loop_; | |
| 69 | |
| 70 DecoderState state_; | |
| 71 | |
| 72 StatisticsCB statistics_cb_; | |
| 73 ReadCB read_cb_; | |
| 74 base::Closure reset_cb_; | |
| 75 | |
| 76 // Pointer to the demuxer stream that will feed us compressed buffers. | |
| 77 scoped_refptr<DemuxerStream> demuxer_stream_; | |
| 78 | |
| 79 vpx_codec_ctx* vpx_codec_; | |
| 80 | |
| 81 DISALLOW_COPY_AND_ASSIGN(VpxVideoDecoder); | |
| 82 }; | |
| 83 | |
| 84 } // namespace media | |
| 85 | |
| 86 #endif // MEDIA_FILTERS_VPX_VIDEO_DECODER_H_ | |
| OLD | NEW |