-
Notifications
You must be signed in to change notification settings - Fork 8
/
buffer.go
49 lines (40 loc) · 1.24 KB
/
buffer.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
package aravis
// #cgo pkg-config: aravis-0.6
// #include <arv.h>
import "C"
import "unsafe"
const (
BUFFER_STATUS_UNKNOWN = C.ARV_BUFFER_STATUS_UNKNOWN
BUFFER_STATUS_SUCCESS = C.ARV_BUFFER_STATUS_SUCCESS
BUFFER_STATUS_CLEARED = C.ARV_BUFFER_STATUS_CLEARED
BUFFER_STATUS_TIMEOUT = C.ARV_BUFFER_STATUS_TIMEOUT
BUFFER_STATUS_MISSING_PACKETS = C.ARV_BUFFER_STATUS_MISSING_PACKETS
BUFFER_STATUS_WRONG_PACKET_ID = C.ARV_BUFFER_STATUS_WRONG_PACKET_ID
BUFFER_STATUS_SIZE_MISMATCH = C.ARV_BUFFER_STATUS_SIZE_MISMATCH
BUFFER_STATUS_FILLING = C.ARV_BUFFER_STATUS_FILLING
BUFFER_STATUS_ABORTED = C.ARV_BUFFER_STATUS_ABORTED
)
type Buffer struct {
buffer *C.struct__ArvBuffer
}
func NewBuffer(size uint) (Buffer, error) {
var b Buffer
if buffer, err := C.arv_buffer_new(C.size_t(size), nil); err != nil || buffer == nil {
return Buffer{nil}, err
} else {
b.buffer = buffer
return b, err
}
}
func (b *Buffer) GetData() ([]byte, error) {
var size int
data, err := C.arv_buffer_get_data(
b.buffer,
(*C.size_t)(unsafe.Pointer(&size)),
)
return C.GoBytes(data, C.int(size)), err
}
func (b *Buffer) GetStatus() (int, error) {
status, err := C.arv_buffer_get_status(b.buffer)
return int(status), err
}