直播:后台 JWT 推流、前台画中画;WebRTC 服务与 Nginx WebSocket 代理
Made-with: Cursor
This commit is contained in:
77
server/vendor/github.com/pion/webrtc/v3/api.go
generated
vendored
Normal file
77
server/vendor/github.com/pion/webrtc/v3/api.go
generated
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
//go:build !js
|
||||
// +build !js
|
||||
|
||||
package webrtc
|
||||
|
||||
import (
|
||||
"github.com/pion/interceptor"
|
||||
"github.com/pion/logging"
|
||||
)
|
||||
|
||||
// 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 *SettingEngine
|
||||
mediaEngine *MediaEngine
|
||||
interceptorRegistry *interceptor.Registry
|
||||
|
||||
interceptor interceptor.Interceptor // Generated per PeerConnection
|
||||
}
|
||||
|
||||
// NewAPI Creates a new API object for keeping semi-global settings to WebRTC objects
|
||||
func NewAPI(options ...func(*API)) *API {
|
||||
a := &API{
|
||||
interceptor: &interceptor.NoOp{},
|
||||
settingEngine: &SettingEngine{},
|
||||
mediaEngine: &MediaEngine{},
|
||||
interceptorRegistry: &interceptor.Registry{},
|
||||
}
|
||||
|
||||
for _, o := range options {
|
||||
o(a)
|
||||
}
|
||||
|
||||
if a.settingEngine.LoggerFactory == nil {
|
||||
a.settingEngine.LoggerFactory = logging.NewDefaultLoggerFactory()
|
||||
}
|
||||
|
||||
return a
|
||||
}
|
||||
|
||||
// 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 WithMediaEngine(m *MediaEngine) func(a *API) {
|
||||
return func(a *API) {
|
||||
a.mediaEngine = m
|
||||
if a.mediaEngine == nil {
|
||||
a.mediaEngine = &MediaEngine{}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// WithSettingEngine allows providing a SettingEngine to the API.
|
||||
// Settings should not be changed after passing the engine to an API.
|
||||
func WithSettingEngine(s SettingEngine) func(a *API) {
|
||||
return func(a *API) {
|
||||
a.settingEngine = &s
|
||||
}
|
||||
}
|
||||
|
||||
// WithInterceptorRegistry allows providing Interceptors to the API.
|
||||
// Settings should not be changed after passing the registry to an API.
|
||||
func WithInterceptorRegistry(ir *interceptor.Registry) func(a *API) {
|
||||
return func(a *API) {
|
||||
a.interceptorRegistry = ir
|
||||
if a.interceptorRegistry == nil {
|
||||
a.interceptorRegistry = &interceptor.Registry{}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user