Source File
api.go
Belonging Package
github.com/pion/webrtc/v4
// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>// SPDX-License-Identifier: MIT//go:build !js// +build !jspackage webrtcimport ()// API allows configuration of a PeerConnection// with APIs that are available in the standard. This// lets you set custom behavior via the SettingEngine, configure// codecs via the MediaEngine and define custom media behaviors via// Interceptors.type API struct {settingEngine *SettingEnginemediaEngine *MediaEngineinterceptorRegistry *interceptor.Registryinterceptor interceptor.Interceptor // Generated per PeerConnection}// NewAPI Creates a new API object for keeping semi-global settings to WebRTC objects//// It uses the default Codecs and Interceptors unless you customize them// using WithMediaEngine and WithInterceptorRegistry respectively.func ( ...func(*API)) *API {:= &API{interceptor: &interceptor.NoOp{},settingEngine: &SettingEngine{},}for , := range {()}if .settingEngine.LoggerFactory == nil {.settingEngine.LoggerFactory = logging.NewDefaultLoggerFactory()}:= .settingEngine.LoggerFactory.NewLogger("api")if .mediaEngine == nil {.mediaEngine = &MediaEngine{}:= .mediaEngine.RegisterDefaultCodecs()if != nil {.Errorf("Failed to register default codecs %s", )}}if .interceptorRegistry == nil {.interceptorRegistry = &interceptor.Registry{}:= RegisterDefaultInterceptors(.mediaEngine, .interceptorRegistry)if != nil {.Errorf("Failed to register default interceptors %s", )}}return}// WithMediaEngine allows providing a MediaEngine to the API.// Settings can be changed after passing the engine to an API.// When a PeerConnection is created the MediaEngine is copied// and no more changes can be made.func ( *MediaEngine) func( *API) {return func( *API) {.mediaEngine =if .mediaEngine == nil {.mediaEngine = &MediaEngine{}}}}// WithSettingEngine allows providing a SettingEngine to the API.// Settings should not be changed after passing the engine to an API.func ( SettingEngine) func( *API) {return func( *API) {.settingEngine = &}}// WithInterceptorRegistry allows providing Interceptors to the API.// Settings should not be changed after passing the registry to an API.func ( *interceptor.Registry) func( *API) {return func( *API) {.interceptorRegistry =if .interceptorRegistry == nil {.interceptorRegistry = &interceptor.Registry{}}}}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |