mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-06 23:57:19 +02:00
Fix "Force high quality codec" feature not working with Kiwi Browser
This commit is contained in:
parent
522830a47d
commit
baf2c2a35d
@ -1021,35 +1021,20 @@ function patchRtcCodecs() {
|
||||
RTCRtpTransceiver.prototype.orgSetCodecPreferences = RTCRtpTransceiver.prototype.setCodecPreferences;
|
||||
RTCRtpTransceiver.prototype.setCodecPreferences = function(codecs) {
|
||||
// Use the same codecs as desktop
|
||||
let profileSetting;
|
||||
for (let codec of codecs) {
|
||||
if (codec.sdpFmtpLine.includes('profile-level-id=4d') || codec.sdpFmtpLine.includes('profile-level-id=42')) {
|
||||
profileSetting = codec.sdpFmtpLine.slice(-4); // get the last 4 characters
|
||||
break;
|
||||
const newCodecs = codecs.slice();
|
||||
newCodecs.forEach((codec, i) => {
|
||||
// Find high quality codecs
|
||||
if (codec.sdpFmtpLine && codec.sdpFmtpLine.includes('profile-level-id=4d')) {
|
||||
// Move it to the top of the array
|
||||
newCodecs.splice(i, 1);
|
||||
newCodecs.unshift(codec);
|
||||
}
|
||||
}
|
||||
|
||||
let newCodecs;
|
||||
if (profileSetting) {
|
||||
newCodecs = [
|
||||
{
|
||||
'clockRate': 90000,
|
||||
'mimeType': 'video/H264',
|
||||
'sdpFmtpLine': 'level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=4d' + profileSetting,
|
||||
},
|
||||
{
|
||||
'clockRate': 90000,
|
||||
'mimeType': 'video/H264',
|
||||
'sdpFmtpLine': 'level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=4d' + profileSetting,
|
||||
}
|
||||
].concat(codecs);
|
||||
} else {
|
||||
newCodecs = codecs;
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
this.orgSetCodecPreferences(newCodecs);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
this.orgSetCodecPreferences(codecs);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user