1 // AudioDecoderSimple.h: Audio decoding using "simple" internal decoders.
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 
21 #ifndef GNASH_AUDIODECODERSIMPLE_H
22 #define GNASH_AUDIODECODERSIMPLE_H
23 
24 #include "AudioDecoder.h" // for inheritance
25 #include "MediaParser.h" // for audioCodecType enum (composition)
26 
27 // Forward declarations
28 namespace gnash {
29     namespace media {
30         class SoundInfo;
31         class AudioInfo;
32     }
33 }
34 
35 namespace gnash {
36 namespace media {
37 
38 /// Audio decoding using "simple" internal decoders.
39 class AudioDecoderSimple : public AudioDecoder {
40 
41 public:
42 
43 	/// @param info
44 	/// 	AudioInfo class with all the info needed to decode
45 	///     the sound correctly. Throws a MediaException on fatal
46 	///     error.
47     ///
48     /// @throws MediaException on failure
49     ///
50 	AudioDecoderSimple(const AudioInfo& info);
51 
52 	/// @param info
53 	/// 	SoundInfo class with all the info needed to decode
54 	///     the sound correctly. Throws a MediaException on fatal
55 	///     error.
56     ///
57     /// @throws MediaException on failure
58     ///
59 	AudioDecoderSimple(const SoundInfo& info);
60 
61 	~AudioDecoderSimple();
62 
63     // See dox in AudioDecoder.h
64 	std::uint8_t* decode(const std::uint8_t* input, std::uint32_t inputSize, std::uint32_t& outputSize, std::uint32_t& decodedBytes);
65 
66 private:
67 
68     // throws MediaException on failure
69 	void setup(const AudioInfo& info);
70 
71     // throws MediaException on failure
72 	void setup(const SoundInfo& info);
73 
74 	// codec
75 	audioCodecType _codec;
76 
77 	// samplerate
78 	std::uint16_t _sampleRate;
79 
80 	// sampleCount
81 	std::uint32_t _sampleCount;
82 
83 	// stereo
84 	bool _stereo;
85 
86 	// samplesize: 8 or 16 bit
87 	bool _is16bit;
88 
89 
90 	//
91 };
92 
93 } // gnash.media namespace
94 } // gnash namespace
95 
96 #endif // __AUDIODECODERSIMPLE_H__
97 
98