Hello,
I want to connect: Render Url -> Video Trans Filter -> SampleGrabber -> SpaceColorConverter -> Video Renderer
The graph runs in graph edit plus an the code is generated by the application.
But when the filter tries to connect "Video Trans Filter" -> "SampleGrabber" i get: HR=-2147220992, COMException: Invalid specified type.
hr = m_FilterGraph.ConnectDirect(GetPin(pVideoTransFilter, "XForm Out"), GetPin(pSampleGrabber, "Input"), null);--->ERROR
Could the problem because i use a sampleGrabber filter instead of the samplegrabber as type?
hr = pBuilder.SetFiltergraph(m_FilterGraph);
checkHR(hr, "Can't SetFilterGraph");
Guid CLSID_CamVivotekFilter = new Guid("{0EF5DB94-D007-407D-8356-42765BDACEC6}"); //NetSourceFiltertalk.ax
// Guid CLSID_AudioTransFilter = new Guid("{9B021DCF-37EF-4EC5-ADB3-8C53D52EC2B}"); //VideoTransFilter.dll
Guid CLSID_VideoTransFilter = new Guid("{B473D86D-4A03-4B76-9020-12A41C838548}"); //VideoTransFilter.dll
Guid CLSID_VideoRenderer = new Guid("{B87BEB7B-8D29-423F-AE4D-6582C10175AC}"); //quartz.dll
Guid CLSID_SampleGrabber = new Guid("{C1F400A0-3F08-11D3-9F0B-006008039E37}"); //qedit.dll
// Add Vivotek inetcamtalk
IBaseFilter pCamVivotekFilter = (IBaseFilter)Activator.CreateInstance(Type.GetTypeFromCLSID(CLSID_CamVivotekFilter));
hr = m_FilterGraph.AddFilter(pCamVivotekFilter, "Vivotek inetcamtalk Filter");
checkHR(hr, "Can't add Vivotek inetcamtalk Filter to graph");
//set source filename
IFileSourceFilter pCamVivotekFilter_src = pCamVivotekFilter as IFileSourceFilter;
if (pCamVivotekFilter_src == null)
checkHR(unchecked((int)0x80004002), "Can't get IFilsourceFilter");
hr = pCamVivotekFilter_src.Load(IPAddress, null);
checkHR(hr, "Can't load file");
// Add Video TransFilter
IBaseFilter pVideoTransFilter = (IBaseFilter)Activator.CreateInstance(Type.GetTypeFromCLSID(CLSID_VideoTransFilter));
hr = m_FilterGraph.AddFilter(pVideoTransFilter, "Video Trans Filter");
checkHR(hr, "Can't add Video Trans Filter Filter to graph");
//connect Vivotek inetcamtalk and Video Trans Filter
hr = m_FilterGraph.ConnectDirect(GetPin(pCamVivotekFilter, "Video Pin"), GetPin(pVideoTransFilter, "XForm In"), null);
checkHR(hr, "Can't connect Vivotek inetcamtalk and Video Trans Filter");
//add sample Grabber
IBaseFilter pSampleGrabber = (IBaseFilter)Activator.CreateInstance(Type.GetTypeFromCLSID(CLSID_SampleGrabber));
hr = m_FilterGraph.AddFilter(pSampleGrabber, "SampleGrabber");
checkHR(hr, "Can't add sampleGrabber");
AMMediaType pSampleGrabber_pmt = new AMMediaType();
pSampleGrabber_pmt.majorType = MediaType.Video;
pSampleGrabber_pmt.subType = MediaSubType.H264;
pSampleGrabber_pmt.formatType = FormatType.VideoInfo;
pSampleGrabber_pmt.fixedSizeSamples = true;
pSampleGrabber_pmt.formatSize = 1128;
pSampleGrabber_pmt.sampleSize = 1622016;
pSampleGrabber_pmt.temporalCompression = false;
VideoInfoHeader pSampleGrabber_format = new VideoInfoHeader();
pSampleGrabber_format.SrcRect = new DsRect();
pSampleGrabber_format.TargetRect = new DsRect();
pSampleGrabber_format.BmiHeader = new BitmapInfoHeader();
pSampleGrabber_format.BmiHeader.Size = 40;
pSampleGrabber_format.BmiHeader.Width = 704;
pSampleGrabber_format.BmiHeader.Height = 576;
pSampleGrabber_format.BmiHeader.Planes = 1;
pSampleGrabber_format.BmiHeader.BitCount = 32;
pSampleGrabber_format.BmiHeader.ImageSize = 1622016;
pSampleGrabber_pmt.formatPtr = Marshal.AllocCoTaskMem(Marshal.SizeOf(pSampleGrabber_format));
Marshal.StructureToPtr(pSampleGrabber_format, pSampleGrabber_pmt.formatPtr, false);
hr = ((ISampleGrabber)pSampleGrabber).SetMediaType(pSampleGrabber_pmt);
DsUtils.FreeAMMediaType(pSampleGrabber_pmt);
checkHR(hr, "Canr set media type to sample grabber");
/*
// Choose to call BufferCB instead of SampleCB
hr = ((ISampleGrabber)pSampleGrabber).SetCallback(this, 1);
DsError.ThrowExceptionForHR(hr);
*/
//connect Video Transfer filter and SampleGrabber
hr = m_FilterGraph.ConnectDirect(GetPin(pVideoTransFilter, "XForm Out"), GetPin(pSampleGrabber, "Input"), null);--->ERROR
checkHR(hr, "Cant set connect Video Transfer filter and Sample Grabber");
//add color space converter
IBaseFilter pColorSpaceConverter = (IBaseFilter)new Colour();
hr = m_FilterGraph.AddFilter(pColorSpaceConverter, "Color Space Converter");
checkHR(hr,"Cant add Color Space Converter");
//connect SampleGrabber to color space converter
hr = m_FilterGraph.ConnectDirect(GetPin(pSampleGrabber, "Ouput"), GetPin(pColorSpaceConverter, "Input"), null);
checkHR(hr, "Cant connect SampleGraber to color space converter");
// add Video Renderer
IBaseFilter pAVideoRenderer = (IBaseFilter)Activator.CreateInstance(Type.GetTypeFromCLSID(CLSID_VideoRenderer));
hr = m_FilterGraph.AddFilter(pAVideoRenderer, "Video Renderer");
checkHR(hr, "Can't add Video Renderer");
//connect color space converter to video renderer
hr = m_FilterGraph.ConnectDirect(GetPin(pColorSpaceConverter, "XForm Out"), GetPin(pAVideoRenderer, "VMR Input0"), null);
checkHR(hr, "Cant connect SampleGrabe to videorender");