Pergunta

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;
};

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)).

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...

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#.

Foi útil?

Solução

You are going to have hard time interfacing DirectShow API from C# code directly. Luckily, this work is already done and available as DirectShow.NET Library. It comes with all bindings you need and sample projects as well.

Specifically 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)).

tells that you are trying to use IGraphBuilder interface identifier IID as a coclass identifier CLSID. This expectedly does not work out.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top