Disable H.264 for android firefox

This commit is contained in:
cnderrauber
2023-10-26 13:50:37 +08:00
parent 30a4581045
commit 60347fc64c
4 changed files with 16 additions and 8 deletions
+2 -1
View File
@@ -33,7 +33,8 @@ var StaticConfigurations = []ConfigurationItem{
// Merge: false,
// },
{
Match: &ScriptMatch{Expr: `c.device_model == "Xiaomi 2201117TI" && c.os == "android"`},
Match: &ScriptMatch{Expr: `(c.device_model == "xiaomi 2201117ti" && c.os == "android) ||
((c.browser == "firefox" || c.browser == "firefox mobile") && (c.os == "linux" || c.os == "android"))`},
Configuration: &livekit.ClientConfiguration{
DisabledCodecs: &livekit.DisabledCodecs{
Publish: []*livekit.Codec{{Mime: "video/h264"}},
+3 -1
View File
@@ -98,7 +98,9 @@ func TestScriptMatch(t *testing.T) {
{name: "simple match", expr: `c.protocol > 5`, result: true},
{name: "invalid expr", expr: `cc.protocol > 5`, err: true},
{name: "unexist field", expr: `c.protocols > 5`, err: true},
{name: "combined condition", expr: `c.protocol > 5 && (c.sdk=="ANDROID" || c.sdk=="IOS")`, result: true},
{name: "combined condition", expr: `c.protocol > 5 && (c.sdk=="android" || c.sdk=="ios")`, result: true},
{name: "combined condition2", expr: `(c.device_model == "xiaomi 2201117ti" && c.os == "android) ||
((c.browser == "firefox" || c.browser == "firefox mobile") && (c.os == "linux" || c.os == "android"))`, result: false},
}
for _, c := range cases {
+5 -4
View File
@@ -17,6 +17,7 @@ package clientconfiguration
import (
"context"
"errors"
"strings"
"github.com/d5/tengo/v2"
@@ -69,19 +70,19 @@ func (c *clientObject) IndexGet(index tengo.Object) (res tengo.Object, err error
switch field.Value {
case "sdk":
return &tengo.String{Value: c.info.Sdk.String()}, nil
return &tengo.String{Value: strings.ToLower(c.info.Sdk.String())}, nil
case "version":
return &tengo.String{Value: c.info.Version}, nil
case "protocol":
return &tengo.Int{Value: int64(c.info.Protocol)}, nil
case "os":
return &tengo.String{Value: c.info.Os}, nil
return &tengo.String{Value: strings.ToLower(c.info.Os)}, nil
case "os_version":
return &tengo.String{Value: c.info.OsVersion}, nil
case "device_model":
return &tengo.String{Value: c.info.DeviceModel}, nil
return &tengo.String{Value: strings.ToLower(c.info.DeviceModel)}, nil
case "browser":
return &tengo.String{Value: c.info.Browser}, nil
return &tengo.String{Value: strings.ToLower(c.info.Browser)}, nil
case "browser_version":
return &tengo.String{Value: c.info.BrowserVersion}, nil
case "address":
+6 -2
View File
@@ -26,7 +26,7 @@ type ClientInfo struct {
}
func (c ClientInfo) isFirefox() bool {
return c.ClientInfo != nil && strings.EqualFold(c.ClientInfo.Browser, "firefox")
return c.ClientInfo != nil && (strings.EqualFold(c.ClientInfo.Browser, "firefox") || strings.EqualFold(c.ClientInfo.Browser, "firefox mobile"))
}
func (c ClientInfo) isSafari() bool {
@@ -41,6 +41,10 @@ func (c ClientInfo) isLinux() bool {
return c.ClientInfo != nil && strings.EqualFold(c.ClientInfo.Os, "linux")
}
func (c ClientInfo) isAndroid() bool {
return c.ClientInfo != nil && strings.EqualFold(c.ClientInfo.Os, "android")
}
func (c ClientInfo) SupportsAudioRED() bool {
return !c.isFirefox() && !c.isSafari()
}
@@ -85,7 +89,7 @@ func (c ClientInfo) SupportsChangeRTPSenderEncodingActive() bool {
}
func (c ClientInfo) ComplyWithCodecOrderInSDPAnswer() bool {
return !(c.isLinux() && c.isFirefox())
return !((c.isLinux() || c.isAndroid()) && c.isFirefox())
}
// compareVersion compares a semver against the current client SDK version