Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds ability to set STUN/TURN, and WebRTC Min/Max Ports #128

Merged
merged 2 commits into from
Mar 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 23 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,20 @@ $ docker run --name rtsp-to-web \
### Server settings

```text
debug - enable debug output
log_level - log level (trace, debug, info, warning, error, fatal, or panic)

http_demo - serve static files
http_debug - debug http api server
http_login - http auth login
http_password - http auth password
http_port - http server port
http_dir - path to serve static files from
debug - enable debug output
log_level - log level (trace, debug, info, warning, error, fatal, or panic)

http_demo - serve static files
http_debug - debug http api server
http_login - http auth login
http_password - http auth password
http_port - http server port
http_dir - path to serve static files from
ice_servers - array of servers to use for STUN/TURN
ice_username - username to use for STUN/TURN
ice_credential - credential to use for STUN/TURN
webrtc_port_min - minimum WebRTC port to use (UDP)
webrtc_port_max - maximum WebRTC port to use (UDP)

https
https_auto_tls
Expand All @@ -78,24 +83,24 @@ https_cert
https_key
https_port

rtsp_port - rtsp server port
rtsp_port - rtsp server port
```

### Stream settings

```text
name - stream name
name - stream name
```

### Channel settings

```text
name - channel name
url - channel rtsp url
on_demand - stream mode static (run any time) or ondemand (run only has viewers)
debug - enable debug output (RTSP client)
audio - enable audio
status - default stream status
name - channel name
url - channel rtsp url
on_demand - stream mode static (run any time) or ondemand (run only has viewers)
debug - enable debug output (RTSP client)
audio - enable audio
status - default stream status
```

#### Authorization play video
Expand Down Expand Up @@ -138,6 +143,7 @@ file.php need response json
"http_login": "demo",
"http_password": "demo",
"http_port": ":8083",
"ice_servers": ["stun:stun.l.google.com:19302"],
"rtsp_port": ":5541"
},
"streams": {
Expand Down
2 changes: 1 addition & 1 deletion apiHTTPWebRTC.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func HTTPAPIServerStreamWebRTC(c *gin.Context) {
}).Errorln(err.Error())
return
}
muxerWebRTC := webrtc.NewMuxer(webrtc.Options{})
muxerWebRTC := webrtc.NewMuxer(webrtc.Options{ICEServers: Storage.ServerICEServers(), ICEUsername: Storage.ServerICEUsername(), ICECredential: Storage.ServerICECredential(), PortMin: Storage.ServerWebRTCPortMin(), PortMax: Storage.ServerWebRTCPortMax()})
answer, err := muxerWebRTC.WriteHeader(codecs, c.PostForm("data"))
if err != nil {
c.IndentedJSON(400, Message{Status: 0, Payload: err.Error()})
Expand Down
1 change: 1 addition & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"https_cert": "server.crt",
"https_key": "server.key",
"https_port": ":443",
"ice_servers": ["stun:stun.l.google.com:19302"],
"log_level": "debug",
"rtsp_port": ":5541",
"token": {
Expand Down
35 changes: 35 additions & 0 deletions storageServer.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,27 @@ func (obj *StorageST) ServerHTTPSKey() string {
return obj.Server.HTTPSKey
}

// ServerICEServers read ICE servers
func (obj *StorageST) ServerICEServers() []string {
obj.mutex.Lock()
defer obj.mutex.Unlock()
return obj.Server.ICEServers
}

// ServerICEServers read ICE username
func (obj *StorageST) ServerICEUsername() string {
obj.mutex.Lock()
defer obj.mutex.Unlock()
return obj.Server.ICEUsername
}

// ServerICEServers read ICE credential
func (obj *StorageST) ServerICECredential() string {
obj.mutex.Lock()
defer obj.mutex.Unlock()
return obj.Server.ICECredential
}

//ServerTokenEnable read HTTPS Key options
func (obj *StorageST) ServerTokenEnable() bool {
obj.mutex.RLock()
Expand All @@ -125,3 +146,17 @@ func (obj *StorageST) ServerTokenBackend() string {
defer obj.mutex.RUnlock()
return obj.Server.Token.Backend
}

// ServerWebRTCPortMin read WebRTC Port Min
func (obj *StorageST) ServerWebRTCPortMin() uint16 {
obj.mutex.Lock()
defer obj.mutex.Unlock()
return obj.Server.WebRTCPortMin
}

// ServerWebRTCPortMax read WebRTC Port Max
func (obj *StorageST) ServerWebRTCPortMax() uint16 {
obj.mutex.Lock()
defer obj.mutex.Unlock()
return obj.Server.WebRTCPortMax
}
5 changes: 5 additions & 0 deletions storageStruct.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@ type ServerST struct {
HTTPSKey string `json:"https_key" groups:"api,config"`
HTTPSAutoTLSEnable bool `json:"https_auto_tls" groups:"api,config"`
HTTPSAutoTLSName string `json:"https_auto_tls_name" groups:"api,config"`
ICEServers []string `json:"ice_servers" groups:"api,config"`
allenporter marked this conversation as resolved.
Show resolved Hide resolved
ICEUsername string `json:"ice_username" groups:"api,config"`
ICECredential string `json:"ice_credential" groups:"api,config"`
Token Token `json:"token,omitempty" groups:"api,config"`
WebRTCPortMin uint16 `json:"webrtc_port_min" groups:"api,config"`
WebRTCPortMax uint16 `json:"webrtc_port_max" groups:"api,config"`
}

//Token auth
Expand Down