Skip to content

Commit

Permalink
fix and doc
Browse files Browse the repository at this point in the history
  • Loading branch information
deepch committed Aug 20, 2020
1 parent a00b1b6 commit 63380fb
Show file tree
Hide file tree
Showing 7 changed files with 273 additions and 28 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.idea/
RTSPtoWeb
232 changes: 219 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ RTSP Stream to WebBrowser MSE or WebRTC or HLS, full native! not use ffmpeg or g
- [Installation from binary](#Installation from binary)
- [Installation from source](#Installation from source)
- [Configuration](#Configuration)
- [Command-Line Arguments](#Command-Line Arguments)
- [API Documentation](#API documentation)
- [Limitations](#Limitations)
- [Performance](#Performance)
Expand All @@ -15,37 +16,48 @@ RTSP Stream to WebBrowser MSE or WebRTC or HLS, full native! not use ffmpeg or g

## Installation from binary

To achieve it, after Darknet compilation (via make) execute following command:
Select the latest release
```shell
GO111MODULE=on go get github.com/deepch/RTSPtoWeb
go to https://github.com/deepch/RTSPtoWeb/releases
```
To achieve it, after Darknet compilation (via make) execute following command:

Download the latest version [$version].tar.gz
```shell
cd src/github.com/deepch/RTSPtoWeb
wget https://github.com/deepch/RTSPtoWeb/archive/v0.0.1.tar.gz
```
To achieve it, after Darknet compilation (via make) execute following command:

Extract the archive
```shell
go run *.go
tar -xvzf v0.0.1.tar.gz
```
To access the web interface, you open a browser.

Change permission
```shell
chmod 777 RTSPtoWeb
```

Run the application
```shell
http://127.0.0.1:8083
./RTSPtoWeb
```

## Installation from source

To achieve it, after Darknet compilation (via make) execute following command:
Enable the go module and get the source code
```shell
GO111MODULE=on go get github.com/deepch/RTSPtoWeb
```
To achieve it, after Darknet compilation (via make) execute following command:
Go to working directory

```shell
cd src/github.com/deepch/RTSPtoWeb
```
To achieve it, after Darknet compilation (via make) execute following command:

Run the source
```shell
go run *.go
```

To access the web interface, you open a browser.
```shell
http://127.0.0.1:8083
Expand All @@ -66,7 +78,7 @@ format:
"http_port": ":8083"
},
"streams": {
"demo1": {
"demo": {
"url": "rtsp://admin:admin@YOU_CAMERA_IP/uri",
"on_demand": false,
"debug": false,
Expand All @@ -79,9 +91,203 @@ format:
}
}
```

## Command-Line Arguments

######Use help show arg

```bash
./RTSPtoWeb --help
```

######Response

```bash
Usage of ./RTSPtoWeb:
-config string
config patch (/etc/server/config.json or config.json) (default "config.json")
-debug
set debug mode (default true)
```

## API documentation

#### Streams List
###### Query
```bash
GET /streams

curl http://demo:[email protected]:8083/streams
```

###### Response
```json
{
"status": 1,
"payload": {
"demo": {
"name": "test name 1",
"url": "rtsp://admin:[email protected]:550/mpeg4",
"on_demand": true,
"debug": false
},
"3demo": {
"name": "test name 2",
"url": "rtsp://admin:[email protected]:551/mpeg4",
"on_demand": false,
"debug": false
},
"demo2": {
"name": "test name 3",
"url": "rtsp://admin:[email protected]:552/mpeg4",
"on_demand": true,
"debug": false
}
}
}
```
#### Stream Add
###### Query
```bash
POST /stream/:uuid/add
curl --header "Content-Type: application/json" \
--request POST \
--data '{"name": "test name 1","url": "rtsp://admin:[email protected]:550/mpeg4", "on_demand": false,"debug": false}' \
http://demo:[email protected]:8083/stream/demo/add
```

###### Response
```json
{
"status": 1,
"payload": "success"
}
```
#### Stream Edit
###### Query
```bash
POST /stream/:uuid/edit
curl --header "Content-Type: application/json" \
--request POST \
--data '{"name": "test name 1","url": "rtsp://admin:[email protected]:550/mpeg4", "on_demand": false,"debug": false}' \
http://demo:[email protected]:8083/stream/demo/edit
```

nope
###### Response
```json
{
"status": 1,
"payload": "success"
}
```
#### Stream Reload
###### Query
```bash
GET /stream/:uuid/reload
curl http://demo:[email protected]:8083/stream/demo/reload
```

###### Response
```json
{
"status": 1,
"payload": "success"
}
```

#### Stream Info
###### Query
```bash
GET /stream/:uuid/info
curl http://demo:[email protected]:8083/stream/demo/info
```

###### Response
```json
{
"status": 1,
"payload": {
"name": "test name 1",
"url": "rtsp://admin:[email protected]/mpeg4",
"on_demand": false,
"debug": false,
"status": 1
}
}
```

#### Stream Codec
###### Query
```bash
GET /stream/:uuid/codec
curl http://demo:[email protected]:8083/stream/demo/codec
```

###### Response
```json
{
"status": 1,
"payload": [
{
"Record": "AUKAKP/hACRnQoAo2gHgCJeWVIAAADwAAA4QMCAAHoSAAAiVRXvfC8IhGoABAARozjyA",
"RecordInfo": {
"AVCProfileIndication": 66,
"ProfileCompatibility": 128,
"AVCLevelIndication": 40,
"LengthSizeMinusOne": 3,
"SPS": [
"Z0KAKNoB4AiXllSAAAA8AAAOEDAgAB6EgAAIlUV73wvCIRqA"
],
"PPS": [
"aM48gA=="
]
},
"SPSInfo": {
"ProfileIdc": 66,
"LevelIdc": 40,
"MbWidth": 120,
"MbHeight": 68,
"CropLeft": 0,
"CropRight": 0,
"CropTop": 0,
"CropBottom": 4,
"Width": 1920,
"Height": 1080
}
}
]
}
```

#### Stream Delete
###### Query
```bash
GET /stream/:uuid/delete
curl http://demo:[email protected]:8083/stream/demo/delete
```

###### Response
```json
{
"status": 1,
"payload": "success"
}
```

#### Stream hls play
###### Query
```bash
GET /stream/:uuid/hls/live/index.m3u8
curl http://127.0.0.1:8083/stream/demo/hls/live/index.m3u8
```

###### Response
```bash
index.m3u8
```
```bash
ffplay http://127.0.0.1:8083/stream/demo/hls/live/index.m3u8
```

## Limitations

Expand Down
34 changes: 31 additions & 3 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,46 @@
"url": "rtsp://admin:[email protected]/mpeg4",
"on_demand": false,
"debug": false,
"status": 0
"status": 1
},
"demo1": {
"name": "Проверка 2 ",
"url": "rtsp://admin:123456@10.128.18.211/mpeg4",
"name": "test name 1",
"url": "rtsp://admin:123456@127.0.0.1:550/mpeg4",
"on_demand": true,
"debug": false,
"status": 0
},
"demo2": {
"name": "Проверка 3",
"url": "rtsp://admin:[email protected]/mpeg4",
"on_demand": false,
"debug": false,
"status": 1
},
"demo4": {
"name": "test name 1",
"url": "rtsp://admin:[email protected]:550/mpeg4",
"on_demand": true,
"debug": false,
"status": 0
},
"demo5": {
"name": "test name 1",
"url": "rtsp://admin:[email protected]:550/mpeg4",
"on_demand": true,
"debug": false,
"status": 0
},
"demo6": {
"name": "test name 1",
"url": "rtsp://admin:[email protected]:550/mpeg4",
"on_demand": true,
"debug": false,
"status": 0
},
"demo7": {
"name": "test name 1",
"url": "rtsp://admin:[email protected]:550/mpeg4",
"on_demand": true,
"debug": false,
"status": 0
Expand Down
2 changes: 1 addition & 1 deletion storageClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func (obj *StorageST) ClientAdd(uuid string) (string, chan *av.Packet, error) {
return "", nil, err
}
ch := make(chan *av.Packet, 2000)
tmp.clients[cid] = ClientST{outgoingPacket: ch}
tmp.clients[cid] = ClientST{outgoingPacket: ch, signals: make(chan int, 100)}
tmp.ack = time.Now()
obj.Streams[uuid] = tmp
return cid, ch, nil
Expand Down
1 change: 1 addition & 0 deletions storageConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func NewStreamCore() *StorageST {
i2.clients = make(map[string]ClientST)
i2.ack = time.Now().Add(-255 * time.Hour)
i2.hlsSegmentBuffer = make(map[int]Segment)
i2.signals = make(chan int, 100)
tmp.Streams[i] = i2
}
return &tmp
Expand Down
8 changes: 7 additions & 1 deletion storageStream.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ func (obj *StorageST) List() map[string]StreamST {
return tmp
}

//curl --header "Content-Type: application/json" --request POST --data '{"name": "test name 1","url": "rtsp://admin:[email protected]:550/mpeg4", "on_demand": false,"debug": false}' http://demo:[email protected]:8083/stream/demo5/add
//StreamAdd add stream
func (obj *StorageST) StreamAdd(uuid string, val StreamST) error {
obj.mutex.Lock()
Expand All @@ -85,6 +86,11 @@ func (obj *StorageST) StreamAdd(uuid string, val StreamST) error {
val.clients = make(map[string]ClientST)
val.ack = time.Now().Add(-255 * time.Hour)
val.hlsSegmentBuffer = make(map[int]Segment)
val.signals = make(chan int, 100)
if !val.OnDemand {
val.runLock = true
go StreamServerRunStreamDo(uuid)
}
obj.Streams[uuid] = val
err := obj.SaveConfig()
if err != nil {
Expand All @@ -93,7 +99,7 @@ func (obj *StorageST) StreamAdd(uuid string, val StreamST) error {
return nil
}

//StreamAdd edit stream
//StreamEdit edit stream
func (obj *StorageST) StreamEdit(uuid string, val StreamST) error {
obj.mutex.Lock()
defer obj.mutex.Unlock()
Expand Down
Loading

0 comments on commit 63380fb

Please sign in to comment.