MCPcopy
hub / github.com/livekit/livekit / TestFireTrackBySdp

Function TestFireTrackBySdp

test/singlenode_test.go:1184–1259  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1182}
1183
1184func TestFireTrackBySdp(t *testing.T) {
1185 _, finish := setupSingleNodeTest("TestFireTrackBySdp")
1186 defer finish()
1187
1188 var cases = []struct {
1189 name string
1190 codecs []webrtc.RTPCodecCapability
1191 pubSDK livekit.ClientInfo_SDK
1192 }{
1193 {
1194 name: "js client could pub a/v tracks",
1195 codecs: []webrtc.RTPCodecCapability{
1196 {MimeType: mime.MimeTypeH264.String()},
1197 {MimeType: mime.MimeTypeOpus.String()},
1198 },
1199 pubSDK: livekit.ClientInfo_JS,
1200 },
1201 {
1202 name: "go client could pub audio tracks",
1203 codecs: []webrtc.RTPCodecCapability{
1204 {MimeType: "audio/opus"},
1205 },
1206 pubSDK: livekit.ClientInfo_GO,
1207 },
1208 }
1209
1210 for _, c := range cases {
1211 codecs, sdk := c.codecs, c.pubSDK
1212 t.Run(c.name, func(t *testing.T) {
1213 for _, testRTCServicePath := range testRTCServicePaths {
1214 t.Run(fmt.Sprintf("testRTCServicePath=%s", testRTCServicePath.String()), func(t *testing.T) {
1215 c1 := createRTCClient(c.name+"_c1", defaultServerPort, testRTCServicePath, &testclient.Options{
1216 ClientInfo: &livekit.ClientInfo{
1217 Sdk: sdk,
1218 },
1219 })
1220 c2 := createRTCClient(c.name+"_c2", defaultServerPort, testRTCServicePath, &testclient.Options{
1221 AutoSubscribe: true,
1222 ClientInfo: &livekit.ClientInfo{
1223 Sdk: livekit.ClientInfo_JS,
1224 },
1225 })
1226 waitUntilConnected(t, c1, c2)
1227 defer func() {
1228 c1.Stop()
1229 c2.Stop()
1230 }()
1231
1232 // publish tracks and don't write any packets
1233 for _, codec := range codecs {
1234 _, err := c1.AddStaticTrackWithCodec(codec, codec.MimeType, codec.MimeType, testclient.AddTrackNoWriter())
1235 require.NoError(t, err)
1236 }
1237
1238 require.Eventually(t, func() bool {
1239 return len(c2.SubscribedTracks()[c1.ID()]) == len(codecs)
1240 }, 5*time.Second, 10*time.Millisecond)
1241

Callers

nothing calls this directly

Calls 11

setupSingleNodeTestFunction · 0.85
createRTCClientFunction · 0.85
waitUntilConnectedFunction · 0.85
SubscribedTracksMethod · 0.80
GetPublishedTrackIDsMethod · 0.80
StopMethod · 0.65
IDMethod · 0.65
CodecMethod · 0.65
StringMethod · 0.45
RunMethod · 0.45

Tested by

no test coverage detected