-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmmal.go
50 lines (43 loc) · 1.3 KB
/
mmal.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
// 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>
extern void set_es_specific_format(MMAL_ES_SPECIFIC_FORMAT_T *esf) {
esf->video.width = 1024;
esf->video.height = 768;
esf->video.crop.x = 0;
esf->video.crop.y = 0;
esf->video.crop.width = 1024;
esf->video.crop.height = 768;
esf->video.frame_rate.num = 0;
esf->video.frame_rate.den = 1;
}
*/
import "C"
import (
"fmt"
)
func SetPortFormat(port *Port) {
port.c.format.encoding = C.MMAL_ENCODING_OPAQUE
var esf C.MMAL_ES_SPECIFIC_FORMAT_T
// TODO(zchee): could not determine kind of name for C.VCOS_ALIGN_UP: C.VCOS_ALIGN_UP(1024, 32)
// esf.video.width = 1024
// TODO(zchee): could not determine kind of name for C.VCOS_ALIGN_UP: C.VCOS_ALIGN_UP(768, 16)
// esf.video.height = 768
// esf.video.crop.x = 0
// esf.video.crop.y = 0
// esf.video.crop.width = 1024
// esf.video.crop.height = 768
// esf.video.frame_rate.num = 0
// esf.video.frame_rate.den = 1
C.set_es_specific_format(&esf)
port.c.format.es = &esf
if err := PortFormatCommit(port); err != nil {
panic(fmt.Sprintf("could not set port format: %v", err))
}
}
func VcosSleep(wait uint32) {
C.vcos_sleep(C.uint32_t(wait))
}