|
|
# RTSPtoWeb API
|
|
|
|
|
|
* [流管理](#streams)
|
|
|
* [列出流](#list-streams)
|
|
|
* [添加流](#add-a-stream)
|
|
|
* [更新流](#update-a-stream)
|
|
|
* [重新加载流](#reload-a-stream)
|
|
|
* [获取流信息](#get-stream-info)
|
|
|
* [删除流](#delete-a-stream)
|
|
|
* [通道管理](#channels)
|
|
|
* [向流添加通道](#add-a-channel-to-a-stream)
|
|
|
* [更新流通道](#update-a-stream-channel)
|
|
|
* [重新加载流通道](#reload-a-stream-channel)
|
|
|
* [获取流通道信息](#get-stream-channel-info)
|
|
|
* [获取流通道编解码器](#get-stream-channel-codec)
|
|
|
* [删除流通道](#delete-a-stream-channel)
|
|
|
* [视频端点](#video-endpoints)
|
|
|
* [HLS](#hls)
|
|
|
* [HLS-LL](#hls-ll)
|
|
|
* [MSE](#mse)
|
|
|
* [WebRTC](#webrtc)
|
|
|
* [RTSP](#rtsp)
|
|
|
|
|
|
## 流管理
|
|
|
|
|
|
### 列出流
|
|
|
|
|
|
#### 请求
|
|
|
|
|
|
`GET /streams`
|
|
|
|
|
|
```bash
|
|
|
curl http://demo:demo@127.0.0.1:8083/streams
|
|
|
```
|
|
|
|
|
|
#### 响应
|
|
|
|
|
|
```json
|
|
|
{
|
|
|
"status": 1,
|
|
|
"payload": {
|
|
|
"demo1": {
|
|
|
"name": "test video",
|
|
|
"channels": {
|
|
|
"0": {
|
|
|
"name": "ch1",
|
|
|
"url": "rtsp://admin:admin@{YOUR_CAMERA_IP}/uri",
|
|
|
"on_demand": true,
|
|
|
"debug": false,
|
|
|
"status": 0
|
|
|
},
|
|
|
"1": {
|
|
|
"name": "ch2",
|
|
|
"url": "rtsp://admin:admin@{YOUR_CAMERA_IP}/uri",
|
|
|
"on_demand": true,
|
|
|
"debug": false,
|
|
|
"status": 0
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
"demo2": {
|
|
|
"name": "test video",
|
|
|
"channels": {
|
|
|
"0": {
|
|
|
"name": "ch1",
|
|
|
"url": "rtsp://admin:admin@{YOUR_CAMERA_IP}/uri",
|
|
|
"on_demand": true,
|
|
|
"debug": false,
|
|
|
"status": 0
|
|
|
},
|
|
|
"1": {
|
|
|
"name": "ch2",
|
|
|
"url": "rtsp://admin:admin@{YOUR_CAMERA_IP}/uri",
|
|
|
"on_demand": true,
|
|
|
"debug": false,
|
|
|
"status": 0
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
```
|
|
|
|
|
|
### 添加流
|
|
|
|
|
|
#### 请求
|
|
|
|
|
|
`POST /stream/{STREAM_ID}/add`
|
|
|
|
|
|
```bash
|
|
|
curl \
|
|
|
--header "Content-Type: application/json" \
|
|
|
--request POST \
|
|
|
--data '{
|
|
|
"name": "test video",
|
|
|
"channels": {
|
|
|
"0": {
|
|
|
"name": "ch1",
|
|
|
"url": "rtsp://admin:admin@{YOUR_CAMERA_IP}/uri",
|
|
|
"on_demand": true,
|
|
|
"debug": false,
|
|
|
"status": 0
|
|
|
},
|
|
|
"1": {
|
|
|
"name": "ch2",
|
|
|
"url": "rtsp://admin:admin@{YOUR_CAMERA_IP}/uri",
|
|
|
"on_demand": true,
|
|
|
"debug": false,
|
|
|
"status": 0
|
|
|
}
|
|
|
}
|
|
|
}' \
|
|
|
http://demo:demo@127.0.0.1:8083/stream/{STREAM_ID}/add
|
|
|
```
|
|
|
|
|
|
#### 响应
|
|
|
|
|
|
```json
|
|
|
{
|
|
|
"status": 1,
|
|
|
"payload": "success"
|
|
|
}
|
|
|
```
|
|
|
|
|
|
### 更新流
|
|
|
|
|
|
#### 请求
|
|
|
|
|
|
`POST /stream/{STREAM_ID}/edit`
|
|
|
|
|
|
```bash
|
|
|
curl \
|
|
|
--header "Content-Type: application/json" \
|
|
|
--request POST \
|
|
|
--data '{
|
|
|
"name": "test video",
|
|
|
"channels": {
|
|
|
"0": {
|
|
|
"name": "ch1",
|
|
|
"url": "rtsp://admin:admin@{YOUR_CAMERA_IP}/uri",
|
|
|
"on_demand": true,
|
|
|
"debug": false,
|
|
|
"status": 0
|
|
|
},
|
|
|
"1": {
|
|
|
"name": "ch2",
|
|
|
"url": "rtsp://admin:admin@{YOUR_CAMERA_IP}/uri",
|
|
|
"on_demand": true,
|
|
|
"debug": false,
|
|
|
"status": 0
|
|
|
}
|
|
|
}
|
|
|
}' \
|
|
|
http://demo:demo@127.0.0.1:8083/stream/{STREAM_ID}/edit
|
|
|
```
|
|
|
|
|
|
#### 响应
|
|
|
|
|
|
```json
|
|
|
{
|
|
|
"status": 1,
|
|
|
"payload": "success"
|
|
|
}
|
|
|
```
|
|
|
|
|
|
### 重新加载流
|
|
|
|
|
|
#### 请求
|
|
|
|
|
|
`GET /stream/{STREAM_ID}/reload`
|
|
|
|
|
|
```bash
|
|
|
curl http://demo:demo@127.0.0.1:8083/stream/{STREAM_ID}/reload
|
|
|
```
|
|
|
|
|
|
#### 响应
|
|
|
|
|
|
```json
|
|
|
{
|
|
|
"status": 1,
|
|
|
"payload": "success"
|
|
|
}
|
|
|
```
|
|
|
|
|
|
### 获取流信息
|
|
|
|
|
|
#### 请求
|
|
|
|
|
|
`GET /stream/{STREAM_ID}/info`
|
|
|
|
|
|
```bash
|
|
|
curl http://demo:demo@127.0.0.1:8083/stream/{STREAM_ID}/info
|
|
|
```
|
|
|
|
|
|
#### 响应
|
|
|
|
|
|
```json
|
|
|
{
|
|
|
"status": 1,
|
|
|
"payload": {
|
|
|
"name": "test video",
|
|
|
"channels": {
|
|
|
"0": {
|
|
|
"name": "ch1",
|
|
|
"url": "rtsp://admin:admin@{YOUR_CAMERA_IP}/uri",
|
|
|
"on_demand": true,
|
|
|
"debug": false,
|
|
|
"status": 0
|
|
|
},
|
|
|
"1": {
|
|
|
"name": "ch2",
|
|
|
"url": "rtsp://admin:admin@{YOUR_CAMERA_IP}/uri",
|
|
|
"on_demand": true,
|
|
|
"debug": false,
|
|
|
"status": 0
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
```
|
|
|
|
|
|
### 删除流
|
|
|
|
|
|
#### 请求
|
|
|
|
|
|
`GET /stream/{STREAM_ID}/delete`
|
|
|
|
|
|
```bash
|
|
|
curl http://demo:demo@127.0.0.1:8083/stream/{STREAM_ID}/delete
|
|
|
```
|
|
|
|
|
|
#### 响应
|
|
|
|
|
|
```json
|
|
|
{
|
|
|
"status": 1,
|
|
|
"payload": "success"
|
|
|
}
|
|
|
```
|
|
|
|
|
|
## 通道管理
|
|
|
|
|
|
### 向流添加通道
|
|
|
|
|
|
#### 请求
|
|
|
|
|
|
`POST /stream/{STREAM_ID}/channel/{CHANNEL_ID}/add`
|
|
|
|
|
|
```bash
|
|
|
curl \
|
|
|
--header "Content-Type: application/json" \
|
|
|
--request POST \
|
|
|
--data '{
|
|
|
"name": "ch4",
|
|
|
"url": "rtsp://admin:admin@{YOUR_CAMERA_IP}/uri",
|
|
|
"on_demand": false,
|
|
|
"debug": false,
|
|
|
"status": 0
|
|
|
}' \
|
|
|
http://demo:demo@127.0.0.1:8083/stream/{STREAM_ID}/channel/{CHANNEL_ID}/add
|
|
|
```
|
|
|
|
|
|
#### 响应
|
|
|
|
|
|
```json
|
|
|
{
|
|
|
"status": 1,
|
|
|
"payload": "success"
|
|
|
}
|
|
|
```
|
|
|
|
|
|
### 更新流通道
|
|
|
|
|
|
#### 请求
|
|
|
|
|
|
`POST /stream/{STREAM_ID}/channel/{CHANNEL_ID}/edit`
|
|
|
|
|
|
```bash
|
|
|
curl \
|
|
|
--header "Content-Type: application/json" \
|
|
|
--request POST \
|
|
|
--data '{
|
|
|
"name": "ch4",
|
|
|
"url": "rtsp://admin:admin@{YOUR_CAMERA_IP}/uri",
|
|
|
"on_demand": true,
|
|
|
"debug": false,
|
|
|
"status": 0
|
|
|
}' \
|
|
|
http://demo:demo@127.0.0.1:8083/stream/{STREAM_ID}/channel/{CHANNEL_ID}/edit
|
|
|
```
|
|
|
|
|
|
#### 响应
|
|
|
|
|
|
```json
|
|
|
{
|
|
|
"status": 1,
|
|
|
"payload": "success"
|
|
|
}
|
|
|
```
|
|
|
|
|
|
### 重新加载流通道
|
|
|
|
|
|
#### 请求
|
|
|
|
|
|
`GET /stream/{STREAM_ID}/channel/{CHANNEL_ID}/reload`
|
|
|
|
|
|
```bash
|
|
|
curl http://demo:demo@127.0.0.1:8083/stream/{STREAM_ID}/channel/{CHANNEL_ID}/reload
|
|
|
```
|
|
|
|
|
|
#### 响应
|
|
|
|
|
|
```json
|
|
|
{
|
|
|
"status": 1,
|
|
|
"payload": "success"
|
|
|
}
|
|
|
```
|
|
|
|
|
|
### 获取流通道信息
|
|
|
|
|
|
#### 请求
|
|
|
|
|
|
`GET /stream/{STREAM_ID}/channel/{CHANNEL_ID}/info`
|
|
|
|
|
|
```bash
|
|
|
curl http://demo:demo@127.0.0.1:8083/stream/{STREAM_ID}/channel/{CHANNEL_ID}/info
|
|
|
```
|
|
|
|
|
|
#### 响应
|
|
|
|
|
|
```json
|
|
|
{
|
|
|
"status": 1,
|
|
|
"payload": {
|
|
|
"name": "ch4",
|
|
|
"url": "rtsp://admin:admin@{YOUR_CAMERA_IP}/uri",
|
|
|
"on_demand": false,
|
|
|
"debug": false,
|
|
|
"status": 1
|
|
|
}
|
|
|
}
|
|
|
```
|
|
|
|
|
|
### 获取流通道编解码器
|
|
|
|
|
|
#### 请求
|
|
|
`GET /stream/{STREAM_ID}/{CHANNEL_ID}/codec`
|
|
|
|
|
|
```bash
|
|
|
curl http://demo:demo@127.0.0.1:8083/stream/{STREAM_ID}/{CHANNEL_ID}/codec
|
|
|
```
|
|
|
|
|
|
#### 响应
|
|
|
```json
|
|
|
{
|
|
|
"status": 1,
|
|
|
"payload": [
|
|
|
{
|
|
|
"Record": "AU0AFP/hABRnTQAUlahQfoQAAAMABAAAAwCiEAEABGjuPIA=",
|
|
|
"RecordInfo": {
|
|
|
"AVCProfileIndication": 77,
|
|
|
"ProfileCompatibility": 0,
|
|
|
"AVCLevelIndication": 20,
|
|
|
"LengthSizeMinusOne": 3,
|
|
|
"SPS": [
|
|
|
"Z00AFJWoUH6EAAADAAQAAAMAohA="
|
|
|
],
|
|
|
"PPS": [
|
|
|
"aO48gA=="
|
|
|
]
|
|
|
},
|
|
|
"SPSInfo": {
|
|
|
"ProfileIdc": 77,
|
|
|
"LevelIdc": 20,
|
|
|
"MbWidth": 20,
|
|
|
"MbHeight": 15,
|
|
|
"CropLeft": 0,
|
|
|
"CropRight": 0,
|
|
|
"CropTop": 0,
|
|
|
"CropBottom": 0,
|
|
|
"Width": 320,
|
|
|
"Height": 240
|
|
|
}
|
|
|
}
|
|
|
]
|
|
|
}
|
|
|
```
|
|
|
|
|
|
### 删除流通道
|
|
|
|
|
|
#### 请求
|
|
|
|
|
|
`GET /stream/{STREAM_ID}/channel/{CHANNEL_ID}/delete`
|
|
|
|
|
|
```bash
|
|
|
curl http://demo:demo@127.0.0.1:8083/stream/{STREAM_ID}/channel/{CHANNEL_ID}/delete
|
|
|
```
|
|
|
|
|
|
#### 响应
|
|
|
```json
|
|
|
{
|
|
|
"status": 1,
|
|
|
"payload": "success"
|
|
|
}
|
|
|
```
|
|
|
|
|
|
## 视频端点
|
|
|
|
|
|
### HLS
|
|
|
|
|
|
`GET /stream/{STREAM_ID}/channel/{CHANNEL_ID}/hls/live/index.m3u8`
|
|
|
|
|
|
```bash
|
|
|
curl http://127.0.0.1:8083/stream/{STREAM_ID}/channel/{CHANNEL_ID}/hls/live/index.m3u8
|
|
|
```
|
|
|
|
|
|
```bash
|
|
|
ffplay http://127.0.0.1:8083/stream/{STREAM_ID}/channel/{CHANNEL_ID}/hls/live/index.m3u8
|
|
|
```
|
|
|
|
|
|
### HLS-LL
|
|
|
|
|
|
`GET /stream/{STREAM_ID}/channel/{CHANNEL_ID}/hlsll/live/index.m3u8`
|
|
|
|
|
|
```bash
|
|
|
curl http://127.0.0.1:8083/stream/{STREAM_ID}/channel/{CHANNEL_ID}/hlsll/live/index.m3u8
|
|
|
```
|
|
|
|
|
|
```bash
|
|
|
ffplay http://127.0.0.1:8083/stream/{STREAM_ID}/channel/{CHANNEL_ID}/hlsll/live/index.m3u8
|
|
|
```
|
|
|
|
|
|
### MSE
|
|
|
|
|
|
`/stream/{STREAM_ID}/channel/{CHANNEL_ID}/mse?uuid={STREAM_ID}&channel={CHANNEL_ID}`
|
|
|
|
|
|
```
|
|
|
ws://127.0.0.1:8083/stream/{STREAM_ID}/channel/{CHANNEL_ID}/mse?uuid={STREAM_ID}&channel={CHANNEL_ID}
|
|
|
```
|
|
|
|
|
|
注意:使用 `wss` 进行安全连接。
|
|
|
|
|
|
### WebRTC
|
|
|
|
|
|
`/stream/{STREAM_ID}/channel/{CHANNEL_ID}/webrtc`
|
|
|
|
|
|
```
|
|
|
http://127.0.0.1:8083/stream/{STREAM_ID}/channel/{CHANNEL_ID}/webrtc
|
|
|
```
|
|
|
|
|
|
#### Request
|
|
|
|
|
|
请求是一个 HTTP `POST`,包含 FormData 参数 `data`,该参数是来自 WebRTC 客户端的 base64 编码的 SDP offer(例如 `v=0...`)。
|
|
|
|
|
|
#### 响应
|
|
|
|
|
|
响应是一个 base64 编码的 SDP Answer。
|
|
|
|
|
|
### RTSP
|
|
|
|
|
|
`/{STREAM_ID}/{CHANNEL_ID}`
|
|
|
|
|
|
```
|
|
|
rtsp://127.0.0.1:{RTSP_PORT}/{STREAM_ID}/{CHANNEL_ID}
|
|
|
```
|
|
|
|
|
|
```bash
|
|
|
ffplay -rtsp_transport tcp rtsp://127.0.0.1/{STREAM_ID}/{CHANNEL_ID}
|
|
|
```
|