MCPcopy Index your code
hub / github.com/livekit/livekit / TestDeviceCodecOverride

Function TestDeviceCodecOverride

test/singlenode_test.go:883–949  ·  view source on GitHub ↗

TestDeviceCodecOverride checks that codecs that are incompatible with a device is not negotiated by the server

(t *testing.T)

Source from the content-addressed store, hash-verified

881// TestDeviceCodecOverride checks that codecs that are incompatible with a device is not
882// negotiated by the server
883func 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")

Callers

nothing calls this directly

Calls 10

setupSingleNodeTestFunction · 0.85
createRTCClientFunction · 0.85
waitUntilConnectedFunction · 0.85
stopWritersFunction · 0.85
AddStaticTrackMethod · 0.80
LastAnswerMethod · 0.80
StopMethod · 0.65
RunMethod · 0.45
StringMethod · 0.45
UnmarshalMethod · 0.45

Tested by

no test coverage detected