Set custom pion API for WebRTC client
This commit is contained in:
+10
-7
@@ -32,17 +32,20 @@ func Init() {
|
|||||||
address := cfg.Mod.Listen
|
address := cfg.Mod.Listen
|
||||||
|
|
||||||
// create pionAPI with custom codecs list and custom network settings
|
// create pionAPI with custom codecs list and custom network settings
|
||||||
pionAPI, err := webrtc.NewAPI(address)
|
serverAPI, err := webrtc.NewAPI(address)
|
||||||
if pionAPI == nil {
|
if err != nil {
|
||||||
log.Error().Err(err).Caller().Send()
|
log.Error().Err(err).Caller().Send()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
// use same API for WebRTC server and client if no address
|
||||||
log.Warn().Err(err).Caller().Send()
|
clientAPI := serverAPI
|
||||||
} else if address != "" {
|
|
||||||
|
if address != "" {
|
||||||
log.Info().Str("addr", address).Msg("[webrtc] listen")
|
log.Info().Str("addr", address).Msg("[webrtc] listen")
|
||||||
_, Port, _ = net.SplitHostPort(address)
|
_, Port, _ = net.SplitHostPort(address)
|
||||||
|
|
||||||
|
clientAPI, _ = webrtc.NewAPI("")
|
||||||
}
|
}
|
||||||
|
|
||||||
pionConf := pion.Configuration{
|
pionConf := pion.Configuration{
|
||||||
@@ -52,9 +55,9 @@ func Init() {
|
|||||||
|
|
||||||
newPeerConnection = func(isServer bool) (*pion.PeerConnection, error) {
|
newPeerConnection = func(isServer bool) (*pion.PeerConnection, error) {
|
||||||
if isServer {
|
if isServer {
|
||||||
return pionAPI.NewPeerConnection(pionConf)
|
return serverAPI.NewPeerConnection(pionConf)
|
||||||
} else {
|
} else {
|
||||||
return pion.NewPeerConnection(pionConf)
|
return clientAPI.NewPeerConnection(pionConf)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user