Click here to Skip to main content
15,886,664 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi currently I am writing a GUI which calls a C H.264 video decoder library. I want to stop the decoder as soon as it finishes decoding one frame and updating a buffer and then read this buffer from C# GUI and then display the same.

How can I achieve this? , not much information is present on event handling between C and C#. Can someone help me out with this, I desperately need a solution, deadlines approaching.

Thanks
Posted
Comments
ZurdoDev 19-Jul-12 10:14am    
I would start by asking whoever developed the decoder library. You want to control how their code works so I would start with them.
mYashodhar 19-Jul-12 10:27am    
its my decoder and I have complete access to it.
ZurdoDev 19-Jul-12 10:30am    
I'm confused then. This is all code you have written so I guess I do not understand exactly what you are asking for. Does your decoder raise an event after it processes each frame or have a property to indicate it stops after each frame? It's your code so I would assume you could do whatever you need. I think we need a more clear explanation of what you are asking.
mYashodhar 19-Jul-12 13:02pm    
currently it raises an event when ever a decoded frame is available, and as its my code to manipulate, I can change this methodology if necessary

1 solution

If you mean C, and not for example C++ with COM, events are not part of its methodology. Nor are interruptible threads or methods. I'd recommend that you expose the 'do one frame' function directly to the outside (i.e. so the C# library can call that), and manage the interruptible loop of calling that function and reading the result in the C# side (in a background thread, probably).
 
Share this answer
 
Comments
mYashodhar 19-Jul-12 13:08pm    
I cannot expose the 'do one frame' function directly as the code is tightly coupled and as the source for decoder could be an off-site streaming server, I do not have the liberty to decide on the incoming packets and hence cannot separate the single frame function as it would mean communication and parsing the data from the server through c#; which has already been implemented in the decoder C code
BobJanova 19-Jul-12 13:15pm    
Okay, so new plan: have your C function accept a pointer to a callback function (which you can hook to with a delegate in C#), that returns whether processing should abort and close the streams etc. That function (in C#) can simply return true or false depending on whether you want to cancel.
mYashodhar 19-Jul-12 13:25pm    
Nice! Ill try it out and let you know!.. thanks alot! I think this should work! :)

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900