华为IPC摄像机X1221-F C#二次开发

华为IPC 挺坑爹的,只有一个开发指南文档,文档中是C++的代码片断,由于用C#实现,中间出现了一个问题,找了半天才找到原因,调用"IVS_PU_RealPlay"函数返回"an error occurred when invoking the video library function"错误信息,经查是由于PU_REAL_PLAY_INFO_S结构体中

public PU_TIME_S stStartTime;//请求预录、录像开始时间
public PU_TIME_S stEndTime;//请求预录、录像结束时间

没有声明,所以出问题,请大家注意!

以下贴出部份代码

//实时浏览结构体

public struct PU_REAL_PLAY_INFO_S
        {
            public UInt32 ulChannelId;//通道号
            public IntPtr hPlayWnd;//播放窗口的句柄,为NULL表示不播放图象
            public PU_STREAM_TYPE_E enStreamType; // 码流类型,0-主码流,1-子码流,2-码流3,3-码流4 等以此类推
            public PU_VIDEO_TYPE_E enVideoType;//流类型:视频流、音频流、复合流、录像流
            public PU_PROTOCOL_TYPE_E enProtocolType;//传输协议类型,UDP,TCP
            public PU_MEDIA_CALLBACK_TYPE_E enMediaCallbackType;//回调类型:0:RTP解密 1:RTP不解密  2:Frame 3:YUV 
            [MarshalAsAttribute(UnmanagedType.ByValTStr, SizeConst = 16)]
            public string szLocalIp;
            public bool bKeepLive;//是否保活
            public PU_TIME_S stStartTime;//请求预录、录像开始时间
            public PU_TIME_S stEndTime;//请求预录、录像结束时间
            public PU_MEDIA_CRYPTO_TYPE_E enMediaCryptoType;
            [MarshalAsAttribute(UnmanagedType.ByValTStr, SizeConst = 44)]
            public string szMediaCrypto;
            [MarshalAsAttribute(UnmanagedType.ByValTStr, SizeConst = 32)]
            public string szReserved;

        }

//时间,时、分、秒,24小时制
        public struct PU_TIME_S
        {
            [MarshalAsAttribute(UnmanagedType.ByValTStr, SizeConst = 5)]
            string szYear;
            [MarshalAsAttribute(UnmanagedType.ByValTStr, SizeConst = 3)]
            string szMonth;
            [MarshalAsAttribute(UnmanagedType.ByValTStr, SizeConst = 3)]
            string szDay;
            [MarshalAsAttribute(UnmanagedType.ByValTStr, SizeConst = 3)]
            string szHour;
            [MarshalAsAttribute(UnmanagedType.ByValTStr, SizeConst = 3)]
            string szMinute;
            [MarshalAsAttribute(UnmanagedType.ByValTStr, SizeConst = 3)]
            string szSecond;
        }

HWPuSDK.PU_REAL_PLAY_INFO_S clientinfo = new HWPuSDK.PU_REAL_PLAY_INFO_S();
            clientinfo.ulChannelId = 101;
            clientinfo.hPlayWnd = this.RealPlayWnd.Handle;
            clientinfo.enProtocolType = HWPuSDK.PU_PROTOCOL_TYPE_E.PU_PROTOCOL_TYPE_TCP;
            clientinfo.enStreamType = HWPuSDK.PU_STREAM_TYPE_E.PU_VIDEO_MAIN_STREAM;
            clientinfo.enVideoType = HWPuSDK.PU_VIDEO_TYPE_E.PU_VIDEO_TYPE_VIDEO;
            clientinfo.enMediaCallbackType = HWPuSDK.PU_MEDIA_CALLBACK_TYPE_E.PU_MEDIA_CALLBACK_TYPE_FRAME;
            clientinfo.bKeepLive = true;

            HWPuSDK.REALDATACALLBACK RealData = new HWPuSDK.REALDATACALLBACK(RealDataCallBack);

            IntPtr pUserData = new IntPtr();
            ulRealPlay = ulIsReaply = HWPuSDK.IVS_PU_RealPlay(ulogin, ref clientinfo, null, pUserData);

相关源码

https://download.csdn.net/download/zhouhui1982/10970605

华为IPC二次开发指南文档

https://download.csdn.net/download/zhouhui1982/10970597

你可能感兴趣的:(C#)