MCPcopy
hub / github.com/livekit/livekit / TestSubscribeToCodecUnsupported

Function TestSubscribeToCodecUnsupported

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

Source from the content-addressed store, hash-verified

949}
950
951func TestSubscribeToCodecUnsupported(t *testing.T) {
952 if testing.Short() {
953 t.SkipNow()
954 return
955 }
956
957 _, finish := setupSingleNodeTest("TestSubscribeToCodecUnsupported")
958 defer finish()
959
960 for _, testRTCServicePath := range testRTCServicePaths {
961 t.Run(fmt.Sprintf("testRTCServicePath=%s", testRTCServicePath.String()), func(t *testing.T) {
962 c1 := createRTCClient("c1", defaultServerPort, testRTCServicePath, nil)
963 // create a client that doesn't support H264
964 c2 := createRTCClient("c2", defaultServerPort, testRTCServicePath, &testclient.Options{
965 AutoSubscribe: true,
966 DisabledCodecs: []webrtc.RTPCodecCapability{
967 {MimeType: "video/H264"},
968 },
969 })
970 waitUntilConnected(t, c1, c2)
971
972 // publish a vp8 video track and ensure c2 receives it ok
973 t1, err := c1.AddStaticTrack("audio/opus", "audio", "webcam")
974 require.NoError(t, err)
975 defer t1.Stop()
976 t2, err := c1.AddStaticTrack("video/vp8", "video", "webcam")
977 require.NoError(t, err)
978 defer t2.Stop()
979
980 testutils.WithTimeout(t, func() string {
981 if len(c2.SubscribedTracks()) == 0 {
982 return "c2 was not subscribed to anything"
983 }
984 // should have received two tracks
985 if len(c2.SubscribedTracks()[c1.ID()]) != 2 {
986 return "c2 was not subscribed to tracks from c1"
987 }
988
989 tracks := c2.SubscribedTracks()[c1.ID()]
990 for _, t := range tracks {
991 if mime.IsMimeTypeStringVP8(t.Codec().MimeType) {
992 return ""
993 }
994 }
995 return "did not receive track with vp8"
996 })
997 require.Nil(t, c2.GetSubscriptionResponseAndClear())
998
999 // publish a h264 track and ensure c2 got subscription error
1000 t3, err := c1.AddStaticTrackWithCodec(webrtc.RTPCodecCapability{
1001 MimeType: "video/h264",
1002 ClockRate: 90000,
1003 SDPFmtpLine: "level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f",
1004 }, "videoscreen", "screen")
1005 defer t3.Stop()
1006 require.NoError(t, err)
1007
1008 var h264TrackID string

Callers

nothing calls this directly

Calls 14

WithTimeoutFunction · 0.92
setupSingleNodeTestFunction · 0.85
createRTCClientFunction · 0.85
waitUntilConnectedFunction · 0.85
AddStaticTrackMethod · 0.80
SubscribedTracksMethod · 0.80
GetRemoteParticipantMethod · 0.80
StopMethod · 0.65
IDMethod · 0.65
CodecMethod · 0.65

Tested by

no test coverage detected