public List <TDIO_ChannelInfo> DIOQueryChannelList(uint loginid, string devname = "")
        {
            MyLog4Net.ILogExtension.DebugWithDebugView(MyLog4Net.Container.Instance.Log, "IVXStreamIOSDKProtocol StrmGetChlInfo loginid:" + loginid + ",devname:" + devname);
            uint pdwQueryChnLstHandle;

            IVXDIOSDKProtocol.DIOCreateQueryChannelList(loginid, out pdwQueryChnLstHandle);
            List <TDIO_ChannelInfo> ret = new List <TDIO_ChannelInfo>();
            StringBuilder           sb  = new StringBuilder();

            while (true)
            {
                TDIO_ChannelInfo info = new TDIO_ChannelInfo();
                uint             pdwQueryOverFlag;
                IVXDIOSDKProtocol.DIOGetNextChannelInfo(pdwQueryChnLstHandle, out info, out pdwQueryOverFlag);

                if (pdwQueryOverFlag == 0)
                {
                    break;
                }
                else
                {
                    info.szRest = loginid.ToString();
                    ret.Add(info);
                    sb.AppendLine("szChannelId:" + info.szChannelId + ",szChannelName:" + info.szChannelName + ",szRest:" + info.szRest);
                }
            }
            IVXDIOSDKProtocol.DIOCloseQueryChannelList(pdwQueryChnLstHandle);

            MyLog4Net.ILogExtension.DebugWithDebugView(MyLog4Net.Container.Instance.Log, "IVXStreamIOSDKProtocol StrmGetChlInfo ret:" + 0 + ",list:" + sb.ToString());
            return(ret);
        }
        public uint DIOLoginDevice(uint dwConnType, string pIp,
                                   ushort uPort, string pUser, string pPassword, uint dwTimeout, out uint pdwLoginId)
        {
            MyLog4Net.ILogExtension.DebugWithDebugView(MyLog4Net.Container.Instance.Log, string.Format("IVXStreamIOSDKProtocol StrmLogin dwConnType:{0}"
                                                                                                       + ",pIp:{1}"
                                                                                                       + ",uPort:{2}"
                                                                                                       + ",pUser:{3}"
                                                                                                       + ",pPassword:{4}"
                                                                                                       + ",dwTimeout:{5}"
                                                                                                       , dwConnType
                                                                                                       , pIp
                                                                                                       , uPort
                                                                                                       , pUser
                                                                                                       , pPassword
                                                                                                       , dwTimeout));
            UInt32 retVal = IVXDIOSDKProtocol.DIOLoginDevice(dwConnType, pIp, uPort, pUser, pPassword, 5000, out pdwLoginId);

            if (retVal > 0)
            {
                pdwLoginId = 0;
                DIO_GetError(retVal);
            }

            MyLog4Net.ILogExtension.DebugWithDebugView(MyLog4Net.Container.Instance.Log, "IVXStreamIOSDKProtocol StrmLogin ret:" + retVal + ",pdwLoginId:" + pdwLoginId);
            return(retVal);
        }
        public string GetErrInfo(uint errCode)
        {
            IntPtr str = Marshal.AllocHGlobal(256);

            IVXDIOSDKProtocol.DIOGetErrInfo(errCode, str);
            string ret = Marshal.PtrToStringAnsi(str);

            return(ret);
        }
        public uint DIOCloseStrm(UInt32 dwStrmId)
        {
            MyLog4Net.ILogExtension.DebugWithDebugView(MyLog4Net.Container.Instance.Log, "IVXStreamIOSDKProtocol StrmRealStop dwStrmId:" + dwStrmId);
            UInt32 retVal = IVXDIOSDKProtocol.DIOCloseRealStrm(dwStrmId);

            if (retVal > 0)
            {
                DIO_GetError((uint)retVal);
            }

            MyLog4Net.ILogExtension.DebugWithDebugView(MyLog4Net.Container.Instance.Log, "IVXStreamIOSDKProtocol StrmRealStop ret:" + retVal);
            return(retVal);
        }
        public uint DIOLogoutDevice(uint dwLoginId)
        {
            MyLog4Net.ILogExtension.DebugWithDebugView(MyLog4Net.Container.Instance.Log, "IVXStreamIOSDKProtocol DIOLogoutDevice pdwLoginId:" + dwLoginId);
            UInt32 retVal = IVXDIOSDKProtocol.DIOLogoutDevice(dwLoginId);

            if (retVal > 0)
            {
                DIO_GetError(retVal);
            }

            MyLog4Net.ILogExtension.DebugWithDebugView(MyLog4Net.Container.Instance.Log, "IVXStreamIOSDKProtocol DIOLogoutDevice ret:" + retVal);
            return(retVal);
        }
        public uint DIOInit()
        {
            MyLog4Net.ILogExtension.DebugWithDebugView(MyLog4Net.Container.Instance.Log, "IVXStreamIOSDKProtocol StrmInit ");
            UInt32 retVal = IVXDIOSDKProtocol.DIOInit();

            if (retVal > 0)
            {
                DIO_GetError(retVal);
            }

            MyLog4Net.ILogExtension.DebugWithDebugView(MyLog4Net.Container.Instance.Log, "IVXStreamIOSDKProtocol StrmInit ret:" + 0);
            return(0);
        }
        public uint DIOStartRealPlayStrm(uint loginid, string pChannelId, IntPtr hWnd, out UInt32 pdwRealStrmId)
        {
            m_LPSTRMCALLBACK = OnLPSTRMCALLBACK;
            if (pChannelId.Contains(" "))
            {
                pChannelId = pChannelId.Substring(pChannelId.LastIndexOf(' ') + 1);
            }
            IntPtr userContext = Marshal.AllocHGlobal(4);

            MyLog4Net.ILogExtension.DebugWithDebugView(MyLog4Net.Container.Instance.Log, "IVXStreamIOSDKProtocol StrmRealStartPlay loginid:" + loginid + ",pChannelId:" + pChannelId + ",hWnd:" + hWnd.ToInt64());
            UInt32 retVal = IVXDIOSDKProtocol.DIORealPlay(loginid, pChannelId, 0, (uint)hWnd.ToInt32(), m_LPSTRMCALLBACK, userContext, out pdwRealStrmId);

            if (retVal > 0)
            {
                DIO_GetError((uint)retVal);
            }

            MyLog4Net.ILogExtension.DebugWithDebugView(MyLog4Net.Container.Instance.Log, "IVXStreamIOSDKProtocol StrmRealStartPlay ret:" + retVal + ",pdwRealStrmId:" + pdwRealStrmId);
            return((uint)retVal);
        }
        public List <TDIO_StrmFileInfo> DIOQueryFileList(uint loginid, string pChannelId, DateTime st, DateTime et)
        {
            MyLog4Net.ILogExtension.DebugWithDebugView(MyLog4Net.Container.Instance.Log, "IVXStreamIOSDKProtocol StrmGetVideoInfo loginid:" + loginid + ",pChannelId:" + pChannelId + ",st:" + st.ToString("yyyyMMddHHmmss") + ",et:" + et.ToString("yyyyMMddHHmmss"));
            uint pdwQueryStrmFilesHandle;
            TDIO_QueryFileCondition query = new TDIO_QueryFileCondition()
            {
                tStart = DataModel.Common.ConvertLinuxTime(st),
                tStop  = DataModel.Common.ConvertLinuxTime(et),
                szRest = "",
            };
            UInt32 retVal = IVXDIOSDKProtocol.DIOCreateQueryStrmFilesList(loginid, pChannelId, ref query, out pdwQueryStrmFilesHandle);

            if (retVal > 0)
            {
                DIO_GetError(retVal);
            }
            List <TDIO_StrmFileInfo> ret = new List <TDIO_StrmFileInfo>();
            StringBuilder            sb  = new StringBuilder();

            while (true)
            {
                TDIO_StrmFileInfo info = new TDIO_StrmFileInfo();
                uint pdwQueryOverFlag;
                IVXDIOSDKProtocol.DIOGetNextFileInfo(pdwQueryStrmFilesHandle, out info, out pdwQueryOverFlag);

                if (pdwQueryOverFlag == 0)
                {
                    break;
                }
                else
                {
                    ret.Add(info);
                    sb.AppendLine("qwFileSize:" + info.qwFileSize + ",tStart:" + info.tStart + ",tStop:" + info.tStop + ",szRest:" + info.szRest);
                }
            }
            IVXDIOSDKProtocol.DIOCloseQueryStrmFilesList(pdwQueryStrmFilesHandle);

            MyLog4Net.ILogExtension.DebugWithDebugView(MyLog4Net.Container.Instance.Log, "IVXStreamIOSDKProtocol StrmGetVideoInfo ret:" + 0 + ",list:" + sb.ToString());
            return(ret);
        }
        public System.Drawing.Image DIOSnapPictureEx(UInt32 dwStrmId)
        {
            MyLog4Net.ILogExtension.DebugWithDebugView(MyLog4Net.Container.Instance.Log, "IVXStreamIOSDKProtocol StrmGrabPictureData dwStrmId:" + dwStrmId);

            string tempfile = System.IO.Path.GetTempFileName();
            uint   retVal   = IVXDIOSDKProtocol.DIORealGrabPicture(dwStrmId, tempfile, 0);

            if (retVal > 0)
            {
                DIO_GetError(retVal);
            }


            System.Drawing.Image img = Image.FromFile(tempfile);
            if (img != null)
            {
                System.IO.File.Delete(tempfile);
            }

            MyLog4Net.ILogExtension.DebugWithDebugView(MyLog4Net.Container.Instance.Log, "IVXStreamIOSDKProtocol StrmGrabPictureData ret:" + 0);

            return(img);
        }