mirror of
https://github.com/go-gst/go-gst.git
synced 2025-10-05 16:06:55 +08:00
pull in updated glib bindings, element class fixes, update examples
This commit is contained in:
@@ -132,9 +132,10 @@ func handleMessage(msg *gst.Message) error {
|
||||
func mainLoop(loop *glib.MainLoop, pipeline *gst.Pipeline) error {
|
||||
// Start the pipeline
|
||||
|
||||
// Due to recent changes in the pipeline - the finalizers might fire on the pipeline
|
||||
// Due to recent changes in the bindings - the finalizers might fire on the pipeline
|
||||
// prematurely when it's passed between scopes. So when you do this, it is safer to
|
||||
// take a reference that you dispose of when you are done.
|
||||
// take a reference that you dispose of when you are done. There is an alternative
|
||||
// to this method in other examples.
|
||||
pipeline.Ref()
|
||||
defer pipeline.Unref()
|
||||
|
||||
|
@@ -114,6 +114,14 @@ func mainLoop(loop *glib.MainLoop, pipeline *gst.Pipeline) error {
|
||||
}
|
||||
}()
|
||||
|
||||
// When passing an object created by the bindings between scopes, there is a posibility
|
||||
// the finalizer will leak and destroy your object before you are done with it. One way
|
||||
// of dealing with this is by taking an additional Ref and disposing of it when you are
|
||||
// done with the new scope. An alternative is to declare Keep() *after* where you know
|
||||
// you will be done with the object. This instructs the runtime to defer the finalizer
|
||||
// until after this point is passed in the code execution.
|
||||
pipeline.Keep()
|
||||
|
||||
return loop.RunError()
|
||||
}
|
||||
|
||||
|
2
go.mod
2
go.mod
@@ -4,5 +4,5 @@ go 1.15
|
||||
|
||||
require (
|
||||
github.com/mattn/go-pointer v0.0.1
|
||||
github.com/tinyzimmer/go-glib v0.0.16
|
||||
github.com/tinyzimmer/go-glib v0.0.18
|
||||
)
|
||||
|
10
go.sum
10
go.sum
@@ -1,10 +1,4 @@
|
||||
github.com/mattn/go-pointer v0.0.1 h1:n+XhsuGeVO6MEAp7xyEukFINEa+Quek5psIR/ylA6o0=
|
||||
github.com/mattn/go-pointer v0.0.1/go.mod h1:2zXcozF6qYGgmsG+SeTZz3oAbFLdD3OWqnUbNvJZAlc=
|
||||
github.com/tinyzimmer/go-glib v0.0.12 h1:3illkvxCT71DT12tix1iGl+jkA/JdZxtcj0z3V9Aevo=
|
||||
github.com/tinyzimmer/go-glib v0.0.12/go.mod h1:zy2cs6eXSTtqqYrv9/UgYMDfr4pWKuYPSzwX87cBGX4=
|
||||
github.com/tinyzimmer/go-glib v0.0.14 h1:Axk3eBfBqaCOvBEXwuqNVJ3YAL41R6GFpj9IlYkPZ+w=
|
||||
github.com/tinyzimmer/go-glib v0.0.14/go.mod h1:zy2cs6eXSTtqqYrv9/UgYMDfr4pWKuYPSzwX87cBGX4=
|
||||
github.com/tinyzimmer/go-glib v0.0.15 h1:F6Ht4OJevy5KsDx/ecO73NIk5OVte3ghdYdEnwDWaPg=
|
||||
github.com/tinyzimmer/go-glib v0.0.15/go.mod h1:zy2cs6eXSTtqqYrv9/UgYMDfr4pWKuYPSzwX87cBGX4=
|
||||
github.com/tinyzimmer/go-glib v0.0.16 h1:5d6jsGR4jfhhmuQhgy7t8PBSi4R3KvFPj9p8qisvJtw=
|
||||
github.com/tinyzimmer/go-glib v0.0.16/go.mod h1:zy2cs6eXSTtqqYrv9/UgYMDfr4pWKuYPSzwX87cBGX4=
|
||||
github.com/tinyzimmer/go-glib v0.0.18 h1:zSlJK5NDcquHK4FFQ2cF6tRavo2Y+6jc3Qowj1sN+oQ=
|
||||
github.com/tinyzimmer/go-glib v0.0.18/go.mod h1:zy2cs6eXSTtqqYrv9/UgYMDfr4pWKuYPSzwX87cBGX4=
|
||||
|
@@ -316,8 +316,7 @@ func (e *Element) GetState() State {
|
||||
}
|
||||
|
||||
// GetStaticPad retrieves a pad from element by name. This version only retrieves
|
||||
// already-existing (i.e. 'static') pads. The caller owns a ref on the pad and
|
||||
// should Unref after usage.
|
||||
// already-existing (i.e. 'static') pads.
|
||||
func (e *Element) GetStaticPad(name string) *Pad {
|
||||
cname := C.CString(name)
|
||||
defer C.free(unsafe.Pointer(cname))
|
||||
|
@@ -40,7 +40,7 @@ func (e *ElementClass) AddMetadata(key, value string) {
|
||||
func (e *ElementClass) AddPadTemplate(templ *PadTemplate) {
|
||||
C.gst_element_class_add_pad_template(
|
||||
e.Instance(),
|
||||
templ.Instance(),
|
||||
(*C.GstPadTemplate)(templ.Unsafe()),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ func (e *ElementClass) AddStaticPadTemplate(templ *PadTemplate) {
|
||||
direction: templ.Instance().direction,
|
||||
presence: templ.Instance().presence,
|
||||
static_caps: C.GstStaticCaps{
|
||||
caps: templ.Caps().Instance(),
|
||||
caps: templ.Caps().Ref().Instance(),
|
||||
string: C.CString(templ.Name()),
|
||||
},
|
||||
}
|
||||
@@ -101,19 +101,11 @@ func (e *ElementClass) GetAllPadTemplates() []*PadTemplate {
|
||||
//
|
||||
// `author` - Name and contact details of the author(s). Use \n to separate multiple author metadata. E.g: "Joe Bloggs <joe.blogs at foo.com>"
|
||||
func (e *ElementClass) SetMetadata(longname, classification, description, author string) {
|
||||
lname := C.CString(longname)
|
||||
class := C.CString(classification)
|
||||
desc := C.CString(description)
|
||||
auth := C.CString(description)
|
||||
defer C.free(unsafe.Pointer(lname))
|
||||
defer C.free(unsafe.Pointer(class))
|
||||
defer C.free(unsafe.Pointer(desc))
|
||||
defer C.free(unsafe.Pointer(auth))
|
||||
C.gst_element_class_set_static_metadata(
|
||||
e.Instance(),
|
||||
(*C.gchar)(unsafe.Pointer(lname)),
|
||||
(*C.gchar)(unsafe.Pointer(class)),
|
||||
(*C.gchar)(unsafe.Pointer(desc)),
|
||||
(*C.gchar)(unsafe.Pointer(auth)),
|
||||
(*C.gchar)(C.CString(longname)),
|
||||
(*C.gchar)(C.CString(classification)),
|
||||
(*C.gchar)(C.CString(description)),
|
||||
(*C.gchar)(C.CString(author)),
|
||||
)
|
||||
}
|
||||
|
Reference in New Issue
Block a user