Avoid defaultAPI

Relates to #434
This commit is contained in:
backkem
2019-02-21 20:58:41 +01:00
committed by Michiel De Backker
parent 4fe2728721
commit 36cf0df239
9 changed files with 33 additions and 57 deletions

View File

@@ -12,12 +12,19 @@ import (
)
func main() {
// Everything below is the pion-WebRTC API! Thanks for using it ❤️.
// Create a MediaEngine object to configure the supported codec
m := webrtc.MediaEngine{}
// Setup the codecs you want to use.
// We'll use a VP8 codec but you can also define your own
webrtc.RegisterCodec(webrtc.NewRTPOpusCodec(webrtc.DefaultPayloadTypeOpus, 48000, 2))
webrtc.RegisterCodec(webrtc.NewRTPVP8Codec(webrtc.DefaultPayloadTypeVP8, 90000))
m.RegisterCodec(webrtc.NewRTPOpusCodec(webrtc.DefaultPayloadTypeOpus, 48000, 2))
m.RegisterCodec(webrtc.NewRTPVP8Codec(webrtc.DefaultPayloadTypeVP8, 90000))
// Create the API object with the MediaEngine
api := webrtc.NewAPI(webrtc.WithMediaEngine(m))
// Everything below is the pion-WebRTC API! Thanks for using it ❤️.
// Prepare the configuration
config := webrtc.Configuration{
@@ -29,7 +36,7 @@ func main() {
}
// Create a new RTCPeerConnection
peerConnection, err := webrtc.NewPeerConnection(config)
peerConnection, err := api.NewPeerConnection(config)
if err != nil {
panic(err)
}