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

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

Issue 14348007: Reland: Remove reference counting from media::VideoDecoder and friends. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes Created 7 years, 8 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"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/weak_ptr.h"
12 #include "media/base/demuxer_stream.h" 12 #include "media/base/demuxer_stream.h"
13 #include "media/base/video_decoder.h" 13 #include "media/base/video_decoder.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 31
31 // VideoDecoder implementation. 32 // VideoDecoder implementation.
32 virtual void Initialize(const scoped_refptr<DemuxerStream>& stream, 33 virtual void Initialize(const scoped_refptr<DemuxerStream>& stream,
33 const PipelineStatusCB& status_cb, 34 const PipelineStatusCB& status_cb,
34 const StatisticsCB& statistics_cb) OVERRIDE; 35 const StatisticsCB& statistics_cb) OVERRIDE;
35 virtual void Read(const ReadCB& read_cb) OVERRIDE; 36 virtual void Read(const ReadCB& read_cb) OVERRIDE;
36 virtual void Reset(const base::Closure& closure) OVERRIDE; 37 virtual void Reset(const base::Closure& closure) OVERRIDE;
37 virtual void Stop(const base::Closure& closure) OVERRIDE; 38 virtual void Stop(const base::Closure& closure) OVERRIDE;
38 39
39 // Callback called from within FFmpeg to allocate a buffer based on 40 // Callback called from within FFmpeg to allocate a buffer based on
40 // the dimensions of |codec_context|. See AVCodecContext.get_buffer 41 // the dimensions of |codec_context|. See AVCodecContext.get_buffer
41 // documentation inside FFmpeg. 42 // documentation inside FFmpeg.
42 int GetVideoBuffer(AVCodecContext *codec_context, AVFrame* frame); 43 int GetVideoBuffer(AVCodecContext *codec_context, AVFrame* frame);
43 44
44 protected:
45 virtual ~FFmpegVideoDecoder();
46
47 private: 45 private:
48 enum DecoderState { 46 enum DecoderState {
49 kUninitialized, 47 kUninitialized,
50 kNormal, 48 kNormal,
51 kFlushCodec, 49 kFlushCodec,
52 kDecodeFinished 50 kDecodeFinished
53 }; 51 };
54 52
55 // Reads from the demuxer stream and corresponding read callback. 53 // Reads from the demuxer stream and corresponding read callback.
56 void ReturnFrameOrReadFromDemuxerStream(); 54 void ReturnFrameOrReadFromDemuxerStream();
(...skipping 10 matching lines...) Expand all
67 bool ConfigureDecoder(); 65 bool ConfigureDecoder();
68 66
69 // Releases resources associated with |codec_context_| and |av_frame_| 67 // Releases resources associated with |codec_context_| and |av_frame_|
70 // and resets them to NULL. 68 // and resets them to NULL.
71 void ReleaseFFmpegResources(); 69 void ReleaseFFmpegResources();
72 70
73 // Reset decoder and call |reset_cb_|. 71 // Reset decoder and call |reset_cb_|.
74 void DoReset(); 72 void DoReset();
75 73
76 scoped_refptr<base::MessageLoopProxy> message_loop_; 74 scoped_refptr<base::MessageLoopProxy> message_loop_;
75 base::WeakPtrFactory<FFmpegVideoDecoder> weak_factory_;
76 base::WeakPtr<FFmpegVideoDecoder> weak_this_;
77 77
78 DecoderState state_; 78 DecoderState state_;
79 79
80 StatisticsCB statistics_cb_; 80 StatisticsCB statistics_cb_;
81 81
82 ReadCB read_cb_; 82 ReadCB read_cb_;
83 base::Closure reset_cb_; 83 base::Closure reset_cb_;
84 84
85 // FFmpeg structures owned by this object. 85 // FFmpeg structures owned by this object.
86 AVCodecContext* codec_context_; 86 AVCodecContext* codec_context_;
87 AVFrame* av_frame_; 87 AVFrame* av_frame_;
88 88
89 // Pointer to the demuxer stream that will feed us compressed buffers. 89 // Pointer to the demuxer stream that will feed us compressed buffers.
90 scoped_refptr<DemuxerStream> demuxer_stream_; 90 scoped_refptr<DemuxerStream> demuxer_stream_;
91 91
92 std::list<scoped_refptr<VideoFrame> > decoded_frames_; 92 std::list<scoped_refptr<VideoFrame> > decoded_frames_;
93 93
94 DISALLOW_COPY_AND_ASSIGN(FFmpegVideoDecoder); 94 DISALLOW_COPY_AND_ASSIGN(FFmpegVideoDecoder);
95 }; 95 };
96 96
97 } // namespace media 97 } // namespace media
98 98
99 #endif // MEDIA_FILTERS_FFMPEG_VIDEO_DECODER_H_ 99 #endif // MEDIA_FILTERS_FFMPEG_VIDEO_DECODER_H_
OLDNEW
« no previous file with comments | « media/filters/decrypting_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