DShow.Net Problem With Opening Camera
-
Hello. I'm streaming a webcam using DirectShow. I can open the camera fine on a windows form once. But, If I close the camera and then try to reopen it my code fails on the RenderStream line. Once I restart my application everything is fine again. I'm quite certain I'm freeing everything up, but i'm stumped. Any help would be GREATLY appreciated.
Guid cat = PinCategory.Capture;
Guid med = MediaType.Video;private IBaseFilter sourceBase; private IGraphBuilder graph; private ICaptureGraphBuilder2 capGraph; private ISampleGrabber sg; private IMediaControl mc; private IBaseFilter grabberBase; private VideoInfoHeader videoInfoHeader; private const int WM\_GRAPHNOTIFY = 0x00008001; private const int WS\_CHILD = 0x40000000; private const int WS\_CLIPCHILDREN = 0x02000000; private const int WS\_CLIPSIBLINGS = 0x04000000; private int frameWidth = 320; private int frameHeight = 240; public bool Start(string SystemID) { using (DsDevice camDevice = GetDeviceFromMon(SystemID)) { if (camDevice != null) { object comObj = null; Guid gbf = typeof(IBaseFilter).GUID; Guid clsid = Clsid.CaptureGraphBuilder2; Guid riid = typeof(ICaptureGraphBuilder2).GUID; AMMediaType media = new AMMediaType(); media.majorType = MediaType.Video; media.subType = MediaSubType.RGB24; media.formatType = FormatType.VideoInfo; //Create Source camDevice.Mon.BindToObject(null, null, ref gbf, out comObj); sourceBase = (IBaseFilter)comObj; comObj = null; //Create Graph comObj = Activator.CreateInstance(Type.GetTypeFromCLSID(Clsid.FilterGraph)); graph = (IGraphBuilder)comObj; comObj = null; //Create Capture Graph comObj = DsBugWO.CreateDsInstance(ref clsid, ref riid); capGraph = (ICaptureGraphBuilder2)comObj; comObj = null; //Create Grabber comObj = Activator.CreateInstance(Type.GetTypeFromCLSID(Clsid.SampleGrabber)); sg = (ISampleGrabber)comObj; comObj = null;
-
Hello. I'm streaming a webcam using DirectShow. I can open the camera fine on a windows form once. But, If I close the camera and then try to reopen it my code fails on the RenderStream line. Once I restart my application everything is fine again. I'm quite certain I'm freeing everything up, but i'm stumped. Any help would be GREATLY appreciated.
Guid cat = PinCategory.Capture;
Guid med = MediaType.Video;private IBaseFilter sourceBase; private IGraphBuilder graph; private ICaptureGraphBuilder2 capGraph; private ISampleGrabber sg; private IMediaControl mc; private IBaseFilter grabberBase; private VideoInfoHeader videoInfoHeader; private const int WM\_GRAPHNOTIFY = 0x00008001; private const int WS\_CHILD = 0x40000000; private const int WS\_CLIPCHILDREN = 0x02000000; private const int WS\_CLIPSIBLINGS = 0x04000000; private int frameWidth = 320; private int frameHeight = 240; public bool Start(string SystemID) { using (DsDevice camDevice = GetDeviceFromMon(SystemID)) { if (camDevice != null) { object comObj = null; Guid gbf = typeof(IBaseFilter).GUID; Guid clsid = Clsid.CaptureGraphBuilder2; Guid riid = typeof(ICaptureGraphBuilder2).GUID; AMMediaType media = new AMMediaType(); media.majorType = MediaType.Video; media.subType = MediaSubType.RGB24; media.formatType = FormatType.VideoInfo; //Create Source camDevice.Mon.BindToObject(null, null, ref gbf, out comObj); sourceBase = (IBaseFilter)comObj; comObj = null; //Create Graph comObj = Activator.CreateInstance(Type.GetTypeFromCLSID(Clsid.FilterGraph)); graph = (IGraphBuilder)comObj; comObj = null; //Create Capture Graph comObj = DsBugWO.CreateDsInstance(ref clsid, ref riid); capGraph = (ICaptureGraphBuilder2)comObj; comObj = null; //Create Grabber comObj = Activator.CreateInstance(Type.GetTypeFromCLSID(Clsid.SampleGrabber)); sg = (ISampleGrabber)comObj; comObj = null;
What is the exception that it throws?
Every day, thousands of innocent plants are killed by vegetarians. Help end the violence EAT BACON
-
What is the exception that it throws?
Every day, thousands of innocent plants are killed by vegetarians. Help end the violence EAT BACON
-
Thanks for replying. capGraph.RenderStreamdoesn't throw an exception, but it returns -2147024809
http://stackoverflow.com/questions/13100698/unknown-error-on-renderstream[^] Can I suggest that you have a read of this
Every day, thousands of innocent plants are killed by vegetarians. Help end the violence EAT BACON
-
http://stackoverflow.com/questions/13100698/unknown-error-on-renderstream[^] Can I suggest that you have a read of this
Every day, thousands of innocent plants are killed by vegetarians. Help end the violence EAT BACON
-
Hello. I'm streaming a webcam using DirectShow. I can open the camera fine on a windows form once. But, If I close the camera and then try to reopen it my code fails on the RenderStream line. Once I restart my application everything is fine again. I'm quite certain I'm freeing everything up, but i'm stumped. Any help would be GREATLY appreciated.
Guid cat = PinCategory.Capture;
Guid med = MediaType.Video;private IBaseFilter sourceBase; private IGraphBuilder graph; private ICaptureGraphBuilder2 capGraph; private ISampleGrabber sg; private IMediaControl mc; private IBaseFilter grabberBase; private VideoInfoHeader videoInfoHeader; private const int WM\_GRAPHNOTIFY = 0x00008001; private const int WS\_CHILD = 0x40000000; private const int WS\_CLIPCHILDREN = 0x02000000; private const int WS\_CLIPSIBLINGS = 0x04000000; private int frameWidth = 320; private int frameHeight = 240; public bool Start(string SystemID) { using (DsDevice camDevice = GetDeviceFromMon(SystemID)) { if (camDevice != null) { object comObj = null; Guid gbf = typeof(IBaseFilter).GUID; Guid clsid = Clsid.CaptureGraphBuilder2; Guid riid = typeof(ICaptureGraphBuilder2).GUID; AMMediaType media = new AMMediaType(); media.majorType = MediaType.Video; media.subType = MediaSubType.RGB24; media.formatType = FormatType.VideoInfo; //Create Source camDevice.Mon.BindToObject(null, null, ref gbf, out comObj); sourceBase = (IBaseFilter)comObj; comObj = null; //Create Graph comObj = Activator.CreateInstance(Type.GetTypeFromCLSID(Clsid.FilterGraph)); graph = (IGraphBuilder)comObj; comObj = null; //Create Capture Graph comObj = DsBugWO.CreateDsInstance(ref clsid, ref riid); capGraph = (ICaptureGraphBuilder2)comObj; comObj = null; //Create Grabber comObj = Activator.CreateInstance(Type.GetTypeFromCLSID(Clsid.SampleGrabber)); sg = (ISampleGrabber)comObj; comObj = null;
-