HRESULT GetCaptureVideoFormatCount(IltmmCapture *pCapture)
{
HRESULT hr;
long lIndex, lCount, lSelection, lWidth, lHeight, lCompression, lBitCount;
VARIANT_BOOL vSelected;
BSTR SubTypeName, SubTypeFriendlyName, Subtype;
IltmmVideoFormats* pVidCapFormats = NULL;
IltmmVideoFormat* pVidFormat = NULL;
// try to get the capture video formats
hr = pCapture->get_VideoCaptureFormats(&pVidCapFormats);
if (FAILED(hr))
return hr;
// get the count here
hr = pVidCapFormats->get_Count(&lCount);
if (FAILED(hr))
{
// release the capture formats object
pVidCapFormats->Release();
return hr;
}
// get the selected format
hr = pVidCapFormats->get_Selection(&lSelection);
if (FAILED(hr))
{
// release the capture formats object
pVidCapFormats->Release();
return hr;
}
// if the first format is not selected, select it
if (lSelection != 0)
{
hr = pVidCapFormats->put_Selection(0);
if (FAILED(hr))
{
// release the capture formats object
pVidCapFormats->Release();
return hr;
}
}
// get the first format object
hr = pVidCapFormats->Item(0, &pVidFormat);
if (FAILED(hr))
{
// release the capture formats object
pVidCapFormats->Release();
return hr;
}
// check it's selected state
hr = pVidFormat->get_Selected(&vSelected);
if (FAILED(hr))
{
// release the capture formats and selected format object
pVidCapFormats->Release();
pVidFormat->Release();
return hr;
}
// if it is not selected, select it
if (vSelected == VARIANT_FALSE)
{
hr = pVidFormat->put_Selected(VARIANT_TRUE);
if (FAILED(hr))
{
// release the capture formats and selected format object
pVidCapFormats->Release();
pVidFormat->Release();
return hr;
}
}
// get the format's subtype name
hr = pVidFormat->get_SubTypeName(&SubTypeName);
if (FAILED(hr))
{
// release the capture formats and selected format object
pVidCapFormats->Release();
pVidFormat->Release();
return hr;
}
// do something with the subtype name bstr and then free it
SysFreeString(SubTypeName);
// get the format's friendly name
hr = pVidFormat->get_SubTypeFriendlyName(&SubTypeFriendlyName);
if (FAILED(hr))
{
// release the capture formats and selected format object
pVidCapFormats->Release();
pVidFormat->Release();
return hr;
}
// do something with the friendly name bstr and then free it
SysFreeString(SubTypeFriendlyName);
// get the format's width
hr = pVidFormat->get_Width(&lWidth);
if (FAILED(hr))
{
// release the capture formats and selected format object
pVidCapFormats->Release();
pVidFormat->Release();
return hr;
}
// get the format's height
hr = pVidFormat->get_Height(&lHeight);
if (FAILED(hr))
{
// release the capture formats and selected format object
pVidCapFormats->Release();
pVidFormat->Release();
return hr;
}
// get the format's compression
hr = pVidFormat->get_Compression(&lCompression);
if (FAILED(hr))
{
// release the capture formats and selected format object
pVidCapFormats->Release();
pVidFormat->Release();
return hr;
}
// get the format's bit count
hr = pVidFormat->get_BitCount(&lBitCount);
if (FAILED(hr))
{
// release the capture formats and selected format object
pVidCapFormats->Release();
pVidFormat->Release();
return hr;
}
Subtype = SysAllocString(ltmmMEDIASUBTYPE_RGB24);
// find a video format with subtype RGB24, 1024x768
hr = pVidCapFormats->Find(Subtype, 1024, 768, &lIndex);
SysFreeString(Subtype);
if (FAILED(hr))
{
// release the capture formats and selected format object
pVidCapFormats->Release();
pVidFormat->Release();
return hr;
}
// release the capture formats and selected format object
pVidCapFormats->Release();
pVidFormat->Release();
return S_OK;
}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.