-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
util_connection.go
127 lines (103 loc) · 3.3 KB
/
util_connection.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
// 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.h>
#include <interface/mmal/util/mmal_connection.h>
*/
import "C"
import "unsafe"
const (
// The connection is tunnelled. Buffer headers do not transit via the client but directly from the output port to the input port. */
ConnectionFlagTunnelling = 0x1
// Force the pool of buffer headers used by the connection to be allocated on the input port. */
ConnectionFlagAllocationOnInput = 0x2
// Force the pool of buffer headers used by the connection to be allocated on the output port. */
ConnectionFlagAllocationOnOutput = 0x4
// Specify that the connection should not modify the buffer requirements. */
ConnectionFlagKeepBufferRequirements = 0x8
// The connection is flagged as direct. This doesn't change the behaviour of the connection itself but is used by the the graph utility to specify that the buffer should be sent to the input port from with the port callback. */
ConnectionFlagDirect = 0x10
)
type ConnectionType struct {
c *C.MMAL_CONNECTION_T
}
func (c ConnectionType) UserData() unsafe.Pointer {
return c.c.user_data
}
func (c ConnectionType) Callback() ConnectionCallbackType {
return ConnectionCallbackType{c.c.callback}
}
type ConnectionCallbackType struct {
c C.MMAL_CONNECTION_CALLBACK_T
}
func (c ConnectionType) IsEnabled() uint32 {
return uint32(c.c.is_enabled)
}
func (c ConnectionType) Flags() uint32 {
return uint32(c.c.flags)
}
func (c ConnectionType) In() Port {
return Port{c.c.in}
}
func (c ConnectionType) Out() Port {
return Port{c.c.out}
}
func (c ConnectionType) Pool() PoolType {
return PoolType{c.c.pool}
}
func (c ConnectionType) Queue() QueueType {
return QueueType{c.c.queue}
}
func (c ConnectionType) Name() string {
return C.GoString(c.c.name)
}
func (c ConnectionType) TimeSetup() int64 {
return int64(c.c.time_setup)
}
func (c ConnectionType) TimeEnable() int64 {
return int64(c.c.time_enable)
}
func (c ConnectionType) TimeDisable() int64 {
return int64(c.c.time_disable)
}
func ConnectionCreate(connection *ConnectionType, out, in *Port, flags uint32) error {
if err := Status(C.mmal_connection_create(&connection.c, out.c, in.c, C.uint32_t(flags))); err != Success {
return err
}
return nil
}
func ConnectionAcquire(connection *ConnectionType) {
C.mmal_connection_acquire(connection.c)
}
func ConnectionRelease(connection *ConnectionType) error {
if err := Status(C.mmal_connection_release(connection.c)); err != Success {
return err
}
return nil
}
func ConnectionDestroy(connection *ConnectionType) error {
if err := Status(C.mmal_connection_destroy(connection.c)); err != Success {
return err
}
return nil
}
func ConnectionEnable(connection *ConnectionType) error {
if err := Status(C.mmal_connection_enable(connection.c)); err != Success {
return err
}
return nil
}
func ConnectionDisable(connection *ConnectionType) error {
if err := Status(C.mmal_connection_disable(connection.c)); err != Success {
return err
}
return nil
}
func ConnectionEventFormatChanged(connection *ConnectionType, buffer *BufferHeader) error {
if err := Status(C.mmal_connection_event_format_changed(connection.c, buffer.c)); err != Success {
return err
}
return nil
}