The code for CsYuv: A DirectShow filter in C# PDF Print E-mail
Written by Daniel P   
Tuesday, 08 November 2005

I've decided to post the code as is. You can find it here. As mentioned in the Readme file, you'll need to have the open-source DirectShowLib. I've included a solution for VS 2002. The code contains only the filter which can be tested in GraphEdit to view movies in black and white. You should also have a copy of the MSDN article in order to compare the implementations.

I've got rid of all the non-essential code from Cutler's Wizard generated C++ files to get things as simple as possible.

 




Bookmark it...
Digg!Reddit!Del.icio.us!Google!Facebook!Slashdot!Technorati!StumbleUpon!Newsvine!Furl!Yahoo!Ma.gnolia!
 
HOWTO: Write a DirectShow filter in C# (with a zest of MC++) PDF Print E-mail
Written by Daniel P   
Thursday, 03 November 2005

I have just written a couple of DirectShow filters in C#. For example, I have ported the YUV filter from the MSDN mag to C#. The official party line from Redmond is that filters shouldn't be written in C# for "performance reasons". I've always been suspicious of wide,  sweeping statements like this, especially when people are not yet familiar with a new technology.

For the past few months, I have played with DirectShow and C# and performance hasn't been an issue. I can't say the same about resources management and threadings; the interactions between managed and native concepts in this area have been more puzzling.

I believe that most people who have looked at the possibilities of writing DirectShow filters in C# walked away after looking at the task of porting the DirectShow base classes to C#. DMOs in C# are a possibility as David Wohlferd pointed out recently (in a comment of my Sept. 3th blog entry, and should be available in the next version of DirectShowLib).

I have written my filters using Cutler's DirectShow Wizard from the DirectShow book. First I compiled the blank transform filter and register the filter, than I add the /clr switch (and a few project changes) and use the gcroot template to embed a pointer to my C# class that implement the filter functionality. Then, in all the member functions of the Wizard generated C++ code that need to be overriden, I forward a call to a corresponding method of my C# class. This is the "zest of MC++" that I alluded in the title. I had to create a custom library for the IMemAllocator and IMemInputPin interfaces to be able to implement the DecideBufferSize method properly. But there was nothing unusual here.

After testing the approach on a couple of filters, I realized that being able to access the interfaces used in the DirectShow base classes is sufficient for most needs. And this is not hard to do in C#. Moreover, mixing MC++ and C# allow us to have a tigher control on the division of labour between the native and managed functionality.

I can't recommend developing DirectShow filters in C# with this approach without further investigation. But for a prototype, or a "quick and dirty job", I believe it is a path that should be explored.




Bookmark it...
Digg!Reddit!Del.icio.us!Google!Facebook!Slashdot!Technorati!StumbleUpon!Newsvine!Furl!Yahoo!Ma.gnolia!
 
<< Start < Prev 11 12 13 14 15 16 17 18 19 20 Next > End >>

Results 61 - 64 of 81
Joomla Template by Joomlashack
Joomla Templates by JoomlaShack Joomla Templates by Compass Design