From 9799e5610e84db487dd6b6c370ad4d21d4a2aaca Mon Sep 17 00:00:00 2001 From: Avi Zimmerman Date: Sat, 6 Feb 2021 08:12:46 +0200 Subject: [PATCH] pull in glib interface changes --- README.md | 3 ++- go.mod | 2 +- go.sum | 6 ++--- gst/gst_child_proxy.go | 54 ++++++++++++++++++++---------------------- gst/gst_tag_setter.go | 6 ++--- gst/gst_uri_handler.go | 8 +++---- gst/rtp/c_util.go | 12 +++++----- 7 files changed, 42 insertions(+), 49 deletions(-) diff --git a/README.md b/README.md index 27df787..39ab823 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,8 @@ func main() { // Add a message handler to the pipeline bus, printing interesting information to the console. pipeline.GetPipelineBus().AddWatch(func(msg *gst.Message) bool { switch msg.Type() { - case gst.MessageEOS: // When end-of-stream is received stop the main loop + case gst.MessageEOS: // When end-of-stream is received flush the pipeling and stop the main loop + pipeline.BlockSetState(gst.StateNull) mainLoop.Quit() case gst.MessageError: // Error messages are always fatal err := msg.ParseError() diff --git a/go.mod b/go.mod index 09decad..a7eac25 100644 --- a/go.mod +++ b/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.19 + github.com/tinyzimmer/go-glib v0.0.20 ) diff --git a/go.sum b/go.sum index cf610ef..7fa4a21 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +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.18 h1:zSlJK5NDcquHK4FFQ2cF6tRavo2Y+6jc3Qowj1sN+oQ= -github.com/tinyzimmer/go-glib v0.0.18/go.mod h1:zy2cs6eXSTtqqYrv9/UgYMDfr4pWKuYPSzwX87cBGX4= -github.com/tinyzimmer/go-glib v0.0.19 h1:3DCrMb+tNHKXzpH6k/KXs9Gt3Wghz/nUbD6UT+HaCo4= -github.com/tinyzimmer/go-glib v0.0.19/go.mod h1:zy2cs6eXSTtqqYrv9/UgYMDfr4pWKuYPSzwX87cBGX4= +github.com/tinyzimmer/go-glib v0.0.20 h1:zkLvoWR2ADkWAjFdRsjzS/nkTNKYeJMx5qUjGQ1corU= +github.com/tinyzimmer/go-glib v0.0.20/go.mod h1:zy2cs6eXSTtqqYrv9/UgYMDfr4pWKuYPSzwX87cBGX4= diff --git a/gst/gst_child_proxy.go b/gst/gst_child_proxy.go index 4e0e3a4..0003b5c 100644 --- a/gst/gst_child_proxy.go +++ b/gst/gst_child_proxy.go @@ -32,39 +32,37 @@ var InterfaceChildProxy glib.Interface = &interfaceChildProxy{} type interfaceChildProxy struct{ glib.Interface } func (i *interfaceChildProxy) Type() glib.Type { return glib.Type(C.GST_TYPE_CHILD_PROXY) } -func (i *interfaceChildProxy) InitFunc() glib.InterfaceInitFunc { - return func(instance *glib.TypeInstance) { - goobj := instance.GoType +func (i *interfaceChildProxy) Init(instance *glib.TypeInstance) { + goobj := instance.GoType - if _, ok := goobj.(interface { - ChildAdded(self *ChildProxy, child *glib.Object, name string) - }); ok { - C.setGstChildProxyChildAdded((C.gpointer)(instance.GTypeInstance)) - } + if _, ok := goobj.(interface { + ChildAdded(self *ChildProxy, child *glib.Object, name string) + }); ok { + C.setGstChildProxyChildAdded((C.gpointer)(instance.GTypeInstance)) + } - if _, ok := goobj.(interface { - ChildRemoved(self *ChildProxy, child *glib.Object, name string) - }); ok { - C.setGstChildProxyChildRemoved((C.gpointer)(instance.GTypeInstance)) - } + if _, ok := goobj.(interface { + ChildRemoved(self *ChildProxy, child *glib.Object, name string) + }); ok { + C.setGstChildProxyChildRemoved((C.gpointer)(instance.GTypeInstance)) + } - if _, ok := goobj.(interface { - GetChildByIndex(self *ChildProxy, idx uint) *glib.Object - }); ok { - C.setGstChildProxyGetChildByIndex((C.gpointer)(instance.GTypeInstance)) - } + if _, ok := goobj.(interface { + GetChildByIndex(self *ChildProxy, idx uint) *glib.Object + }); ok { + C.setGstChildProxyGetChildByIndex((C.gpointer)(instance.GTypeInstance)) + } - if _, ok := goobj.(interface { - GetChildByName(self *ChildProxy, name string) *glib.Object - }); ok { - C.setGstChildProxyGetChildByName((C.gpointer)(instance.GTypeInstance)) - } + if _, ok := goobj.(interface { + GetChildByName(self *ChildProxy, name string) *glib.Object + }); ok { + C.setGstChildProxyGetChildByName((C.gpointer)(instance.GTypeInstance)) + } - if _, ok := goobj.(interface { - GetChildrenCount(self *ChildProxy) uint - }); ok { - C.setGstChildProxyGetChildrenCount((C.gpointer)(instance.GTypeInstance)) - } + if _, ok := goobj.(interface { + GetChildrenCount(self *ChildProxy) uint + }); ok { + C.setGstChildProxyGetChildrenCount((C.gpointer)(instance.GTypeInstance)) } } diff --git a/gst/gst_tag_setter.go b/gst/gst_tag_setter.go index 385add2..7cc405a 100644 --- a/gst/gst_tag_setter.go +++ b/gst/gst_tag_setter.go @@ -14,10 +14,8 @@ var InterfaceTagSetter glib.Interface = &interfaceTagSetter{} type interfaceTagSetter struct{} -func (i *interfaceTagSetter) Type() glib.Type { return glib.Type(C.GST_TYPE_TAG_SETTER) } -func (i *interfaceTagSetter) InitFunc() glib.InterfaceInitFunc { - return func(instance *glib.TypeInstance) {} -} +func (i *interfaceTagSetter) Type() glib.Type { return glib.Type(C.GST_TYPE_TAG_SETTER) } +func (i *interfaceTagSetter) Init(instance *glib.TypeInstance) {} // TagSetter is an interface that elements can implement to provide Tag writing capabilities. type TagSetter interface { diff --git a/gst/gst_uri_handler.go b/gst/gst_uri_handler.go index fd9b994..b631a7f 100644 --- a/gst/gst_uri_handler.go +++ b/gst/gst_uri_handler.go @@ -36,11 +36,9 @@ var InterfaceURIHandler glib.Interface = &interfaceURIHandler{} type interfaceURIHandler struct{ glib.Interface } func (i *interfaceURIHandler) Type() glib.Type { return glib.Type(C.GST_TYPE_URI_HANDLER) } -func (i *interfaceURIHandler) InitFunc() glib.InterfaceInitFunc { - return func(instance *glib.TypeInstance) { - globalURIHdlr = instance.GoType.(URIHandler) - C.uriHandlerInit((C.gpointer)(instance.GTypeInstance), nil) - } +func (i *interfaceURIHandler) Init(instance *glib.TypeInstance) { + globalURIHdlr = instance.GoType.(URIHandler) + C.uriHandlerInit((C.gpointer)(instance.GTypeInstance), nil) } // URIHandler represents an interface that elements can implement to provide URI handling diff --git a/gst/rtp/c_util.go b/gst/rtp/c_util.go index f15c079..701f0d4 100644 --- a/gst/rtp/c_util.go +++ b/gst/rtp/c_util.go @@ -6,12 +6,12 @@ package rtp import "C" // gboolean converts a go bool to a C.gboolean. -func gboolean(b bool) C.gboolean { - if b { - return C.gboolean(1) - } - return C.gboolean(0) -} +// func gboolean(b bool) C.gboolean { +// if b { +// return C.gboolean(1) +// } +// return C.gboolean(0) +// } // gobool provides an easy type conversion between C.gboolean and a go bool. func gobool(b C.gboolean) bool {