android, desktop: fix android video calls (#4118)

This commit is contained in:
Stanislav Dmitrenko 2024-05-02 22:47:52 +07:00 committed by GitHub
parent 7cc86574fe
commit 5f501f1cb9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 23 additions and 4 deletions

View file

@ -453,7 +453,11 @@ const processCommand = (function () {
// For opus (where encodedFrame.type is not set) this is the TOC byte from
// https://tools.ietf.org/html/rfc6716#section-3.1
var _a;
const capabilities = RTCRtpSender.getCapabilities("video");
// Using RTCRtpReceiver instead of RTCRtpSender, see these lines:
// - if (!is_recv_codec && !is_send_codec) {
// + if (!is_recv_codec) {
// https://webrtc.googlesource.com/src.git/+/db2f52ba88cf9f98211df2dabb3f8aca9251c4a2%5E%21/
const capabilities = RTCRtpReceiver.getCapabilities("video");
if (capabilities) {
const { codecs } = capabilities;
const selectedCodecIndex = codecs.findIndex((c) => c.mimeType === "video/VP8");
@ -464,7 +468,13 @@ const processCommand = (function () {
// Firefox doesn't have this function implemented:
// https://bugzilla.mozilla.org/show_bug.cgi?id=1396922
if (((_a = t.sender.track) === null || _a === void 0 ? void 0 : _a.kind) === "video" && t.setCodecPreferences) {
t.setCodecPreferences(codecs);
try {
t.setCodecPreferences(codecs);
}
catch (error) {
// Shouldn't be here but in case something goes wrong, it will allow to make a call with auto-selected codecs
console.log("Failed to set codec preferences, trying without any preferences: " + error);
}
}
}
}

View file

@ -657,7 +657,11 @@ const processCommand = (function () {
// For opus (where encodedFrame.type is not set) this is the TOC byte from
// https://tools.ietf.org/html/rfc6716#section-3.1
const capabilities = RTCRtpSender.getCapabilities("video")
// Using RTCRtpReceiver instead of RTCRtpSender, see these lines:
// - if (!is_recv_codec && !is_send_codec) {
// + if (!is_recv_codec) {
// https://webrtc.googlesource.com/src.git/+/db2f52ba88cf9f98211df2dabb3f8aca9251c4a2%5E%21/
const capabilities = RTCRtpReceiver.getCapabilities("video")
if (capabilities) {
const {codecs} = capabilities
const selectedCodecIndex = codecs.findIndex((c) => c.mimeType === "video/VP8")
@ -668,7 +672,12 @@ const processCommand = (function () {
// Firefox doesn't have this function implemented:
// https://bugzilla.mozilla.org/show_bug.cgi?id=1396922
if (t.sender.track?.kind === "video" && t.setCodecPreferences) {
t.setCodecPreferences(codecs)
try {
t.setCodecPreferences(codecs)
} catch (error) {
// Shouldn't be here but in case something goes wrong, it will allow to make a call with auto-selected codecs
console.log("Failed to set codec preferences, trying without any preferences: " + error)
}
}
}
}