From aba91dc00cd79653c4867c954434b0adff035598 Mon Sep 17 00:00:00 2001
From: heyujie <516346543@qq.com>
Date: 星期五, 15 十月 2021 15:38:23 +0800
Subject: [PATCH] 转动

---
 hikptz.go |   81 ++++++++++++----------------------------
 1 files changed, 25 insertions(+), 56 deletions(-)

diff --git a/hikptz.go b/hikptz.go
index 862d2ed..f58964a 100644
--- a/hikptz.go
+++ b/hikptz.go
@@ -1,70 +1,39 @@
-package hikvoice
+package hikControl
 
 /*
-#cgo CFLAGS: -I${SRCDIR}/include -w -g
-#cgo LDFLAGS: -L${SRCDIR}/libs
-#cgo LDFLAGS: -lHikVoice -lAudioRender -lHCCore -lhcnetsdk -lhpr
-#cgo LDFLAGS: -ldl -lm
-
+#cgo CXXFLAGS: -I${SRCDIR}/include -w -g
+#cgo LDFLAGS: -L${SRCDIR}/lib
+#cgo LDFLAGS: -lhcnetsdk -lhpr -lHCCore
 #include <stdlib.h>
-#include "Voice.h"
+#include "hikptz.h"
 */
 import "C"
-
-// type PtzDevice struct {
-// 	IpAddr string `form:"ipAddr" json:"ipAddr"`
-// 	Port string `form:"port" json:"port"`
-// 	UserName string `form:"userName" json:"userName"`
-// 	Password string `form:"password" json:"password"`
-// }
-
-// type PtzZoneService struct {
-// 	UserName string `form:"userName" json:"userName"`
-// 	Channel    string `form:"channel" json:"channel"`
-// 	XTop string `form:"xTop" json:"xTop"`
-// 	YTop string `form:"yTop" json:"yTop"`
-// 	XBottom string `form:"xBottom" json:"xBottom"`
-// 	YBottom string `form:"yBottom" json:"yBottom"`
-// }
-
+import (
+	"unsafe"
+)
 
 // SendVoice Send Voice
-func PtzTrack(ip,password,port,userName,channel,xBottom,xTop,yBottom,yTop string)  {
-	
-	//  // 鍒濆鍖�
-	//  NET_DVR_Init();
+func PtzTrack(ip, userName, password string, port, channel, xBottom, xTop, yBottom, yTop int) {
 
-	c.NET_DVR_Init()
-	//  //璁剧疆杩炴帴鏃堕棿涓庨噸杩炴椂闂�
-	//  NET_DVR_SetConnectTime(2000, 1);
-	//  NET_DVR_SetReconnect(10000, true);
-	c.NET_DVR_SetConnectTime(2000, 1)
-	c.NET_DVR_SetReconnect(10000, true)
-	//  // 娉ㄥ唽璁惧
-	//  LONG lUserID;
-	
-	//  //鐧诲綍鍙傛暟锛屽寘鎷澶囧湴鍧�銆佺櫥褰曠敤鎴枫�佸瘑鐮佺瓑
-	//  NET_DVR_USER_LOGIN_INFO struLoginInfo = {0};
-	//  struLoginInfo.bUseAsynLogin = 0; //鍚屾鐧诲綍鏂瑰紡
-	//  strcpy(struLoginInfo.sDeviceAddress, "10.13.35.229"); //璁惧IP鍦板潃
-	//  struLoginInfo.wPort = 8000; //璁惧鏈嶅姟绔彛
-	//  strcpy(struLoginInfo.sUserName, "admin"); //璁惧鐧诲綍鐢ㄦ埛鍚�
-	//  strcpy(struLoginInfo.sPassword, "abcd1234"); //璁惧鐧诲綍瀵嗙爜
+	cIp := C.CString(ip)
+	cUsrname := C.CString(userName)
+	cPasswd := C.CString(password)
 
-	//   //璁惧淇℃伅, 杈撳嚭鍙傛暟
-	//   NET_DVR_DEVICEINFO_V40 struDeviceInfoV40 = {0};
+	defer C.free(unsafe.Pointer(cIp))
+	defer C.free(unsafe.Pointer(cUsrname))
+	defer C.free(unsafe.Pointer(cPasswd))
 
-	//   lUserID = NET_DVR_Login_V40(&struLoginInfo, &struDeviceInfoV40);
+	C.ptzTrack(cIp, cUsrname, cPasswd, C.int(port), C.int(channel), C.int(xBottom), C.int(xTop), C.int(yBottom), C.int(yTop))
+}
 
-	//   int iChannel = 1;//璁惧閫氶亾鍙�
-	// DWORD dwPTZCommand = PAN_LEFT; //浜戝彴宸﹁浆
-	// DWORD dwStop = 0; //寮�濮嬭浆鍔�
-	// NET_DVR_PTZControl_Other(lUserID, iChannel, PAN_LEFT, dwStop)
+func ToPreset(ip, userName, password string, port, ch int) {
 
-	// //娉ㄩ攢鐢ㄦ埛
-	// NET_DVR_Logout(lUserID);
+	cip := C.CString(ip)
+	defer C.free(unsafe.Pointer(cip))
+	cusrname := C.CString(userName)
+	defer C.free(unsafe.Pointer(cusrname))
+	cpasswd := C.CString(password)
+	defer C.free(unsafe.Pointer(cpasswd))
 
-	// //閲婃斁SDK璧勬簮
-	// NET_DVR_Cleanup();
-
+	C.toPreset(cip, cusrname, cpasswd, C.int(port), C.int(ch))
 }

--
Gitblit v1.8.0