/// <summary> /// 录像 /// </summary> public void record(Panel panel) { if (m_mainForm.RecordPath.Length == 0) { MessageBox.Show("未设置录像路径"); return; } foreach (OneDialog dlg in m_dialogs) { if (dlg.panel == panel) { dlg.recording = !dlg.recording; if (dlg.recording) { try { //录像 int ret = BVCU.ManagedLayer_CuSetRecordStorageParam(m_bvsdkHandle, dlg.dialogHandle, Encoding.UTF8.GetBytes(m_mainForm.RecordPath), 3600); BVCU.FAILED(ret); } catch { MessageBox.Show("保存文件失败"); dlg.recording = false; } } else { BVCU.ManagedLayer_CuSetRecordStorageParam(m_bvsdkHandle, dlg.dialogHandle, Encoding.UTF8.GetBytes(""), 0); } break; } } }
/// <summary> /// 截图 /// </summary> public void capture(Panel panel) { if (m_mainForm.CapturePath.Length == 0) { MessageBox.Show("未设置截图路径"); return; } try { foreach (OneDialog dlg in m_dialogs) { if (dlg.panel == panel) { string path = m_mainForm.CapturePath + "\\" + dlg.timeStamp.Year + dlg.timeStamp.Month.ToString().PadLeft(2, '0') + dlg.timeStamp.Day.ToString().PadLeft(2, '0') + dlg.timeStamp.Hour.ToString().PadLeft(2, '0') + dlg.timeStamp.Minute.ToString().PadLeft(2, '0') + dlg.timeStamp.Second.ToString().PadLeft(2, '0') + dlg.timeStamp.Millisecond.ToString().PadLeft(3, '0') + ".jpg"; //截图 int ret = BVCU.ManagedLayer_CuSnapshot(m_bvsdkHandle, dlg.dialogHandle, Encoding.UTF8.GetBytes(path), 85); BVCU.FAILED(ret); break; } } } catch { MessageBox.Show("截图失败"); } }
/// <summary> /// 构造函数 /// </summary> /// <param name="mainform">主窗口</param> public BVCUSdkOperator(MainWinForm mainform) { m_mainForm = mainform; BVCU.FAILED(BVCU.ManagedLayer_CuInit(ref m_bvcuSdkHandle));//初始化库 m_eventHandler = new EventHandler(); m_session = new Session(m_bvcuSdkHandle, m_eventHandler, m_mainForm); m_dialog = new Dialog(m_bvcuSdkHandle, m_eventHandler, m_mainForm, m_session); m_eventHandler.init(m_bvcuSdkHandle, m_session, m_dialog); m_session.SetBVCUSdk(this); }
/// <summary> /// 打开对话(Dialog) /// </summary> /// <param name="pu"></param> /// <param name="channelNo"></param> /// <param name="panel"></param> public void openBrowse(Pu pu, int channelNo, Panel panel) { try { BVCU_DialogControlParam_Network net = new BVCU_DialogControlParam_Network(0, 5, 1, 3); BVRect dispRect = new BVRect(0, 0, panel.ClientRectangle.Height, panel.ClientRectangle.Width); OneDialog dlg = new OneDialog(); foreach (Channel channel in pu.channelList) { int volume = -1; if (channel.channelNo == channelNo) { if (channel.audioPlayback) { volume = 0; } //打开视屏浏览, 主要参数:sdkHandle、sessionHandle、puID、channelNo、显示区域的大小 int ret = BVCU.ManagedLayer_CuBrowsePu(m_bvsdkHandle, //sdk handle ref dlg.dialogHandle, //dialog handle m_session.Handle, //session handle Encoding.UTF8.GetBytes(pu.id), //pu id channelNo, //channel no panel.Handle, //pannel handle ref dispRect, //上下左右,矩形 volume, //音量 0, //single Rec File Sec Encoding.UTF8.GetBytes(""), //rec File Dir true, //videoTrans ref net, //network 时延 m_bvsdkEventHandler.dialog_OnDialogEvent, m_bvsdkEventHandler.dialog_OnStorageEvent); BVCU.FAILED(ret); LogHelper.LogHelper.RecordLog(4, string.Format("打开[{0}, {1}]的视屏预览通道", pu.puName, channelNo)); break; } } dlg.panel = panel; dlg.pu = pu; dlg.channelNo = channelNo; m_dialogs.Add(dlg); } catch { panel.ContextMenuStrip = null; MessageBox.Show("打开预览失败"); } }
public void openTalkOnly(Pu pu, int channelNo, Panel panel) { try { BVCU_DialogControlParam_Network net = new BVCU_DialogControlParam_Network(0, 5, 1, 3); BVRect dispRect = new BVRect(0, 0, panel.ClientRectangle.Height, panel.ClientRectangle.Width); OneDialog dlg = new OneDialog(); foreach (Channel channel in pu.channelList) { int captureVolume = 50; int audioVolume = 50; if (channel.channelNo == channelNo) { int ret = BVCU.ManagedLayer_CuNewTalk(m_bvsdkHandle, ref dlg.dialogHandle, m_session.Handle, Encoding.UTF8.GetBytes(pu.id), channelNo, captureVolume, audioVolume, ref net, m_bvsdkEventHandler.dialog_OnDialogEvent, m_bvsdkEventHandler.dialog_OnStorageEvent); BVCU.FAILED(ret); LogHelper.LogHelper.RecordLog(4, string.Format("打开[{0}]对讲", pu.puName)); break; } } dlg.panel = panel; dlg.pu = pu; dlg.channelNo = channelNo; m_dialogs.Add(dlg); } catch { panel.ContextMenuStrip = null; MessageBox.Show("打开对讲失败"); } }
public void login(string ip, int port, string usrName, string psw) { m_server.ip = ip; m_server.port = port; m_server.usrName = usrName; m_server.psw = psw; m_server.ukeyid = ""; m_server.ukeycode = ""; try { //封装 int ret = BVCU.ManagedLayer_CuLogin(m_bvsdkHandle, ref m_server.sessionHandle, Encoding.UTF8.GetBytes(ip), port, Encoding.UTF8.GetBytes(usrName), Encoding.UTF8.GetBytes(psw), SERVER_TIME_OUT_SECOND, m_bvsdkEventHandler.server_OnEvent, m_bvsdkEventHandler.server_ProcChannelInfo); BVCU.FAILED(ret); } catch { MessageBox.Show("登录失败"); } }