// query the capture filter for the iamvideoprocamp interface.
iamvideoprocamp *pprocamp = 0;
hr = pcap->queryinterface(iid_iamvideoprocamp, (void**)&pprocamp);
if (failed(hr))
{
// the device does not support iamvideoprocamp, so disable the control.
enablewindow(htrackbar, false);
}
else
{
long min, max, step, default, flags, val;
// get the range and default value.
hr = m_pprocamp->getrange(videoprocamp_brightness, &min, &max, &step,
&default, &flags);
if (succeeded(hr))
{
// get the current value.
hr = m_pprocamp->get(videoprocamp_brightness, &val, &flags);
}
if (succeeded(hr))
{
// set the trackbar range and position.
sendmessage(htrackbar, tbm_setrange, true, makelong(min, max));
sendmessage(htrackbar, tbm_setpos, true, val);
enablewindow(htrackbar, true);
}
else
{
// this property is not supported, so disable the control.
enablewindow(htrackbar, false);
}
}
我们知道视频流可以有多种输出格式,一个设备可以支持16-bit rgb, 32-bit rgb, and yuyv,在每一种格式下,设备还可以调整视频桢的大小。
在wdm驱动设备上,iamstreamconfig 接口用来报告设备输出视频的格式的,vfw设备,可以采用对话框的方式来设置,参见前面的内容。
捕捉filter的捕捉pin和预览pin都支持iamstreamconfig 接口,可以通过icapturegraphbuilder2::findinterface获得iamstreamconfig接口。
iamstreamconfig *pconfig = null;设备还支持一系列的媒体类型,对于每一个媒体类型,设备都要支持一系列的属性,比如,桢的大小,图像如何缩放,桢率的范围等。
hr = pbuild->findinterface(
&pin_category_preview, // preview pin.
0, // any media type.
pcap, // pointer to the capture filter.
iid_iamstreamconfig, (void**)&pconfig);
通过iamstreamconfig::getnumberofcapabilities获得设备所支持的媒体类型的数量。这个方法返回两个值,一个是媒体类型的数量,二是属性所需结构的大小。
这个结构的大小很重要,因为这个方法是用于视频和音频的,视频采用的是video_stream_config_caps结构,音频用audio_stream_config_caps结构。
通过函数iamstreamconfig::getstreamcaps来枚举媒体类型,要给这个函数传递一个序号作为参数,这个函数返回媒体类型和相应的属性结构体。看代码把
int icount = 0, isize = 0;
hr = pconfig->getnumberofcapabilities(&icount, &isize);// check the size to make sure we pass in the correct structure.
if (isize == sizeof(video_stream_config_caps)
{
// use the video capabilities structure.
for (int iformat = 0; iformat < icount; iformat++)
{
video_stream_config_caps scc;
am_media_type *pmtconfig;
hr = pconfig->getstreamcaps(iformat, &pmtconfig, (byte*)&scc);
if (succeeded(hr))
{
/* examine the format, and possibly use it. */
// delete the media type when you are done.
hr = pconfig->setformat(pmtconfig);//重新设置视频格式
deletemediatype(pmtconfig);
}
}