-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
util_params.go
149 lines (129 loc) · 4.22 KB
/
util_params.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
// 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/util/mmal_util_params.h>
*/
import "C"
import (
"unsafe"
)
func PortParameterSetBoolean(port *Port, id uint32, value BoolT) error {
if err := Status(C.mmal_port_parameter_set_boolean(port.c, C.uint32_t(id), C.MMAL_BOOL_T(value))); err != Success {
return err
}
return nil
}
func PortParameterGetBoolean(port *Port, id uint32, value *BoolT) error {
v := C.MMAL_BOOL_T(*value)
if err := Status(C.mmal_port_parameter_get_boolean(port.c, C.uint32_t(id), &v)); err != Success {
return err
}
return nil
}
func PortParameterSetUint64(port *Port, id uint32, value uint64) error {
if err := Status(C.mmal_port_parameter_set_uint64(port.c, C.uint32_t(id), C.uint64_t(value))); err != Success {
return err
}
return nil
}
func PortParameterGetUint64(port *Port, id uint32, value *uint64) error {
v := C.uint64_t(*value)
if err := Status(C.mmal_port_parameter_get_uint64(port.c, C.uint32_t(id), &v)); err != Success {
return err
}
return nil
}
func PortParameterSetInt64(port *Port, id uint32, value int64) error {
if err := Status(C.mmal_port_parameter_set_int64(port.c, C.uint32_t(id), C.int64_t(value))); err != Success {
return err
}
return nil
}
func PortParameterGetInt64(port *Port, id uint32, value *int64) error {
v := C.int64_t(*value)
if err := Status(C.mmal_port_parameter_get_int64(port.c, C.uint32_t(id), &v)); err != Success {
return err
}
return nil
}
func PortParameterSetUint32(port *Port, id uint32, value uint32) error {
if err := Status(C.mmal_port_parameter_set_uint32(port.c, C.uint32_t(id), C.uint32_t(value))); err != Success {
return err
}
return nil
}
func PortParameterGetUint32(port *Port, id uint32, value *uint32) error {
v := C.uint32_t(*value)
if err := Status(C.mmal_port_parameter_get_uint32(port.c, C.uint32_t(id), &v)); err != Success {
return err
}
return nil
}
func PortParameterSetInt32(port *Port, id uint32, value int32) error {
if err := Status(C.mmal_port_parameter_set_int32(port.c, C.uint32_t(id), C.int32_t(value))); err != Success {
return err
}
return nil
}
func PortParameterGetInt32(port *Port, id uint32, value *int32) error {
v := C.int32_t(*value)
if err := Status(C.mmal_port_parameter_get_int32(port.c, C.uint32_t(id), &v)); err != Success {
return err
}
return nil
}
func PortParameterSetRational(port *Port, id uint32, value Rational) error {
if err := Status(C.mmal_port_parameter_set_rational(port.c, C.uint32_t(id), C.MMAL_RATIONAL_T(value.c))); err != Success {
return err
}
return nil
}
func PortParameterGetRational(port *Port, id uint32, value *Rational) error {
if err := Status(C.mmal_port_parameter_get_rational(port.c, C.uint32_t(id), &value.c)); err != Success {
return err
}
return nil
}
func PortParameterSetString(port *Port, id uint32, value string) error {
v := C.CString(value)
defer C.free(unsafe.Pointer(v))
if err := Status(C.mmal_port_parameter_set_string(port.c, C.uint32_t(id), v)); err != Success {
return err
}
return nil
}
func PortParameterSetBytes(port *Port, id uint32, data uint8, size uint) error {
d := C.uint8_t(data)
if err := Status(C.mmal_port_parameter_set_bytes(port.c, C.uint32_t(id), &d, C.uint(size))); err != Success {
return err
}
return nil
}
func UtilPortSetUri(port *Port, uri string) error {
u := C.CString(uri)
defer C.free(unsafe.Pointer(u))
if err := Status(C.mmal_util_port_set_uri(port.c, u)); err != Success {
return err
}
return nil
}
func UtilSetDisplayRegion(port *Port, region *Displayregion) error {
if err := Status(C.mmal_util_set_display_region(port.c, ®ion.c)); err != Success {
return err
}
return nil
}
func UtilCameraUseStcTimestamp(port *Port, mode CameraSTCMode) error {
if err := Status(C.mmal_util_camera_use_stc_timestamp(port.c, C.MMAL_CAMERA_STC_MODE_T(mode))); err != Success {
return err
}
return nil
}
func UtilGetCorePortStats(port *Port, dir CoreStatsDir, reset BoolT, stats CoreStatisticsType) error {
if err := Status(C.mmal_util_get_core_port_stats(port.c, C.MMAL_CORE_STATS_DIR(dir), C.MMAL_BOOL_T(reset), &stats.c)); err != Success {
return err
}
return nil
}