public void StopDownloadAsync() { if (_fileHandle > -1) { OfficalAPI.NET_DVR_StopGetFile(_fileHandle); } }
public void StartDownloadAsync(DateTime beginTime, DateTime endTime, string fileName) { NetDvrTime begin = new NetDvrTime { Year = (uint)beginTime.Year, Month = (uint)beginTime.Month, Day = (uint)beginTime.Day, Hour = (uint)beginTime.Hour, Minute = (uint)beginTime.Minute }; NetDvrTime end = new NetDvrTime { Year = (uint)endTime.Year, Month = (uint)endTime.Month, Day = (uint)endTime.Day, Hour = (uint)endTime.Hour, Minute = (uint)endTime.Minute }; NetDvrPlayCondition condition = new NetDvrPlayCondition(); condition.Channel = 33; condition.StartTime = begin; condition.StopTime = end; _fileHandle = OfficalAPI.NET_DVR_GetFileByTime_V40(_userId, fileName, ref condition); PlayBackControl(NetDvrPlayBackControlCode.NET_DVR_PLAYSTART); }
public int GetDownloadPercent() { if (_fileHandle == -1) { return(-1); } return(OfficalAPI.NET_DVR_GetDownloadPos(_fileHandle)); }
public void Logout() { Debug.Assert(_userId >= 0); if (!OfficalAPI.NET_DVR_Logout_V30(_userId)) { WarnDvrSdkFailWithReason("NET_DVR_Logout_V30"); } }
public override void Write(int data) { var handle = ((FyyingIOBoardDevice)Parent).Handle; Debug.Assert(handle != IntPtr.Zero); OfficalAPI.FY6400_DO_Bit(handle, data, Index); }
public override int Read() { var handle = ((FyyingIOBoardDevice)Parent).Handle; Debug.Assert(handle != IntPtr.Zero); Value = OfficalAPI.FY6400_DI_Bit(handle, Index); return(Value); }
protected override sealed bool StopConnectCore() { var errorCode = OfficalAPI.FY6400_CloseDevice(Handle); if (errorCode != ErrorCode.失败.ToInt32()) { return(false); } return(base.StopConnectCore()); }
protected override bool StopDispatchCore() { _captureLooper.Stop(); if (_realHandle < 0) { return(true); } //停止视频预览 if (!OfficalAPI.NET_DVR_StopRealPlay(_realHandle)) { WarnDvrSdkFailWithReason("NET_DVR_StopRealPlay"); return(false); } this.InfoSuccess("NET_DVR_StopRealPlay"); _realHandle = InvalidRealHandle; if (_playPort == InvalidPlayPort) { return(true); } // 停止解码 if (!OfficalAPI.PlayM4_Stop(_playPort)) { WarnPlaySdkFailWithReason("PlayM4_Stop"); return(false); } this.InfoSuccess("PlayM4_Stop"); //关闭流, 回收源数据缓冲 if (!OfficalAPI.PlayM4_CloseStream(_playPort)) { WarnPlaySdkFailWithReason("PlayM4_CloseStream"); return(false); } this.InfoSuccess("PlayM4_CloseStream"); //释放播放库端口号 if (!OfficalAPI.PlayM4_FreePort(_playPort)) { WarnPlaySdkFailWithReason("PlayM4_FreePort"); return(false); } this.InfoSuccess("PlayM4_FreePort"); _playPort = InvalidPlayPort; return(true); }
protected override sealed bool StopConnectCore() { if (_userId < 0) { return(true); } if (!OfficalAPI.NET_DVR_Logout_V30(_userId)) { WarnDvrSdkFailWithReason("NET_DVR_Logout_V30"); } return(true); }
protected override bool StartConnectCore() { if (!base.StartConnectCore()) { return(false); } Handle = OfficalAPI.FY6400_OpenDevice(BoardId); if (Handle.ToInt32() == -1) { this.Warn($"未检测到{BoardId}号板卡."); return(false); } return(true); }
protected override bool StartDispatchCore() { //CreateBitmapPool(); if (_capturePtr == IntPtr.Zero) { int bitmapBytesCount = Width * Height * PixelFormat.GetBytes(); _prepareCaptureBytesCount = bitmapBytesCount + MicrosoftBitmapExtensions.FileHeaderTotalBytes + MicrosoftBitmapExtensions.InfoHeaderTotalBytes; _capturePtr = Marshal.AllocHGlobal(_prepareCaptureBytesCount); unsafe { var tempPtr = ((byte *)_capturePtr.ToPointer()) + +MicrosoftBitmapExtensions.FileHeaderTotalBytes + MicrosoftBitmapExtensions.InfoHeaderTotalBytes; _bitmapPtr = new IntPtr(tempPtr); } //_bitmapPtr = _capturePtr + +BitmapExtensions.FileHeaderTotalBytes + // BitmapExtensions.InfoHeaderTotalBytes; } //X64 //RealHandle = HikvisionSDK.NET_DVR_RealPlay_V40(UserId, ref _clientInfo, _realDataSnapCallBack, // UserPtr, 0); //X86 _realHandle = OfficalAPI.NET_DVR_RealPlay_V40(_userId, ref _previewInfo, _realDataCallBack, _userPtr); if (_realHandle == InvalidRealHandle) { WarnDvrSdkFailWithReason("NET_DVR_RealPlay_V40"); return(false); } this.InfoSuccess("NET_DVR_RealPlay_V40"); OfficalAPI.NET_DVR_SetPlayerBufNumber(_realHandle, 3); return(_captureLooper.Start()); }
public void Login() { for (int i = 0; i < 5; i++) { _userId = OfficalAPI.NET_DVR_Login_V30(IPAddress.ToString(), Authorization.PortNumber, Authorization.UserName, Authorization.Password, ref _deviceInfo); Trace.WriteLine(_deviceInfo.byIPChanNum); if (_userId != InvalidUserId) { this.Info("NET_DVR_Login_V30调用成功, 用户标识:" + _userId); break; } } }
protected override bool StartCore() { if (!OfficalAPI.NET_DVR_Init()) { this.Info("摄像机运行环境创建失败, 错误代码" + OfficalAPI.NET_DVR_GetLastError()); return(false); } this.Info("摄像机运行环境创建成功"); Trace.WriteLine("xianshi"); //OfficalAPI.NET_DVR_SetConnectTime(3000, 1); //OfficalAPI.NET_DVR_SetReconnect(500, 0); // OfficalAPI.NET_DVR_SetRecvTimeOut(3000); Trace.WriteLine("xianshi2"); return(true); }
protected override sealed bool StartConnectCore() { for (int i = 0; i < 5; i++) { _userId = OfficalAPI.NET_DVR_Login_V30(IPAddress.ToString(), Authorization.PortNumber, Authorization.UserName, Authorization.Password, ref _deviceInfo); if (_userId != InvalidUserId) { this.Info("NET_DVR_Login_V30调用成功, 用户标识:" + _userId); return(true); } } WarnDvrSdkFailWithReason("NET_DVR_Login_V30"); return(true); }
public void StartPlayBack(DateTime beginTime, DateTime endTime, IntPtr hwnd) { NetDvrTime begin = new NetDvrTime { Year = (uint)beginTime.Year, Month = (uint)beginTime.Month, Day = (uint)beginTime.Day, Hour = (uint)beginTime.Hour, Minute = (uint)beginTime.Minute }; NetDvrTime end = new NetDvrTime { Year = (uint)endTime.Year, Month = (uint)endTime.Month, Day = (uint)endTime.Day, Hour = (uint)endTime.Hour, Minute = (uint)endTime.Minute }; //按时间播放 NetDvrVodPara vod = new NetDvrVodPara(); vod.Size = (uint)Marshal.SizeOf(vod); //vod.struIDInfo.dwSize = Marshal.SizeOf(NET_DVR_STREAM_INFO); vod.struIDInfo.Channel = 33; //按录像机网口32+i计算 vod.HWnd = hwnd; vod.BeginTime = begin; vod.EndTime = end; _playHandle = OfficalAPI.NET_DVR_PlayBackByTime(_userId, 33, ref begin, ref end, hwnd); //playHandle = OfficalAPI.NET_DVR_PlayBackByTime_V40(_userId, ref vod); Trace.WriteLine($"playHandle {_playHandle}"); var error = OfficalAPI.NET_DVR_GetLastError(); Trace.WriteLine($"error {error}"); }
private void WarnPlaySdkFailWithReason(string operation) { this.WarnFail(operation + OfficalAPI.PlayM4_GetLastError(_playPort)); }
private void WarnDvrSdkFailWithReason(string operation) { this.WarnFail(operation + OfficalAPI.NET_DVR_GetLastError()); }
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; } }
protected override bool StopCore() { //GlobalLoger.Info("摄像机运行环境清理" + (!IsCreated ? "成功" : "失败, 错误代码" + HikvisionSDK.NET_DVR_GetLastError())); return(OfficalAPI.NET_DVR_Cleanup()); }
public void PlayBackControl(NetDvrPlayBackControlCode controlCode) { uint outValue = 0; OfficalAPI.NET_DVR_PlayBackControl(_playHandle, controlCode, 0, ref outValue); }
public void StopPlayBack() { Debug.Assert(_playHandle > -1); OfficalAPI.NET_DVR_StopPlayBack(_playHandle); }