DShow programming in C# (1 Viewer)

Status
Not open for further replies.

stax

Portal Member
October 29, 2004
47
0
Hi,
I will much likely work a lot with a COM+ API in the future namely DirectShow. The exaxt interop strategy is however foggy. In C++ DirectShow code would look like this:

IPin* pPin;
HRESULT hr = GetPin(&pPin);

if (FAILED(hr))
Return hr;

I've learned programing using .NET and found this way of programming very inconvenient and unproductive. A managed API designed after .NET guidelines would look like this in C#:

Pin pin = GetPin();

so what we got here is 1 line of code instead of 4 lines code not even counting releasing the interface which have to be done as well. Besides the amount of how many lines of code need to be written .NET has many other advantages as well of course. It makes code both a lot easier to write and read. I would like to wrap the DShow API in a way I can use it like my C# example meaning functions return things how it's supposed to be but not with out parameters, if a error occurs a exception get's thrown. The managed DirectX implementation is designed in this fashion using C++ managed extensions. The resources about how to implement such a API that I found are thin. I found a little page in MSDN called:

Implementing a Custom Runtime Callable Wrapper

it's a simple containment example where a ref class (new syntax for __gc class, I use the new C++/CLR of VS 2005 already) using a smartpointer containing the interface to wrap. I've made a little library very similar, it's not different than wrapping normal C++ object pointers. I wonder if somebody is working on a managed DShow implementation. I think it would already very usuful to have basic stuff available, it should be possible to mix this with runtime callable wrappers available with NETMasters DShowNET.dll. I couldn't help myself other than using reflector on the Managed DX implementation which as usual turned out to be very useful to understand how things work. Is anybody else here interested in this topic?

stax
 

Frodo

Retired Team Member
  • Premium Supporter
  • April 22, 2004
    1,518
    121
    51
    The Netherlands
    Home Country
    Netherlands Netherlands
    we already do directshow programming in C#
    so sorry, but old news


    frodo
     

    stax

    Portal Member
    October 29, 2004
    47
    0
    I know but I was talking about using CRCW's instead of RCW's in order to make a COM API feel like a .NET API. If you use RCW's you write C# code like this:


    Code:
    IPin pin;
    int hr = GetPin(pin);
    
    if (hr != 0)
        handle error...

    if you make CRCW's your C# code looks like this:

    Code:
    Pin pin = GetPin();

    this is how I want to write my dshow code
     
    A

    Anonymous

    Guest
    stax said:
    I know but I was talking about using CRCW's instead of RCW's in order to make a COM API feel like a .NET API. If you use RCW's you write C# code like this:


    Code:
    IPin pin;
    int hr = GetPin(pin);
    
    if (hr != 0)
        handle error...

    if you make CRCW's your C# code looks like this:

    Code:
    Pin pin = GetPin();

    this is how I want to write my dshow code

    Seems all is said, so i close here.

    Greets
    Agree
     
    Status
    Not open for further replies.

    Users who are viewing this thread

    Top Bottom