More test cases for fire track by sdp (#3248)

* More test cases for fire track by sdp

* name
This commit is contained in:
cnderrauber
2024-12-13 21:02:26 +08:00
committed by GitHub
parent 5dd6858acf
commit 499fbd2a1d
+32 -9
View File
@@ -711,12 +711,37 @@ func TestFireTrackBySdp(t *testing.T) {
_, finish := setupSingleNodeTest("TestFireTrackBySdp") _, finish := setupSingleNodeTest("TestFireTrackBySdp")
defer finish() defer finish()
c1 := createRTCClient("c1", defaultServerPort, &testclient.Options{ var cases = []struct {
name string
codecs []webrtc.RTPCodecCapability
pubSDK livekit.ClientInfo_SDK
}{
{
name: "js client could pub a/v tracks",
codecs: []webrtc.RTPCodecCapability{
{MimeType: "video/H264"},
{MimeType: "audio/opus"},
},
pubSDK: livekit.ClientInfo_JS,
},
{
name: "go client could pub audio tracks",
codecs: []webrtc.RTPCodecCapability{
{MimeType: "audio/opus"},
},
pubSDK: livekit.ClientInfo_GO,
},
}
for _, c := range cases {
codecs, sdk := c.codecs, c.pubSDK
t.Run(c.name, func(t *testing.T) {
c1 := createRTCClient(c.name+"_c1", defaultServerPort, &testclient.Options{
ClientInfo: &livekit.ClientInfo{ ClientInfo: &livekit.ClientInfo{
Sdk: livekit.ClientInfo_JS, Sdk: sdk,
}, },
}) })
c2 := createRTCClient("c2", defaultServerPort, &testclient.Options{ c2 := createRTCClient(c.name+"_c2", defaultServerPort, &testclient.Options{
AutoSubscribe: true, AutoSubscribe: true,
ClientInfo: &livekit.ClientInfo{ ClientInfo: &livekit.ClientInfo{
Sdk: livekit.ClientInfo_JS, Sdk: livekit.ClientInfo_JS,
@@ -728,10 +753,6 @@ func TestFireTrackBySdp(t *testing.T) {
c2.Stop() c2.Stop()
}() }()
codecs := []webrtc.RTPCodecCapability{
{MimeType: "video/H264"},
{MimeType: "audio/opus"},
}
// publish tracks and don't write any packets // publish tracks and don't write any packets
for _, codec := range codecs { for _, codec := range codecs {
_, err := c1.AddStaticTrackWithCodec(codec, codec.MimeType, codec.MimeType, testclient.AddTrackNoWriter()) _, err := c1.AddStaticTrackWithCodec(codec, codec.MimeType, codec.MimeType, testclient.AddTrackNoWriter())
@@ -739,7 +760,7 @@ func TestFireTrackBySdp(t *testing.T) {
} }
require.Eventually(t, func() bool { require.Eventually(t, func() bool {
return len(c2.SubscribedTracks()[c1.ID()]) == 2 return len(c2.SubscribedTracks()[c1.ID()]) == len(codecs)
}, 5*time.Second, 10*time.Millisecond) }, 5*time.Second, 10*time.Millisecond)
var found int var found int
@@ -754,5 +775,7 @@ func TestFireTrackBySdp(t *testing.T) {
} }
} }
} }
require.Equal(t, 2, found) require.Equal(t, len(codecs), found)
})
}
} }