Skip to content

Commit

Permalink
Remove video framerate as explicit constraint (pion#394)
Browse files Browse the repository at this point in the history
* Do not consider video framerate in the constraints fitness function
* Remove test about video framerate
  • Loading branch information
f-fl0 authored Apr 6, 2022
1 parent e780bdc commit 0d09f7f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 20 deletions.
18 changes: 0 additions & 18 deletions mediadevices_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
7 changes: 5 additions & 2 deletions pkg/prop/prop.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down

0 comments on commit 0d09f7f

Please sign in to comment.