Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(304)

Side by Side Diff: media/filters/ffmpeg_video_decoder.h

Issue 297553002: Add callback in VideoDecoder and AudioDecoder to return decoded frames. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_FFMPEG_VIDEO_DECODER_H_ 5 #ifndef MEDIA_FILTERS_FFMPEG_VIDEO_DECODER_H_
6 #define MEDIA_FILTERS_FFMPEG_VIDEO_DECODER_H_ 6 #define MEDIA_FILTERS_FFMPEG_VIDEO_DECODER_H_
7 7
8 #include <list> 8 #include <list>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 16 matching lines...) Expand all
27 27
28 class MEDIA_EXPORT FFmpegVideoDecoder : public VideoDecoder { 28 class MEDIA_EXPORT FFmpegVideoDecoder : public VideoDecoder {
29 public: 29 public:
30 explicit FFmpegVideoDecoder( 30 explicit FFmpegVideoDecoder(
31 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); 31 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner);
32 virtual ~FFmpegVideoDecoder(); 32 virtual ~FFmpegVideoDecoder();
33 33
34 // VideoDecoder implementation. 34 // VideoDecoder implementation.
35 virtual void Initialize(const VideoDecoderConfig& config, 35 virtual void Initialize(const VideoDecoderConfig& config,
36 bool low_delay, 36 bool low_delay,
37 const PipelineStatusCB& status_cb) OVERRIDE; 37 const PipelineStatusCB& status_cb,
38 const OutputCB& output_cb) OVERRIDE;
38 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer, 39 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer,
39 const DecodeCB& decode_cb) OVERRIDE; 40 const DecodeCB& decode_cb) OVERRIDE;
40 virtual void Reset(const base::Closure& closure) OVERRIDE; 41 virtual void Reset(const base::Closure& closure) OVERRIDE;
41 virtual void Stop() OVERRIDE; 42 virtual void Stop() OVERRIDE;
42 43
43 // Callback called from within FFmpeg to allocate a buffer based on 44 // Callback called from within FFmpeg to allocate a buffer based on
44 // the dimensions of |codec_context|. See AVCodecContext.get_buffer2 45 // the dimensions of |codec_context|. See AVCodecContext.get_buffer2
45 // documentation inside FFmpeg. 46 // documentation inside FFmpeg.
46 int GetVideoBuffer(struct AVCodecContext* codec_context, 47 int GetVideoBuffer(struct AVCodecContext* codec_context,
47 AVFrame* frame, 48 AVFrame* frame,
48 int flags); 49 int flags);
49 50
50 private: 51 private:
51 enum DecoderState { 52 enum DecoderState {
52 kUninitialized, 53 kUninitialized,
53 kNormal, 54 kNormal,
54 kFlushCodec,
55 kDecodeFinished, 55 kDecodeFinished,
56 kError 56 kError
57 }; 57 };
58 58
59 // Handles decoding an unencrypted encoded buffer. 59 // Handles decoding an unencrypted encoded buffer.
60 void DecodeBuffer(const scoped_refptr<DecoderBuffer>& buffer);
61 bool FFmpegDecode(const scoped_refptr<DecoderBuffer>& buffer, 60 bool FFmpegDecode(const scoped_refptr<DecoderBuffer>& buffer,
62 scoped_refptr<VideoFrame>* video_frame); 61 bool* produced_frame);
63 62
64 // Handles (re-)initializing the decoder with a (new) config. 63 // Handles (re-)initializing the decoder with a (new) config.
65 // Returns true if initialization was successful. 64 // Returns true if initialization was successful.
66 bool ConfigureDecoder(bool low_delay); 65 bool ConfigureDecoder(bool low_delay);
67 66
68 // Releases resources associated with |codec_context_| and |av_frame_| 67 // Releases resources associated with |codec_context_| and |av_frame_|
69 // and resets them to NULL. 68 // and resets them to NULL.
70 void ReleaseFFmpegResources(); 69 void ReleaseFFmpegResources();
71 70
72 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 71 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
73 72
74 DecoderState state_; 73 DecoderState state_;
75 74
76 // TODO(xhwang): Merge DecodeBuffer() into Decode() and remove this. 75 OutputCB output_cb_;
77 DecodeCB decode_cb_;
78 76
79 // FFmpeg structures owned by this object. 77 // FFmpeg structures owned by this object.
80 scoped_ptr<AVCodecContext, ScopedPtrAVFreeContext> codec_context_; 78 scoped_ptr<AVCodecContext, ScopedPtrAVFreeContext> codec_context_;
81 scoped_ptr<AVFrame, ScopedPtrAVFreeFrame> av_frame_; 79 scoped_ptr<AVFrame, ScopedPtrAVFreeFrame> av_frame_;
82 80
83 VideoDecoderConfig config_; 81 VideoDecoderConfig config_;
84 82
85 VideoFramePool frame_pool_; 83 VideoFramePool frame_pool_;
86 84
87 DISALLOW_COPY_AND_ASSIGN(FFmpegVideoDecoder); 85 DISALLOW_COPY_AND_ASSIGN(FFmpegVideoDecoder);
88 }; 86 };
89 87
90 } // namespace media 88 } // namespace media
91 89
92 #endif // MEDIA_FILTERS_FFMPEG_VIDEO_DECODER_H_ 90 #endif // MEDIA_FILTERS_FFMPEG_VIDEO_DECODER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698