コード例 #1
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)
            { }
        }