00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include "stdafx.h"
00034 #include "SpeexDecodeFilter.h"
00035
00036
00037
00038 CFactoryTemplate g_Templates[] =
00039 {
00040 {
00041 L"Speex Decode Filter",
00042 &CLSID_SpeexDecodeFilter,
00043 SpeexDecodeFilter::CreateInstance,
00044 NULL,
00045 NULL
00046 }
00047
00048 };
00049
00050
00051 int g_cTemplates = sizeof(g_Templates) / sizeof(g_Templates[0]);
00052
00053 SpeexDecodeFilter::SpeexDecodeFilter()
00054 : AbstractTransformFilter(NAME("Speex Audio Decoder"), CLSID_SpeexDecodeFilter)
00055 , mSpeexFormatInfo(NULL)
00056 {
00057
00058 bool locWasConstructed = ConstructPins();
00059 }
00060
00061 bool SpeexDecodeFilter::ConstructPins()
00062 {
00063
00064
00065 vector<CMediaType*> locAcceptableTypes;
00066
00067
00068 CMediaType* locAcceptMediaType = new CMediaType(&MEDIATYPE_Audio);
00069 locAcceptMediaType->subtype = MEDIASUBTYPE_PCM;
00070 locAcceptMediaType->formattype = FORMAT_WaveFormatEx;
00071
00072 locAcceptableTypes.push_back(locAcceptMediaType);
00073
00074
00075 mOutputPin = new SpeexDecodeOutputPin(this, m_pLock, locAcceptableTypes);
00076
00077
00078 locAcceptableTypes.clear();
00079
00080
00081 locAcceptMediaType = NULL;
00082 locAcceptMediaType = new CMediaType(&MEDIATYPE_OggPacketStream);
00083
00084
00085
00086
00087 locAcceptMediaType->subtype = MEDIASUBTYPE_None;
00088 locAcceptMediaType->formattype = FORMAT_OggIdentHeader;
00089
00090 locAcceptableTypes.push_back(locAcceptMediaType);
00091
00092 mInputPin = new SpeexDecodeInputPin(this, m_pLock, mOutputPin, locAcceptableTypes);
00093 return true;
00094
00095 }
00096
00097 SpeexDecodeFilter::~SpeexDecodeFilter(void)
00098 {
00099 delete mSpeexFormatInfo;
00100 }
00101
00102 CUnknown* WINAPI SpeexDecodeFilter::CreateInstance(LPUNKNOWN pUnk, HRESULT *pHr)
00103 {
00104
00105 SpeexDecodeFilter *pNewObject = new SpeexDecodeFilter();
00106 if (pNewObject == NULL) {
00107 *pHr = E_OUTOFMEMORY;
00108 }
00109 return pNewObject;
00110 }
00111
00112
00113
00114 sSpeexFormatBlock* SpeexDecodeFilter::getSpeexFormatBlock()
00115 {
00116 return mSpeexFormatInfo;
00117 }
00118 void SpeexDecodeFilter::setSpeexFormat(BYTE* inFormatBlock)
00119 {
00120 delete mSpeexFormatInfo;
00121 mSpeexFormatInfo = new sSpeexFormatBlock;
00122
00123 mSpeexFormatInfo->speexVersion = iLE_Math::charArrToULong(inFormatBlock + 28);
00124 mSpeexFormatInfo->numChannels = iLE_Math::charArrToULong(inFormatBlock + 48);
00125 mSpeexFormatInfo->samplesPerSec = iLE_Math::charArrToULong(inFormatBlock + 36);
00126 mSpeexFormatInfo->avgBitsPerSec = 0;
00127 mSpeexFormatInfo->maxBitsPerSec = 0;
00128 mSpeexFormatInfo->minBitsPerSec = 0;
00129
00130 }