MCPcopy
hub / github.com/livekit/livekit / Test_RenegotiationWithDifferentCodecs

Function Test_RenegotiationWithDifferentCodecs

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

Source from the content-addressed store, hash-verified

485}
486
487func Test_RenegotiationWithDifferentCodecs(t *testing.T) {
488 if testing.Short() {
489 t.SkipNow()
490 return
491 }
492
493 _, finish := setupSingleNodeTest("TestRenegotiationWithDifferentCodecs")
494 defer finish()
495
496 for _, testRTCServicePath := range testRTCServicePaths {
497 t.Run(fmt.Sprintf("testRTCServicePath=%s", testRTCServicePath.String()), func(t *testing.T) {
498 c1 := createRTCClient("c1", defaultServerPort, testRTCServicePath, nil)
499 c2 := createRTCClient("c2", defaultServerPort, testRTCServicePath, nil)
500 waitUntilConnected(t, c1, c2)
501
502 // publish a vp8 video track and ensure clients receive it ok
503 t1, err := c1.AddStaticTrack("audio/opus", "audio", "webcam")
504 require.NoError(t, err)
505 defer t1.Stop()
506 t2, err := c1.AddStaticTrack("video/vp8", "video", "webcam")
507 require.NoError(t, err)
508 defer t2.Stop()
509
510 testutils.WithTimeout(t, func() string {
511 if len(c2.SubscribedTracks()) == 0 {
512 return "c2 was not subscribed to anything"
513 }
514 // should have received two tracks
515 if len(c2.SubscribedTracks()[c1.ID()]) != 2 {
516 return "c2 was not subscribed to tracks from c1"
517 }
518
519 tracks := c2.SubscribedTracks()[c1.ID()]
520 for _, t := range tracks {
521 if mime.IsMimeTypeStringVP8(t.Codec().MimeType) {
522 return ""
523
524 }
525 }
526 return "did not receive track with vp8"
527 })
528
529 t3, err := c1.AddStaticTrackWithCodec(webrtc.RTPCodecCapability{
530 MimeType: "video/h264",
531 ClockRate: 90000,
532 SDPFmtpLine: "level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f",
533 }, "videoscreen", "screen")
534 defer t3.Stop()
535 require.NoError(t, err)
536
537 testutils.WithTimeout(t, func() string {
538 if len(c2.SubscribedTracks()) == 0 {
539 return "c2's not subscribed to anything"
540 }
541 // should have received three tracks
542 if len(c2.SubscribedTracks()[c1.ID()]) != 3 {
543 return "c2's not subscribed to 3 tracks from c1"
544 }

Callers

nothing calls this directly

Calls 12

WithTimeoutFunction · 0.92
setupSingleNodeTestFunction · 0.85
createRTCClientFunction · 0.85
waitUntilConnectedFunction · 0.85
AddStaticTrackMethod · 0.80
SubscribedTracksMethod · 0.80
StopMethod · 0.65
IDMethod · 0.65
CodecMethod · 0.65
RunMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected