forked from ziutek/gst
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pad.go
135 lines (112 loc) · 2.96 KB
/
pad.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
package gst
/*
#include <stdlib.h>
#include <gst/gst.h>
*/
import "C"
import (
"unsafe"
"github.com/ziutek/glib"
)
type PadLinkReturn C.GstPadLinkReturn
const (
PAD_LINK_OK = PadLinkReturn(C.GST_PAD_LINK_OK)
PAD_LINK_WRONG_HIERARCHY = PadLinkReturn(C.GST_PAD_LINK_WRONG_HIERARCHY)
PAD_LINK_WAS_LINKED = PadLinkReturn(C.GST_PAD_LINK_WAS_LINKED)
PAD_LINK_WRONG_DIRECTION = PadLinkReturn(C.GST_PAD_LINK_WRONG_DIRECTION)
PAD_LINK_NOFORMAT = PadLinkReturn(C.GST_PAD_LINK_NOFORMAT)
PAD_LINK_NOSCHED = PadLinkReturn(C.GST_PAD_LINK_NOSCHED)
PAD_LINK_REFUSED = PadLinkReturn(C.GST_PAD_LINK_REFUSED)
)
func (p PadLinkReturn) String() string {
switch p {
case PAD_LINK_OK:
return "PAD_LINK_OK"
case PAD_LINK_WRONG_HIERARCHY:
return "PAD_LINK_WRONG_HIERARCHY"
case PAD_LINK_WAS_LINKED:
return "PAD_LINK_WAS_LINKED"
case PAD_LINK_WRONG_DIRECTION:
return "PAD_LINK_WRONG_DIRECTION"
case PAD_LINK_NOFORMAT:
return "PAD_LINK_NOFORMAT"
case PAD_LINK_NOSCHED:
return "PAD_LINK_NOSCHED"
case PAD_LINK_REFUSED:
return "PAD_LINK_REFUSED"
}
panic("Wrong value of PadLinkReturn variable")
}
type PadDirection C.GstPadDirection
const (
PAD_UNKNOWN = PadDirection(C.GST_PAD_UNKNOWN)
PAD_SRC = PadDirection(C.GST_PAD_SRC)
PAD_SINK = PadDirection(C.GST_PAD_SINK)
)
func (p PadDirection) g() C.GstPadDirection {
return C.GstPadDirection(p)
}
func (p PadDirection) String() string {
switch p {
case PAD_UNKNOWN:
return "PAD_UNKNOWN"
case PAD_SRC:
return "PAD_SRC"
case PAD_SINK:
return "PAD_SINK"
}
panic("Wrong value of PadDirection variable")
}
type Pad struct {
GstObj
}
func (p *Pad) g() *C.GstPad {
return (*C.GstPad)(p.GetPtr())
}
func (p *Pad) AsPad() *Pad {
return p
}
func (p *Pad) CanLink(sink_pad *Pad) bool {
return C.gst_pad_can_link(p.g(), sink_pad.g()) != 0
}
func (p *Pad) Link(sink_pad *Pad) PadLinkReturn {
return PadLinkReturn(C.gst_pad_link(p.g(), sink_pad.g()))
}
func (p *Pad) GetCurrentCaps() *Caps {
// unref the caps when you're done
return (*Caps)( C.gst_pad_get_current_caps((*C.GstPad)(p.GetPtr())) )
}
type GhostPad struct {
Pad
}
func (p *GhostPad) g() *C.GstGhostPad {
return (*C.GstGhostPad)(p.GetPtr())
}
func (p *GhostPad) AsGhostPad() *GhostPad {
return p
}
func (p *GhostPad) SetTarget(new_target *Pad) bool {
return C.gst_ghost_pad_set_target(p.g(), new_target.g()) != 0
}
func (p *GhostPad) GetTarget() *Pad {
r := new(Pad)
r.SetPtr(glib.Pointer(C.gst_ghost_pad_get_target(p.g())))
return r
}
func (p *GhostPad) Construct() bool {
return C.gst_ghost_pad_construct(p.g()) != 0
}
func NewGhostPad(name string, target *Pad) *GhostPad {
s := (*C.gchar)(C.CString(name))
defer C.free(unsafe.Pointer(s))
p := new(GhostPad)
p.SetPtr(glib.Pointer(C.gst_ghost_pad_new(s, target.g())))
return p
}
func NewGhostPadNoTarget(name string, dir PadDirection) *GhostPad {
s := (*C.gchar)(C.CString(name))
defer C.free(unsafe.Pointer(s))
p := new(GhostPad)
p.SetPtr(glib.Pointer(C.gst_ghost_pad_new_no_target(s, dir.g())))
return p
}