如何将EZrgb24过滤器连接到我的图形 [英] How to connect EZrgb24 filter to my graph
问题描述
我成功加载了32位ezrgb24 COM(从示例中编译得到)
I successfully loaded a 32 bit ezrgb24 COM (compiled it from the samples)
但是,我不知道如何将我创建的ezrgb24过滤器连接到图形。
However, I dont know how to connect the ezrgb24 filter I created to my graph.
[ComImport,
System.Security.SuppressUnmanagedCodeSecurity,
Guid("fd5010a3-8ebe-11ce-8183-00aa00577da1"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IIPEffect
{
[PreserveSig]
void get_IPEffect([Out] out int effectNum, [Out] out double StartTime, [Out] out double Length);
[PreserveSig]
void put_IPEffect([In] int effectNum, [In] double StartTime, [In] double Length);
}
internal enum CLSCTX
{
Inproc = 0x03,
Server = 0x15,
All = 0x17,
}
[ComImport]
[Guid("8B498501-1218-11CF-ADC4-00A0D100041B")]
public class EZRGB24
{
}
相关代码
Relevant code
IBaseFilter ibfRenderer = null;
ISampleGrabber sampGrabber = null;
IBaseFilter capFilter = null;
IPin iPinInFilter = null;
IPin iPinOutFilter = null;
IPin iPinInDest = null;
Type comType = null;
object comObj = null;
m_FilterGraph = new FilterGraph() as IFilterGraph2;
try
{
// Get the SampleGrabber interface
sampGrabber = new SampleGrabber() as ISampleGrabber;
// Add the video source
hr = m_FilterGraph.AddSourceFilter(_videoPath, "Ds.NET FileFilter", out capFilter);
DsError.ThrowExceptionForHR(hr);
// Hopefully this will be the video pin
IPin iPinOutSource = DsFindPin.ByDirection(capFilter, PinDirection.Output, 0);
IBaseFilter baseGrabFlt = sampGrabber as IBaseFilter;
ConfigureSampleGrabber(sampGrabber);
iPinInFilter = DsFindPin.ByDirection(baseGrabFlt, PinDirection.Input, 0);
iPinOutFilter = DsFindPin.ByDirection(baseGrabFlt, PinDirection.Output, 0);
// Add the frame grabber to the graph
hr = m_FilterGraph.AddFilter(baseGrabFlt, "Ds.NET Grabber");
DsError.ThrowExceptionForHR(hr);
hr = m_FilterGraph.Connect(iPinOutSource, iPinInFilter);
DsError.ThrowExceptionForHR(hr);
// Get the default video renderer
ibfRenderer = (IBaseFilter)new VideoRendererDefault();
// Add it to the graph
hr = m_FilterGraph.AddFilter(ibfRenderer, "Ds.NET VideoRendererDefault");
DsError.ThrowExceptionForHR(hr);
iPinInDest = DsFindPin.ByDirection(ibfRenderer, PinDirection.Input, 0);
// Connect the graph. Many other filters automatically get added here
hr = m_FilterGraph.Connect(iPinOutFilter, iPinInDest);
DsError.ThrowExceptionForHR(hr);
SaveSizeInfo(sampGrabber);
----- everything works fine up to here.
IIPEffect myClass = (IIPEffect)(new EZRGB24());
myClass.put_IPEffect(1008, 0, 100000);
hr = m_FilterGraph.AddFilter((IBaseFilter)myClass, "EZRGB24");
IPin inPinx = DsFindPin.ByDirection((IBaseFilter)myClass, PinDirection.Input, 0);
m_FilterGraph.Connect(iPinOutSource, inPinx);
DsError.ThrowExceptionForHR(hr);
当我将鼠标悬停在myClass上时,我看到它不为空。
When I mouse over myClass, I can see it's not null.
此外,我尝试通过图形编辑插入到图形中,但未列出我的程序。
另外,在该行
hr = m_FilterGraph.AddFilter((IBaseFilter)myClass, EZRGB24); hr为0
Also, I tryed to plug onto my graph with graph edit, but my program isn't listed. Also, hr is 0 after that line hr = m_FilterGraph.AddFilter((IBaseFilter)myClass, "EZRGB24");
我正在使用directshow.net,但是,这也被标记为directshow,因为我认为该解决方案适用于c#或c ++。
I am using directshow.net, however, this is also tagged both directshow as I feel the solution will work for either c# or c++.
这是我之前的问题的后续内容< a href = https://stackoverflow.com/questions/25797025/how-to-use-ezrgb24-filter>如何使用EZrgb24过滤器
This is a follow up of my previous question How to use EZrgb24 filter
推荐答案
您两次使用 iPinOutSource
进行连接。首先执行:
You are using iPinOutSource
twice to connect. First you execute:
// Hopefully this will be the video pin
IPin iPinOutSource = DsFindPin.ByDirection(capFilter, PinDirection.Output, 0);
hr = m_FilterGraph.Connect(iPinOutSource, iPinInFilter);
及更高版本
m_FilterGraph.Connect(iPinOutSource, inPinx);
一个引脚只能有一个连接。
A pin can only have one connection.
这篇关于如何将EZrgb24过滤器连接到我的图形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!