forked from hootrhino/rulex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeneric_camera_stream_linux_mipsle.go
96 lines (77 loc) · 2.39 KB
/
generic_camera_stream_linux_mipsle.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package device
import (
"fmt"
"github.com/hootrhino/rulex/typex"
)
// RTSP URL格式= rtsp://<username>:<password>@<ip>:<port>,
type _MainConfig struct {
MaxThread int `json:"maxThread"` // 最大连接数, 防止连接过多导致摄像头拉流失败
InputMode string `json:"inputMode"` // 视频输入模式:RTSP | LOCAL
Device string `json:"device"` // 本地视频设备路径,在输入模式=LOCAL时生效
RtspUrl string `json:"rtspUrl"` // 远程视频设备地址,在输入模式=RTSP时生效
OutputMode string `json:"outputMode"` // 输出模式:JPEG_STREAM | RTSP_STREAM
OutputAddr string `json:"outputAddr"` // 输出地址, 格式为: "Ip:Port",例如127.0.0.1:7890
}
// 摄像头
type videoCamera struct {
typex.XStatus
status typex.DeviceState
mainConfig _MainConfig
}
func NewVideoCamera(e typex.RuleX) typex.XDevice {
videoCamera := new(videoCamera)
videoCamera.RuleEngine = e
videoCamera.status = typex.DEV_DOWN
videoCamera.mainConfig = _MainConfig{
Device: "video0",
RtspUrl: "rtsp://127.0.0.1",
InputMode: "LOCAL",
OutputMode: "JPEG_STREAM",
}
return videoCamera
}
// 初始化 通常用来获取设备的配置
func (vc *videoCamera) Init(devId string, configMap map[string]interface{}) error {
return fmt.Errorf("video camera not support windows")
}
// 启动, 设备的工作进程
func (vc *videoCamera) Start(cctx typex.CCTX) error {
vc.status = typex.DEV_UP
return nil
}
func (vc *videoCamera) OnRead(cmd []byte, data []byte) (int, error) {
return 0, nil
}
func (vc *videoCamera) OnWrite(cmd []byte, data []byte) (int, error) {
return 0, nil
}
/*
*
* 外部指令,未来可以实现一些对摄像头的操作,例如拍照等
*
*/
func (vc *videoCamera) OnCtrl(cmd []byte, args []byte) ([]byte, error) {
return nil, nil
}
// 设备当前状态
func (vc *videoCamera) Status() typex.DeviceState {
return vc.status
}
func (vc *videoCamera) Stop() {
vc.status = typex.DEV_STOP
vc.CancelCTX()
}
func (vc *videoCamera) Property() []typex.DeviceProperty {
return []typex.DeviceProperty{}
}
func (vc *videoCamera) Details() *typex.Device {
return vc.RuleEngine.GetDevice(vc.PointId)
}
func (vc *videoCamera) SetState(_ typex.DeviceState) {
}
func (vc *videoCamera) Driver() typex.XExternalDriver {
return nil
}
func (vc *videoCamera) OnDCACall(_ string, _ string, _ interface{}) typex.DCAResult {
return typex.DCAResult{}
}