C#调用的dll里面有自定义的结构体指针
本文介绍了C#调用的dll里面有自定义的结构体指针的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
我用ffmpeg 解码yuv数据,封装成一个dll,然后c#进行调用,但是回调函数里面的参数有一个
CvHandle类型的指针,
typedef struct CvtHandle
{
AVFormatContext *pFormatCtx;
int i, videoindex;
AVCodecContext *pCodecCtx;
AVCodec *pCodec;
AVFrame *pFrame, *pFrameYUV;
uint8_t *out_buffer;
AVPacket *packet;
int y_size;
int ret, got_picture;
SwsContext *img_convert_ctx;
/*int screen_w = 0, screen_h = 0;
SDL_Window *screen;
SDL_Renderer* sdlRenderer;
SDL_Texture* sdlTexture;
SDL_Rect sdlRect;
FILE *fp_yuv;*/
}CvtHandle;
C回调函数
extern "C" __declspec(dllexport) int __stdcall OpenStream(char* filepath);
extern "C" __declspec(dllexport) int __stdcall play(CvtHandle* cvthandle, int width, int height, int leftx, int lefty);
extern "C" __declspec(dllexport) int __stdcall CloseStream(CvtHandle* cvthandle);
我应该怎么解决这个问题?
解决方案
好久没有写过C#了,但我记得好像有一个 叫 StructLayout 的东西,
这篇关于C#调用的dll里面有自定义的结构体指针的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文