Click here to Skip to main content
11,438,226 members (69,301 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ C# COM directshow
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#.
Posted 27-Sep-12 1:57am
Edited 27-Sep-12 4:07am
v2
Comments
Argonia at 27-Sep-12 9:59am
   
Use OLE/Com object viewer (or similar program) to see if the DirectShow API isn't available for you to use directly. I use that program and it saved me a lot of time. It helps you with the exported functions as well
Member 8210399 at 27-Sep-12 11:03am
   
Thank you Markus, I was searching too and found that site and realized that converting the c++'s API is very complicated and that's why this site excites.
NeonMika at 27-Sep-12 11:10am
   
As far as I have seen they have many examples on how to use it. Don't know if they have one for your problem, but I can imagine that they have at least something similar.
http://directshownet.sourceforge.net/about.html

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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 Smile | :)

Greets, Markus
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web02 | 2.8.150506.1 | Last Updated 27 Sep 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100