void AddSourceFilter()
{
int hr = 0;
// Add the source filter to the graph
hr = graphBuilder.AddFilter(fsourceBaseFilter, "Webcam Source");
DsError.ThrowExceptionForHR(hr);
// We want to configure the video capture pin
// So, we first find the interface
Object o = null;
Guid iid = typeof(IAMStreamConfig).GUID;
hr = captureGraphBuilder.FindInterface(PinCategory.Capture, MediaType.Video, fsourceBaseFilter, iid, out o);
if (hr != 0)
o = null;
// If there was no interface found, then just return
if (null == o)
return;
fVideoStreamConfig = o as IAMStreamConfig;
ConfigureSourceFilter(fVideoStreamConfig, fDesiredWidth, fDesiredHeight, 24);
}