forked from thinkski/go-v4l2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstructs.go
135 lines (114 loc) · 2.42 KB
/
structs.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
// +build linux
package v4l2
import (
"golang.org/x/sys/unix"
"unsafe"
)
const (
maxSizeBufferDotM = 4
maxSizeExtControlDotValue = 8
maxSizeFormatDotFmt = 200
sizePixFormat = 48
sizeCaptureParm = 28
)
type v4l2_streamparm struct {
typ uint32
parm [maxSizeFormatDotFmt]byte
}
type v4l2_fract struct {
numerator uint32
denominator uint32
}
type v4l2_captureparm struct {
capability uint32
capturemode uint32
timeperframe v4l2_fract
extendedmode uint32
readbuffers uint32
reserved [4]uint32
}
type v4l2_capability struct {
driver [16]uint8
card [32]uint8
bus_info [32]uint8
version uint32
capabilities uint32
device_caps uint32
reserved [3]uint32
}
type v4l2_pix_format struct {
width uint32
height uint32
pixelformat uint32
field uint32
bytesperline uint32
sizeimage uint32
colorspace uint32
priv uint32
flags uint32
xx_enc uint32
quantization uint32
xfer_func uint32
}
type v4l2_format struct {
typ uint
fmt [maxSizeFormatDotFmt]byte // union
}
type v4l2_control struct {
id uint32
value int32
}
type v4l2_requestbuffers struct {
count uint32
typ uint32
memory uint32
reserved [2]uint32
}
type v4l2_timecode struct {
typ uint32
flags uint32
frames uint8
seconds uint8
minutes uint8
hours uint8
userbits [4]uint8
}
type v4l2_buffer struct {
index uint32
typ uint32
bytesused uint32
flags uint32
field uint32
timestamp unix.Timeval
timecode v4l2_timecode
sequence uint32
memory uint32
m [unsafe.Sizeof(unsafe.Pointer(uintptr(0)))]uint8
length uint32
reserved2 uint32
reserved uint32
}
type v4l2_ext_control struct {
id uint32
size uint32
reserved2 [1]uint32
value [maxSizeExtControlDotValue]byte // union
}
type v4l2_ext_controls struct {
ctrl_class uint32
count uint32
error_idx uint32
reserved [2]uint32
controls unsafe.Pointer
}
// marshals v4l2_pix_format struct into v4l2_format.fmt union
func (pfmt *v4l2_pix_format) marshal() [maxSizeFormatDotFmt]byte {
var b [maxSizeFormatDotFmt]byte
copy(b[0:sizePixFormat], (*[sizePixFormat]byte)(unsafe.Pointer(pfmt))[:])
return b
}
func (cparm *v4l2_captureparm) marshal() [maxSizeFormatDotFmt]byte {
var b [maxSizeFormatDotFmt]byte
copy(b[0:sizeCaptureParm], (*[sizeCaptureParm]byte)(unsafe.Pointer(cparm))[:])
return b
}