-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathcaps.go
54 lines (44 loc) · 1.01 KB
/
caps.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
package gst
/*
#cgo pkg-config: gstreamer-1.0
#include "gst.h"
*/
import "C"
import (
"runtime"
"unsafe"
)
type Caps struct {
caps *C.GstCaps
}
func CapsFromString(caps string) (gstCaps *Caps) {
c := (*C.gchar)(unsafe.Pointer(C.CString(caps)))
defer C.g_free(C.gpointer(unsafe.Pointer(c)))
CCaps := C.gst_caps_from_string(c)
gstCaps = &Caps{
caps: CCaps,
}
runtime.SetFinalizer(gstCaps, func(gstCaps *Caps) {
C.gst_caps_unref(gstCaps.caps)
})
return
}
func (c *Caps) ToString() (str string) {
CStr := C.gst_caps_to_string(c.caps)
defer C.g_free(C.gpointer(unsafe.Pointer(CStr)))
str = C.GoString((*C.char)(unsafe.Pointer(CStr)))
return
}
func (c *Caps) String() (str string) {
CStr := C.gst_caps_to_string(c.caps)
defer C.g_free(C.gpointer(unsafe.Pointer(CStr)))
str = C.GoString((*C.char)(unsafe.Pointer(CStr)))
return
}
func (c *Caps) GetStructure(index int) (structure *Structure) {
Cstructure := C.gst_caps_get_structure(c.caps, C.uint(index))
structure = &Structure{
C: Cstructure,
}
return
}