public void RealDataCallBack(Int32 lRealHandle, UInt32 dwDataType, ref byte pBuffer, UInt32 dwBufSize, IntPtr pUser)
        {
            //MyDebugInfo AlarmInfo = new MyDebugInfo(DebugInfo);
            switch (dwDataType)
            {
            case CHCNetSDK.NET_DVR_SYSHEAD:         // sys head
                if (!PlayCtrl.PlayM4_GetPort(ref this.Camera.m_lPort))
                {
                    MessageBox.Show("Get Port Fail");
                }

                if (dwBufSize > 0)
                {
                    //set as stream mode, real-time stream under preview
                    if (!PlayCtrl.PlayM4_SetStreamOpenMode(this.Camera.m_lPort, PlayCtrl.STREAME_REALTIME))
                    {
                        //this.BeginInvoke(AlarmInfo, "PlayM4_SetStreamOpenMode fail");
                    }
                    //start player
                    if (!PlayCtrl.PlayM4_OpenStream(this.Camera.m_lPort, ref pBuffer, dwBufSize, 1024 * 1024))
                    {
                        this.Camera.m_lPort = -1;
                        // this.BeginInvoke(AlarmInfo, "PlayM4_OpenStream fail");
                        break;
                    }
                    //set soft decode display callback function to capture
                    this.m_fDisplayFun = new PlayCtrl.DISPLAYCBFUN(RemoteDisplayCBFun);
                    if (!PlayCtrl.PlayM4_SetDisplayCallBack(this.Camera.m_lPort, m_fDisplayFun))
                    {
                        //this.BeginInvoke(AlarmInfo, "PlayM4_SetDisplayCallBack fail");
                    }

                    //start play, set play window
                    // this.BeginInvoke(AlarmInfo, "About to call PlayM4_Play");

                    if (!PlayCtrl.PlayM4_Play(this.Camera.m_lPort, m_ptrRealHandle))
                    {
                        this.Camera.m_lPort = -1;
                        //this.BeginInvoke(AlarmInfo, "PlayM4_Play fail");
                        break;
                    }

                    //set frame buffer number

                    if (!PlayCtrl.PlayM4_SetDisplayBuf(this.Camera.m_lPort, 15))
                    {
                        //this.BeginInvoke(AlarmInfo, "PlayM4_SetDisplayBuf fail");
                    }

                    //set display mode
                    if (!PlayCtrl.PlayM4_SetOverlayMode(this.Camera.m_lPort, 0, 0 /* COLORREF(0)*/))   //play off screen // todo!!!
                    {
                        //this.BeginInvoke(AlarmInfo, " PlayM4_SetOverlayMode fail");
                    }
                }

                break;

            case CHCNetSDK.NET_DVR_STREAMDATA:         // video stream data
                if (dwBufSize > 0 && this.Camera.m_lPort != -1)
                {
                    if (!PlayCtrl.PlayM4_InputData(this.Camera.m_lPort, ref pBuffer, dwBufSize))
                    {
                        // this.BeginInvoke(AlarmInfo, " PlayM4_InputData fail");
                    }
                }
                break;

            case CHCNetSDK.NET_DVR_AUDIOSTREAMDATA:         //  Audio Stream Data
                if (dwBufSize > 0 && this.Camera.m_lPort != -1)
                {
                    if (!PlayCtrl.PlayM4_InputVideoData(this.Camera.m_lPort, ref pBuffer, dwBufSize))
                    {
                        // this.BeginInvoke(AlarmInfo, "PlayM4_InputVideoData Fail");
                    }
                }

                break;

            default:
                break;
            }
        }
Пример #2
0
        public void RealDataCallBack(Int32 lRealHandle, UInt32 dwDataType, ref byte pBuffer, UInt32 dwBufSize, IntPtr pUser)
        {
            switch (dwDataType)
            {
            case CHCNetSDK.NET_DVR_SYSHEAD:         // sys head
                if (!PlayCtrl.PlayM4_GetPort(ref m_lPort))
                {
                    MessageBox.Show("获取播放端口失败!");
                }

                if (dwBufSize > 0)
                {
                    //set as stream mode, real-time stream under preview
                    if (!PlayCtrl.PlayM4_SetStreamOpenMode(m_lPort, PlayCtrl.STREAME_REALTIME))
                    {
                        uint nError = CHCNetSDK.NET_DVR_GetLastError();
                        VideoRetErrorDis(nError);
                    }
                    //start player
                    if (!PlayCtrl.PlayM4_OpenStream(m_lPort, ref pBuffer, dwBufSize, 1024 * 1024))
                    {
                        m_lPort = -1;
                        break;
                    }
                    //set soft decode display callback function to capture
                    m_fDisplayFun = new PlayCtrl.DISPLAYCBFUN(RemoteDisplayCBFun);
                    if (!PlayCtrl.PlayM4_SetDisplayCallBack(m_lPort, m_fDisplayFun))
                    {
                        uint nError = CHCNetSDK.NET_DVR_GetLastError();
                        VideoRetErrorDis(nError);
                    }
                    //start play, set play window
                    if (!PlayCtrl.PlayM4_Play(m_lPort, m_ptrRealHandle))
                    {
                        m_lPort = -1;
                        break;
                    }
                    //set frame buffer number
                    if (!PlayCtrl.PlayM4_SetDisplayBuf(m_lPort, 15))
                    {
                        uint nError = CHCNetSDK.NET_DVR_GetLastError();
                        VideoRetErrorDis(nError);
                    }
                    //set display mode
                    if (!PlayCtrl.PlayM4_SetOverlayMode(m_lPort, 0, 0 /* COLORREF(0)*/))   //play off screen // todo!!!
                    {
                        uint nError = CHCNetSDK.NET_DVR_GetLastError();
                        VideoRetErrorDis(nError);
                    }
                }

                break;

            case CHCNetSDK.NET_DVR_STREAMDATA:         // video stream data
                if (dwBufSize > 0 && m_lPort != -1)
                {
                    if (!PlayCtrl.PlayM4_InputData(m_lPort, ref pBuffer, dwBufSize))
                    {
                        uint nError = CHCNetSDK.NET_DVR_GetLastError();
                        VideoRetErrorDis(nError);
                    }
                }
                break;

            case CHCNetSDK.NET_DVR_AUDIOSTREAMDATA:         //  Audio Stream Data
                if (dwBufSize > 0 && m_lPort != -1)
                {
                    if (!PlayCtrl.PlayM4_InputVideoData(m_lPort, ref pBuffer, dwBufSize))
                    {
                        uint nError = CHCNetSDK.NET_DVR_GetLastError();
                        VideoRetErrorDis(nError);
                    }
                }
                break;

            default:
                break;
            }
        }
Пример #3
0
        public void RealDataCallBack(Int32 lRealHandle, UInt32 dwDataType, IntPtr pBuffer, UInt32 dwBufSize, IntPtr pUser)
        {
            MyDebugInfo AlarmInfo = new MyDebugInfo(DebugInfo);
            IntPtr      pObject   = new IntPtr();
            GCHandle    hObject   = new GCHandle();

            hObject = GCHandle.Alloc(pBuffer, GCHandleType.Pinned);

            pObject = hObject.AddrOfPinnedObject();
            switch (dwDataType)
            {
            case CHCNetSDK.NET_DVR_SYSHEAD:         // sys head
                if (!PlayCtrl.PlayM4_GetPort(ref m_lPort))
                {
                    MessageBox.Show("Get Port Fail");
                }

                if (dwBufSize > 0)
                {
                    //set as stream mode, real-time stream under preview
                    if (!PlayCtrl.PlayM4_SetStreamOpenMode(m_lPort, PlayCtrl.STREAME_REALTIME))
                    {
                        //this.Dispatcher.BeginInvoke(AlarmInfo, "PlayM4_SetStreamOpenMode fail");
                    }
                    //start player
                    if (!PlayCtrl.PlayM4_OpenStream(m_lPort, pObject, dwBufSize, 320 * 280))
                    {
                        m_lPort = -1;
                        //this.Dispatcher.BeginInvoke(AlarmInfo, "PlayM4_OpenStream fail");
                        break;
                    }

                    m_fDisplayFun = new PlayCtrl.DISPLAYCBFUN(RemoteDisplayCBFun);
                    if (!PlayCtrl.PlayM4_SetDisplayCallBack(m_lPort, m_fDisplayFun))
                    {
                        //this.Dispatcher.BeginInvoke(AlarmInfo, "PlayM4_SetDisplayCallBack fail");
                    }


                    if (!PlayCtrl.PlayM4_Play(m_lPort, m_ptrRealHandle))
                    {
                        m_lPort = -1;
                        //this.Dispatcher.BeginInvoke(AlarmInfo, "PlayM4_Play fail");
                        break;
                    }
                }

                break;

            case CHCNetSDK.NET_DVR_STREAMDATA:         // video stream data
                if (dwBufSize > 0 && m_lPort != -1)
                {
                    try
                    {
                        //送入码流数据进行解码 Input the stream data to decode
                        PlayCtrl.PlayM4_InputData(m_lPort, pBuffer, dwBufSize);
                    }
                    catch (Exception e)
                    {
                        throw;
                    }
                }
                break;

            case CHCNetSDK.NET_DVR_AUDIOSTREAMDATA:         //  Audio Stream Data
                if (dwBufSize > 0 && m_lPort != -1)
                {
                    if (!PlayCtrl.PlayM4_InputVideoData(m_lPort, pObject, dwBufSize))
                    {
                        //this.Dispatcher.BeginInvoke(AlarmInfo, "PlayM4_InputVideoData Fail");
                    }
                }

                break;

            default:
                break;
            }
            if (hObject.IsAllocated)
            {
                hObject.Free();
            }
        }