private void RealDataSnapCallBack(Int32 lRealHandle, uint dwDataType, ref byte pBuffer,
                                          uint dwBufSize,
                                          IntPtr pUser)
        {
            if (ConnectState != ConnectState.Connected || DispatchState != DispatchState.Established)
            {
                return;
            }

            bool isSuccess;

            switch (dwDataType)
            {
            case OfficalAPI.NET_DVR_SYSHEAD:                     // 系统头
                isSuccess = OfficalAPI.PlayM4_GetPort(ref _playPort);
                if (isSuccess)
                {
                    this.InfoSuccessWithDescription("获取通道", "通道编号" + _playPort);
                }
                else
                {
                    WarnPlaySdkFailWithReason("获取通道");
                    //Shutdown();
                    break;
                }

                if (dwBufSize > 0)
                {
                    isSuccess = OfficalAPI.PlayM4_SetStreamOpenMode(_playPort,
                                                                    OfficalAPI.STREAME_REALTIME);
                    if (isSuccess)
                    {
                        this.InfoSuccess("设置码流开启模式");
                    }
                    else
                    {
                        WarnPlaySdkFailWithReason("设置码流开启模式");
                        //Stop();
                        break;
                    }


                    isSuccess = OfficalAPI.PlayM4_OpenStream(_playPort,
                                                             ref pBuffer,
                                                             dwBufSize,
                                                             (uint)(Width * Height * 6));
                    if (isSuccess)
                    {
                        this.InfoSuccess("开启码流");
                    }
                    else
                    {
                        WarnPlaySdkFailWithReason("开启码流失败");

                        _playPort = InvalidPlayPort;
                        //Stop();
                        break;
                    }

                    //if (!HikvisionSDK.PlayM4_SetDisplayBuf(_playPort, 5))
                    //{
                    //        WarnPlaySdkFailWithReason("设置实时播放缓冲区失败");
                    //}


                    //if (!HikvisionSDK.PlayM4_SetOverlayMode(_playPort, 0, 0 /* COLORREF(0)*/))
                    //{
                    //        WarnPlaySdkFailWithReason("设置采集模式失败");
                    //}


                    isSuccess = OfficalAPI.PlayM4_Play(_playPort, IntPtr.Zero);
                    if (isSuccess)
                    {
                        this.InfoSuccess("开启解码");
                    }
                    else
                    {
                        WarnPlaySdkFailWithReason("开启解码");
                        _playPort = -1;

                        //Stop();
                    }
                }
                break;

            case OfficalAPI.NET_DVR_STREAMDATA:                     // video stream data
                if (dwBufSize == 0 || _playPort == -1)
                {
                    return;
                }

                isSuccess = OfficalAPI.PlayM4_InputData(_playPort, ref pBuffer, dwBufSize);
                if (!isSuccess)
                {
                    uint errorCode = OfficalAPI.PlayM4_GetLastError(_playPort);
                    this.ErrorFailWithReason("输入码流", "错误代码" + errorCode);

                    switch (errorCode)
                    {
                    case OfficalAPI.PLAYM4_BUF_OVER:
                        this.Warn("播放缓冲区满");
                        for (;;)
                        {
                            Thread.Sleep(5);
                            errorCode =
                                OfficalAPI.PlayM4_GetLastError(
                                    _playPort);

                            if (errorCode == OfficalAPI.PLAYM4_NOERROR)
                            {
                                this.Warn("播放缓冲区正常");
                                break;
                            }
                        }
                        break;

                    default:
                        //Stop();
                        break;
                    }
                }
                break;
            }
        }