-
Notifications
You must be signed in to change notification settings - Fork 48
/
pipeline.go
46 lines (39 loc) · 850 Bytes
/
pipeline.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
package gst
/*
#include <stdlib.h>
#include <gst/gst.h>
*/
import "C"
import (
"github.com/ziutek/glib"
"unsafe"
)
type Pipeline struct {
Bin
}
func (p *Pipeline) g() *C.GstPipeline {
return (*C.GstPipeline)(p.GetPtr())
}
func (p *Pipeline) AsPipeline() *Pipeline {
return p
}
func NewPipeline(name string) *Pipeline {
s := (*C.gchar)(C.CString(name))
defer C.free(unsafe.Pointer(s))
p := new(Pipeline)
p.SetPtr(glib.Pointer(C.gst_pipeline_new(s)))
return p
}
func ParseLaunch(pipeline_description string) (*Pipeline, error) {
pd := (*C.gchar)(C.CString(pipeline_description))
defer C.free(unsafe.Pointer(pd))
p := new(Pipeline)
var Cerr *C.GError
p.SetPtr(glib.Pointer(C.gst_parse_launch(pd, &Cerr)))
if Cerr != nil {
err := *(*glib.Error)(unsafe.Pointer(Cerr))
C.g_error_free(Cerr)
return nil, &err
}
return p, nil
}