mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-07 16:17:20 +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.orgSetCodecPreferences = RTCRtpTransceiver.prototype.setCodecPreferences;
|
||||||
RTCRtpTransceiver.prototype.setCodecPreferences = function(codecs) {
|
RTCRtpTransceiver.prototype.setCodecPreferences = function(codecs) {
|
||||||
// Use the same codecs as desktop
|
// Use the same codecs as desktop
|
||||||
let profileSetting;
|
const newCodecs = codecs.slice();
|
||||||
for (let codec of codecs) {
|
newCodecs.forEach((codec, i) => {
|
||||||
if (codec.sdpFmtpLine.includes('profile-level-id=4d') || codec.sdpFmtpLine.includes('profile-level-id=42')) {
|
// Find high quality codecs
|
||||||
profileSetting = codec.sdpFmtpLine.slice(-4); // get the last 4 characters
|
if (codec.sdpFmtpLine && codec.sdpFmtpLine.includes('profile-level-id=4d')) {
|
||||||
break;
|
// 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 {
|
try {
|
||||||
this.orgSetCodecPreferences(newCodecs);
|
this.orgSetCodecPreferences(newCodecs);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
this.orgSetCodecPreferences(codecs);
|
this.orgSetCodecPreferences(codecs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user