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
Class containing information about an embedded sound definition.
Definition: SoundInfo.h:34
An encoded audio frame.
Definition: MediaParser.h:453
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:40
Information about an audio stream.
Definition: MediaParser.h:236
FFMPEG based AudioDecoder.
Definition: AudioDecoderFfmpeg.h:42
FFMPEG based AudioResampler.
Definition: AudioResamplerFfmpeg.h:38
Audio decoding base class.
Definition: AudioDecoder.h:36