-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtypes.go
160 lines (143 loc) · 2.7 KB
/
types.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
// Copyright 2017 The go-mmal Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package mmal
/*
#include <interface/mmal/mmal_types.h>
*/
import "C"
import (
"fmt"
)
type Status C.MMAL_STATUS_T
const (
Success Status = iota
ErrNoMem
ErrNoSpc
ErrInVal
ErrNoSys
ErrNoEnt
ErrNXIO
ErrIO
ErrSPipe
ErrCorrupt
ErrNotReady
ErrConfig
ErrIsConn
ErrNotConn
ErrAgain
ErrFault
ErrMax = 0x7FFFFFFF
)
func (s Status) String() string {
switch s {
case Success:
return "Success"
case ErrNoMem:
return "ErrNoMem"
case ErrNoSpc:
return "ErrNoSpc"
case ErrInVal:
return "ErrInVal"
case ErrNoSys:
return "ErrNoSys"
case ErrNoEnt:
return "ErrNoEnt"
case ErrNXIO:
return "ErrNXIO"
case ErrIO:
return "ErrIO"
case ErrSPipe:
return "ErrSPipe"
case ErrCorrupt:
return "ErrCorrupt"
case ErrNotReady:
return "ErrNotReady"
case ErrConfig:
return "ErrConfig"
case ErrIsConn:
return "ErrIsConn"
case ErrNotConn:
return "ErrNotConn"
case ErrAgain:
return "ErrAgain"
case ErrFault:
return "ErrFault"
case ErrMax:
return "ErrMax"
}
return fmt.Sprintf("Status(%d)", s)
}
func (s Status) Error() string {
switch s {
case Success:
return "Success"
case ErrNoMem:
return "Out of memory"
case ErrNoSpc:
return "Out of resources (other than memory)"
case ErrInVal:
return "Argument is invalid"
case ErrNoSys:
return "Function not implemented"
case ErrNoEnt:
return "No such file or directory"
case ErrNXIO:
return "No such device or address"
case ErrIO:
return "I/O error"
case ErrSPipe:
return "Illegal seek"
case ErrCorrupt:
return "Data is corrupt"
case ErrNotReady:
return "Component is not ready"
case ErrConfig:
return "Component is not configured"
case ErrIsConn:
return "Port is already connected"
case ErrNotConn:
return "Port is disconnected"
case ErrAgain:
return "Resource temporarily unavailable"
case ErrFault:
return "Bad address"
case ErrMax:
return "Force to 32 bit"
}
return "unknown error"
}
type Rect struct {
c C.MMAL_RECT_T
}
func NewRect(x, y, width, height int32) Rect {
var rect C.MMAL_RECT_T
rect.x = C.int32_t(x)
rect.y = C.int32_t(y)
rect.width = C.int32_t(width)
rect.height = C.int32_t(height)
return Rect{rect}
}
func (r Rect) X() int32 {
return int32(r.c.x)
}
func (r Rect) Y() int32 {
return int32(r.c.y)
}
func (r Rect) Width() int32 {
return int32(r.c.width)
}
func (r Rect) Height() int32 {
return int32(r.c.height)
}
type Rational struct {
c C.MMAL_RATIONAL_T
}
func (r Rational) Num() int32 {
return int32(r.c.num)
}
func (r Rational) Den() int32 {
return int32(r.c.den)
}
const TimeUnknown = 1 << 63
type FourCCT uint32