forked from lijo-jose/gst
-
Notifications
You must be signed in to change notification settings - Fork 4
/
caps.go
69 lines (53 loc) · 1.22 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package gst
/*
#include <stdlib.h>
#include <gst/gst.h>
int capsRefCount(GstCaps *c) {
return GST_CAPS_REFCOUNT(c);
}
*/
import "C"
import (
"unsafe"
"github.com/lijo-jose/glib"
)
type Caps C.GstCaps
func (c *Caps) g() *C.GstCaps {
return (*C.GstCaps)(c)
}
func (c *Caps) Ref() *Caps {
return (*Caps)(C.gst_caps_ref(c.g()))
}
func (c *Caps) Unref() {
C.gst_caps_unref(c.g())
}
func (c *Caps) RefCount() int {
return int(C.capsRefCount(c.g()))
}
func (c *Caps) AppendStructure(media_type string, fields glib.Params) {
C.gst_caps_append_structure(c.g(), makeGstStructure(media_type, fields))
}
func (c *Caps) GetSize() int {
return int(C.gst_caps_get_size(c.g()))
}
func (c *Caps) String() string {
s := (*C.char)(C.gst_caps_to_string(c.g()))
defer C.free(unsafe.Pointer(s))
return C.GoString(s)
}
func NewCapsAny() *Caps {
return (*Caps)(C.gst_caps_new_any())
}
func NewCapsEmpty() *Caps {
return (*Caps)(C.gst_caps_new_empty())
}
func NewCapsSimple(media_type string, fields glib.Params) *Caps {
c := NewCapsEmpty()
c.AppendStructure(media_type, fields)
return c
}
func CapsFromString(s string) *Caps {
cs := (*C.gchar)(C.CString(s))
defer C.free(unsafe.Pointer(cs))
return (*Caps)(C.gst_caps_from_string(cs))
}