mirror of
https://github.com/pion/mediadevices.git
synced 2025-10-21 15:49:38 +08:00
Add IsFloat, IsBigEndian, and IsInterleaved props
* Add bool constraint * Add IsFloat, IsBigEndian, and IsInterleaved properties
This commit is contained in:
30
pkg/prop/bool.go
Normal file
30
pkg/prop/bool.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package prop
|
||||
|
||||
// BoolConstraint is an interface to represent bool value constraint.
|
||||
type BoolConstraint interface {
|
||||
Compare(bool) (float64, bool)
|
||||
Value() bool
|
||||
}
|
||||
|
||||
// BoolExact specifies exact bool value.
|
||||
type BoolExact bool
|
||||
|
||||
// Compare implements BoolConstraint.
|
||||
func (b BoolExact) Compare(o bool) (float64, bool) {
|
||||
if bool(b) == o {
|
||||
return 0.0, true
|
||||
}
|
||||
return 1.0, false
|
||||
}
|
||||
|
||||
// Value implements BoolConstraint.
|
||||
func (b BoolExact) Value() bool { return bool(b) }
|
||||
|
||||
// Bool specifies ideal bool value.
|
||||
type Bool BoolExact
|
||||
|
||||
// Compare implements BoolConstraint.
|
||||
func (b Bool) Compare(o bool) (float64, bool) {
|
||||
dist, _ := BoolExact(b).Compare(o)
|
||||
return dist, true
|
||||
}
|
Reference in New Issue
Block a user