Gnash  0.8.11dev
AudioDecoderFfmpeg.h
Go to the documentation of this file.
1 // AudioDecoderFfmpeg.h: Audio decoding using the FFMPEG library.
2 //
3 // Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012
4 // Free Software Foundation, Inc.
5 //
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 
20 #ifndef GNASH_AUDIODECODERFFMPEG_H
21 #define GNASH_AUDIODECODERFFMPEG_H
22 
23 #include "ffmpegHeaders.h"
24 
25 #include "log.h"
26 #include "AudioDecoder.h" // for inheritance
27 #include "AudioResamplerFfmpeg.h" // for composition
28 
29 // Forward declarations
30 namespace gnash {
31  namespace media {
32  class SoundInfo;
33  class AudioInfo;
34  }
35 }
36 
37 namespace gnash {
38 namespace media {
39 namespace ffmpeg {
40 
43 
44 public:
49  AudioDecoderFfmpeg(const AudioInfo& info);
50 
57 
58  // See dox in AudioDecoder.h
59  std::uint8_t* decode(const std::uint8_t* input,
60  std::uint32_t inputSize, std::uint32_t& outputSize,
61  std::uint32_t& decodedBytes);
62 
63  std::uint8_t* decode(const EncodedAudioFrame& af,
64  std::uint32_t& outputSize);
65 
66 private:
67 
68  void setup(const AudioInfo& info);
69  void setup(SoundInfo& info);
70 
71  std::uint8_t* decodeFrame(const std::uint8_t* input,
72  std::uint32_t inputSize, std::uint32_t& outputSize);
73 
74  AVCodec* _audioCodec;
75  AVCodecContext* _audioCodecCtx;
76  AVCodecParserContext* _parser;
77 
78  // Use for resampling audio
79  AudioResamplerFfmpeg _resampler;
80 
82  bool _needsParsing;
83 
85  //
102  int parseInput(const std::uint8_t* input, std::uint32_t inputSize,
103  std::uint8_t const ** outFrame, int* outFrameSize);
104 };
105 
106 } // gnash.media.ffmpeg namespace
107 } // gnash.media namespace
108 } // gnash namespace
109 
110 #endif
gnash::media::ffmpeg::AudioDecoderFfmpeg
FFMPEG based AudioDecoder.
Definition: AudioDecoderFfmpeg.h:42
ffmpegHeaders.h
AudioDecoder.h
SoundInfo.h
gnash::media::ffmpeg::AudioResamplerFfmpeg::init
DSOEXPORT bool init(AVCodecContext *ctx)
Initializes the resampler.
Definition: AudioResamplerFfmpeg.cpp:50
gnash::media::AUDIO_CODEC_ADPCM
@ AUDIO_CODEC_ADPCM
ADPCM format.
Definition: MediaParser.h:148
FRAMEALLOC
#define FRAMEALLOC
Definition: ffmpegHeaders.h:126
gnash::media::SoundInfo
Class containing information about an embedded sound definition.
Definition: SoundInfo.h:34
CODECID
#define CODECID
Definition: ffmpegHeaders.h:137
gnash::log_debug
void log_debug(StringType msg, Args... args)
Definition: log.h:301
_
#define _(String)
Definition: log.h:44
gnash
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:41
gnash::media::AudioInfo::codec
int codec
Codec identifier.
Definition: MediaParser.h:286
gnash::media::SoundInfo::getSampleRate
unsigned long getSampleRate() const
Returns the samplerate of the sound.
Definition: SoundInfo.h:94
gnash::media::EncodedAudioFrame
An encoded audio frame.
Definition: MediaParser.h:454
FrameDeleter
Definition: ffmpegHeaders.h:128
gnash::log_error
void log_error(StringType msg, Args... args)
Definition: log.h:283
gnash::media::ffmpeg::AudioDecoderFfmpeg::AudioDecoderFfmpeg
AudioDecoderFfmpeg(const AudioInfo &info)
Definition: AudioDecoderFfmpeg.cpp:37
gnash::media::AUDIO_CODEC_MP3
@ AUDIO_CODEC_MP3
MP3 format.
Definition: MediaParser.h:164
gnash::media::AudioDecoder
Audio decoding base class.
Definition: AudioDecoder.h:36
gnash::media::AUDIO_CODEC_UNCOMPRESSED
@ AUDIO_CODEC_UNCOMPRESSED
Linear PCM, strictly little-endian.
Definition: MediaParser.h:167
gnash::media::ffmpeg::AudioResamplerFfmpeg
FFMPEG based AudioResampler.
Definition: AudioResamplerFfmpeg.h:39
FLVParser.h
MAX_AUDIO_FRAME_SIZE
#define MAX_AUDIO_FRAME_SIZE
Definition: ffmpegHeaders.h:41
gnash::media::AUDIO_CODEC_RAW
@ AUDIO_CODEC_RAW
Signed Linear PCM, unspecified byte order.
Definition: MediaParser.h:135
gnash::media::audioCodecType
audioCodecType
Audio codec ids as defined in flash.
Definition: MediaParser.h:123
gnash::media::AUDIO_CODEC_NELLYMOSER
@ AUDIO_CODEC_NELLYMOSER
Proprietary simple format.
Definition: MediaParser.h:181
gnash::media::SoundInfo::isStereo
bool isStereo() const
Returns the stereo status of the sound.
Definition: SoundInfo.h:89
gnash::media::AUDIO_CODEC_AAC
@ AUDIO_CODEC_AAC
Advanced Audio Coding.
Definition: MediaParser.h:184
AudioDecoderFfmpeg.h
MediaParser.h
gnash::media::CODEC_TYPE_FLASH
@ CODEC_TYPE_FLASH
The internal flash codec ids.
Definition: MediaParser.h:68
AudioResamplerFfmpeg.h
gnash::media::AudioInfo
Information about an audio stream.
Definition: MediaParser.h:237
MediaParserFfmpeg.h
log.h
gnash::media::ffmpeg::AudioResamplerFfmpeg::resample
DSOEXPORT int resample(std::uint8_t **input, int plane_size, int samples, std::uint8_t **output)
Resamples audio.
Definition: AudioResamplerFfmpeg.cpp:86
gnash::media::EncodedAudioFrame::dataSize
std::uint32_t dataSize
Definition: MediaParser.h:456
gnash::media::EncodedAudioFrame::data
std::unique_ptr< std::uint8_t[]> data
Definition: MediaParser.h:457
gnash::media::ffmpeg::AudioDecoderFfmpeg::~AudioDecoderFfmpeg
~AudioDecoderFfmpeg()
Definition: AudioDecoderFfmpeg.cpp:69
gnash::media::CODEC_TYPE_CUSTOM
@ CODEC_TYPE_CUSTOM
Custom codecs ids.
Definition: MediaParser.h:71
gnash::media::SoundInfo::getFormat
audioCodecType getFormat() const
Returns the format of the sound.
Definition: SoundInfo.h:84
gnash::MediaException
An exception from MediaHandler subsystem.
Definition: GnashException.h:50
gnash::media::AudioInfo::type
codecType type
Definition: MediaParser.h:297
gnash::media::ffmpeg::AudioDecoderFfmpeg::decode
std::uint8_t * decode(const std::uint8_t *input, std::uint32_t inputSize, std::uint32_t &outputSize, std::uint32_t &decodedBytes)
Decodes a frame and returns a pointer to the data.
Definition: AudioDecoderFfmpeg.cpp:321