-
Notifications
You must be signed in to change notification settings - Fork 9
/
formatfamily.go
98 lines (95 loc) · 2.33 KB
/
formatfamily.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package v4l2
import (
"github.com/reiver/go-v4l2/buftype"
"github.com/reiver/go-v4l2/pixelformat"
)
// FormatFamily is a format family.
//
// A format family contains:
//
// • a human-readable description,
//
// • a pixel format (as a FOURCC code), and
//
// • flags.
//
// As well as logicall "containing" a list of frame sizes.
//
// The possible flags are given by the constants:
//
// • v4l2.FormatFamilyFlagCompressed, and
//
// • v4l2.FormatFamilyFlagEmulated.
//
// Samples:
//
// An example format migh have have values such as:
//
// • description: "YUYV 4:2:2"
//
// • pixel format: "YUYV"
//
// • (flag) compressed: false
//
// • (flag) emulated: false
//
// Or an example format migh have have values such as:
//
// • description: "Motion-JPEG"
//
// • pixel format: "MJPG"
//
// • (flag) compressed: true
//
// • (flag) emulated: false
//
// Etc.
//
// Usually, one would get a series of formats by iterating through all the supported formats
// that are supported by a device.
//
// Example:
//
// var device v4l2.Device
//
// // ...
//
// formats, err := device.Formats()
// if nil != err {
// return err
// }
// defer formats.Close()
//
// var formatFamily v4l2.FormatFamily // <---- NOTE THAT THIS IS THE v4l2.FormatFamily TYPE.
// forformats.Next() {
//
// err := formats.Decode(&formatFamily) // <---- NOTE THAT WE ARE PUTTING A NEW VALUE INTO THE v4l2.FormatFamily HERE.
// if nil != err {
// fmt.Fprintf(os.Stderr, "ERROR: Problem decoding format family: (%T) %v \n", err, err)
// return err
// }
//
// fmt.Printf("[format family] %q (%q) {compressed=%t} {emulated=%t} \n",
// formatFamily.Description(),
// formatFamily.PixelFormat(),
// formatFamily.HasFlags(v4l2.FormatFamilyFlagCompressed),
// formatFamily.HasFlags(v4l2.FormatFamilyFlagEmulated),
// )
// }
// if err := formats.Err(); nil != err {
// return err
// }
//
// v4l2.FormatFamily is the same as the V4L2 (Video4Linux version 2) type v4l2_fmtdesc.
type FormatFamily struct {
device *Device
internal internalFormatFamily
}
type internalFormatFamily struct {
index uint32 // Format number
typ v4l2_buftype.Type // enum v4l2_buf_type
flags uint32
description [32]byte // Description string
pixelFormat v4l2_pixelformat.Type // Format fourcc
reserved [4]uint32
}