Skip to content

Commit

Permalink
Adds ability to set STUN/TURN, and WebRTC Min/Max Ports
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswiggins committed Mar 21, 2022
1 parent 05b184b commit f267878
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 1 deletion.
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
3 changes: 3 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
"https_cert": "server.crt",
"https_key": "server.key",
"https_port": ":443",
"ice_servers": ["stun:stun.l.google.com:19302"],
"ice_username": "",
"ice_credential": "",
"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"`
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

0 comments on commit f267878

Please sign in to comment.