interop - Using a C++ callback interface in C# -


I am writing an application using DirectShow to record the video - I am using the DirectShowLib, interop library I do need to do great work to do that

However, now I need to get callback notifications because the samples are written in a file, so I can add data unit extensions. According to the MSDN documentation, C ++ is implemented by implementing this interface, and passing the item as a result of the method of the IAMWMBufferPass interface of a pin.

Then, I created a small square that implements the IAMWMBufferPassCallback interface from DirectShowLib:

  class IAMWMBufferPassCallbackImpl: IAMWMBufferPassCallback {Private RecordingPlayer player; Public IAMWMBufferPassCallbackImpl (recording player player) {this.player = player; } Inform the public integer (INSSBuffer3 pNSSBuffer3, IPIN pPin, long prtStart, long prtEnd) {if (player.bufferPin == pPin & Player Player.firstBufferHandled} {player.firstBufferHandled = true // with buffer Work ....} 0 Return; }}  

Then I retrieved the IAMWMBufferPass interface for the required PIN, and passed an example of that class with the SetNotify method:

  BufferPass Callback Interface = New IAMWMBufferPassCallbackImpl (this); IAMWMBufferPass bPass = (IAMWMBufferPass) DSHelper.GetPin (pWMASFWriter, "Video Input 01"); Hr = bPass.SetNotify (buffercoccrollback interface); DsError.ThrowExceptionForHR (Hour);  

No exceptions have been thrown, it indicates that the SetNotify method is successful.

Now, the problem is that the notification method in my callback object is never called without video recording, except for the fact that the callback is not being executed at all.

Is there a problem with this way I am interoping?

I usually work with representatives of Function Points in the unsafe C # code.
The only move is that you need to make sure that the rep does not get the garbage collected because the reference of the unsafe code is not used when counting references inside the garbage collector. Thus functions require either static or an object, in which context an additional artificial reference is required to ensure its availability. This is on an MSDN.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -