(t *testing.T)
| 1259 | } |
| 1260 | |
| 1261 | func TestSinglePublisherDataTrack(t *testing.T) { |
| 1262 | if testing.Short() { |
| 1263 | t.SkipNow() |
| 1264 | return |
| 1265 | } |
| 1266 | |
| 1267 | s, finish := setupSingleNodeTest("TestSinglePublisherDataTrack") |
| 1268 | defer finish() |
| 1269 | |
| 1270 | for _, testRTCServicePath := range testRTCServicePaths { |
| 1271 | t.Run(fmt.Sprintf("testRTCServicePath=%s", testRTCServicePath.String()), func(t *testing.T) { |
| 1272 | c1 := createRTCClient("c1", defaultServerPort, testRTCServicePath, &testclient.Options{AutoSubscribeDataTrack: true}) |
| 1273 | c2 := createRTCClient("c2", defaultServerPort, testRTCServicePath, &testclient.Options{AutoSubscribeDataTrack: true}) |
| 1274 | waitUntilConnected(t, c1, c2) |
| 1275 | |
| 1276 | // publish a couple of data tracks and ensure clients receive it ok |
| 1277 | dt1, err := c1.PublishDataTrack() |
| 1278 | require.NoError(t, err) |
| 1279 | defer dt1.Stop() |
| 1280 | |
| 1281 | dt2, err := c1.PublishDataTrack() |
| 1282 | require.NoError(t, err) |
| 1283 | defer dt2.Stop() |
| 1284 | |
| 1285 | testutils.WithTimeout(t, func() string { |
| 1286 | if len(c2.SubscribedDataTracks()) == 0 { |
| 1287 | return "c2 was not subscribed to any data tracks" |
| 1288 | } |
| 1289 | // should have received two data tracks |
| 1290 | if len(c2.SubscribedDataTracks()[c1.ID()]) != 2 { |
| 1291 | return "c2 didn't subscribe to both data tracks from c1" |
| 1292 | } |
| 1293 | return "" |
| 1294 | }) |
| 1295 | |
| 1296 | // a new client joins and should get the initial stream |
| 1297 | c3 := createRTCClient("c3", defaultServerPort, testRTCServicePath, &testclient.Options{AutoSubscribeDataTrack: true}) |
| 1298 | |
| 1299 | // ensure that new client that has joined also received data tracks |
| 1300 | waitUntilConnected(t, c3) |
| 1301 | testutils.WithTimeout(t, func() string { |
| 1302 | if len(c3.SubscribedDataTracks()) == 0 { |
| 1303 | return "c3 didn't subscribe to any data tracks" |
| 1304 | } |
| 1305 | // should have received two data tracks |
| 1306 | if len(c3.SubscribedDataTracks()[c1.ID()]) != 2 { |
| 1307 | return "c3 didn't subscribe to tracks from c1" |
| 1308 | } |
| 1309 | return "" |
| 1310 | }) |
| 1311 | |
| 1312 | // ensure that the data track ids are generated by server |
| 1313 | tracks := c3.SubscribedDataTracks()[c1.ID()] |
| 1314 | for _, tr := range tracks { |
| 1315 | require.True(t, strings.HasPrefix(string(tr.ID()), "DTR_"), "data track should begin with DTR") |
| 1316 | } |
| 1317 | |
| 1318 | // when c3 disconnects, ensure subscriber is cleaned up correctly |
nothing calls this directly
no test coverage detected
searching dependent graphs…