webrtc: apply operator ICEServers override in subsystem.New for issue #23
This commit is contained in:
parent
b6d2a77f8b
commit
4364d9176f
1 changed files with 13 additions and 3 deletions
|
|
@ -85,6 +85,14 @@ func New(dataCfg config.DataWebRTC, logger log.Logger) (*Subsystem, error) {
|
||||||
}
|
}
|
||||||
coreCfg.NAT1To1IPs = nat1to1IPs
|
coreCfg.NAT1To1IPs = nat1to1IPs
|
||||||
|
|
||||||
|
// If the operator supplied explicit ICE server URIs via config/env,
|
||||||
|
// override the built-in defaults (typically Google's public STUN servers).
|
||||||
|
// An empty list means "keep the built-in defaults".
|
||||||
|
if len(dataCfg.ICEServers) > 0 {
|
||||||
|
coreCfg.ICEServers = make([]string, len(dataCfg.ICEServers))
|
||||||
|
copy(coreCfg.ICEServers, dataCfg.ICEServers)
|
||||||
|
}
|
||||||
|
|
||||||
factory, err := corewebrtc.NewPeerFactory(coreCfg)
|
factory, err := corewebrtc.NewPeerFactory(coreCfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("webrtc subsystem: build peer factory: %w", err)
|
return nil, fmt.Errorf("webrtc subsystem: build peer factory: %w", err)
|
||||||
|
|
@ -190,9 +198,11 @@ func (s *Subsystem) StreamCount() int {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ICEServerURIs returns the ICE server URI list from the core config.
|
// ICEServerURIs returns the ICE server URI list from the core config.
|
||||||
// Used by the WHEP handler to emit RFC 9429 §4.3 Link headers so that
|
// Used by the WHEP and WHIP handlers to emit RFC 9429 / RFC 9261 Link
|
||||||
// browsers can discover STUN/TURN servers without a separate signalling
|
// headers so that browsers can discover STUN/TURN servers without a
|
||||||
// round-trip.
|
// separate signalling round-trip. If the operator configured explicit
|
||||||
|
// servers via CORE_WEBRTC_ICE_SERVERS those are returned; otherwise
|
||||||
|
// the built-in Pion defaults are returned.
|
||||||
func (s *Subsystem) ICEServerURIs() []string {
|
func (s *Subsystem) ICEServerURIs() []string {
|
||||||
return s.coreCfg.ICEServers
|
return s.coreCfg.ICEServers
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue