forked from notedit/gst
-
Notifications
You must be signed in to change notification settings - Fork 0
/
caps.go
45 lines (37 loc) · 853 Bytes
/
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
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
}