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 |
| 52 // Carries out the buffer reading operation scheduled by Read(). |
| 53 void DoRead(const ReadCB& read_cb); |
| 54 |
| 55 void ReadFromDemuxerStream(); |
| 56 |
| 57 // Carries out the buffer processing operation scheduled by |
| 58 // DecryptOrDecodeBuffer(). |
| 59 void DoDecryptOrDecodeBuffer(DemuxerStream::Status status, |
| 60 const scoped_refptr<DecoderBuffer>& buffer); |
| 61 |
| 62 void DecodeBuffer(const scoped_refptr<DecoderBuffer>& buffer); |
| 63 bool Decode(const scoped_refptr<DecoderBuffer>& buffer, |
| 64 scoped_refptr<VideoFrame>* video_frame); |
| 65 |
| 66 // Reset decoder and call |reset_cb_|. |
| 67 void DoReset(); |
| 68 |
| 69 bool CopyVpxImageTo(const vpx_image* vpx_image, |
| 70 scoped_refptr<VideoFrame>* video_frame); |
| 71 |
| 72 scoped_refptr<base::MessageLoopProxy> message_loop_; |
| 73 |
| 74 DecoderState state_; |
| 75 |
| 76 StatisticsCB statistics_cb_; |
| 77 ReadCB read_cb_; |
| 78 base::Closure reset_cb_; |
| 79 |
| 80 // Pointer to the demuxer stream that will feed us compressed buffers. |
| 81 scoped_refptr<DemuxerStream> demuxer_stream_; |
| 82 |
| 83 vpx_codec_ctx* vpx_codec_; |
| 84 |
| 85 DISALLOW_COPY_AND_ASSIGN(VpxVideoDecoder); |
| 86 }; |
| 87 |
| 88 } // namespace media |
| 89 |
| 90 #endif // MEDIA_FILTERS_VPX_VIDEO_DECODER_H_ |
OLD | NEW |