diff --git a/gst/cgo_exports.go b/gst/cgo_exports.go index 1e01a1f..f8f40c5 100644 --- a/gst/cgo_exports.go +++ b/gst/cgo_exports.go @@ -58,7 +58,13 @@ func goBusFunc(bus *C.GstBus, cMsg *C.GstMessage, userData C.gpointer) C.gboolea } func getMetaInfoCbFuncs(meta *C.GstMeta) *MetaInfoCallbackFuncs { - return registeredMetas[glib.Type(meta.info._type)] + gapi := glib.Type(meta.info.api) + gtype := glib.Type(meta.info._type) + typeCbs := registeredMetas[gapi] + if typeCbs == nil { + return nil + } + return typeCbs[gtype.Name()] } //export goMetaFreeFunc diff --git a/gst/gst_buffer.go b/gst/gst_buffer.go index b8c9cbb..b19dbcb 100644 --- a/gst/gst_buffer.go +++ b/gst/gst_buffer.go @@ -188,7 +188,7 @@ func (b *Buffer) Map() *MapInfo { // // Example // -// metaInfo := gst.RegisterMeta(glib.TypeFromName("GstObject"), "my-meta", 1024, &gst.MetaInfoCallbackFuncs{ +// metaInfo := gst.RegisterMeta(glib.TypeFromName("MyObjectType"), "my-meta", 1024, &gst.MetaInfoCallbackFuncs{ // InitFunc: func(params interface{}, buffer *gst.Buffer) bool { // paramStr := params.(string) // fmt.Println("Buffer initialized with params:", paramStr) diff --git a/gst/gst_meta.go b/gst/gst_meta.go index a5f9885..151a832 100644 --- a/gst/gst_meta.go +++ b/gst/gst_meta.go @@ -107,8 +107,9 @@ type MetaInfoCallbackFuncs struct { TransformFunc MetaTransformFunc } -// Register metas internally as well so we can track callback functions -var registeredMetas = make(map[glib.Type]*MetaInfoCallbackFuncs) +// Register meta callbacks internally as well so we can track them. Not all +// GstMeta callbacks include userdata. +var registeredMetas = make(map[glib.Type]map[string]*MetaInfoCallbackFuncs) // RegisterMeta registers and returns a new MetaInfo instance denoting the // given type, name, and size. @@ -127,7 +128,10 @@ func RegisterMeta(api glib.Type, name string, size int64, cbFuncs *MetaInfoCallb return nil } wrapped := wrapMetaInfo(metaInfo) - registeredMetas[wrapped.Type()] = cbFuncs + if registeredMetas[api] == nil { + registeredMetas[api] = make(map[string]*MetaInfoCallbackFuncs) + } + registeredMetas[api][name] = cbFuncs return wrapped }