Merge pull request #17 from travishaagen/turn-creds
Add username and credential arguments to config options
This commit is contained in:
commit
be0abf0857
@ -37,8 +37,15 @@ type Stream struct {
|
||||
track *webrtc.TrackLocalStaticSample
|
||||
}
|
||||
type Options struct {
|
||||
// ICEServers is a required array of ICE server URLs to connect to (e.g., STUN or TURN server URLs)
|
||||
ICEServers []string
|
||||
// ICEUsername is an optional username for authenticating with the given ICEServers
|
||||
ICEUsername string
|
||||
// ICECredential is an optional credential (i.e., password) for authenticating with the given ICEServers
|
||||
ICECredential string
|
||||
// PortMin is an optional minimum (inclusive) ephemeral UDP port range for the ICEServers connections
|
||||
PortMin uint16
|
||||
// PortMin is an optional maximum (inclusive) ephemeral UDP port range for the ICEServers connections
|
||||
PortMax uint16
|
||||
}
|
||||
|
||||
@ -50,7 +57,12 @@ func NewMuxer(options Options) *Muxer {
|
||||
func (element *Muxer) NewPeerConnection(configuration webrtc.Configuration) (*webrtc.PeerConnection, error) {
|
||||
if len(element.Options.ICEServers) > 0 {
|
||||
log.Println("Set ICEServers", element.Options.ICEServers)
|
||||
configuration.ICEServers = append(configuration.ICEServers, webrtc.ICEServer{URLs: element.Options.ICEServers})
|
||||
configuration.ICEServers = append(configuration.ICEServers, webrtc.ICEServer{
|
||||
URLs: element.Options.ICEServers,
|
||||
Username: element.Options.ICEUsername,
|
||||
Credential: element.Options.ICECredential,
|
||||
CredentialType: webrtc.ICECredentialTypePassword,
|
||||
})
|
||||
}
|
||||
m := &webrtc.MediaEngine{}
|
||||
if err := m.RegisterDefaultCodecs(); err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user