add gnash_la_CPPFLAGS to see if it makes distcheck happy
[gnash.git] / libmedia / SoundInfo.h
blobd1b068a321d70311a77aaa327fa5c6e8aa2c71f9
1 //
2 // Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
3 //
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 //
22 #ifndef __SOUNDINFO_H__
23 #define __SOUNDINFO_H__
25 #include "MediaParser.h" // for audioCodecType enum and AudioInfo
27 namespace gnash {
28 namespace media {
30 /// Class containing information about an embedded sound definition
32 /// Is created by the parser while
33 /// parsing, and ownership is then transfered to EmbeddedSound. When the parser is
34 /// parsing streams, it will ask the soundhandler for this to know what properties
35 /// the stream has.
36 ///
37 class SoundInfo {
38 public:
39 /// Constructor
41 /// @param format
42 /// The encoding/format of this sound.
43 ///
44 /// @param stereo
45 /// Defines whether the sound is in stereo.
46 ///
47 /// @param sampleRate
48 /// The sample rate of the sound.
49 ///
50 /// @param sampleCount
51 /// The sample count in the sound.
52 /// In soundstreams this is an average for each frame.
53 ///
54 /// @param is16bit
55 /// If true, the sound is in 16bit format (samplesize == 2)
56 /// else it is 8bit (samplesize == 1).
57 /// Used for streams when decoding adpcm.
58 ///
59 /// @param delaySeek
60 /// Number of samples to seek forward or delay.
61 /// If this value is positive, the player seeks this
62 /// number of samples into the sound block before the
63 /// sound is played.
64 /// If this value is negative the player plays this
65 /// number of silent samples before playing the sound block
66 /// NOTE that this value refers to input samples, so must
67 /// be multiplied by OUTPUT_SAMPLE_RATE/getSampleRate()
68 /// and by 2 (two channels) to find number of output
69 /// samples to skip or fill.
70 ///
71 SoundInfo(audioCodecType format, bool stereo, boost::uint32_t sampleRate,
72 boost::uint32_t sampleCount, bool is16bit,
73 boost::int16_t delaySeek=0)
75 _format(format),
76 _stereo(stereo),
77 _sampleRate(sampleRate),
78 _sampleCount(sampleCount),
79 _delaySeek(delaySeek),
80 _is16bit(is16bit)
84 /// Returns the format of the sound
86 /// @return the format of the sound
87 audioCodecType getFormat() const { return _format; }
89 /// Returns the stereo status of the sound
91 /// @return the stereo status of the sound
92 bool isStereo() const { return _stereo; }
94 /// Returns the samplerate of the sound
96 /// @return the samplerate of the sound
97 unsigned long getSampleRate() const { return _sampleRate; }
99 /// Returns the samplecount of the sound
101 /// This is the amount of samples you'd get after
102 /// successfully decoding the sound.
104 /// @return the samplecount of the sound
106 unsigned long getSampleCount() const { return _sampleCount; }
108 /// Return the number of samples to seek forward or delay
110 /// The number is to be considered in pre-resampling units.
112 boost::int16_t getDelaySeek() const { return _delaySeek; }
114 /// Returns the 16bit status of the sound
116 /// @return the 16bit status of the sound
117 bool is16bit() const { return _is16bit; }
119 private:
120 /// Current format of the sound (MP3, raw, etc).
121 audioCodecType _format;
123 /// The size of the undecoded data
124 unsigned long _dataSize;
126 /// Stereo or not
127 bool _stereo;
129 /// Sample rate, one of 5512, 11025, 22050, 44100
130 boost::uint32_t _sampleRate;
132 /// Number of samples
133 boost::uint32_t _sampleCount;
135 /// Number of samples to seek forward or delay.
136 boost::int16_t _delaySeek;
138 /// Is the audio in 16bit format (samplesize == 2)? else it
139 /// is 8bit (samplesize == 1). Used for streams when decoding adpcm.
140 bool _is16bit;
143 } // gnash.media namespace
144 } // namespace gnash
146 #endif // __SOUNDINFO_H__