TT#145900 Call - Configure video constraints including frameRate

Change-Id: I0662ec689d8309049a05c659b0a86056d12d9973
pull/9/head
Hans-Peter Herzog 4 years ago
parent 3c92d05648
commit 90eb048e8d

@ -21,13 +21,38 @@ const TERMINATION_OPTIONS = {
reason_phrase: 'Decline' reason_phrase: 'Decline'
} }
const MEDIA_VIDEO_DEFAULT_CONFIG = { const VIDEO_MAX_FRAME_RATE = 30
width: { const VIDEO_IDEAL_WIDTH = 1920
ideal: 4096 const VIDEO_IDEAL_HEIGHT = 1080
},
height: { function callGetVideoConstraints () {
ideal: 2160 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() export const callEvent = new EventEmitter()
@ -235,7 +260,7 @@ export async function callSendVideo (stream, audioMuted) {
export async function callAddCamera () { export async function callAddCamera () {
$isVideoScreen = false $isVideoScreen = false
await callSendVideo(await navigator.mediaDevices.getUserMedia({ await callSendVideo(await navigator.mediaDevices.getUserMedia({
video: MEDIA_VIDEO_DEFAULT_CONFIG, video: callGetCameraConstraints(),
audio: false audio: false
})) }))
} }
@ -243,7 +268,7 @@ export async function callAddCamera () {
export async function callAddScreen () { export async function callAddScreen () {
$isVideoScreen = true $isVideoScreen = true
await callSendVideo(await navigator.mediaDevices.getDisplayMedia({ await callSendVideo(await navigator.mediaDevices.getDisplayMedia({
video: MEDIA_VIDEO_DEFAULT_CONFIG, video: callGetScreenConstraints(),
audio: false audio: false
})) }))
} }

Loading…
Cancel
Save