From 0d09f7f458466c164d60d436fa6419a770970222 Mon Sep 17 00:00:00 2001 From: f-fl0 <66578286+f-fl0@users.noreply.github.com> Date: Wed, 6 Apr 2022 10:07:15 +0900 Subject: [PATCH] Remove video framerate as explicit constraint (#394) * Do not consider video framerate in the constraints fitness function * Remove test about video framerate --- mediadevices_test.go | 18 ------------------ pkg/prop/prop.go | 7 +++++-- 2 files changed, 5 insertions(+), 20 deletions(-) diff --git a/mediadevices_test.go b/mediadevices_test.go index f5024a86..247813ac 100644 --- a/mediadevices_test.go +++ b/mediadevices_test.go @@ -125,18 +125,6 @@ func TestSelectBestDriverConstraintsResultIsSetProperly(t *testing.T) { frameFormat: frame.FormatI420, frameRate: expectedProp.FrameRate, }, - "DifferentFrameRate": { - width: expectedProp.Width, - height: expectedProp.Height, - frameFormat: expectedProp.FrameFormat, - frameRate: expectedProp.FrameRate - 1, - }, - "NoFrameRateConstraints": { - width: expectedProp.Width, - height: expectedProp.Height, - frameFormat: expectedProp.FrameFormat, - frameRate: -1, - }, } for name, c := range cases { @@ -229,12 +217,6 @@ func TestSelectBestDriverConstraintsNoFit(t *testing.T) { frameFormat: frame.FormatI420, frameRate: expectedProp.FrameRate, }, - "DifferentFrameRate": { - width: expectedProp.Width, - height: expectedProp.Height, - frameFormat: expectedProp.FrameFormat, - frameRate: expectedProp.FrameRate - 1, - }, } for name, c := range cases { diff --git a/pkg/prop/prop.go b/pkg/prop/prop.go index 90edde79..3499413f 100644 --- a/pkg/prop/prop.go +++ b/pkg/prop/prop.go @@ -145,14 +145,17 @@ func (p *MediaConstraints) FitnessDistance(o Media) (float64, bool) { cmps.add(p.Width, o.Width) cmps.add(p.Height, o.Height) cmps.add(p.FrameFormat, o.FrameFormat) - cmps.add(p.FrameRate, o.FrameRate) + // The next line is comment out for now to not include framerate in the fitness function. + // As camera.Properties does not have access to the list of available framerate at the moment, + // no driver can be matched with a framerate constraint. + // Note this also affect screen caputre as screen.Properties does not fill in the Framerate field. + // cmps.add(p.FrameRate, o.FrameRate) cmps.add(p.SampleRate, o.SampleRate) cmps.add(p.Latency, o.Latency) cmps.add(p.ChannelCount, o.ChannelCount) cmps.add(p.IsBigEndian, o.IsBigEndian) cmps.add(p.IsFloat, o.IsFloat) cmps.add(p.IsInterleaved, o.IsInterleaved) - return cmps.fitnessDistance() }