diff --git a/peerconnection_media_test.go b/peerconnection_media_test.go index bfc3f33a..b4956b5d 100644 --- a/peerconnection_media_test.go +++ b/peerconnection_media_test.go @@ -7,11 +7,13 @@ import ( "fmt" "io" "math/rand" + "reflect" "sync" "testing" "time" "github.com/pion/rtcp" + "github.com/pion/sdp/v2" "github.com/pion/transport/test" "github.com/pion/webrtc/v2/pkg/media" ) @@ -452,3 +454,45 @@ func TestPeerConnection_Media_Closed(t *testing.T) { t.Fatal(err) } } + +func TestOfferRejectionMissingCodec(t *testing.T) { + api := NewAPI() + api.mediaEngine.RegisterDefaultCodecs() + pc, err := api.NewPeerConnection(Configuration{}) + if err != nil { + t.Fatal(err) + } + + noCodecAPI := NewAPI() + noCodecPC, err := noCodecAPI.NewPeerConnection(Configuration{}) + if err != nil { + t.Fatal(err) + } + + track, err := pc.NewTrack(DefaultPayloadTypeVP8, rand.Uint32(), "video", "pion2") + if err != nil { + t.Fatal(err) + } + if _, err := pc.AddTrack(track); err != nil { + t.Fatal(err) + } + + if err := signalPair(pc, noCodecPC); err != nil { + t.Fatal(err) + } + + var sdes sdp.SessionDescription + if err := sdes.Unmarshal([]byte(pc.RemoteDescription().SDP)); err != nil { + t.Fatal(err) + } + var videoDesc sdp.MediaDescription + for _, m := range sdes.MediaDescriptions { + if m.MediaName.Media == "video" { + videoDesc = *m + } + } + + if got, want := videoDesc.MediaName.Formats, []string{"0"}; !reflect.DeepEqual(got, want) { + t.Fatalf("rejecting unknown codec: sdp m=%s, want trailing 0", *videoDesc.MediaName.String()) + } +} diff --git a/peerconnection_test.go b/peerconnection_test.go index 52bae15d..88cb1ad0 100644 --- a/peerconnection_test.go +++ b/peerconnection_test.go @@ -2,13 +2,11 @@ package webrtc import ( "fmt" - "math/rand" "reflect" "sync" "testing" "time" - "github.com/pion/sdp/v2" "github.com/pion/webrtc/v2/pkg/rtcerr" "github.com/stretchr/testify/assert" ) @@ -318,48 +316,6 @@ func TestCreateOfferAnswer(t *testing.T) { } } -func TestOfferRejectionMissingCodec(t *testing.T) { - api := NewAPI() - api.mediaEngine.RegisterDefaultCodecs() - pc, err := api.NewPeerConnection(Configuration{}) - if err != nil { - t.Fatal(err) - } - - noCodecAPI := NewAPI() - noCodecPC, err := noCodecAPI.NewPeerConnection(Configuration{}) - if err != nil { - t.Fatal(err) - } - - track, err := pc.NewTrack(DefaultPayloadTypeVP8, rand.Uint32(), "video", "pion2") - if err != nil { - t.Fatal(err) - } - if _, err := pc.AddTrack(track); err != nil { - t.Fatal(err) - } - - if err := signalPair(pc, noCodecPC); err != nil { - t.Fatal(err) - } - - var sdes sdp.SessionDescription - if err := sdes.Unmarshal([]byte(pc.RemoteDescription().SDP)); err != nil { - t.Fatal(err) - } - var videoDesc sdp.MediaDescription - for _, m := range sdes.MediaDescriptions { - if m.MediaName.Media == "video" { - videoDesc = *m - } - } - - if got, want := videoDesc.MediaName.Formats, []string{"0"}; !reflect.DeepEqual(got, want) { - t.Fatalf("rejecting unknown codec: sdp m=%s, want trailing 0", *videoDesc.MediaName.String()) - } -} - func TestPeerConnection_EventHandlers(t *testing.T) { pcOffer, err := NewPeerConnection(Configuration{}) assert.NoError(t, err)