IltmmVideoFormats::get_Count Example for C
HRESULT hr;
long lIndex, lCount, lSelection, lWidth, lHeight, lCompression, lBitCount;
VARIANT_BOOL vSelected;
BSTR SubTypeName, SubTypeFriendlyName, Subtype;
IltmmVideoFormats* pVidCapFormats = NULL;
IltmmVideoFormat* pVidFormat = NULL;
hr = IltmmCapture_get_VideoCaptureFormats (g_capture, &pVidCapFormats);
if (FAILED(hr))
return hr;
hr = IltmmVideoFormats_get_Count (pVidCapFormats, &lCount);
if (FAILED(hr))
{
IltmmVideoFormats_Release(pVidCapFormats);
pVidCapFormats = NULL;
return hr;
}
hr = IltmmVideoFormats_get_Selection (pVidCapFormats, &lSelection);
if (FAILED(hr))
{
IltmmVideoFormats_Release(pVidCapFormats);
pVidCapFormats = NULL;
return hr;
}
if (lSelection != 0)
{
hr = IltmmVideoFormats_put_Selection (pVidCapFormats, 0);
if (FAILED(hr))
{
IltmmVideoFormats_Release(pVidCapFormats);
pVidCapFormats = NULL;
return hr;
}
}
hr = IltmmVideoFormats_Item (pVidCapFormats, 0, &pVidFormat);
if (FAILED(hr))
{
IltmmVideoFormats_Release(pVidCapFormats);
pVidCapFormats = NULL;
return hr;
}
hr = IltmmVideoFormat_get_Selected (pVidFormat, &vSelected);
if (FAILED(hr))
{
IltmmVideoFormat_Release(pVidFormat);
pVidFormat = NULL;
IltmmVideoFormats_Release(pVidCapFormats);
pVidCapFormats = NULL;
return hr;
}
if (vSelected == VARIANT_FALSE)
{
hr = IltmmVideoFormat_put_Selected (pVidFormat, VARIANT_TRUE);
if (FAILED(hr))
{
IltmmVideoFormat_Release(pVidFormat);
pVidFormat = NULL;
IltmmVideoFormats_Release(pVidCapFormats);
pVidCapFormats = NULL;
return hr;
}
}
hr = IltmmVideoFormat_get_SubTypeName (pVidFormat, &SubTypeName);
SysFreeString(SubTypeName);
if (FAILED(hr))
{
IltmmVideoFormat_Release(pVidFormat);
pVidFormat = NULL;
IltmmVideoFormats_Release(pVidCapFormats);
pVidCapFormats = NULL;
return hr;
}
hr = IltmmVideoFormat_get_SubTypeFriendlyName (pVidFormat, &SubTypeFriendlyName);
SysFreeString(SubTypeFriendlyName);
if (FAILED(hr))
{
IltmmVideoFormat_Release(pVidFormat);
pVidFormat = NULL;
IltmmVideoFormats_Release(pVidCapFormats);
pVidCapFormats = NULL;
return hr;
}
hr = IltmmVideoFormat_get_Width (pVidFormat, &lWidth);
if (FAILED(hr))
{
IltmmVideoFormat_Release(pVidFormat);
pVidFormat = NULL;
IltmmVideoFormats_Release(pVidCapFormats);
pVidCapFormats = NULL;
return hr;
}
hr = IltmmVideoFormat_get_Height (pVidFormat, &lHeight);
if (FAILED(hr))
{
IltmmVideoFormat_Release(pVidFormat);
pVidFormat = NULL;
IltmmVideoFormats_Release(pVidCapFormats);
pVidCapFormats = NULL;
return hr;
}
hr = IltmmVideoFormat_get_Compression (pVidFormat, &lCompression);
if (FAILED(hr))
{
IltmmVideoFormat_Release(pVidFormat);
pVidFormat = NULL;
IltmmVideoFormats_Release(pVidCapFormats);
pVidCapFormats = NULL;
return hr;
}
hr = IltmmVideoFormat_get_BitCount (pVidFormat, &lBitCount);
if (FAILED(hr))
{
IltmmVideoFormat_Release(pVidFormat);
pVidFormat = NULL;
IltmmVideoFormats_Release(pVidCapFormats);
pVidCapFormats = NULL;
return hr;
}
Subtype = SysAllocString(ltmmMEDIASUBTYPE_RGB24);
hr = IltmmVideoFormats_Find (pVidCapFormats, Subtype, 1024, 768, &lIndex);
SysFreeString(Subtype);
if (FAILED(hr))
{
IltmmVideoFormat_Release(pVidFormat);
pVidFormat = NULL;
IltmmVideoFormats_Release(pVidCapFormats);
pVidCapFormats = NULL;
return hr;
}
IltmmVideoFormat_Release(pVidFormat);
pVidFormat = NULL;
IltmmVideoFormats_Release(pVidCapFormats);
pVidCapFormats = NULL;