| 1 |
/* |
|---|
| 2 |
* FFissionDecoder.h |
|---|
| 3 |
* |
|---|
| 4 |
* Copyright (c) 2006 David Conrad |
|---|
| 5 |
* |
|---|
| 6 |
* This program is free software; you can redistribute it and/or |
|---|
| 7 |
* modify it under the terms of the GNU Lesser General Public |
|---|
| 8 |
* License as published by the Free Software Foundation; |
|---|
| 9 |
* version 2.1 of the License. |
|---|
| 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 GNU |
|---|
| 14 |
* Lesser General Public License for more details. |
|---|
| 15 |
* |
|---|
| 16 |
* You should have received a copy of the GNU Lesser General Public |
|---|
| 17 |
* License 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 |
|
|---|
| 22 |
#ifndef __FFISSIONDECODER_H__ |
|---|
| 23 |
#define __FFISSIONDECODER_H__ |
|---|
| 24 |
|
|---|
| 25 |
#include "FFissionCodec.h" |
|---|
| 26 |
#include "avcodec.h" |
|---|
| 27 |
#include "RingBuffer.h" |
|---|
| 28 |
|
|---|
| 29 |
class FFissionDecoder : public FFissionCodec |
|---|
| 30 |
{ |
|---|
| 31 |
public: |
|---|
| 32 |
FFissionDecoder(UInt32 inInputBufferByteSize = 76800); |
|---|
| 33 |
virtual ~FFissionDecoder(); |
|---|
| 34 |
|
|---|
| 35 |
virtual void Initialize(const AudioStreamBasicDescription* inInputFormat, const AudioStreamBasicDescription* inOutputFormat, const void* inMagicCookie, UInt32 inMagicCookieByteSize); |
|---|
| 36 |
virtual void Uninitialize(); |
|---|
| 37 |
virtual void Reset(); |
|---|
| 38 |
|
|---|
| 39 |
virtual void GetProperty(AudioCodecPropertyID inPropertyID, UInt32& ioPropertyDataSize, void* outPropertyData); |
|---|
| 40 |
virtual void SetMagicCookie(const void* inMagicCookieData, UInt32 inMagicCookieDataByteSize); |
|---|
| 41 |
|
|---|
| 42 |
virtual void SetCurrentInputFormat(const AudioStreamBasicDescription& inInputFormat); |
|---|
| 43 |
virtual void SetCurrentOutputFormat(const AudioStreamBasicDescription& inOutputFormat); |
|---|
| 44 |
virtual UInt32 GetVersion() const; |
|---|
| 45 |
|
|---|
| 46 |
virtual void AppendInputData(const void* inInputData, UInt32& ioInputDataByteSize, UInt32& ioNumberPackets, const AudioStreamPacketDescription* inPacketDescription); |
|---|
| 47 |
virtual UInt32 ProduceOutputPackets(void* outOutputData, UInt32& ioOutputDataByteSize, UInt32& ioNumberPackets, AudioStreamPacketDescription* outPacketDescription); |
|---|
| 48 |
|
|---|
| 49 |
private: |
|---|
| 50 |
void SetupExtradata(OSType formatID); |
|---|
| 51 |
int ConvertXiphVorbisCookie(); |
|---|
| 52 |
void OpenAVCodec(); |
|---|
| 53 |
|
|---|
| 54 |
UInt32 kIntPCMOutFormatFlag; |
|---|
| 55 |
Byte *magicCookie; |
|---|
| 56 |
UInt32 magicCookieSize; |
|---|
| 57 |
|
|---|
| 58 |
RingBuffer inputBuffer; |
|---|
| 59 |
Byte *outputBuffer; |
|---|
| 60 |
int outBufSize; |
|---|
| 61 |
int outBufUsed; |
|---|
| 62 |
}; |
|---|
| 63 |
|
|---|
| 64 |
// kAudioCodecPropertyHasVariablePacketByteSizes is queried before our input format is set, |
|---|
| 65 |
// so we can't use that to determine our answer... |
|---|
| 66 |
class FFissionVBRDecoder : public FFissionDecoder |
|---|
| 67 |
{ |
|---|
| 68 |
public: |
|---|
| 69 |
FFissionVBRDecoder() : FFissionDecoder() { } |
|---|
| 70 |
virtual void GetProperty(AudioCodecPropertyID inPropertyID, UInt32& ioPropertyDataSize, void* outPropertyData); |
|---|
| 71 |
}; |
|---|
| 72 |
|
|---|
| 73 |
#endif |
|---|