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

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

Issue 465044: Refactor FFmpegVideoDecoder to try and generalize code common to all video decoders. (Closed)
Patch Set: Fix SCOPED_TRACE since VS faults on %zd. Created 11 years 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
« no previous file with comments | « media/filters/decoder_base.h ('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) 2009 The Chromium Authors. All rights reserved. Use of this 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the 2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file. 3 // 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 "media/base/factory.h" 8 #include "media/base/factory.h"
9 #include "media/filters/decoder_base.h" 9 #include "media/filters/decoder_base.h"
10 10
11 struct AVCodecContext; 11 struct AVCodecContext;
12 12
13 namespace media { 13 namespace media {
14 14
15 // Forward declaration for scoped_ptr_malloc. 15 // Forward declaration for scoped_ptr_malloc.
16 class ScopedPtrAVFree; 16 class ScopedPtrAVFree;
17 17
18 class FFmpegAudioDecoder : public DecoderBase<AudioDecoder, Buffer> { 18 class FFmpegAudioDecoder : public DecoderBase<AudioDecoder, Buffer> {
19 public: 19 public:
20 static FilterFactory* CreateFactory() { 20 static FilterFactory* CreateFactory() {
21 return new FilterFactoryImpl0<FFmpegAudioDecoder>(); 21 return new FilterFactoryImpl0<FFmpegAudioDecoder>();
22 } 22 }
23 23
24 static bool IsMediaFormatSupported(const MediaFormat& media_format); 24 static bool IsMediaFormatSupported(const MediaFormat& media_format);
25 25
26 protected: 26 protected:
27 virtual bool OnInitialize(DemuxerStream* demuxer_stream); 27 virtual void DoInitialize(DemuxerStream* demuxer_stream, bool* success,
28 Task* done_cb);
28 29
29 virtual void OnSeek(base::TimeDelta time); 30 virtual void DoSeek(base::TimeDelta time, Task* done_cb);
30 31
31 virtual void OnStop(); 32 virtual void DoDecode(Buffer* input, Task* done_cb);
32
33 virtual void OnDecode(Buffer* input);
34 33
35 private: 34 private:
36 friend class FilterFactoryImpl0<FFmpegAudioDecoder>; 35 friend class FilterFactoryImpl0<FFmpegAudioDecoder>;
37 FFmpegAudioDecoder(); 36 FFmpegAudioDecoder();
38 virtual ~FFmpegAudioDecoder(); 37 virtual ~FFmpegAudioDecoder();
39 38
40 // Calculates the duration of an audio buffer based on the sample rate, 39 // Calculates the duration of an audio buffer based on the sample rate,
41 // channels and bits per sample given the size in bytes. 40 // channels and bits per sample given the size in bytes.
42 base::TimeDelta CalculateDuration(size_t size); 41 base::TimeDelta CalculateDuration(size_t size);
43 42
44 // A FFmpeg defined structure that holds decoder information, this variable 43 // A FFmpeg defined structure that holds decoder information, this variable
45 // is initialized in OnInitialize(). 44 // is initialized in OnInitialize().
46 AVCodecContext* codec_context_; 45 AVCodecContext* codec_context_;
47 46
48 // Estimated timestamp for next packet. Useful for packets without timestamps. 47 // Estimated timestamp for next packet. Useful for packets without timestamps.
49 base::TimeDelta estimated_next_timestamp_; 48 base::TimeDelta estimated_next_timestamp_;
50 49
51 // Data buffer to carry decoded raw PCM samples. This buffer is created by 50 // Data buffer to carry decoded raw PCM samples. This buffer is created by
52 // av_malloc() and is used throughout the lifetime of this class. 51 // av_malloc() and is used throughout the lifetime of this class.
53 scoped_ptr_malloc<uint8, ScopedPtrAVFree> output_buffer_; 52 scoped_ptr_malloc<uint8, ScopedPtrAVFree> output_buffer_;
54 53
55 static const size_t kOutputBufferSize; 54 static const size_t kOutputBufferSize;
56 55
57 DISALLOW_COPY_AND_ASSIGN(FFmpegAudioDecoder); 56 DISALLOW_COPY_AND_ASSIGN(FFmpegAudioDecoder);
58 }; 57 };
59 58
60 } // namespace media 59 } // namespace media
61 60
62 #endif // MEDIA_FILTERS_FFMPEG_AUDIO_DECODER_H_ 61 #endif // MEDIA_FILTERS_FFMPEG_AUDIO_DECODER_H_
OLDNEW
« no previous file with comments | « media/filters/decoder_base.h ('k') | media/filters/ffmpeg_audio_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698