TestDeviceCodecOverride checks that codecs that are incompatible with a device is not negotiated by the server
(t *testing.T)
| 881 | // TestDeviceCodecOverride checks that codecs that are incompatible with a device is not |
| 882 | // negotiated by the server |
| 883 | func TestDeviceCodecOverride(t *testing.T) { |
| 884 | if testing.Short() { |
| 885 | t.SkipNow() |
| 886 | return |
| 887 | } |
| 888 | |
| 889 | _, finish := setupSingleNodeTest("TestDeviceCodecOverride") |
| 890 | defer finish() |
| 891 | |
| 892 | for _, testRTCServicePath := range testRTCServicePaths { |
| 893 | t.Run(fmt.Sprintf("testRTCServicePath=%s", testRTCServicePath.String()), func(t *testing.T) { |
| 894 | // simulate device that isn't compatible with H.264 |
| 895 | c1 := createRTCClient("c1", defaultServerPort, testRTCServicePath, &testclient.Options{ |
| 896 | ClientInfo: &livekit.ClientInfo{ |
| 897 | Os: "android", |
| 898 | DeviceModel: "Xiaomi 2201117TI", |
| 899 | }, |
| 900 | }) |
| 901 | defer c1.Stop() |
| 902 | waitUntilConnected(t, c1) |
| 903 | |
| 904 | // it doesn't really matter what the codec set here is, uses default Pion MediaEngine codecs |
| 905 | tw, err := c1.AddStaticTrack("video/h264", "video", "webcam") |
| 906 | require.NoError(t, err) |
| 907 | defer stopWriters(tw) |
| 908 | |
| 909 | var desc *sdp.MediaDescription |
| 910 | require.Eventually(t, func() bool { |
| 911 | lastAnswer := c1.LastAnswer() |
| 912 | if lastAnswer == nil { |
| 913 | return false |
| 914 | } |
| 915 | |
| 916 | sd := webrtc.SessionDescription{ |
| 917 | Type: webrtc.SDPTypeAnswer, |
| 918 | SDP: lastAnswer.SDP, |
| 919 | } |
| 920 | answer, err := sd.Unmarshal() |
| 921 | require.NoError(t, err) |
| 922 | |
| 923 | // video and data channel |
| 924 | if len(answer.MediaDescriptions) < 2 { |
| 925 | return false |
| 926 | } |
| 927 | |
| 928 | for _, md := range answer.MediaDescriptions { |
| 929 | if md.MediaName.Media == "video" { |
| 930 | desc = md |
| 931 | break |
| 932 | } |
| 933 | } |
| 934 | return desc != nil |
| 935 | }, waitTimeout, waitTick, "did not receive answer") |
| 936 | |
| 937 | hasSeenVP8 := false |
| 938 | for _, a := range desc.Attributes { |
| 939 | if a.Key == "rtpmap" { |
| 940 | require.NotContains(t, a.Value, mime.MimeTypeCodecH264.String(), "should not contain H264 codec") |
nothing calls this directly
no test coverage detected