-
Notifications
You must be signed in to change notification settings - Fork 9
/
device_card.go
42 lines (38 loc) · 1.1 KB
/
device_card.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
36
37
38
39
40
41
42
package v4l2
// Card returns the name of the device.
//
// Example values that Card might return are:
//
// • "Laptop_Integrated_Webcam_HD"
//
// • "Yoyodyne TV/FM"
//
// The information that Card returns is intended for users.
// I.e., intended to be human readable)
// And can be used for things such as being use in a menu of available devices.
//
// Note that it is possible for a system to have multiple cards from the same brand.
//
// And thus it is possible for multiple devices to return the exact same value from Card.
//
// To make the name, shown to the user, unique, it can be combined with either the file name path,
// or what BusInfo returns.
func (receiver Device) Card() (string, error) {
if err := receiver.unfit(); nil != err {
return "", err
}
return receiver.cap.Card(), nil
}
// MustCard is like BusCard, except it panic()s if there is an error.
//
// device := v4l2.MustOpen(v4l2.Video0)
// defer device.MustClose()
//
// fmt.Printf("Card: %q \n", device.MustCard())
func (receiver Device) MustCard() string {
datum, err := receiver.Card()
if nil != err {
panic(err)
}
return datum
}