private void btnPrivate_Click(object sender, EventArgs e)
        {
            int iPort = CHCNetSDK.NET_DVR_GetRealPlayerIndex(m_lRealHandle);

            if (iPort > -1)
            {
                if (!PlayCtrl.PlayM4_RenderPrivateData(iPort, 0x20, true))
                {
                    iLastErr = PlayCtrl.PlayM4_GetLastError(iPort);
                    str      = "PlayM4_RenderPrivateData failed, error code= " + iLastErr;
                    DebugInfo(str);
                }
                if (!PlayCtrl.PlayM4_RenderPrivateDataEx(iPort, 0x00000020, 0x00000001 + 0x00000002 + 0x00000004, true))
                {
                    iLastErr = PlayCtrl.PlayM4_GetLastError(iPort);
                    str      = "PlayM4_RenderPrivateDataEx failed, error code= " + iLastErr;
                    DebugInfo(str);
                }
                if (!PlayCtrl.PlayM4_SetOverlayPriInfoFlag(iPort, 0x20, true))
                {
                    iLastErr = PlayCtrl.PlayM4_GetLastError(iPort);
                    str      = "PlayM4_SetOverlayPriInfoFlag failed, error code= " + iLastErr;
                    DebugInfo(str);
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// 实时预览
        /// </summary>
        /// <param name="RealPlayWnd">窗口PictureBox控件</param>
        /// <param name="index">预览的设备通道</param>
        /// <param name="StreamType">码流类型,默认为子码流1,主码流的代码为0</param>
        public void Preview(System.Windows.Forms.PictureBox RealPlayWnd, int index, uint StreamType = 1)
        {
            if (m_lUserID < 0)
            {
                throw new VideoPlayerException("Please login the device firstly!");
            }
            if (m_lRealHandle[index] < 0)
            {
                CHCNetSDK.NET_DVR_PREVIEWINFO lpPreviewInfo = new CHCNetSDK.NET_DVR_PREVIEWINFO();
                lpPreviewInfo.hPlayWnd        = RealPlayWnd.Handle; //预览窗口 live view window
                lpPreviewInfo.lChannel        = iChannelNum[index]; //预览的设备通道 the device channel number
                lpPreviewInfo.dwStreamType    = StreamType;         //码流类型:0-主码流,1-子码流,2-码流3,3-码流4,以此类推
                lpPreviewInfo.dwLinkMode      = 0;                  //连接方式:0- TCP方式,1- UDP方式,2- 多播方式,3- RTP方式,4-RTP/RTSP,5-RSTP/HTTP
                lpPreviewInfo.bBlocked        = true;               //0- 非阻塞取流,1- 阻塞取流
                lpPreviewInfo.dwDisplayBufNum = 1;                  //播放库显示缓冲区最大帧数

                IntPtr pUser = IntPtr.Zero;                         //用户数据 user data

                //打开预览 Start live view
                m_lRealHandle[index] = CHCNetSDK.NET_DVR_RealPlay_V40(m_lUserID, ref lpPreviewInfo, null /*RealData*/, pUser);

                if (m_lRealHandle[index] < 0)
                {
                    iLastErr = CHCNetSDK.NET_DVR_GetLastError();
                    str      = "NET_DVR_RealPlay_V40 failed, error code= " + iLastErr; //预览失败,输出错误号 failed to start live view, and output the error code.
                    throw new VideoPlayerException(str);
                }
                else
                {
                    PlayCtrl.PlayM4_RenderPrivateData(CHCNetSDK.NET_DVR_GetRealPlayerIndex(m_lRealHandle[index]), (int)PlayCtrl.PLAYM4_PRIDATA_RENDER.PLAYM4_RENDER_ANA_INTEL_DATA, false);
                    PlayCtrl.PlayM4_RenderPrivateData(CHCNetSDK.NET_DVR_GetRealPlayerIndex(m_lRealHandle[index]), (int)PlayCtrl.PLAYM4_PRIDATA_RENDER.PLAYM4_RENDER_MD, false);
                    PlayCtrl.PlayM4_RenderPrivateData(CHCNetSDK.NET_DVR_GetRealPlayerIndex(m_lRealHandle[index]), (int)PlayCtrl.PLAYM4_PRIDATA_RENDER.PLAYM4_RENDER_FIRE_DETCET, false);
                    PlayCtrl.PlayM4_RenderPrivateData(CHCNetSDK.NET_DVR_GetRealPlayerIndex(m_lRealHandle[index]), (int)PlayCtrl.PLAYM4_PRIDATA_RENDER.PLAYM4_RENDER_ADD_PIC, false);
                    PlayCtrl.PlayM4_RenderPrivateData(CHCNetSDK.NET_DVR_GetRealPlayerIndex(m_lRealHandle[index]), (int)PlayCtrl.PLAYM4_PRIDATA_RENDER.PLAYM4_RENDER_TEM, false);
                    PlayCtrl.PlayM4_RenderPrivateData(CHCNetSDK.NET_DVR_GetRealPlayerIndex(m_lRealHandle[index]), (int)PlayCtrl.PLAYM4_PRIDATA_RENDER.PLAYM4_RENDER_ADD_POS, false);
                }
            }
        }