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