67 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			67 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| package HikNetSDK
 | |
| 
 | |
| import (
 | |
| 	"fmt"
 | |
| 	"github.com/ebitengine/purego"
 | |
| 	"runtime"
 | |
| 	"unsafe"
 | |
| )
 | |
| 
 | |
| var libc uintptr
 | |
| 
 | |
| var (
 | |
| 	DvrInit func() bool
 | |
| 
 | |
| 	newHIKBallCamera func() unsafe.Pointer
 | |
| 	initBallCamera   func(core unsafe.Pointer, ip string, port string, username string, password string, BallMachineType string) bool
 | |
| 	ptzTo            func(core unsafe.Pointer, Action int, P float32, T float32, Z float32) bool
 | |
| 	ptzGet           func(unsafe.Pointer, unsafe.Pointer, unsafe.Pointer, unsafe.Pointer) bool
 | |
| 	stopBus          func(unsafe.Pointer, int) bool
 | |
| 	startBus         func(unsafe.Pointer, int, int) bool
 | |
| 
 | |
| 	newHIKNvr                func() unsafe.Pointer
 | |
| 	initNvr                  func(unsafe.Pointer, string, string, string, string, int) bool
 | |
| 	checkTimeRegionWithMonth func(core unsafe.Pointer, year int, month int) string
 | |
| 	checkTimeRegionWithDay   func(core unsafe.Pointer, year int, month int, day int) string
 | |
| 	nvrUTCDiff               func(core unsafe.Pointer) int
 | |
| )
 | |
| 
 | |
| func init() {
 | |
| 	var err error
 | |
| 	libc, err = openLibrary(getSystemLibrary())
 | |
| 	if err != nil {
 | |
| 		panic(err)
 | |
| 	}
 | |
| 
 | |
| 	purego.RegisterLibFunc(&DvrInit, libc, "DVR_Init")
 | |
| 
 | |
| 	purego.RegisterLibFunc(&newHIKBallCamera, libc, "NewHIKBallCamera")
 | |
| 	purego.RegisterLibFunc(&initBallCamera, libc, "InitBallCamera")
 | |
| 	purego.RegisterLibFunc(&ptzTo, libc, "PtzGotoPut")
 | |
| 	purego.RegisterLibFunc(&ptzGet, libc, "PtzGet")
 | |
| 	purego.RegisterLibFunc(&stopBus, libc, "StopBus")
 | |
| 	purego.RegisterLibFunc(&startBus, libc, "StartBus")
 | |
| 
 | |
| 	purego.RegisterLibFunc(&newHIKNvr, libc, "NewHIKNvr")
 | |
| 	purego.RegisterLibFunc(&initNvr, libc, "InitNvr")
 | |
| 	purego.RegisterLibFunc(&checkTimeRegionWithMonth, libc, "CheckTimeRegionWithMonth")
 | |
| 	purego.RegisterLibFunc(&checkTimeRegionWithDay, libc, "CheckTimeRegionWithDay")
 | |
| 	purego.RegisterLibFunc(&nvrUTCDiff, libc, "NvrUTCDiff")
 | |
| 
 | |
| }
 | |
| 
 | |
| func getSystemLibrary() string {
 | |
| 	switch runtime.GOOS {
 | |
| 	case "linux":
 | |
| 		if runtime.GOARCH == "amd64" || runtime.GOARCH == "386" {
 | |
| 			return "libHikNetSDKPkg_linux_amd64.so"
 | |
| 		} else {
 | |
| 			return "libHikNetSDKPkg_linux_arm64.so"
 | |
| 		}
 | |
| 	case "windows":
 | |
| 		return "HikNetSDKPkg_win_amd64.dll"
 | |
| 	default:
 | |
| 		panic(fmt.Errorf("GOOS=%s is not supported", runtime.GOOS))
 | |
| 	}
 | |
| }
 | 
