【发布时间】:2014-05-05 20:02:58
【问题描述】:
我有这样的 C++ 代码:
typedef void (CALLBACK * VideoCaptureCB_Ptr)(PVOID pContext, BYTE * apData[3],
VideoSampleInfo_T * pVSI);
typedef struct _VideoSampleInfo_T
{
ULONG idFormat; //
ULONG lSignalState;
int nLen; // not used for raw video data(e.g. YUV420)
int nWidth;
int nHeight;
int anPitchs[3]; // only used for raw video data(e.g. YUV420)
ULONG dwMicrosecsPerFrame; // 1000*1000/FPS
ULONG field;
int iSerial;
} VideoSampleInfo_T;
WD_RegisterVideoPreviewCB(HANDLE hChannel, PVOID pContext, VideoCaptureCB_Ptr pCB);
我编写 C# 代码以在 C# 中使用 WD_RegisterVideoPreviewCB()
public delegate void VideoCaptureCB_Ptr(IntPtr pContext, byte[] apData, VideoSampleInfo_T pVSI);
public static void HandleVideoStatic(IntPtr pContext, byte[] apData, VideoSampleInfo_T pVSI)
{
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct VideoSampleInfo_T
{
public uint idFormat;
public uint lSignalState;
public int nLen; // not used for raw video data(e.g. YUV420)
public int nWidth;
public int nHeight;
public int[] anPitchs ; // only used for raw video data(e.g. YUV420)
public uint dwMicrosecsPerFrame; // 1000*1000/FPS
public uint field;
public int iSerial;
}
WD_RegisterVideoPreviewCB(m_ahChannels[i], m_aMediaHandler[i], HandleVideoStatic);
在运行我的 C# 代码之前,我在 HandleVideoStatic() 处放置了一个调试点。当我运行我的代码时。 VS 2013 并没有在调试点停止:(
【问题讨论】:
标签: c# callback delegates pinvoke dllimport