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

Side by Side Diff: media/filters/ffmpeg_audio_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
« no previous file with comments | « media/filters/fake_video_decoder_unittest.cc ('k') | media/filters/ffmpeg_audio_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_AUDIO_DECODER_H_ 5 #ifndef MEDIA_FILTERS_FFMPEG_AUDIO_DECODER_H_
6 #define MEDIA_FILTERS_FFMPEG_AUDIO_DECODER_H_ 6 #define MEDIA_FILTERS_FFMPEG_AUDIO_DECODER_H_
7 7
8 #include <list> 8 #include <list>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 19 matching lines...) Expand all
30 30
31 class MEDIA_EXPORT FFmpegAudioDecoder : public AudioDecoder { 31 class MEDIA_EXPORT FFmpegAudioDecoder : public AudioDecoder {
32 public: 32 public:
33 FFmpegAudioDecoder( 33 FFmpegAudioDecoder(
34 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, 34 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
35 const LogCB& log_cb); 35 const LogCB& log_cb);
36 virtual ~FFmpegAudioDecoder(); 36 virtual ~FFmpegAudioDecoder();
37 37
38 // AudioDecoder implementation. 38 // AudioDecoder implementation.
39 virtual void Initialize(const AudioDecoderConfig& config, 39 virtual void Initialize(const AudioDecoderConfig& config,
40 const PipelineStatusCB& status_cb) OVERRIDE; 40 const PipelineStatusCB& status_cb,
41 const OutputCB& output_cb) OVERRIDE;
41 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer, 42 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer,
42 const DecodeCB& decode_cb) OVERRIDE; 43 const DecodeCB& decode_cb) OVERRIDE;
43 virtual scoped_refptr<AudioBuffer> GetDecodeOutput() OVERRIDE;
44 virtual void Reset(const base::Closure& closure) OVERRIDE; 44 virtual void Reset(const base::Closure& closure) OVERRIDE;
45 virtual void Stop() OVERRIDE; 45 virtual void Stop() OVERRIDE;
46 46
47 private: 47 private:
48 enum DecoderState { 48 enum DecoderState {
49 kUninitialized, 49 kUninitialized,
50 kNormal, 50 kNormal,
51 kFlushCodec,
52 kDecodeFinished, 51 kDecodeFinished,
53 kError 52 kError
54 }; 53 };
55 54
56 // Reset decoder and call |reset_cb_|. 55 // Reset decoder and call |reset_cb_|.
57 void DoReset(); 56 void DoReset();
58 57
59 // Handles decoding an unencrypted encoded buffer. 58 // Handles decoding an unencrypted encoded buffer.
60 void DecodeBuffer(const scoped_refptr<DecoderBuffer>& buffer, 59 void DecodeBuffer(const scoped_refptr<DecoderBuffer>& buffer,
61 const DecodeCB& decode_cb); 60 const DecodeCB& decode_cb);
62 bool FFmpegDecode(const scoped_refptr<DecoderBuffer>& buffer); 61 bool FFmpegDecode(const scoped_refptr<DecoderBuffer>& buffer);
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(); 65 bool ConfigureDecoder();
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 void ResetTimestampState(); 70 void ResetTimestampState();
72 71
73 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 72 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
74 73
74 OutputCB output_cb_;
75
75 DecoderState state_; 76 DecoderState state_;
76 77
77 // FFmpeg structures owned by this object. 78 // FFmpeg structures owned by this object.
78 scoped_ptr<AVCodecContext, ScopedPtrAVFreeContext> codec_context_; 79 scoped_ptr<AVCodecContext, ScopedPtrAVFreeContext> codec_context_;
79 scoped_ptr<AVFrame, ScopedPtrAVFreeFrame> av_frame_; 80 scoped_ptr<AVFrame, ScopedPtrAVFreeFrame> av_frame_;
80 81
81 AudioDecoderConfig config_; 82 AudioDecoderConfig config_;
82 83
83 // AVSampleFormat initially requested; not Chrome's SampleFormat. 84 // AVSampleFormat initially requested; not Chrome's SampleFormat.
84 int av_sample_format_; 85 int av_sample_format_;
85 86
86 scoped_ptr<AudioDiscardHelper> discard_helper_; 87 scoped_ptr<AudioDiscardHelper> discard_helper_;
87 88
88 // Since multiple frames may be decoded from the same packet we need to queue
89 // them up.
90 std::list<scoped_refptr<AudioBuffer> > queued_audio_;
91
92 LogCB log_cb_; 89 LogCB log_cb_;
93 90
94 DISALLOW_IMPLICIT_CONSTRUCTORS(FFmpegAudioDecoder); 91 DISALLOW_IMPLICIT_CONSTRUCTORS(FFmpegAudioDecoder);
95 }; 92 };
96 93
97 } // namespace media 94 } // namespace media
98 95
99 #endif // MEDIA_FILTERS_FFMPEG_AUDIO_DECODER_H_ 96 #endif // MEDIA_FILTERS_FFMPEG_AUDIO_DECODER_H_
OLDNEW
« no previous file with comments | « media/filters/fake_video_decoder_unittest.cc ('k') | media/filters/ffmpeg_audio_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698