oggVorbisDecoder.h
Engine/source/core/ogg/oggVorbisDecoder.h
Classes:
class
Decodes a Vorbis substream into sample packets.
Detailed Description
1 2//----------------------------------------------------------------------------- 3// Copyright (c) 2012 GarageGames, LLC 4// 5// Permission is hereby granted, free of charge, to any person obtaining a copy 6// of this software and associated documentation files (the "Software"), to 7// deal in the Software without restriction, including without limitation the 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 9// sell copies of the Software, and to permit persons to whom the Software is 10// furnished to do so, subject to the following conditions: 11// 12// The above copyright notice and this permission notice shall be included in 13// all copies or substantial portions of the Software. 14// 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21// IN THE SOFTWARE. 22//----------------------------------------------------------------------------- 23 24#ifndef _OGGVORBISDECODER_H_ 25#define _OGGVORBISDECODER_H_ 26 27#ifndef _OGGINPUTSTREAM_H_ 28 #include "core/ogg/oggInputStream.h" 29#endif 30#ifndef _TSTREAM_H_ 31 #include "core/stream/tStream.h" 32#endif 33#ifndef _RAWDATA_H_ 34 #include "core/util/rawData.h" 35#endif 36#include "vorbis/codec.h" 37 38 39/// Decodes a Vorbis substream into sample packets. 40/// 41/// Vorbis samples are always 16bits. 42class OggVorbisDecoder : public OggDecoder, 43 public IInputStream< RawData* > 44{ 45 public: 46 47 typedef OggDecoder Parent; 48 49 protected: 50 51 /// 52 vorbis_info mVorbisInfo; 53 54 /// 55 vorbis_comment mVorbisComment; 56 57 /// 58 vorbis_dsp_state mVorbisDspState; 59 60 /// 61 vorbis_block mVorbisBlock; 62 63 #ifdef TORQUE_DEBUG 64 U32 mLock; 65 #endif 66 67 // OggDecoder. 68 virtual bool _detect( ogg_page* startPage ); 69 virtual bool _init(); 70 virtual bool _packetin( ogg_packet* packet ); 71 72 public: 73 74 /// 75 OggVorbisDecoder( const ThreadSafeRef< OggInputStream>& stream ); 76 77 ~OggVorbisDecoder(); 78 79 /// 80 U32 getNumChannels() const { return mVorbisInfo.channels; } 81 82 /// 83 U32 getSamplesPerSecond() const { return mVorbisInfo.rate; } 84 85 // OggDecoder. 86 virtual const char* getName() const { return "Vorbis"; } 87 88 // IInputStream. 89 virtual U32 read( RawData** buffer, U32 num ); 90}; 91 92#endif // !_OGGVORBISDECODER_H_ 93