I'd like to call a C++ function, and the function has another function as callback function.
While in Objective-C, this is how I do:
cpp.h
typedef void (* FRAME_CALLBACK) (unsigned long, unsigned char *, unsigned long, long, long , VIDEO_B2_FRAME *);
Handle MOpen( void );
void MSetFrameCallback( Handle h, unsigned long param, FRAME_CALLBACK fnCallback );
and then in the Objective-C code:
objc.m
Hnadle handle = MOpen();
MSetFrameCallback(handle, (id)self, frameCallback);
void frameCallback(id param, unsigned char *rawData, unsigned long dataLen, long width, long height, VIDEO_B2_FRAME *b2)
{
ViewController *VC = (ViewController *)param;
[VC updateFrameWithData:rawData dataLen:dataLen width:width height:height];
}
But how should I do when this thing in the Swift code? I can't figure it out.
I know if I want to use ObjC or C++ Class or function that I should create a bridging file. In that situation, it works fine, but the scenario above I have no idea.