Skip to content
This repository was archived by the owner on Oct 16, 2024. It is now read-only.

Commit 4ffe7d9

Browse files
committed
添加摄像头协议
1 parent 99a471d commit 4ffe7d9

File tree

1 file changed

+154
-0
lines changed

1 file changed

+154
-0
lines changed

docs/protocol_camera.md

+154
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
# IoT通讯协议 之摄像头
2+
3+
本节规定了摄像头的交互内容
4+
5+
## 1、查询
6+
7+
```json5
8+
{
9+
"module": "camera",
10+
"command": "list",
11+
}
12+
```
13+
14+
15+
查询反馈
16+
17+
```json5
18+
{
19+
"result": "ok/fail", //结果
20+
"reason": "", //错误原因
21+
"data": [
22+
{
23+
"id": "/dev/usb-video0",
24+
"name": "usb camera",
25+
"type": "camera", //camera, screen
26+
},
27+
{
28+
"id": "ipc0",
29+
"name": "IP摄像头1",
30+
"type": "ipc",
31+
"url": "rtsp://admin:[email protected]",
32+
},
33+
]
34+
}
35+
```
36+
37+
38+
## 2、创建或更新IP摄像头
39+
40+
```json5
41+
{
42+
"module": "camera",
43+
"command": "replace", //create update
44+
"data": {
45+
"id": "ipc0",
46+
"name": "IP摄像头1",
47+
"type": "ipc",
48+
"url": "rtsp://admin:[email protected]",
49+
}
50+
}
51+
```
52+
53+
54+
## 3、删除IP摄像头
55+
```json5
56+
{
57+
"module": "camera",
58+
"command": "delete",
59+
"data": {
60+
"id": "ipc0",
61+
}
62+
}
63+
```
64+
65+
## 4、摄像头拍照
66+
67+
```json5
68+
{
69+
"module": "camera",
70+
"command": "take", //photo, snap
71+
"data": {
72+
"id": "ipc0",
73+
"quality": 8, //质量 1-10,可选
74+
"size": "720P", //尺寸,可选 VGA/480P PAL/576P HD/720P FULL/1080P 2K/1440P 4K/2160P
75+
}
76+
}
77+
```
78+
反馈
79+
80+
```json5
81+
{
82+
"result": "ok/fail", //结果
83+
"reason": "摄像头异常", //错误原因
84+
"data": {
85+
"path": "/usr/local/DCIM/20240807090205.jpg",
86+
}
87+
}
88+
```
89+
90+
## 5、摄像头录像
91+
92+
```json5
93+
{
94+
"module": "camera",
95+
"command": "record", //video
96+
"data": {
97+
"id": "ipc0",
98+
"duration": 3600, //时长 秒
99+
"frame": 10, //帧率,可选
100+
"quality": 8, //质量 1-10,可选
101+
"size": "720P", //尺寸,可选 VGA/480P PAL/576P HD/720P FULL/1080P 2K/1440P 4K/2160P
102+
}
103+
}
104+
```
105+
106+
反馈
107+
108+
```json5
109+
{
110+
"result": "ok/fail", //结果
111+
"reason": "摄像头异常", //错误原因
112+
"data": {
113+
"path": "/usr/local/DCIM/20240807090206.mp4",
114+
}
115+
}
116+
```
117+
118+
119+
120+
## 6、摄像头webrtc桥接
121+
122+
```json5
123+
{
124+
"module": "camera",
125+
"command": "webrtc",
126+
"data": {
127+
"id": "ipc0",
128+
}
129+
}
130+
```
131+
132+
133+
响应
134+
135+
```json5
136+
{
137+
"result": "ok/fail", //结果
138+
"reason": "不支持的操作", //错误原因
139+
"data": {
140+
"stream": 89, //流ID,在流中实现webrtc交互
141+
}
142+
}
143+
```
144+
145+
webrtc握手流程
146+
147+
| 指令 | | 内容 | 说明 |
148+
|------------|----|-------|------------------|
149+
| offer | 上行 | sdp | 客户端 createAnswer |
150+
| answer | 下行 | sdp | |
151+
| candidate | 双向 | ice候选 | ice交换 |
152+
153+
连接成功之后,就可以结束流了
154+

0 commit comments

Comments
 (0)