mirror of
https://github.com/ziutek/gst.git
synced 2025-12-24 10:40:59 +08:00
Binding for GstBin started
This commit is contained in:
24
LICENSE
Normal file
24
LICENSE
Normal file
@@ -0,0 +1,24 @@
|
||||
Copyright (c) 2010, Michal Derkacz
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. The name of the author may not be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
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
|
||||
CGOFILES = functions.go object.go element.go bin.go
|
||||
|
||||
include $(GOROOT)/src/Make.pkg
|
||||
|
||||
58
bin.go
Normal file
58
bin.go
Normal file
@@ -0,0 +1,58 @@
|
||||
package gst
|
||||
|
||||
/*
|
||||
#include <stdlib.h>
|
||||
#include <gst/gst.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
"github.com/ziutek/glib"
|
||||
)
|
||||
|
||||
type Bin struct {
|
||||
Element
|
||||
}
|
||||
|
||||
func (b *Bin) g() *C.GstBin {
|
||||
return (*C.GstBin)(b.Pointer())
|
||||
}
|
||||
|
||||
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.Set(glib.Pointer(C.gst_bin_new(s)))
|
||||
return b
|
||||
}
|
||||
|
||||
func (b *Bin) Add(e *Element) bool {
|
||||
return C.gst_bin_add(b.g(), e.g()) != 0
|
||||
}
|
||||
|
||||
func (b *Bin) Remove(e *Element) bool {
|
||||
return C.gst_bin_remove(b.g(), e.g()) != 0
|
||||
}
|
||||
|
||||
func (b *Bin) AddMany(els ...*Element) bool {
|
||||
for _, e := range els {
|
||||
if !b.Add(e) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (b *Bin) RemoveMany(els ...*Element) bool {
|
||||
for _, e := range els {
|
||||
if !b.Remove(e) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
53
element.go
53
element.go
@@ -6,6 +6,10 @@ package gst
|
||||
*/
|
||||
import "C"
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
type State C.GstState
|
||||
|
||||
const (
|
||||
@@ -20,10 +24,51 @@ type Element struct {
|
||||
GstObj
|
||||
}
|
||||
|
||||
func (o *Element) g() *C.GstElement {
|
||||
return (*C.GstElement)(o.Pointer())
|
||||
func (e *Element) g() *C.GstElement {
|
||||
return (*C.GstElement)(e.Pointer())
|
||||
}
|
||||
|
||||
func (o *Element) AsElement() *Element {
|
||||
return o
|
||||
func (e *Element) AsElement() *Element {
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *Element) Link(dst *Element) bool {
|
||||
return C.gst_element_link(e.g(), dst.g()) != 0
|
||||
}
|
||||
|
||||
func (e *Element) Unlink(dst *Element) {
|
||||
C.gst_element_unlink(e.g(), dst.g())
|
||||
}
|
||||
|
||||
func (e *Element) LinkMany(next ...*Element) bool {
|
||||
for _, dst := range next {
|
||||
if !e.Link(dst) {
|
||||
return false
|
||||
}
|
||||
e = dst
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (e *Element) UnlinkMany(next ...*Element) {
|
||||
for _, dst := range next {
|
||||
e.Unlink(dst)
|
||||
e = dst
|
||||
}
|
||||
}
|
||||
|
||||
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))
|
||||
dst_pname := (*C.gchar)(C.CString(dst_pad_name))
|
||||
defer C.free(unsafe.Pointer(dst_pname))
|
||||
return C.gst_element_link_pads(e.g(), src_pname, dst.g(), dst_pname) != 0
|
||||
}
|
||||
|
||||
func (e *Element) UnlinkPads(pad_name string, dst *Element, dst_pad_name string) {
|
||||
src_pname := (*C.gchar)(C.CString(pad_name))
|
||||
defer C.free(unsafe.Pointer(src_pname))
|
||||
dst_pname := (*C.gchar)(C.CString(dst_pad_name))
|
||||
defer C.free(unsafe.Pointer(dst_pname))
|
||||
C.gst_element_unlink_pads(e.g(), src_pname, dst.g(), dst_pname)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user