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

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

Issue 16274005: Separate DemuxerStream and VideoDecoder. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix win64 Created 7 years, 5 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
« no previous file with comments | « media/filters/fake_video_decoder_unittest.cc ('k') | media/filters/ffmpeg_video_decoder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "media/base/demuxer_stream.h"
13 #include "media/base/video_decoder.h" 12 #include "media/base/video_decoder.h"
13 #include "media/base/video_decoder_config.h"
14 14
15 struct AVCodecContext; 15 struct AVCodecContext;
16 struct AVFrame; 16 struct AVFrame;
17 17
18 namespace base { 18 namespace base {
19 class MessageLoopProxy; 19 class MessageLoopProxy;
20 } 20 }
21 21
22 namespace media { 22 namespace media {
23 23
24 class DecoderBuffer; 24 class DecoderBuffer;
25 25
26 class MEDIA_EXPORT FFmpegVideoDecoder : public VideoDecoder { 26 class MEDIA_EXPORT FFmpegVideoDecoder : public VideoDecoder {
27 public: 27 public:
28 explicit FFmpegVideoDecoder( 28 explicit FFmpegVideoDecoder(
29 const scoped_refptr<base::MessageLoopProxy>& message_loop); 29 const scoped_refptr<base::MessageLoopProxy>& message_loop);
30 virtual ~FFmpegVideoDecoder(); 30 virtual ~FFmpegVideoDecoder();
31 31
32 // VideoDecoder implementation. 32 // VideoDecoder implementation.
33 virtual void Initialize(DemuxerStream* stream, 33 virtual void Initialize(const VideoDecoderConfig& config,
34 const PipelineStatusCB& status_cb, 34 const PipelineStatusCB& status_cb,
35 const StatisticsCB& statistics_cb) OVERRIDE; 35 const StatisticsCB& statistics_cb) OVERRIDE;
36 virtual void Read(const ReadCB& read_cb) OVERRIDE; 36 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer,
37 const ReadCB& read_cb) OVERRIDE;
37 virtual void Reset(const base::Closure& closure) OVERRIDE; 38 virtual void Reset(const base::Closure& closure) OVERRIDE;
38 virtual void Stop(const base::Closure& closure) OVERRIDE; 39 virtual void Stop(const base::Closure& closure) OVERRIDE;
39 40
40 // Callback called from within FFmpeg to allocate a buffer based on 41 // Callback called from within FFmpeg to allocate a buffer based on
41 // the dimensions of |codec_context|. See AVCodecContext.get_buffer 42 // the dimensions of |codec_context|. See AVCodecContext.get_buffer
42 // documentation inside FFmpeg. 43 // documentation inside FFmpeg.
43 int GetVideoBuffer(AVCodecContext *codec_context, AVFrame* frame); 44 int GetVideoBuffer(AVCodecContext *codec_context, AVFrame* frame);
44 45
45 private: 46 private:
46 enum DecoderState { 47 enum DecoderState {
47 kUninitialized, 48 kUninitialized,
48 kNormal, 49 kNormal,
49 kFlushCodec, 50 kFlushCodec,
50 kDecodeFinished, 51 kDecodeFinished,
51 kError 52 kError
52 }; 53 };
53 54
54 // Reads from the demuxer stream and corresponding read callback.
55 void ReadFromDemuxerStream();
56 void BufferReady(DemuxerStream::Status status,
57 const scoped_refptr<DecoderBuffer>& buffer);
58
59 // Handles decoding an unencrypted encoded buffer. 55 // Handles decoding an unencrypted encoded buffer.
60 void DecodeBuffer(const scoped_refptr<DecoderBuffer>& buffer); 56 void DecodeBuffer(const scoped_refptr<DecoderBuffer>& buffer);
61 bool Decode(const scoped_refptr<DecoderBuffer>& buffer, 57 bool FFmpegDecode(const scoped_refptr<DecoderBuffer>& buffer,
62 scoped_refptr<VideoFrame>* video_frame); 58 scoped_refptr<VideoFrame>* video_frame);
63 59
64 // Handles (re-)initializing the decoder with a (new) config. 60 // Handles (re-)initializing the decoder with a (new) config.
65 // Returns true if initialization was successful. 61 // Returns true if initialization was successful.
66 bool ConfigureDecoder(); 62 bool ConfigureDecoder();
67 63
68 // Releases resources associated with |codec_context_| and |av_frame_| 64 // Releases resources associated with |codec_context_| and |av_frame_|
69 // and resets them to NULL. 65 // and resets them to NULL.
70 void ReleaseFFmpegResources(); 66 void ReleaseFFmpegResources();
71 67
72 // Reset decoder and call |reset_cb_|. 68 // Reset decoder and call |reset_cb_|.
73 void DoReset(); 69 void DoReset();
74 70
75 scoped_refptr<base::MessageLoopProxy> message_loop_; 71 scoped_refptr<base::MessageLoopProxy> message_loop_;
76 base::WeakPtrFactory<FFmpegVideoDecoder> weak_factory_; 72 base::WeakPtrFactory<FFmpegVideoDecoder> weak_factory_;
77 base::WeakPtr<FFmpegVideoDecoder> weak_this_; 73 base::WeakPtr<FFmpegVideoDecoder> weak_this_;
78 74
79 DecoderState state_; 75 DecoderState state_;
80 76
81 StatisticsCB statistics_cb_; 77 StatisticsCB statistics_cb_;
82 78
83 ReadCB read_cb_; 79 ReadCB read_cb_;
84 base::Closure reset_cb_; 80 base::Closure reset_cb_;
85 81
86 // FFmpeg structures owned by this object. 82 // FFmpeg structures owned by this object.
87 AVCodecContext* codec_context_; 83 AVCodecContext* codec_context_;
88 AVFrame* av_frame_; 84 AVFrame* av_frame_;
89 85
90 // Pointer to the demuxer stream that will feed us compressed buffers. 86 VideoDecoderConfig config_;
91 DemuxerStream* demuxer_stream_;
92 87
93 DISALLOW_COPY_AND_ASSIGN(FFmpegVideoDecoder); 88 DISALLOW_COPY_AND_ASSIGN(FFmpegVideoDecoder);
94 }; 89 };
95 90
96 } // namespace media 91 } // namespace media
97 92
98 #endif // MEDIA_FILTERS_FFMPEG_VIDEO_DECODER_H_ 93 #endif // MEDIA_FILTERS_FFMPEG_VIDEO_DECODER_H_
OLDNEW
« no previous file with comments | « media/filters/fake_video_decoder_unittest.cc ('k') | media/filters/ffmpeg_video_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698