From 90eb048e8d2fff805b8e05f6e949a8dfccd47cf8 Mon Sep 17 00:00:00 2001 From: Hans-Peter Herzog Date: Wed, 27 Oct 2021 09:58:17 +0200 Subject: [PATCH] TT#145900 Call - Configure video constraints including frameRate Change-Id: I0662ec689d8309049a05c659b0a86056d12d9973 --- src/api/ngcp-call.js | 41 +++++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/src/api/ngcp-call.js b/src/api/ngcp-call.js index 08e73517..e828318d 100644 --- a/src/api/ngcp-call.js +++ b/src/api/ngcp-call.js @@ -21,13 +21,38 @@ const TERMINATION_OPTIONS = { reason_phrase: 'Decline' } -const MEDIA_VIDEO_DEFAULT_CONFIG = { - width: { - ideal: 4096 - }, - height: { - ideal: 2160 +const VIDEO_MAX_FRAME_RATE = 30 +const VIDEO_IDEAL_WIDTH = 1920 +const VIDEO_IDEAL_HEIGHT = 1080 + +function callGetVideoConstraints () { + const supported = navigator?.mediaDevices?.getSupportedConstraints() + const constraints = {} + if (supported.frameRate) { + constraints.frameRate = { + max: VIDEO_MAX_FRAME_RATE + } + } + constraints.width = { + ideal: VIDEO_IDEAL_WIDTH + } + constraints.height = { + ideal: VIDEO_IDEAL_HEIGHT + } + return constraints +} + +function callGetCameraConstraints () { + const supported = navigator?.mediaDevices?.getSupportedConstraints() + const constraints = callGetVideoConstraints() + if (supported.facingMode) { + constraints.facingMode = 'user' } + return constraints +} + +function callGetScreenConstraints () { + return callGetVideoConstraints() } export const callEvent = new EventEmitter() @@ -235,7 +260,7 @@ export async function callSendVideo (stream, audioMuted) { export async function callAddCamera () { $isVideoScreen = false await callSendVideo(await navigator.mediaDevices.getUserMedia({ - video: MEDIA_VIDEO_DEFAULT_CONFIG, + video: callGetCameraConstraints(), audio: false })) } @@ -243,7 +268,7 @@ export async function callAddCamera () { export async function callAddScreen () { $isVideoScreen = true await callSendVideo(await navigator.mediaDevices.getDisplayMedia({ - video: MEDIA_VIDEO_DEFAULT_CONFIG, + video: callGetScreenConstraints(), audio: false })) }