110,535
社区成员
发帖
与我相关
我的任务
分享
try
{
int hr = 0;
hr = this.m_graphBuilder.AddFilter(theVideoDevice, "Video Capture");
DsError.ThrowExceptionForHR(hr);
// 通过theVideoDevice(IBaseFilter)视频接口对象的Preview Pin预览
hr = this.m_captureGraphBuilder.RenderStream(PinCategory.Preview, MediaType.Video, theVideoDevice, null, null);
//DsError.ThrowExceptionForHR(hr);
//插入SampleGrabber
m_pinStill = DsFindPin.ByCategory(theVideoDevice, PinCategory.Still, 0);
if (m_pinStill == null)
{
m_pinStill = DsFindPin.ByCategory(theVideoDevice, PinCategory.Capture, 0);
}
// 获取theVideoDevice的IAMVideoControl对象,对于具有Still Pin的对象可以获到,采集设备不具备Still Pin,那么该对象将为Null
m_VidControl = theVideoDevice as IAMVideoControl;
// 设置采集视频参数
//if (this.Height + this.Width + this.Width > 0)
//{
// SetConfigParms(m_pinStill, this.Width, this.Height, 24);
//}
//开始拍照功能所需的接口对象
// 获得SampleGrabber对象接口
sampGrabber = new SampleGrabber() as ISampleGrabber;
// 配置sample grabber
baseGrabFlt = sampGrabber as IBaseFilter;
// ConfigureSampleGrabber(sampGrabber);
// 将sample grabber添加到图形过滤器中
hr = m_graphBuilder.AddFilter(baseGrabFlt, "Ds.NET Grabber");
DsError.ThrowExceptionForHR(hr);
// //通过渲染将采集设备的相关输出Pin与sample grabber对象的输入Pin连接起来
// //如果采集设备提供Still Pin,则通过Still Pin连接,否则直接使用Capture Pin连接
if (m_VidControl != null)
{
hr = this.m_captureGraphBuilder.RenderStream(PinCategory.Still, MediaType.Video, theVideoDevice, null, baseGrabFlt);
DsError.ThrowExceptionForHR(hr);
}
else
{
hr = this.m_captureGraphBuilder.RenderStream(PinCategory.Capture, MediaType.Video, theVideoDevice, null, baseGrabFlt);
DsError.ThrowExceptionForHR(hr);
}
// //设置抓取图片相关参数
// // SaveSizeInfo(sampGrabber);
// //拍照功能所需的接口对象添加结束
//// 开始将视频窗口绑定到主窗体上
hr = this.m_videoWindow.put_Owner(this.Handle);
hr = this.m_videoWindow.put_WindowStyle(WindowStyle.Child | WindowStyle.ClipChildren);
if (this.m_videoWindow != null)
{
this.m_videoWindow.SetWindowPosition(0, 0, this.Width, this.Height);
}
//hr = this.m_videoWindow.put_Visible(OABool.True);
//// 开始预览采集设备采集到的视频
hr = this.m_mediaControl.Run();
}
catch
{
throw new Exception("VideoPreview函数出现异常,视频预览失败!");
}
if (m_VidControl != null)
{
hr = this.m_captureGraphBuilder.RenderStream(PinCategory.Still, MediaType.Video, theVideoDevice, null, baseGrabFlt);
DsError.ThrowExceptionForHR(hr);
}
else
{
hr = this.m_captureGraphBuilder.RenderStream(PinCategory.Capture, MediaType.Video, theVideoDevice, null, baseGrabFlt);
DsError.ThrowExceptionForHR(hr);
}
是否用来采集视频流?public static class PinCategory
{
public static readonly Guid AnalogVideoIn;
public static readonly Guid Capture;
public static readonly Guid CC;
public static readonly Guid EDS;
public static readonly Guid NABTS;
public static readonly Guid Preview;
public static readonly Guid Still;
public static readonly Guid TeleText;
public static readonly Guid TimeCode;
public static readonly Guid VBI;
public static readonly Guid VideoPort;
public static readonly Guid VideoPortVBI;
}
这些都是什么意思啊?