How to enumerates media types on a given pin
-
I want to enumerates ac3filter's preferred media types, I suppose this process should be very easy, but I can't get this work. PLZ help!
int _tmain(int argc, _TCHAR* argv[])
{
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
CLSID clsid;
//ac3filter's clsid
::CLSIDFromString(_T("{A753A1EC-973E-4718-AF8E-A3F554D45C44}"), &clsid);
IBaseFilter* pFilter = NULL;
HRESULT hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, __uuidof(IBaseFilter), (void **)&pFilter);
IEnumPins* pEnumPins = NULL;
hr = pFilter->EnumPins(&pEnumPins);
if (SUCCEEDED(hr))
{
IPin* pPin = NULL;
while (pEnumPins->Next(1, &pPin, NULL) == S_OK)
{
PIN_DIRECTION pinDir;
//the pin direction can be queried
pPin->QueryDirection(&pinDir);
IEnumMediaTypes* pEnumMediaTypes = NULL;
HRESULT hr = pPin->EnumMediaTypes(&pEnumMediaTypes);
if (SUCCEEDED(hr))
{
AM_MEDIA_TYPE* pMediaType = NULL;
//hr always S_FALSE, so the media type can not acquired
hr = pEnumMediaTypes->Next(1, &pMediaType, NULL);
pEnumMediaTypes->Release();
}
pPin->Release();
}
pEnumPins->Release();
}
return 0;
}A Chinese VC++ programmer
-
I want to enumerates ac3filter's preferred media types, I suppose this process should be very easy, but I can't get this work. PLZ help!
int _tmain(int argc, _TCHAR* argv[])
{
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
CLSID clsid;
//ac3filter's clsid
::CLSIDFromString(_T("{A753A1EC-973E-4718-AF8E-A3F554D45C44}"), &clsid);
IBaseFilter* pFilter = NULL;
HRESULT hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, __uuidof(IBaseFilter), (void **)&pFilter);
IEnumPins* pEnumPins = NULL;
hr = pFilter->EnumPins(&pEnumPins);
if (SUCCEEDED(hr))
{
IPin* pPin = NULL;
while (pEnumPins->Next(1, &pPin, NULL) == S_OK)
{
PIN_DIRECTION pinDir;
//the pin direction can be queried
pPin->QueryDirection(&pinDir);
IEnumMediaTypes* pEnumMediaTypes = NULL;
HRESULT hr = pPin->EnumMediaTypes(&pEnumMediaTypes);
if (SUCCEEDED(hr))
{
AM_MEDIA_TYPE* pMediaType = NULL;
//hr always S_FALSE, so the media type can not acquired
hr = pEnumMediaTypes->Next(1, &pMediaType, NULL);
pEnumMediaTypes->Release();
}
pPin->Release();
}
pEnumPins->Release();
}
return 0;
}A Chinese VC++ programmer
I'm not an expert on Pins, but I'm sure you can give more information on your problem. *What* didn;t work? Does it not compile? Does CoCreateInstance even work? Does it give success code, but no Pins? Do you get enumerators, they just are empty? Etc. We're not going to visit you and sit at your computer and use the debugger. China is a long way from here! Iain.
-
I'm not an expert on Pins, but I'm sure you can give more information on your problem. *What* didn;t work? Does it not compile? Does CoCreateInstance even work? Does it give success code, but no Pins? Do you get enumerators, they just are empty? Etc. We're not going to visit you and sit at your computer and use the debugger. China is a long way from here! Iain.
Thank you Iain. ;) As I commentted in the code, everything looks finely.The filter can be created; the pins can be enumerated; and the direction of the pins can be queried too, but when it comes to the media types of a given pin,
IEnumMediaTypes::Next
always returns S_FALSE. So I can't numerates media types on a given pin.A Chinese VC++ programmer