Skip to content

Commit

Permalink
Refactor NewPeerConnection
Browse files Browse the repository at this point in the history
Skip registering the default codecs and interceptors in
NewPeerConnection.
The NewAPI() function already registers them by default  (since #2630)
  • Loading branch information
andrein committed Dec 11, 2023
1 parent 21c5a71 commit 54356ed
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions peerconnection.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,24 +89,13 @@ type PeerConnection struct {
interceptorRTCPWriter interceptor.RTCPWriter
}

// NewPeerConnection creates a PeerConnection with the default codecs and
// interceptors. See RegisterDefaultCodecs and RegisterDefaultInterceptors.
// NewPeerConnection creates a PeerConnection with the default codecs and interceptors.
//
// If you wish to customize the set of available codecs or the set of
// active interceptors, create a MediaEngine and call api.NewPeerConnection
// instead of this function.
// If you wish to customize the set of available codecs and/or the set of active interceptors,
// create an API with a custom MediaEngine and/or interceptor.Registry,
// then call API.NewPeerConnection() instead of this function.
func NewPeerConnection(configuration Configuration) (*PeerConnection, error) {
m := &MediaEngine{}
if err := m.RegisterDefaultCodecs(); err != nil {
return nil, err
}

i := &interceptor.Registry{}
if err := RegisterDefaultInterceptors(m, i); err != nil {
return nil, err
}

api := NewAPI(WithMediaEngine(m), WithInterceptorRegistry(i))
api := NewAPI()
return api.NewPeerConnection(configuration)
}

Expand Down

0 comments on commit 54356ed

Please sign in to comment.