From 15ea00516b4cddff2dcfc54791209a0d5adfc103 Mon Sep 17 00:00:00 2001 From: Rob1in <73953872+Rob1in@users.noreply.github.com> Date: Wed, 18 Jan 2023 15:50:05 -0500 Subject: [PATCH] RSDK-1729 - change resolution constraints to be of IntExact when configured --- components/camera/videosource/webcam.go | 32 +++++++++---------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/components/camera/videosource/webcam.go b/components/camera/videosource/webcam.go index eda6125649e..aab17bc5787 100644 --- a/components/camera/videosource/webcam.go +++ b/components/camera/videosource/webcam.go @@ -147,29 +147,19 @@ type WebcamAttrs struct { } func makeConstraints(attrs *WebcamAttrs, debug bool, logger golog.Logger) mediadevices.MediaStreamConstraints { - minWidth := 0 - maxWidth := 4096 - idealWidth := 800 - minHeight := 0 - maxHeight := 2160 - idealHeight := 600 - - if attrs.Width > 0 { - minWidth = 0 - maxWidth = attrs.Width - idealWidth = attrs.Width - } - - if attrs.Height > 0 { - minHeight = 0 - maxHeight = attrs.Height - idealHeight = attrs.Height - } - return mediadevices.MediaStreamConstraints{ Video: func(constraint *mediadevices.MediaTrackConstraints) { - constraint.Width = prop.IntRanged{minWidth, maxWidth, idealWidth} - constraint.Height = prop.IntRanged{minHeight, maxHeight, idealHeight} + if attrs.Width > 0 { + constraint.Width = prop.IntExact(attrs.Width) + } else { + constraint.Width = prop.IntRanged{Min: 0, Ideal: 640, Max: 4096} + } + + if attrs.Height > 0 { + constraint.Height = prop.IntExact(attrs.Height) + } else { + constraint.Height = prop.IntRanged{Min: 0, Ideal: 480, Max: 2160} + } constraint.FrameRate = prop.FloatRanged{0, 200, 60} if attrs.Format == "" {