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 "FLACDecodeFilter.h"
00034
00035
00036
00037 CFactoryTemplate g_Templates[] =
00038 {
00039 {
00040 L"FLAC Decode Filter",
00041 &CLSID_FLACDecodeFilter,
00042 FLACDecodeFilter::CreateInstance,
00043 NULL,
00044 NULL
00045 }
00046
00047 };
00048
00049
00050 int g_cTemplates = sizeof(g_Templates) / sizeof(g_Templates[0]);
00051
00052 FLACDecodeFilter::FLACDecodeFilter(void)
00053 : AbstractTransformFilter(NAME("FLAC Audio Decoder"), CLSID_FLACDecodeFilter)
00054 , mFLACFormatBlock(NULL)
00055 {
00056 bool locWasConstructed = ConstructPins();
00057 }
00058
00059 FLACDecodeFilter::~FLACDecodeFilter(void)
00060 {
00061 delete mFLACFormatBlock;
00062 mFLACFormatBlock = NULL;
00063 }
00064
00065 bool FLACDecodeFilter::ConstructPins()
00066 {
00067
00068 vector<CMediaType*> locAcceptableTypes;
00069
00070
00071 CMediaType* locAcceptMediaType = new CMediaType(&MEDIATYPE_Audio);
00072 locAcceptMediaType->subtype = MEDIASUBTYPE_PCM;
00073 locAcceptMediaType->formattype = FORMAT_WaveFormatEx;
00074
00075 locAcceptableTypes.push_back(locAcceptMediaType);
00076
00077
00078 mOutputPin = new FLACDecodeOutputPin(this, m_pLock, locAcceptableTypes);
00079
00080
00081 locAcceptableTypes.clear();
00082
00083
00084 locAcceptMediaType = NULL;
00085 locAcceptMediaType = new CMediaType(&MEDIATYPE_Audio);
00086
00087 locAcceptMediaType->subtype = MEDIASUBTYPE_FLAC;
00088 locAcceptMediaType->formattype = FORMAT_FLAC;
00089
00090 locAcceptableTypes.push_back(locAcceptMediaType);
00091
00092 mInputPin = new FLACDecodeInputPin(this, m_pLock, mOutputPin, locAcceptableTypes);
00093 return true;
00094
00095 }
00096
00097 CUnknown* WINAPI FLACDecodeFilter::CreateInstance(LPUNKNOWN pUnk, HRESULT *pHr)
00098 {
00099
00100 FLACDecodeFilter *pNewObject = new FLACDecodeFilter();
00101 if (pNewObject == NULL) {
00102 *pHr = E_OUTOFMEMORY;
00103 }
00104 return pNewObject;
00105 }
00106
00107 sFLACFormatBlock* FLACDecodeFilter::getFLACFormatBlock()
00108 {
00109 return mFLACFormatBlock;
00110 }
00111 void FLACDecodeFilter::setFLACFormatBlock(sFLACFormatBlock* inFormatBlock)
00112 {
00113 delete mFLACFormatBlock;
00114 mFLACFormatBlock = new sFLACFormatBlock;
00115 *mFLACFormatBlock = *inFormatBlock;
00116 }