I am new to COM and C#.
I have a pretty basic filter graph that is modified to show the image on a picturebox in winforms application.
Everything is working as expected in a regular PC. But I am getting black image on picturebox (as if the same dark state right before image appears never proceeded to show the stream data) on the target PC, which is pretty weak.
The graph renders fine on that same PC if I am using the original videorenderer filter intact. The problem arises as I replace that last renderer with picturebox.
As there are no errors, and it seems to be platform spec related, I need help from an experienced COM developer.
//pUSB = video capture device
//pMJPEGDecompressor = decompressor
//pColorSpaceConverter = color space
//pNullrenderer2 = null renderer`
//add MJPEG Decompressor
IBaseFilter pMJPEGDecompressor = (IBaseFilter)new MjpegDec();
hr = pGraph.AddFilter(pMJPEGDecompressor, "MJPEG Decompressor");
//connect USB ビデオ デバイス and MJPEG Decompressor
//hr = pGraph.ConnectDirect(GetPin(pUSB, getCatName(pUSB)), GetPin(pMJPEGDecompressor, "XForm In"), null);
//hr = pGraphBuilder.RenderStream(null, MediaType.Video, pUSB, null, pMJPEGDecompressor);
//add Color Space Converter
IBaseFilter pColorSpaceConverter = (IBaseFilter)new Colour();
hr = pGraph.AddFilter(pColorSpaceConverter, "Color Space Converter");
//connect MJPEG Decompressor and Color Space Converter
//hr = pGraph.ConnectDirect(GetPin(pMJPEGDecompressor, "XForm Out"), GetPin(pColorSpaceConverter, "Input"), null);
//hr = pGraphBuilder.RenderStream(null, MediaType.Video, pMJPEGDecompressor, null, pColorSpaceConverter);
//Add the NULL Renderer
IBaseFilter pNullrenderer2 = (IBaseFilter)new NullRenderer();
hr = pGraph.AddFilter(pNullrenderer2, "Null Renderer");
//hr = pGraphBuilder.RenderStream(null, MediaType.Video, pColorSpaceConverter, null, pNullrenderer2);
hr = pGraphBuilder.RenderStream(null, MediaType.Video, pUSB, null, null);
Marshal.ReleaseComObject(pUSB);
`
No error messages received
I found the issue. By the way it was in the auto generated code from GrapheditPlus.
The weird issue was due to the call of RenderStream
after each AddFilter
. A single call after the last "filter" (a picturebox
in my case) was good enough.
Probably, the low spec nature of the PC made the whole thing to fail in half way. The system assumed earlier call to be good, but it obviously wasn't.
I am commenting out the redundant lines in the question. The rest of the code did not require modifications.