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 #include "stdafx.h"
00033 #include "vorbisdecodefilter.h"
00034
00035
00036 #include "stdafx.h"
00037 #include "VorbisDecodeFilter.h"
00038
00039
00040 CFactoryTemplate g_Templates[] =
00041 {
00042 {
00043 L"Vorbis Decode Filter",
00044 &CLSID_VorbisDecodeFilter,
00045 VorbisDecodeFilter::CreateInstance,
00046 NULL,
00047 NULL
00048 }
00049
00050 };
00051
00052
00053 int g_cTemplates = sizeof(g_Templates) / sizeof(g_Templates[0]);
00054
00055
00056
00057
00058 VorbisDecodeFilter::VorbisDecodeFilter()
00059 : AbstractTransformFilter(NAME("Vorbis Decoder"), CLSID_VorbisDecodeFilter)
00060 , mVorbisFormatInfo(NULL)
00061 {
00062
00063 bool locWasConstructed = ConstructPins();
00064
00065 }
00066
00067 bool VorbisDecodeFilter::ConstructPins()
00068 {
00069
00070 vector<CMediaType*> locAcceptableTypes;
00071
00072
00073 CMediaType* locAcceptMediaType = new CMediaType(&MEDIATYPE_Audio);
00074 locAcceptMediaType->subtype = MEDIASUBTYPE_PCM;
00075 locAcceptMediaType->formattype = FORMAT_WaveFormatEx;
00076
00077 locAcceptableTypes.push_back(locAcceptMediaType);
00078
00079
00080 mOutputPin = new VorbisDecodeOutputPin(this, m_pLock, locAcceptableTypes);
00081
00082
00083 locAcceptableTypes.clear();
00084
00085
00086 locAcceptMediaType = NULL;
00087 locAcceptMediaType = new CMediaType(&MEDIATYPE_OggPacketStream);
00088
00089 locAcceptMediaType->subtype = MEDIASUBTYPE_None;
00090 locAcceptMediaType->formattype = FORMAT_OggIdentHeader;
00091
00092 locAcceptableTypes.push_back(locAcceptMediaType);
00093
00094 mInputPin = new VorbisDecodeInputPin(this, m_pLock, mOutputPin, locAcceptableTypes);
00095 return true;
00096 }
00097
00098 VorbisDecodeFilter::~VorbisDecodeFilter(void)
00099 {
00100 DbgLog((LOG_TRACE,1,TEXT("Vorbis Destructor...")));
00101
00102 delete mVorbisFormatInfo;
00103 }
00104
00105 CUnknown* WINAPI VorbisDecodeFilter::CreateInstance(LPUNKNOWN pUnk, HRESULT *pHr)
00106 {
00107
00108 VorbisDecodeFilter *pNewObject = new VorbisDecodeFilter();
00109 if (pNewObject == NULL) {
00110 *pHr = E_OUTOFMEMORY;
00111 }
00112 return pNewObject;
00113 }
00114
00115
00116
00117 sVorbisFormatBlock* VorbisDecodeFilter::getVorbisFormatBlock()
00118 {
00119 return mVorbisFormatInfo;
00120 }
00121 void VorbisDecodeFilter::setVorbisFormat(BYTE* inFormatBlock)
00122 {
00123 delete mVorbisFormatInfo;
00124 mVorbisFormatInfo = new sVorbisFormatBlock;
00125
00126
00127 mVorbisFormatInfo->vorbisVersion = iLE_Math::charArrToULong(inFormatBlock + 7);
00128 mVorbisFormatInfo->numChannels = inFormatBlock[11];
00129 mVorbisFormatInfo->samplesPerSec = iLE_Math::charArrToULong(inFormatBlock + 12);
00130 mVorbisFormatInfo->maxBitsPerSec = iLE_Math::charArrToULong(inFormatBlock + 16);
00131 mVorbisFormatInfo->avgBitsPerSec = iLE_Math::charArrToULong(inFormatBlock + 20);
00132 mVorbisFormatInfo->minBitsPerSec = iLE_Math::charArrToULong(inFormatBlock + 24);
00133
00134 }