-
Notifications
You must be signed in to change notification settings - Fork 9
/
device_cap.go
35 lines (30 loc) · 892 Bytes
/
device_cap.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package v4l2
// HasCapability return whether the device has a capability a particular capability.
//
// Example:
//
// device, err := v4l2.Open(v4l2.Video17)
//
// // ...
//
// hasVideoCaptureCapability, err := device.HasCapability(CapabilityVideoCapture)
func (receiver Device) HasCapability(cap uint32) (bool, error) {
if err := receiver.unfit(); nil != err {
return false, err
}
has := 0 != (receiver.cap.capabilities & cap)
return has, nil
}
// MustHasCapability is like HasCapability, except it panic()s if there is an error.
//
// device := v4l2.MustOpen(v4l2.Video0)
// defer device.MustClose()
//
// fmt.Printf("Has Streaming Capability: %t \n", device.MustHasCapability(v4l2.CapabilityStreaming))
func (receiver Device) MustHasCapability(cap uint32) bool {
datum, err := receiver.HasCapability(cap)
if nil != err {
panic(err)
}
return datum
}