Fixed an issue for some devices. They send screen width as not even value. (#1797)

This commit is contained in:
Roman Sokolov
2025-04-28 00:04:00 +03:00
committed by GitHub
parent 6a1970c075
commit 266be72606
2 changed files with 8 additions and 2 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@scrypted/webrtc",
"version": "0.2.77",
"version": "0.2.78",
"scripts": {
"scrypted-setup-project": "scrypted-setup-project",
"prescrypted-setup-project": "scrypted-package-json",

View File

@@ -458,7 +458,13 @@ export function parseOptions(options: RTCSignalingOptions) {
if (options?.userAgent?.includes('Firefox/'))
sessionSupportsH264High = true;
const transcodeWidth = Math.max(640, Math.min(options?.screen?.width || 960, 1280));
// Some devices return a `screen width` value that is not a multiple of 2, which is not allowed for the h264 codec.
// Convert to a smaller even value.
const screenWidthForTranscodeH264 = !options?.screen?.width
? 960
: Math.trunc(options?.screen?.width / 2) * 2;
const transcodeWidth = Math.max(640, Math.min(screenWidthForTranscodeH264, 1280));
const devicePixelRatio = options?.screen?.devicePixelRatio || 1;
const width = (options?.screen?.width * devicePixelRatio) || undefined;
const height = (options?.screen?.height * devicePixelRatio) || undefined;