mirror of
https://github.com/pion/webrtc.git
synced 2025-10-05 07:06:51 +08:00
Implement Interceptors
Provide API so that handling around RTP can be easily defined by the user. See the design doc here[0] [0] https://github.com/pion/webrtc-v3-design/issues/34
This commit is contained in:
14
api.go
14
api.go
@@ -3,6 +3,7 @@
|
||||
package webrtc
|
||||
|
||||
import (
|
||||
"github.com/pion/interceptor"
|
||||
"github.com/pion/logging"
|
||||
)
|
||||
|
||||
@@ -13,6 +14,7 @@ import (
|
||||
type API struct {
|
||||
settingEngine *SettingEngine
|
||||
mediaEngine *MediaEngine
|
||||
interceptor interceptor.Interceptor
|
||||
}
|
||||
|
||||
// NewAPI Creates a new API object for keeping semi-global settings to WebRTC objects
|
||||
@@ -35,6 +37,10 @@ func NewAPI(options ...func(*API)) *API {
|
||||
a.mediaEngine = &MediaEngine{}
|
||||
}
|
||||
|
||||
if a.interceptor == nil {
|
||||
a.interceptor = &interceptor.NoOp{}
|
||||
}
|
||||
|
||||
return a
|
||||
}
|
||||
|
||||
@@ -57,3 +63,11 @@ func WithSettingEngine(s SettingEngine) 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(interceptorRegistry *interceptor.Registry) func(a *API) {
|
||||
return func(a *API) {
|
||||
a.interceptor = interceptorRegistry.Build()
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user