Skip to content

Commit 313ca8c

Browse files
andreinSean-Der
authored andcommitted
Refactor NewPeerConnection
Skip registering the default codecs and interceptors in NewPeerConnection. The NewAPI() function already registers them by default (since #2630)
1 parent fb82fff commit 313ca8c

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

peerconnection.go

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -89,24 +89,13 @@ type PeerConnection struct {
8989
interceptorRTCPWriter interceptor.RTCPWriter
9090
}
9191

92-
// NewPeerConnection creates a PeerConnection with the default codecs and
93-
// interceptors. See RegisterDefaultCodecs and RegisterDefaultInterceptors.
92+
// NewPeerConnection creates a PeerConnection with the default codecs and interceptors.
9493
//
95-
// If you wish to customize the set of available codecs or the set of
96-
// active interceptors, create a MediaEngine and call api.NewPeerConnection
97-
// instead of this function.
94+
// If you wish to customize the set of available codecs and/or the set of active interceptors,
95+
// create an API with a custom MediaEngine and/or interceptor.Registry,
96+
// then call API.NewPeerConnection() instead of this function.
9897
func NewPeerConnection(configuration Configuration) (*PeerConnection, error) {
99-
m := &MediaEngine{}
100-
if err := m.RegisterDefaultCodecs(); err != nil {
101-
return nil, err
102-
}
103-
104-
i := &interceptor.Registry{}
105-
if err := RegisterDefaultInterceptors(m, i); err != nil {
106-
return nil, err
107-
}
108-
109-
api := NewAPI(WithMediaEngine(m), WithInterceptorRegistry(i))
98+
api := NewAPI()
11099
return api.NewPeerConnection(configuration)
111100
}
112101

0 commit comments

Comments
 (0)