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