Skip to content

Commit d7f2dd0

Browse files
authored
Merge pull request #128 from chriswiggins/ice-servers-port-minmax
Adds ability to set STUN/TURN, and WebRTC Min/Max Ports
2 parents 05b184b + 21fcde0 commit d7f2dd0

File tree

5 files changed

+65
-18
lines changed

5 files changed

+65
-18
lines changed

README.md

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,20 @@ $ docker run --name rtsp-to-web \
6161
### Server settings
6262

6363
```text
64-
debug - enable debug output
65-
log_level - log level (trace, debug, info, warning, error, fatal, or panic)
66-
67-
http_demo - serve static files
68-
http_debug - debug http api server
69-
http_login - http auth login
70-
http_password - http auth password
71-
http_port - http server port
72-
http_dir - path to serve static files from
64+
debug - enable debug output
65+
log_level - log level (trace, debug, info, warning, error, fatal, or panic)
66+
67+
http_demo - serve static files
68+
http_debug - debug http api server
69+
http_login - http auth login
70+
http_password - http auth password
71+
http_port - http server port
72+
http_dir - path to serve static files from
73+
ice_servers - array of servers to use for STUN/TURN
74+
ice_username - username to use for STUN/TURN
75+
ice_credential - credential to use for STUN/TURN
76+
webrtc_port_min - minimum WebRTC port to use (UDP)
77+
webrtc_port_max - maximum WebRTC port to use (UDP)
7378
7479
https
7580
https_auto_tls
@@ -78,24 +83,24 @@ https_cert
7883
https_key
7984
https_port
8085
81-
rtsp_port - rtsp server port
86+
rtsp_port - rtsp server port
8287
```
8388

8489
### Stream settings
8590

8691
```text
87-
name - stream name
92+
name - stream name
8893
```
8994

9095
### Channel settings
9196

9297
```text
93-
name - channel name
94-
url - channel rtsp url
95-
on_demand - stream mode static (run any time) or ondemand (run only has viewers)
96-
debug - enable debug output (RTSP client)
97-
audio - enable audio
98-
status - default stream status
98+
name - channel name
99+
url - channel rtsp url
100+
on_demand - stream mode static (run any time) or ondemand (run only has viewers)
101+
debug - enable debug output (RTSP client)
102+
audio - enable audio
103+
status - default stream status
99104
```
100105

101106
#### Authorization play video
@@ -138,6 +143,7 @@ file.php need response json
138143
"http_login": "demo",
139144
"http_password": "demo",
140145
"http_port": ":8083",
146+
"ice_servers": ["stun:stun.l.google.com:19302"],
141147
"rtsp_port": ":5541"
142148
},
143149
"streams": {

apiHTTPWebRTC.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func HTTPAPIServerStreamWebRTC(c *gin.Context) {
3333
}).Errorln(err.Error())
3434
return
3535
}
36-
muxerWebRTC := webrtc.NewMuxer(webrtc.Options{})
36+
muxerWebRTC := webrtc.NewMuxer(webrtc.Options{ICEServers: Storage.ServerICEServers(), ICEUsername: Storage.ServerICEUsername(), ICECredential: Storage.ServerICECredential(), PortMin: Storage.ServerWebRTCPortMin(), PortMax: Storage.ServerWebRTCPortMax()})
3737
answer, err := muxerWebRTC.WriteHeader(codecs, c.PostForm("data"))
3838
if err != nil {
3939
c.IndentedJSON(400, Message{Status: 0, Payload: err.Error()})

config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"https_cert": "server.crt",
1414
"https_key": "server.key",
1515
"https_port": ":443",
16+
"ice_servers": ["stun:stun.l.google.com:19302"],
1617
"log_level": "debug",
1718
"rtsp_port": ":5541",
1819
"token": {

storageServer.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,27 @@ func (obj *StorageST) ServerHTTPSKey() string {
112112
return obj.Server.HTTPSKey
113113
}
114114

115+
// ServerICEServers read ICE servers
116+
func (obj *StorageST) ServerICEServers() []string {
117+
obj.mutex.Lock()
118+
defer obj.mutex.Unlock()
119+
return obj.Server.ICEServers
120+
}
121+
122+
// ServerICEServers read ICE username
123+
func (obj *StorageST) ServerICEUsername() string {
124+
obj.mutex.Lock()
125+
defer obj.mutex.Unlock()
126+
return obj.Server.ICEUsername
127+
}
128+
129+
// ServerICEServers read ICE credential
130+
func (obj *StorageST) ServerICECredential() string {
131+
obj.mutex.Lock()
132+
defer obj.mutex.Unlock()
133+
return obj.Server.ICECredential
134+
}
135+
115136
//ServerTokenEnable read HTTPS Key options
116137
func (obj *StorageST) ServerTokenEnable() bool {
117138
obj.mutex.RLock()
@@ -125,3 +146,17 @@ func (obj *StorageST) ServerTokenBackend() string {
125146
defer obj.mutex.RUnlock()
126147
return obj.Server.Token.Backend
127148
}
149+
150+
// ServerWebRTCPortMin read WebRTC Port Min
151+
func (obj *StorageST) ServerWebRTCPortMin() uint16 {
152+
obj.mutex.Lock()
153+
defer obj.mutex.Unlock()
154+
return obj.Server.WebRTCPortMin
155+
}
156+
157+
// ServerWebRTCPortMax read WebRTC Port Max
158+
func (obj *StorageST) ServerWebRTCPortMax() uint16 {
159+
obj.mutex.Lock()
160+
defer obj.mutex.Unlock()
161+
return obj.Server.WebRTCPortMax
162+
}

storageStruct.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,12 @@ type ServerST struct {
6767
HTTPSKey string `json:"https_key" groups:"api,config"`
6868
HTTPSAutoTLSEnable bool `json:"https_auto_tls" groups:"api,config"`
6969
HTTPSAutoTLSName string `json:"https_auto_tls_name" groups:"api,config"`
70+
ICEServers []string `json:"ice_servers" groups:"api,config"`
71+
ICEUsername string `json:"ice_username" groups:"api,config"`
72+
ICECredential string `json:"ice_credential" groups:"api,config"`
7073
Token Token `json:"token,omitempty" groups:"api,config"`
74+
WebRTCPortMin uint16 `json:"webrtc_port_min" groups:"api,config"`
75+
WebRTCPortMax uint16 `json:"webrtc_port_max" groups:"api,config"`
7176
}
7277

7378
//Token auth

0 commit comments

Comments
 (0)