コード例 #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (!play && PlayCtrl.PlayM4_Play(0, pictureBox1.Handle))
     {
         button1.Text = "暂停";
         play         = true;
         Console.WriteLine("播放成功");
     }
     else
     {
         if (!m_bPause)
         {
             PlayCtrl.PlayM4_Pause(0, 1);
             button1.Text = "继续播放";
             m_bPause     = true;
             Console.WriteLine("暂停成功");
         }
         else
         {
             PlayCtrl.PlayM4_Pause(0, 0);
             button1.Text = "暂停";
             m_bPause     = false;
             Console.WriteLine("恢复播放成功");
         }
     }
 }
コード例 #2
0
ファイル: frmBackVideo.cs プロジェクト: wollfman/ToolsManage
 private void StartPlayVideo(string filename)
 {
     if (filename != "")
     {
         StopVideo();
         if (PlayCtrl.PlayM4_GetPort(ref m_lPort))
         {
             m_ptrRealHandle = picPlayBack.Handle;
             m_FileRefDone   = new PlayCtrl.PFILEREFDONE(PlayCallBack);
             if (PlayCtrl.PlayM4_SetFileRefCallBack(m_lPort, m_FileRefDone, 0))
             {
             }
             if (PlayCtrl.PlayM4_OpenFile(m_lPort, filename))
             {
                 if (PlayCtrl.PlayM4_Play(m_lPort, m_ptrRealHandle))
                 {
                     m_CurPlayState = PlayState.PlayNormal;
                     SetCtrlEnable();
                 }
                 else
                 {
                     uint error = PlayCtrl.PlayM4_GetLastError(m_lPort);
                 }
             }
         }
         else
         {
             uint error = PlayCtrl.PlayM4_GetLastError(m_lPort);
         }
     }
 }
コード例 #3
0
ファイル: frmBackVideo.cs プロジェクト: wollfman/ToolsManage
 private void sbtnNormal_Click(object sender, EventArgs e)
 {
     if (PlayCtrl.PlayM4_Play(m_lPort, m_ptrRealHandle))
     {
         m_CurPlayState = PlayState.PlayNormal;
         SetCtrlEnable();
     }
 }
コード例 #4
0
ファイル: frmBackVideo.cs プロジェクト: wollfman/ToolsManage
 private void sbtnSlow_Click(object sender, EventArgs e)
 {
     if (PlayCtrl.PlayM4_Play(m_lPort, m_ptrRealHandle))
     {//先恢复正常播放
         if (PlayCtrl.PlayM4_Slow(m_lPort))
         {
             m_CurPlayState = PlayState.PlaySlow;
             SetCtrlEnable();
         }
     }
 }
コード例 #5
0
ファイル: frmVideoTime.cs プロジェクト: wollfman/ToolsManage
        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;
            }
        }
コード例 #6
0
        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;
            }
        }
コード例 #7
0
        private void realDataCallBack(int realHandle, uint dataType, IntPtr buffer, uint bufferSize, IntPtr pUser)
        {
            if (bufferSize <= 0)
            {
                return;
            }

            if (dataType == CHCNetSDK.NET_DVR_SYSHEAD)
            {
                if (livePlayer_.RealPlayPort >= 0)
                {
                    return;                     // The same code stream does not need to call the open stream interface multiple times.
                }

                // Get the port to play
                if (!PlayCtrl.PlayM4_GetPort(ref livePlayer_.RealPlayPort))
                {
                    invokeOnPreviewErrorEvent(PlayCtrl.PlayM4_GetLastError(livePlayer_.RealPlayPort), "PlayM4_GetPort failed");
                    return;
                }

                // Set the stream mode: real-time stream mode
                if (!PlayCtrl.PlayM4_SetStreamOpenMode(livePlayer_.RealPlayPort, PlayCtrl.STREAME_REALTIME))
                {
                    invokeOnPreviewErrorEvent(PlayCtrl.PlayM4_GetLastError(livePlayer_.RealPlayPort), "PlayM4_SetStreamOpenMode 'STREAME_REALTIME' failed");
                    return;
                }

                // Open stream
                if (!PlayCtrl.PlayM4_OpenStream(livePlayer_.RealPlayPort, buffer, bufferSize, livePlayer_.PreviewSettings.PlayerBufSize))
                {
                    invokeOnPreviewErrorEvent(PlayCtrl.PlayM4_GetLastError(livePlayer_.RealPlayPort), "PlayM4_OpenStream failed");
                    return;
                }

                // Set the display buffer number
                if (!PlayCtrl.PlayM4_SetDisplayBuf(livePlayer_.RealPlayPort, livePlayer_.PreviewSettings.DisplayBufNum))
                {
                    invokeOnPreviewErrorEvent(PlayCtrl.PlayM4_GetLastError(livePlayer_.RealPlayPort), "PlayM4_SetDisplayBuf failed");
                    return;
                }

                // Set the display mode
                if (!PlayCtrl.PlayM4_SetOverlayMode(livePlayer_.RealPlayPort, 0, 0 /* COLORREF(0)*/))
                {
                    invokeOnPreviewErrorEvent(PlayCtrl.PlayM4_GetLastError(livePlayer_.RealPlayPort), "PlayM4_SetOverlayMode failed");
                    return;
                }

                if (livePlayer_.PreviewSettings.PreviewQuality != PreviewQualityType.NotSet)
                {
                    if (!PlayCtrl.PlayM4_SetPicQuality(livePlayer_.RealPlayPort, (int)livePlayer_.PreviewSettings.PreviewQuality))
                    {
                        invokeOnPreviewErrorEvent(PlayCtrl.PlayM4_GetLastError(livePlayer_.RealPlayPort), "PlayM4_SetPicQuality failed");
                        return;
                    }
                }

                // Set the decoding callback function to obtain the decoded audio and video raw data.
                //m_fDisplayFun = new PlayCtrl.DECCBFUN(DecCallbackFUN);
                //if (!PlayCtrl.PlayM4_SetDecCallBackEx(livePlayer_.RealPlayPort, m_fDisplayFun, IntPtr.Zero, 0)) {
                //	invokeOnPreviewErrorEvent(PlayCtrl.PlayM4_GetLastError(livePlayer_.RealPlayPort), "PlayM4_SetDecCallBackEx failed");
                //}

                // Start to play
                if (!PlayCtrl.PlayM4_Play(livePlayer_.RealPlayPort, livePlayer_.PlayWndHandlePtr))
                {
                    invokeOnPreviewErrorEvent(PlayCtrl.PlayM4_GetLastError(livePlayer_.RealPlayPort), "PlayM4_Play failed");
                    return;
                }
            }
            else if (dataType == CHCNetSDK.NET_DVR_AUDIOSTREAMDATA)
            {
                debugInfo("NET_DVR_AUDIOSTREAMDATA");
            }
            else if (dataType == 112 /*NET_DVR_PRIVATE_DATA*/)
            {
                // NET_DVR_PRIVATE_DATA - Private data, including intelligent information
            }
            else
            {
                // dataType == CHCNetSDK.NET_DVR_STREAMDATA or else
                if (livePlayer_.RealPlayPort != -1)
                {
                    for (int i = 0; i < 999; i++)
                    {
                        // Input the stream data to decode
                        if (!PlayCtrl.PlayM4_InputData(livePlayer_.RealPlayPort, buffer, bufferSize))
                        {
                            debugInfo("RealDataCallBack: PlayM4_InputData failed, error=" + PlayCtrl.PlayM4_GetLastError(livePlayer_.RealPlayPort));
                            Thread.Sleep(50);
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }
        }
コード例 #8
0
        public void RealDataCallBack(int lRealHandle, uint dwDataType, IntPtr pBuffer, uint dwBufSize, IntPtr pUser)
        {
            var alarmInfo = new MyDebugInfo(DebugInfo);

            switch (dwDataType)
            {
            case ChcNetSdk.NetDvrSyshead:         // sys head
                if (dwBufSize > 0)
                {
                    //获取播放句柄 Get the port to play
                    if (!PlayCtrl.PlayM4_GetPort(ref _mLPort))
                    {
                        _iLastErr = PlayCtrl.PlayM4_GetLastError(_mLPort);
                        _str      = "PlayM4_GetPort failed, error code= " + _iLastErr;
                        BeginInvoke(alarmInfo, _str);
                        break;
                    }

                    //设置流播放模式 Set the stream mode: real-time stream mode
                    if (!PlayCtrl.PlayM4_SetStreamOpenMode(_mLPort, PlayCtrl.StreameRealtime))
                    {
                        _iLastErr = PlayCtrl.PlayM4_GetLastError(_mLPort);
                        _str      = "Set STREAME_REALTIME mode failed, error code= " + _iLastErr;
                        BeginInvoke(alarmInfo, _str);
                    }

                    //打开码流,送入头数据 Open stream
                    if (!PlayCtrl.PlayM4_OpenStream(_mLPort, pBuffer, dwBufSize, 2 * 1024 * 1024))
                    {
                        _iLastErr = PlayCtrl.PlayM4_GetLastError(_mLPort);
                        _str      = "PlayM4_OpenStream failed, error code= " + _iLastErr;
                        BeginInvoke(alarmInfo, _str);
                        break;
                    }


                    //设置显示缓冲区个数 Set the display buffer number
                    if (!PlayCtrl.PlayM4_SetDisplayBuf(_mLPort, 15))
                    {
                        _iLastErr = PlayCtrl.PlayM4_GetLastError(_mLPort);
                        _str      = "PlayM4_SetDisplayBuf failed, error code= " + _iLastErr;
                        BeginInvoke(alarmInfo, _str);
                    }

                    //设置显示模式 Set the display mode
                    if (!PlayCtrl.PlayM4_SetOverlayMode(_mLPort, 0, 0 /* COLORREF(0)*/))    //play off screen
                    {
                        _iLastErr = PlayCtrl.PlayM4_GetLastError(_mLPort);
                        _str      = "PlayM4_SetOverlayMode failed, error code= " + _iLastErr;
                        BeginInvoke(alarmInfo, _str);
                    }

                    //设置解码回调函数,获取解码后音视频原始数据 Set callback function of decoded data
                    _mFDisplayFun = DecCallbackFun;
                    if (!PlayCtrl.PlayM4_SetDecCallBackEx(_mLPort, _mFDisplayFun, IntPtr.Zero, 0))
                    {
                        BeginInvoke(alarmInfo, "PlayM4_SetDisplayCallBack fail");
                    }

                    //开始解码 Start to play
                    if (!PlayCtrl.PlayM4_Play(_mLPort, _mPtrRealHandle))
                    {
                        _iLastErr = PlayCtrl.PlayM4_GetLastError(_mLPort);
                        _str      = "PlayM4_Play failed, error code= " + _iLastErr;
                        BeginInvoke(alarmInfo, _str);
                    }
                }
                break;

            case ChcNetSdk.NetDvrStreamdata:         // video stream data
                if (dwBufSize > 0 && _mLPort != -1)
                {
                    for (var i = 0; i < 999; i++)
                    {
                        //送入码流数据进行解码 Input the stream data to decode
                        if (!PlayCtrl.PlayM4_InputData(_mLPort, pBuffer, dwBufSize))
                        {
                            _iLastErr = PlayCtrl.PlayM4_GetLastError(_mLPort);
                            _str      = "PlayM4_InputData failed, error code= " + _iLastErr;
                            Thread.Sleep(2);
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                break;

            default:
                if (dwBufSize > 0 && _mLPort != -1)
                {
                    //送入其他数据 Input the other data
                    for (var i = 0; i < 999; i++)
                    {
                        if (!PlayCtrl.PlayM4_InputData(_mLPort, pBuffer, dwBufSize))
                        {
                            _iLastErr = PlayCtrl.PlayM4_GetLastError(_mLPort);
                            _str      = "PlayM4_InputData failed, error code= " + _iLastErr;
                            Thread.Sleep(2);
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                break;
            }
        }
コード例 #9
0
        public void RealDataCallBack(Int32 lRealHandle, UInt32 dwDataType, IntPtr pBuffer, UInt32 dwBufSize, IntPtr pUser)
        {
            MyDebugInfo AlarmInfo = new MyDebugInfo(DebugInfo);

            switch (dwDataType)
            {
            case CHCNetSDK.NET_DVR_SYSHEAD:         // sys head
                if (dwBufSize > 0)
                {
                    //获取播放句柄 Get the port to play
                    if (!PlayCtrl.PlayM4_GetPort(ref m_lPort))
                    {
                        iLastErr = PlayCtrl.PlayM4_GetLastError(m_lPort);
                        str      = "PlayM4_GetPort failed, error code= " + iLastErr;
                        this.BeginInvoke(AlarmInfo, str);
                        break;
                    }

                    //设置流播放模式 Set the stream mode: real-time stream mode
                    if (!PlayCtrl.PlayM4_SetStreamOpenMode(m_lPort, PlayCtrl.STREAME_REALTIME))
                    {
                        iLastErr = PlayCtrl.PlayM4_GetLastError(m_lPort);
                        str      = "Set STREAME_REALTIME mode failed, error code= " + iLastErr;
                        this.BeginInvoke(AlarmInfo, str);
                    }

                    //打开码流,送入头数据 Open stream
                    if (!PlayCtrl.PlayM4_OpenStream(m_lPort, pBuffer, dwBufSize, 2 * 1024 * 1024))
                    {
                        iLastErr = PlayCtrl.PlayM4_GetLastError(m_lPort);
                        str      = "PlayM4_OpenStream failed, error code= " + iLastErr;
                        this.BeginInvoke(AlarmInfo, str);
                        break;
                    }

                    //设置显示缓冲区个数 Set the display buffer number
                    if (!PlayCtrl.PlayM4_SetDisplayBuf(m_lPort, 15))
                    {
                        iLastErr = PlayCtrl.PlayM4_GetLastError(m_lPort);
                        str      = "PlayM4_SetDisplayBuf failed, error code= " + iLastErr;
                        this.BeginInvoke(AlarmInfo, str);
                    }

                    //设置显示模式 Set the display mode
                    if (!PlayCtrl.PlayM4_SetOverlayMode(m_lPort, 0, 0 /* COLORREF(0)*/))    //play off screen
                    {
                        iLastErr = PlayCtrl.PlayM4_GetLastError(m_lPort);
                        str      = "PlayM4_SetOverlayMode failed, error code= " + iLastErr;
                        this.BeginInvoke(AlarmInfo, str);
                    }

                    //设置解码回调函数,获取解码后音视频原始数据 Set callback function of decoded data
                    m_fDisplayFun = new PlayCtrl.DECCBFUN(DecCallbackFUN);
                    if (!PlayCtrl.PlayM4_SetDecCallBackEx(m_lPort, m_fDisplayFun, IntPtr.Zero, 0))
                    {
                        this.BeginInvoke(AlarmInfo, "PlayM4_SetDisplayCallBack fail");
                    }

                    //开始解码 Start to play
                    if (!PlayCtrl.PlayM4_Play(m_lPort, m_ptrRealHandle))
                    {
                        iLastErr = PlayCtrl.PlayM4_GetLastError(m_lPort);
                        str      = "PlayM4_Play failed, error code= " + iLastErr;
                        this.BeginInvoke(AlarmInfo, str);
                        break;
                    }
                }
                break;

            case CHCNetSDK.NET_DVR_STREAMDATA:         // video stream data
                if (dwBufSize > 0 && m_lPort != -1)
                {
                    for (int i = 0; i < 999; i++)
                    {
                        //送入码流数据进行解码 Input the stream data to decode
                        if (!PlayCtrl.PlayM4_InputData(m_lPort, pBuffer, dwBufSize))
                        {
                            iLastErr = PlayCtrl.PlayM4_GetLastError(m_lPort);
                            str      = "PlayM4_InputData failed, error code= " + iLastErr;
                            Thread.Sleep(2);
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                break;

            default:
                if (dwBufSize > 0 && m_lPort != -1)
                {
                    //送入其他数据 Input the other data
                    for (int i = 0; i < 999; i++)
                    {
                        if (!PlayCtrl.PlayM4_InputData(m_lPort, pBuffer, dwBufSize))
                        {
                            iLastErr = PlayCtrl.PlayM4_GetLastError(m_lPort);
                            str      = "PlayM4_InputData failed, error code= " + iLastErr;
                            Thread.Sleep(2);
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                break;
            }
        }
コード例 #10
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();
            }
        }
コード例 #11
0
ファイル: UCHikVideo.cs プロジェクト: wollfman/ToolsManage
        private void RealDataCallBack(Int32 lRealHandler, UInt32 dwDataType, ref byte pBuffer, UInt32 dwBufSize, IntPtr pUser)
        {
            try
            {
                int lRealHandle = 0;
                if (dicRealHandlerChannel.ContainsKey(lRealHandler))
                {
                    lRealHandle = dicRealHandlerChannel[lRealHandler] % StartDChan;
                }
                else
                {
                    return;
                }
                //int lRealHandle = lRealHandler % CameraCount;
                uint dwErr = 0;
                switch (dwDataType)
                {
                case CHCNetSDK.NET_DVR_SYSHEAD:
                    if (m_Channel[lRealHandle] != -1)
                    {
                        return;
                    }
                    if (m_Channel[lRealHandle] == -1)
                    {
                        if (!PlayCtrl.PlayM4_GetPort(ref m_Channel[lRealHandle]))
                        {
                            //dwErr = PlayCtrl.PlayM4_GetLastError(m_Channel);
                        }
                        //m_Channel[lRealHandle] = lRealHandle;
                        uint version = PlayCtrl.PlayM4_GetSdkVersion();
                    }
                    if (dwBufSize > 0)
                    {
                        if (!PlayCtrl.PlayM4_SetStreamOpenMode(m_Channel[lRealHandle], m_StreamPlayMode))      //设置实时流播放模式
                        {
                            dwErr = PlayCtrl.PlayM4_GetLastError(m_Channel[lRealHandle]);
                            break;
                        }

                        if (!PlayCtrl.PlayM4_OpenStream(m_Channel[lRealHandle], ref pBuffer, dwBufSize, 15 * 1024 * 1024))     //打开流接口
                        {
                            dwErr = PlayCtrl.PlayM4_GetLastError(m_Channel[lRealHandle]);
                            break;
                        }

                        if (!PlayCtrl.PlayM4_SetDisplayBuf(m_Channel[lRealHandle], 6))
                        {
                            dwErr = PlayCtrl.PlayM4_GetLastError(m_Channel[lRealHandle]);
                            break;
                        }

                        //if (!PlayCtrl.PlayM4_SetDecodeEngineEx(m_Channel[lRealHandle], PlayCtrl.HARD_DECODE_ENGINE))
                        //{
                        //    dwErr = PlayCtrl.PlayM4_GetLastError(m_Channel[lRealHandle]);
                        //    break;
                        //}
                        if (CheckEagleEyeStream(dicRealHandlerChannel[lRealHandler]))    //小鹰眼码流的特殊处理
                        {
                            if (!PlayCtrl.PlayM4_SetDecodeEngineEx(m_Channel[lRealHandle], PlayCtrl.HARD_DECODE_ENGINE))
                            {
                                break;
                            }
                            //UCVideo video= listVideo.Find(p => Convert.ToInt32(p.Tag) == lRealHandle);
                            PlayCtrl.PLAYM4SRMODELMODE struParam = new PlayCtrl.PLAYM4SRMODELMODE();
                            struParam.emTextureMode  = (uint)PlayCtrl.PLAYM4SRTEXTUREMODE.PLAYM4_TEXTURE_DOUBLE;
                            struParam.ulDisplayType  = PlayCtrl.PLAYM4_MODEL_SOLID;
                            struParam.nTransformMode = 0;
                            struParam.emModelType    = (uint)PlayCtrl.PLAYM4SRMODELTYPE.PLAYM4_MODELTYPE_EAGLE_EYE;
                            struParam.bModelMode     = true; // true是碗装,false是块状
                            int    dwSize       = Marshal.SizeOf(struParam);
                            IntPtr ptrDeviceCfg = Marshal.AllocHGlobal(dwSize);
                            Marshal.StructureToPtr(struParam, ptrDeviceCfg, false);
                            if (!PlayCtrl.PlayM4_SR_SetConfig(m_Channel[lRealHandle], PlayCtrl.CFG_DISPLAY_MODEL_MODE, ptrDeviceCfg))
                            {
                                Marshal.FreeHGlobal(ptrDeviceCfg);
                                break;
                            }
                            Marshal.FreeHGlobal(ptrDeviceCfg);
                        }

                        if (!PlayCtrl.PlayM4_Play(m_Channel[lRealHandle], m_ptrRealHandle[lRealHandle]))     //播放开始
                        {
                            break;
                        }
                    }
                    break;

                case CHCNetSDK.NET_DVR_STREAMDATA:
                    if (dwBufSize > 0 && m_Channel[lRealHandle] != -1)
                    {
                        for (int i = 0; i < 4000; i++)
                        {
                            if (!PlayCtrl.PlayM4_InputData(m_Channel[lRealHandle], ref pBuffer, dwBufSize))
                            {
                                dwErr = PlayCtrl.PlayM4_GetLastError(m_Channel[lRealHandle]);
                                if (dwErr == PlayCtrl.PLAYM4_BUF_OVER)
                                {
                                    continue;
                                }
                                else
                                {
                                    return;
                                }
                            }
                            else
                            {
                                return;
                            }
                        }
                    }
                    break;
                }
            }
            catch (Exception ex)
            { }
        }