Click here to get back home

calling C# methods from directshow filter code

 HomeNewsGroups | Search | About
 microsoft.public.smartphone.developer    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
calling C# methods from directshow filter code Rab 08-28-2008
Posted by Rab on August 28, 2008, 2:42 am
Please log in for more thread options


Hi all,

I developped a directShow filter in Windows Mobile that successfuly
processes and render video frames inside a C# application.

My filter graph is : CameraCaptureFilter->MyProcessingFilter-
>RenderFilter.

I now want to call a C# method from my C++ transform filter to show a
dialog box for example.

I succeeded to call this C# method from a C++ method outside my filter
graph using a C# delegate and Interop C#/C++.
But when I call this same C# method from my directShow filter, it
freezes my application instead.

Why is it working from a dll function and not from the directShow
processing filter function if you know?


--------- Begin Form1.cs ---------

[DllImport("myDLL.dll")]
private extern static bool initCallBack(ReportBackHere callBack);

public delegate void ReportBackHere(int x, int y, int z);
(...)

private void InitializeApp()
{
ReportBackHere myCallBack = new ReportBackHere(Form1.
myFunction);
initCallBack(myCallBack);
(...)
}

(...)

public static void myFunction(int x, int y, int z)
{
MessageBox.Show("My callback function has been called from C++ !! ");
(...)
}

--------- End Form1.cs ---------


--------- Begin myDLL.cpp ---------

typedef void (CALLBACK *myPrototype)(int, int, int);

void (*myFunctionPointer)(int, int, int) = NULL;

extern "C" bool __declspec(dllexport) initCallBack(myPrototype dm)
{
myFunctionPointer = dm;

return true;
}


//CMonoFilter Class
HRESULT CMonoFilter::Transform(
IMediaSample *pIn,IMediaSample *pOut)
{
(...)

//here i call my function
(*myFunctionPointer)(20, 40, 0);

}

--------- End myDLL.cpp ---------

thanks for your help.

Similar ThreadsPosted
DirectShow source filter March 14, 2006, 9:36 am
Link errors with Directshow filter June 2, 2005, 3:14 pm
Camera DirectSHow custom render filter July 14, 2006, 3:53 am
Calling an extension / Pin Code... June 28, 2005, 6:25 am
Directshow Smart Tee filter is occurred Data Abort April 4, 2006, 2:03 am
Error Rendering PCM output pin of MPEG DirectShow filter December 1, 2006, 2:54 pm
Methods on the tpcutil.dll February 2, 2006, 8:11 am
methods for WBXML decoding October 5, 2006, 11:17 am
Examining Execution Speed of JITted Code with CF 2.0 Sample Code June 5, 2008, 10:06 am
How to differentiate between Manged code and Native code November 14, 2006, 8:55 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap