mirror of
https://github.com/ziutek/gst.git
synced 2025-12-24 10:40:59 +08:00
Changes according to glib
This commit is contained in:
2
Makefile
2
Makefile
@@ -1,6 +1,6 @@
|
||||
include $(GOROOT)/src/Make.inc
|
||||
|
||||
TARG = github.com/ziutek/gst
|
||||
CGOFILES = functions.go object.go element.go bin.go pipeline.go clock.go pad.go
|
||||
CGOFILES = common.go object.go element.go bin.go pipeline.go clock.go pad.go caps.go structure.go
|
||||
|
||||
include $(GOROOT)/src/Make.pkg
|
||||
|
||||
8
bin.go
8
bin.go
@@ -7,7 +7,7 @@ package gst
|
||||
import "C"
|
||||
|
||||
import (
|
||||
//"unsafe"
|
||||
"unsafe"
|
||||
"github.com/ziutek/glib"
|
||||
)
|
||||
|
||||
@@ -16,7 +16,7 @@ type Bin struct {
|
||||
}
|
||||
|
||||
func (b *Bin) g() *C.GstBin {
|
||||
return (*C.GstBin)(b.Pointer())
|
||||
return (*C.GstBin)(b.GetPtr())
|
||||
}
|
||||
|
||||
func (b *Bin) AsBin() *Bin {
|
||||
@@ -25,9 +25,9 @@ func (b *Bin) AsBin() *Bin {
|
||||
|
||||
func NewBin(name string) *Bin {
|
||||
s := (*C.gchar)(C.CString(name))
|
||||
//defer C.free(unsafe.Pointer(s))
|
||||
defer C.free(unsafe.Pointer(s))
|
||||
b := new(Bin)
|
||||
b.Set(glib.Pointer(C.gst_bin_new(s)))
|
||||
b.SetPtr(glib.Pointer(C.gst_bin_new(s)))
|
||||
return b
|
||||
}
|
||||
|
||||
|
||||
2
clock.go
2
clock.go
@@ -10,7 +10,7 @@ type Clock struct {
|
||||
}
|
||||
|
||||
func (c *Clock) g() *C.GstClock {
|
||||
return (*C.GstClock)(c.Pointer())
|
||||
return (*C.GstClock)(c.GetPtr())
|
||||
}
|
||||
|
||||
func (c *Clock) AsClock() *Clock {
|
||||
|
||||
@@ -35,7 +35,7 @@ type Element struct {
|
||||
}
|
||||
|
||||
func (e *Element) g() *C.GstElement {
|
||||
return (*C.GstElement)(e.Pointer())
|
||||
return (*C.GstElement)(e.GetPtr())
|
||||
}
|
||||
|
||||
func (e *Element) AsElement() *Element {
|
||||
@@ -59,6 +59,8 @@ func (e *Element) Unlink(next ...*Element) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
func (e *Element) LinkPads(pad_name string, dst *Element, dst_pad_name string) bool {
|
||||
src_pname := (*C.gchar)(C.CString(pad_name))
|
||||
defer C.free(unsafe.Pointer(src_pname))
|
||||
@@ -87,7 +89,7 @@ func (e *Element) GetStaticPad(name string) *Pad {
|
||||
return nil
|
||||
}
|
||||
p := new(Pad)
|
||||
p.Set(glib.Pointer(cp))
|
||||
p.SetPtr(glib.Pointer(cp))
|
||||
return p
|
||||
}
|
||||
|
||||
@@ -98,6 +100,6 @@ func ElementFactoryMake(factory_name, name string) *Element {
|
||||
n := (*C.gchar)(C.CString(name))
|
||||
defer C.free(unsafe.Pointer(n))
|
||||
e := new(Element)
|
||||
e.Set(glib.Pointer(C.gst_element_factory_make(fn, n)))
|
||||
e.SetPtr(glib.Pointer(C.gst_element_factory_make(fn, n)))
|
||||
return e
|
||||
}
|
||||
|
||||
32
functions.go
32
functions.go
@@ -1,32 +0,0 @@
|
||||
package gst
|
||||
|
||||
/*
|
||||
#include <gst/gst.h>
|
||||
|
||||
char** _gst_init(int* argc, char** argv) {
|
||||
gst_init(argc, &argv);
|
||||
return argv;
|
||||
}
|
||||
|
||||
#cgo pkg-config: gstreamer-0.10
|
||||
*/
|
||||
import "C"
|
||||
|
||||
import (
|
||||
"os"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
func init() {
|
||||
alen := C.int(len(os.Args))
|
||||
argv := make([]*C.char, alen)
|
||||
for i, s := range os.Args {
|
||||
argv[i] = C.CString(s)
|
||||
}
|
||||
ret := C._gst_init(&alen, &argv[0])
|
||||
argv = (*[1<<16]*C.char)(unsafe.Pointer(ret))[:alen]
|
||||
os.Args = make([]string, alen)
|
||||
for i, s := range argv {
|
||||
os.Args[i] = C.GoString(s)
|
||||
}
|
||||
}
|
||||
@@ -16,15 +16,15 @@ type GstObj struct {
|
||||
}
|
||||
|
||||
func (o *GstObj) g() *C.GstObject {
|
||||
return (*C.GstObject)(o.Pointer())
|
||||
return (*C.GstObject)(o.GetPtr())
|
||||
}
|
||||
|
||||
func (o *GstObj) AsGstObj() *GstObj {
|
||||
return o
|
||||
}
|
||||
|
||||
// Sets the name of object, or gives object a guaranteed unique name
|
||||
// if name is nil. Returns true if the name could be set. MT safe.
|
||||
// Sets the name of object.
|
||||
// Returns true if the name could be set. MT safe.
|
||||
func (o *GstObj) SetName(name string) bool {
|
||||
s := C.CString(name)
|
||||
defer C.free(unsafe.Pointer(s))
|
||||
@@ -51,7 +51,7 @@ func (o *GstObj) SetParent(p *GstObj) bool {
|
||||
// should Unref it after usage.
|
||||
func (o *GstObj) GetParent() *GstObj {
|
||||
p := new(GstObj)
|
||||
p.Set(glib.Pointer(C.gst_object_get_parent(o.g())))
|
||||
p.SetPtr(glib.Pointer(C.gst_object_get_parent(o.g())))
|
||||
return p
|
||||
}
|
||||
|
||||
|
||||
2
pad.go
2
pad.go
@@ -30,7 +30,7 @@ type Pad struct {
|
||||
}
|
||||
|
||||
func (p *Pad) g() *C.GstPad {
|
||||
return (*C.GstPad)(p.Pointer())
|
||||
return (*C.GstPad)(p.GetPtr())
|
||||
}
|
||||
|
||||
func (p *Pad) AsPad() *Pad {
|
||||
|
||||
@@ -16,7 +16,7 @@ type Pipeline struct {
|
||||
}
|
||||
|
||||
func (p *Pipeline) g() *C.GstPipeline {
|
||||
return (*C.GstPipeline)(p.Pointer())
|
||||
return (*C.GstPipeline)(p.GetPtr())
|
||||
}
|
||||
|
||||
func (p *Pipeline) AsPipeline() *Pipeline {
|
||||
@@ -27,6 +27,6 @@ func NewPipeline(name string) *Pipeline {
|
||||
s := (*C.gchar)(C.CString(name))
|
||||
defer C.free(unsafe.Pointer(s))
|
||||
p := new(Pipeline)
|
||||
p.Set(glib.Pointer(C.gst_pipeline_new(s)))
|
||||
p.SetPtr(glib.Pointer(C.gst_pipeline_new(s)))
|
||||
return p
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user