1

I'm currently working on a C# wrapper to work with Dallmeier Common API light.
See previous posting: C# wrapper and Callbacks

I've got pretty much everything 'wrapped' but I'm stuck on wrapping a callback which contains an array of three pointers & an array integers:

dlm_setYUVDataCllback

int(int SessionHandle, void (*callback) (long IPlayerID, unsigned char** yuvData,  
    int* pitch, int width, int height, int64_t ts, char* extData))  

Function Set callback, to receive current YUV image.
Arguments SessionHandle: handle to current session.
Return PlayerID (see callback).
Callback - IPlayerId: id to the Player object
- yuvData: array of three pointers to Y, U and V part of image
The YUV format used is YUV420 planar (not packed).
char *y = yuvData[0];
char *u = yuvData[1];
char *v = yuvData[2];
- pitch: array of integers for pitches for Y, U and V part of image
- width: intrinsic width of image.
- height
- ts : timestamp of current frame
- extData: additional data to frame

How do I go about wrapping this in c#?

Any help is much appreciated.

1 Answer 1

0

unsigned char** yuvData should be defined as [MarshalAs(UnmanagedType.ByValArray,SizeConst=3)] IntPtr[] yuvData

You will then get an array of 3 IntPtrs. You can the read the actual data using the Marshal.Read or Marshal.Copy.

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks logicnp. Just a followup on this, i have created a struct with the parameters as above but what should 'Int64_t' be in c# and do I use the same MashalAs for the 'pitch' which is also an array of integers e.g. [MarshalAs(UnmanagedType.ByValArray,SizeConst=1)] IntPtr[] pitch
int64_t should be defined as long (which is also 64-bits in c#). For the pitch, your definition is correct if 'pitch' is a one-dimensional array.
How and Were do I use the Marshal.Read or Marshal.Copy
@logicnp: I think you meant UnmanagedType.LPArray. ByValArray is only valid on structure fields.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.