Hi,
I have below code to capture and preview using GMFPreview bridge. Its working fine. Now i need to add sample Grabber filter so that i can capture image parallel without any glitch using SetMode function. Please let me know how to add sample grabber filter in this block.
I tried a lot but not able to achieve. Please help as i am new to this.
public void
SelectDevice(DsDevice dev, IntPtr hwnd)
{
int hr;
IBaseFilter pfDevice = null;
ICaptureGraphBuilder2 pBuilder = null;
try
{
m_pSourceGraph = (IGraphBuilder)new FilterGraph();
m_rot1 = new DsROTEntry(m_pSourceGraph);
m_pBridge = (IGMFBridgeController)new GMFBridgeController();
hr = m_pBridge.AddStream(true, eFormatType.MuxInputs, true);
DsError.ThrowExceptionForHR(hr);
hr = ((IFilterGraph2)m_pSourceGraph).AddSourceFilterForMoniker(dev.Mon, null, dev.Name, out pfDevice);
DsError.ThrowExceptionForHR(hr);
hr = m_pBridge.InsertSinkFilter(m_pSourceGraph, out m_pSourceGraphSinkFilter);
DsError.ThrowExceptionForHR(hr);
pBuilder = (ICaptureGraphBuilder2)new CaptureGraphBuilder2();
hr = pBuilder.SetFiltergraph(m_pSourceGraph);
DsError.ThrowExceptionForHR(hr);
hr = pBuilder.RenderStream(PinCategory.Preview, MediaType.Video, pfDevice, null, null);
DsError.ThrowExceptionForHR(hr);
hr = pBuilder.RenderStream(PinCategory.Capture, MediaType.Video, pfDevice, null, m_pSourceGraphSinkFilter);
DsError.ThrowExceptionForHR(hr);
hr = pBuilder.FindPin(pfDevice, PinDirection.Output, PinCategory.Capture, MediaType.Video, false, 0, out m_pCapOutput);
if (hr >= 0)
{
IAMStreamControl pSC = (IAMStreamControl)m_pCapOutput;
pSC.StartAt(NEVER, 0);
}
ConfigureVideo(hwnd);
IMediaControl pMC = (IMediaControl)m_pSourceGraph;
hr = pMC.Run();
DsError.ThrowExceptionForHR(hr);
m_DeviceSelected = true;
}
catch
{
ReleaseSelectMembers();
throw;
}
finally
{
if (pBuilder != null)
{
Marshal.ReleaseComObject(pBuilder);
}
if (pfDevice != null)
{
Marshal.ReleaseComObject(pfDevice);
}
Saved_m_pSourceGraph = m_pSourceGraph;
}
}