forked from ziutek/gst
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bin.go
64 lines (55 loc) · 1.08 KB
/
bin.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
package gst
/*
#include <stdlib.h>
#include <gst/gst.h>
*/
import "C"
import (
"github.com/Xeralux/glib"
"unsafe"
)
type Bin struct {
Element
}
func (b *Bin) g() *C.GstBin {
return (*C.GstBin)(b.GetPtr())
}
func (b *Bin) AsBin() *Bin {
return b
}
func NewBin(name string) *Bin {
s := (*C.gchar)(C.CString(name))
defer C.free(unsafe.Pointer(s))
b := new(Bin)
b.SetPtr(glib.Pointer(C.gst_bin_new(s)))
return b
}
func (b *Bin) Add(els ...*Element) bool {
for _, e := range els {
if C.gst_bin_add(b.g(), e.g()) == 0 {
return false
}
}
return true
}
func (b *Bin) Remove(els ...*Element) bool {
for _, e := range els {
if C.gst_bin_remove(b.g(), e.g()) == 0 {
return false
}
}
return true
}
// GetByName returns the element with the given name from a bin. Returns nil
// if no element with the given name is found in the bin.
func (b *Bin) GetByName(name string) *Element {
en := (*C.gchar)(C.CString(name))
defer C.free(unsafe.Pointer(en))
p := glib.Pointer(C.gst_bin_get_by_name(b.g(), en))
if p == nil {
return nil
}
e := new(Element)
e.SetPtr(p)
return e
}