DirectShow C ++的带有c#的API(COM组件) [英] DirectShow C++'s API with c# (COM component)

查看:63
本文介绍了DirectShow C ++的带有c#的API(COM组件)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Directshow开发Windwos表单应用程序.
开始时,我使用位于Windows/system32中的Quarts.dll来获取Directshow的基本API.
过了一会儿,我意识到我需要Directshow的整个API,因为我需要创建一个新的Video Renderer过滤器(VM7).
为此,我需要访问Directshow c ++ API中提供的某些接口.
我发现Directshow是COM组件,如果我找到正确的绑定方法,便可以使用C#访问他的API.

现在,这就是我访问API的步骤:

我发现Windows SDK中提供了C ++ API.我需要的API位于devenum.idl,axcore.idl和axextend.idl中.

这些是界面描述语言文件,我发现我可以通过cmd使用midl.exe来创建.tlb文件(类型库),现在有了该文件的帮助,我可以访问所需的接口.但是要使用Midl编译器,我需要创建一个新的.idl文件,其中包含我想要的接口,它看起来像这样:

I am developing a Windwos form application using Directshow.
At start I was using Quarts.dll located in windows/system32 in purpose of getting the basic API of Directshow.
After a while I realized I need the whole API of Directshow, because I need to create a new Video Renderer filter (VM7).
For this to take place I need to have access to some of the interfaces provided in Directshow c++ API.
I discovered that Directshow is a COM component and I can get access to his API in C#, if I find the right way to bound with it.

Now, this is what I did to get access to the API:

I found out that the C++ API is provided in the Windows SDK. The API I need are located in devenum.idl, axcore.idl and axextend.idl.

Those are interface description language files, and I found out that I can use the midl.exe through the cmd to create a .tlb file (a typelib), now with the file''s help I can get access to the interfaces I need. But to use the midl compiler I needed to create a new .idl file that contains the interfaces I want, it looks like that:

import "devenum.idl";
import "axcore.idl";
import "axextend.idl";

[
uuid(A68F9934-FDB9-4AAE-A631-F9307171B2FA),
helpstring("DirectShow interfaces")
]
library DirectShow
{
    interface IFilterGraph;
    interface ICreateDevEnum;
    interface IGraphBuilder;
    interface ICaptureGraphBuilder2;
    interface IFileSinkFilter;
    interface IFileSinkFilter2;
    interface IAMAudioInputMixer;
};


这需要创建一个新的Guid.

之后,我可以运行midl并创建一个.tlb文件,但是当我尝试添加对.tlb文件的引用时,出现了错误.

我找到了一种通过在.tlb文件上通过cmd运行tlbimp.exe来从此.tlb文件创建.dll文件的方法.它创建了一个.dll,我成功将其添加到项目中.
现在,Visual Studio知道了如何与我试图获取的所有接口进行交互.

但是对于我现在面临的问题:

在运行时出现此错误:


That required to create a new guid.

After that I was able to run the midl and create a .tlb file, But when I tried to add reference to the .tlb file it gave an error.

I found a way to create a .dll file from this .tlb file, by running tlbimp.exe through the cmd on the .tlb file. It created a .dll that I succeeded to add to my project.
Now Visual Studio knows how to interact withh all the interfaces I was trying to get.

But for the problem I am facing now:

At runtime I am getting this error:

Retrieving the COM class factory for component with CLSID {56A868A9-0AD4-11CE-B03A-0020AF0BA770} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).



我可以看到问题的组件clsid不是我在.idl文件中创建的库的clsid,它可以证明问题出在我正在使用的导入文件上,也许是那些文件中的GUID错误? />
我也认为问题可能是.dll没有在我的系统上注册.我尝试使用regsvr32,但它给了我一个错误,说:



I can see that the component clsid of the problem is not the clsid of the library in the .idl file I created, it could testify that the problem is on the import files I am using, maybe a bad guid in those files?

I also think the problem can be that the .dll is not registered on my system. I tried to use the regsvr32 but It gave me an error saying:

The module "directshow.dll" was loaded but the entry-point DLLRegisterServer was not found...



现在有人请救救我,告诉我如何解决该问题,或者建议我通过c#使用Directshow的C ++ API的其他解决方案.



Now somebody please save me and tell me how to fix the problem or suggest me a different solution of using the C++ API of Directshow through c#.

推荐答案

大约一个月前,因为我不得不第一次使用C#来处理视频.
我看到了这个项目[ http://directshownet.sourceforge.net/],可能可以为您提供帮助.
我真的不知道这到底有多少属于您的工作,只是试图提供帮助:)

问候,马库斯
I were just googeling around some month''s ago because I had to work with video in C# for the first time.
I saw this project [http://directshownet.sourceforge.net/] and probably this can help you.
I don''t really know how much this really belongs to your work, just trying to help :)

Greets, Markus


这篇关于DirectShow C ++的带有c#的API(COM组件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆