mirror of
https://github.com/pion/webrtc.git
synced 2025-10-04 23:02:48 +08:00
Move missing codec test to media_test
So it doesn't conflict with WASM. Related to #449
This commit is contained in:
@@ -7,11 +7,13 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
"reflect"
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/pion/rtcp"
|
"github.com/pion/rtcp"
|
||||||
|
"github.com/pion/sdp/v2"
|
||||||
"github.com/pion/transport/test"
|
"github.com/pion/transport/test"
|
||||||
"github.com/pion/webrtc/v2/pkg/media"
|
"github.com/pion/webrtc/v2/pkg/media"
|
||||||
)
|
)
|
||||||
@@ -452,3 +454,45 @@ func TestPeerConnection_Media_Closed(t *testing.T) {
|
|||||||
t.Fatal(err)
|
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())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -2,13 +2,11 @@ package webrtc
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/pion/sdp/v2"
|
|
||||||
"github.com/pion/webrtc/v2/pkg/rtcerr"
|
"github.com/pion/webrtc/v2/pkg/rtcerr"
|
||||||
"github.com/stretchr/testify/assert"
|
"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) {
|
func TestPeerConnection_EventHandlers(t *testing.T) {
|
||||||
pcOffer, err := NewPeerConnection(Configuration{})
|
pcOffer, err := NewPeerConnection(Configuration{})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
Reference in New Issue
Block a user