diff --git a/examples/plugins/registered_elements/internal/custombin/element.go b/examples/plugins/registered_elements/internal/custombin/element.go index 166eef0..f041d5b 100644 --- a/examples/plugins/registered_elements/internal/custombin/element.go +++ b/examples/plugins/registered_elements/internal/custombin/element.go @@ -7,14 +7,14 @@ import ( ) type customBin struct { - gst.Bin // parent object must be first embedded field - source1 gst.Element - source2 gst.Element - mixer gst.Element + gst.BinInstance // parent object must be first embedded field + source1 gst.Element + source2 gst.Element + mixer gst.Element } -// init should initialize the element. Keep in mind that the properties are not yet present. When this is called. -func (bin *customBin) init() { +// constructed is the method we use to override the GOBject.constructed method. +func (bin *customBin) constructed() { bin.source1 = gst.ElementFactoryMakeWithProperties("gocustomsrc", map[string]interface{}{ "duration": int64(5 * time.Second), }) diff --git a/examples/plugins/registered_elements/internal/custombin/register.go b/examples/plugins/registered_elements/internal/custombin/register.go index 154761c..3e00947 100644 --- a/examples/plugins/registered_elements/internal/custombin/register.go +++ b/examples/plugins/registered_elements/internal/custombin/register.go @@ -1,41 +1,45 @@ package custombin +import ( + "github.com/diamondburned/gotk4/pkg/gobject/v2" + "github.com/go-gst/go-gst/pkg/gst" +) + // Register needs to be called after gst.Init() to make the gocustombin available in the standard // gst element registry. After this call the element can be used like any other gstreamer element func Register() bool { - panic("Register is not implemented yet") - // registered := glib.RegisterSubclassWithConstructor[*customBin]( - // func() *customBin { - // return &customBin{} - // }, - // glib.WithOverrides[*customBin, gst.BinOverrides](func(b *customBin) gst.BinOverrides { - // return gst.BinOverrides{} - // }), - // glib.WithClassInit[*gst.BinClass](func(bc *gst.BinClass) { - // bc.ParentClass().SetStaticMetadata( - // "custom test source", - // "Src/Test", - // "Demo source bin with volume", - // "Wilhelm Bartel ", - // ) + registered := gst.RegisterBinSubClass[*customBin]( + "gocustombin", + func(class *gst.BinClass) { + class.ParentClass().SetStaticMetadata( + "custom test source", + "Src/Test", + "Demo source bin with volume", + "Wilhelm Bartel ", + ) + }, + nil, + gst.BinOverrides[*customBin]{ + ElementOverrides: gst.ElementOverrides[*customBin]{ + ObjectOverrides: gst.ObjectOverrides[*customBin]{ + InitiallyUnownedOverrides: gobject.InitiallyUnownedOverrides[*customBin]{ + ObjectOverrides: gobject.ObjectOverrides[*customBin]{ + Constructed: (*customBin).constructed, + }, + }, + }, + }, + }, + map[string]gobject.SignalDefinition{}, + ) - // bc.ParentClass().AddPadTemplate(gst.NewPadTemplate( - // "src", - // gst.PadSrc, - // gst.PadAlways, - // gst.CapsFromString("audio/x-raw,channels=2,rate=48000"), - // )) - // }), - // ) - - // return gst.ElementRegister( - // // no plugin: - // nil, - // // The name of the element - // "gocustombin", - // // The rank of the element - // uint(gst.RankNone), - // // The GoElement implementation for the element - // registered.Type(), - // ) + return gst.ElementRegister( + // no plugin: + nil, + // The name of the element + "gocustombin", + // The rank of the element + uint(gst.RankNone), + registered, + ) } diff --git a/examples/plugins/registered_elements/internal/customsrc/element.go b/examples/plugins/registered_elements/internal/customsrc/element.go index 038a004..0c43ad5 100644 --- a/examples/plugins/registered_elements/internal/customsrc/element.go +++ b/examples/plugins/registered_elements/internal/customsrc/element.go @@ -4,6 +4,7 @@ import ( "math" "time" + "github.com/diamondburned/gotk4/pkg/gobject/v2" "github.com/go-gst/go-gst/pkg/gst" ) @@ -13,12 +14,12 @@ const samplesperbuffer = 4800 const samplerate = 48000 type customSrc struct { - gst.Bin // parent must be embedded as the first field + gst.BinInstance // parent must be embedded as the first field source gst.Element volume gst.Element - Duration time.Duration `glib:"duration"` + Duration time.Duration } // InstanceInit should initialize the element. Keep in mind that the properties are not yet present. When this is called. @@ -45,6 +46,25 @@ func (bin *customSrc) init() { bin.updateSource() } +func (bin *customSrc) setProperty(_ uint, value any, pspec *gobject.ParamSpec) { + switch pspec.Name() { + case "duration": + bin.Duration = value.(time.Duration) + bin.updateSource() + default: + panic("unknown property") + } +} + +func (bin *customSrc) getProperty(_ uint, pspec *gobject.ParamSpec) any { + switch pspec.Name() { + case "duration": + return bin.Duration + default: + panic("unknown property") + } +} + // updateSource will get called to update the audiotestsrc when a property changes func (s *customSrc) updateSource() { if s.source != nil { diff --git a/examples/plugins/registered_elements/internal/customsrc/register.go b/examples/plugins/registered_elements/internal/customsrc/register.go index a3325a3..18f5a13 100644 --- a/examples/plugins/registered_elements/internal/customsrc/register.go +++ b/examples/plugins/registered_elements/internal/customsrc/register.go @@ -1,40 +1,60 @@ package customsrc +import ( + "math" + + "github.com/diamondburned/gotk4/pkg/gobject/v2" + "github.com/go-gst/go-gst/pkg/gst" +) + // Register needs to be called after gst.Init() to make the gocustomsrc available in the standard // gst element registry. After this call the element can be used like any other gstreamer element func Register() bool { - panic("Register is not implemented yet") - // registered := glib.RegisterSubclassWithConstructor[*customSrc]( - // func() *customSrc { - // return &customSrc{} - // }, - // glib.WithOverrides[*customSrc, gst.BinOverrides](func(b *customSrc) gst.BinOverrides { - // return gst.BinOverrides{} - // }), - // glib.WithClassInit[*gst.BinClass](func(bc *gst.BinClass) { - // bc.ParentClass().SetStaticMetadata( - // "custom test source", - // "Src/Test", - // "Demo source bin with volume", - // "Wilhelm Bartel ", - // ) + registered := gst.RegisterBinSubClass[*customSrc]( + "gocustomsrc", + func(class *gst.BinClass) { + class.ParentClass().SetStaticMetadata( + "custom test source", + "Src/Test", + "Demo source bin with volume", + "Wilhelm Bartel ", + ) - // bc.ParentClass().AddPadTemplate(gst.NewPadTemplate( - // "src", - // gst.PadSrc, - // gst.PadAlways, - // gst.CapsFromString("audio/x-raw,channels=2,rate=48000"), - // )) - // }), - // ) + class.ParentClass().ParentClass().ParentClass().ParentClass().InstallProperties([]*gobject.ParamSpec{ + gobject.ParamSpecInt( + "duration", + "Duration", + "Duration of the source in nanoseconds", + 0, + math.MaxInt64, + 0, + gobject.ParamWritable|gobject.ParamReadable|gst.ParamMutableReady), + }) + }, + nil, + gst.BinOverrides[*customSrc]{ + ElementOverrides: gst.ElementOverrides[*customSrc]{ + ObjectOverrides: gst.ObjectOverrides[*customSrc]{ + InitiallyUnownedOverrides: gobject.InitiallyUnownedOverrides[*customSrc]{ + ObjectOverrides: gobject.ObjectOverrides[*customSrc]{ + Constructed: (*customSrc).init, + SetProperty: (*customSrc).setProperty, + GetProperty: (*customSrc).getProperty, + }, + }, + }, + }, + }, + map[string]gobject.SignalDefinition{}, + ) - // return gst.ElementRegister( - // // no plugin: - // nil, - // // The name of the element - // "gocustomsrc", - // // The rank of the element - // uint(gst.RankNone), - // registered.Type(), - // ) + return gst.ElementRegister( + // no plugin: + nil, + // The name of the element + "gocustomsrc", + // The rank of the element + uint(gst.RankNone), + registered, + ) } diff --git a/examples/plugins/registered_elements/main.go b/examples/plugins/registered_elements/main.go index c474b9e..016ed17 100644 --- a/examples/plugins/registered_elements/main.go +++ b/examples/plugins/registered_elements/main.go @@ -72,6 +72,8 @@ func run(ctx context.Context) error { fmt.Println("reached EOS") cancel() return + default: + fmt.Println("got message:", msg.String()) } return diff --git a/generator.go b/generator.go index 8761b0e..be35fdf 100644 --- a/generator.go +++ b/generator.go @@ -160,6 +160,10 @@ var Data = genmain.Overlay( // Requires a gvalue arg, manually implemented: typesystem.IgnoreMatching("TagSetter.add_tag_value"), + + // ParamSpec subclass colliding with constructor: + typesystem.IgnoreMatching("ParamSpecArray"), + typesystem.IgnoreMatching("ParamSpecFraction"), }, }, "GstBase-1": { diff --git a/pkg/gst/gst.gen.go b/pkg/gst/gst.gen.go index 2b702ad..4465e6d 100644 --- a/pkg/gst/gst.gen.go +++ b/pkg/gst/gst.gen.go @@ -103,6 +103,10 @@ import ( // gboolean _gotk4_gst1_URIHandler_virtual_set_uri(void* fnptr, GstURIHandler* carg0, gchar* carg1, GError** _cerr) { // return ((gboolean (*) (GstURIHandler*, gchar*, GError**))(fnptr))(carg0, carg1, _cerr); // } +// extern void _gotk4_gst1_Object_deep_notify(GstObject*, GstObject*, GParamSpec*); +// void _gotk4_gst1_Object_virtual_deep_notify(void* fnptr, GstObject* carg0, GstObject* carg1, GParamSpec* carg2) { +// return ((void (*) (GstObject*, GstObject*, GParamSpec*))(fnptr))(carg0, carg1, carg2); +// } // extern void _gotk4_gst1_Pad_linked(GstPad*, GstPad*); // extern void _gotk4_gst1_Pad_unlinked(GstPad*, GstPad*); // void _gotk4_gst1_Pad_virtual_linked(void* fnptr, GstPad* carg0, GstPad* carg1) { @@ -115,6 +119,10 @@ import ( // void _gotk4_gst1_PadTemplate_virtual_pad_created(void* fnptr, GstPadTemplate* carg0, GstPad* carg1) { // return ((void (*) (GstPadTemplate*, GstPad*))(fnptr))(carg0, carg1); // } +// extern void _gotk4_gst1_StreamCollection_stream_notify(GstStreamCollection*, GstStream*, GParamSpec*); +// void _gotk4_gst1_StreamCollection_virtual_stream_notify(void* fnptr, GstStreamCollection* carg0, GstStream* carg1, GParamSpec* carg2) { +// return ((void (*) (GstStreamCollection*, GstStream*, GParamSpec*))(fnptr))(carg0, carg1, carg2); +// } // extern void _gotk4_gst1_TaskPool_cleanup(GstTaskPool*); // extern void _gotk4_gst1_TaskPool_prepare(GstTaskPool*, GError*); // void _gotk4_gst1_TaskPool_virtual_cleanup(void* fnptr, GstTaskPool* carg0) { @@ -8804,6 +8812,126 @@ func IsInitialized() bool { return goret } +// ParamSpecArray wraps gst_param_spec_array +// +// The function takes the following parameters: +// +// - name string: canonical name of the property specified +// - nick string: nick name for the property specified +// - blurb string: description of the property specified +// - elementSpec *gobject.ParamSpec: GParamSpec of the array +// - flags gobject.ParamFlags: flags for the property specified +// +// The function returns the following values: +// +// - goret *gobject.ParamSpec +// +// This function creates a GstArray GParamSpec for use by objects/elements +// that want to expose properties of GstArray type. This function is +// typically * used in connection with g_object_class_install_property() in a +// GObjects's instance_init function. +func ParamSpecArray(name string, nick string, blurb string, elementSpec *gobject.ParamSpec, flags gobject.ParamFlags) *gobject.ParamSpec { + var carg1 *C.gchar // in, none, string + var carg2 *C.gchar // in, none, string + var carg3 *C.gchar // in, none, string + var carg4 *C.GParamSpec // in, none, converted + var carg5 C.GParamFlags // in, none, casted + var cret *C.GParamSpec // return, full, converted + + carg1 = (*C.gchar)(unsafe.Pointer(C.CString(name))) + defer C.free(unsafe.Pointer(carg1)) + carg2 = (*C.gchar)(unsafe.Pointer(C.CString(nick))) + defer C.free(unsafe.Pointer(carg2)) + carg3 = (*C.gchar)(unsafe.Pointer(C.CString(blurb))) + defer C.free(unsafe.Pointer(carg3)) + carg4 = (*C.GParamSpec)(gobject.UnsafeParamSpecToGlibNone(elementSpec)) + carg5 = C.GParamFlags(flags) + + cret = C.gst_param_spec_array(carg1, carg2, carg3, carg4, carg5) + runtime.KeepAlive(name) + runtime.KeepAlive(nick) + runtime.KeepAlive(blurb) + runtime.KeepAlive(elementSpec) + runtime.KeepAlive(flags) + + var goret *gobject.ParamSpec + + goret = gobject.UnsafeParamSpecFromGlibFull(unsafe.Pointer(cret)) + + return goret +} + +// ParamSpecFraction wraps gst_param_spec_fraction +// +// The function takes the following parameters: +// +// - name string: canonical name of the property specified +// - nick string: nick name for the property specified +// - blurb string: description of the property specified +// - minNum int: minimum value (fraction numerator) +// - minDenom int: minimum value (fraction denominator) +// - maxNum int: maximum value (fraction numerator) +// - maxDenom int: maximum value (fraction denominator) +// - defaultNum int: default value (fraction numerator) +// - defaultDenom int: default value (fraction denominator) +// - flags gobject.ParamFlags: flags for the property specified +// +// The function returns the following values: +// +// - goret *gobject.ParamSpec (nullable) +// +// This function creates a fraction GParamSpec for use by objects/elements +// that want to expose properties of fraction type. This function is typically +// used in connection with g_object_class_install_property() in a GObjects's +// instance_init function. +func ParamSpecFraction(name string, nick string, blurb string, minNum int, minDenom int, maxNum int, maxDenom int, defaultNum int, defaultDenom int, flags gobject.ParamFlags) *gobject.ParamSpec { + var carg1 *C.gchar // in, none, string + var carg2 *C.gchar // in, none, string + var carg3 *C.gchar // in, none, string + var carg4 C.gint // in, none, casted + var carg5 C.gint // in, none, casted + var carg6 C.gint // in, none, casted + var carg7 C.gint // in, none, casted + var carg8 C.gint // in, none, casted + var carg9 C.gint // in, none, casted + var carg10 C.GParamFlags // in, none, casted + var cret *C.GParamSpec // return, full, converted, nullable + + carg1 = (*C.gchar)(unsafe.Pointer(C.CString(name))) + defer C.free(unsafe.Pointer(carg1)) + carg2 = (*C.gchar)(unsafe.Pointer(C.CString(nick))) + defer C.free(unsafe.Pointer(carg2)) + carg3 = (*C.gchar)(unsafe.Pointer(C.CString(blurb))) + defer C.free(unsafe.Pointer(carg3)) + carg4 = C.gint(minNum) + carg5 = C.gint(minDenom) + carg6 = C.gint(maxNum) + carg7 = C.gint(maxDenom) + carg8 = C.gint(defaultNum) + carg9 = C.gint(defaultDenom) + carg10 = C.GParamFlags(flags) + + cret = C.gst_param_spec_fraction(carg1, carg2, carg3, carg4, carg5, carg6, carg7, carg8, carg9, carg10) + runtime.KeepAlive(name) + runtime.KeepAlive(nick) + runtime.KeepAlive(blurb) + runtime.KeepAlive(minNum) + runtime.KeepAlive(minDenom) + runtime.KeepAlive(maxNum) + runtime.KeepAlive(maxDenom) + runtime.KeepAlive(defaultNum) + runtime.KeepAlive(defaultDenom) + runtime.KeepAlive(flags) + + var goret *gobject.ParamSpec + + if cret != nil { + goret = gobject.UnsafeParamSpecFromGlibFull(unsafe.Pointer(cret)) + } + + return goret +} + // ParentBufferMetaApiGetType wraps gst_parent_buffer_meta_api_get_type // // The function returns the following values: @@ -10559,6 +10687,51 @@ func ValueDeserialize(src string) (gobject.Value, bool) { return dest, goret } +// ValueDeserializeWithPspec wraps gst_value_deserialize_with_pspec +// +// The function takes the following parameters: +// +// - src string: string to deserialize +// - pspec *gobject.ParamSpec (nullable): the #GParamSpec describing the expected value +// +// The function returns the following values: +// +// - dest gobject.Value: #GValue to fill with contents of +// deserialization +// - goret bool +// +// Tries to deserialize a string into the type specified by the given GValue. +// @pspec may be used to guide the deserializing of nested members. +// If the operation succeeds, %TRUE is returned, %FALSE otherwise. +func ValueDeserializeWithPspec(src string, pspec *gobject.ParamSpec) (gobject.Value, bool) { + var carg2 *C.gchar // in, none, string + var carg3 *C.GParamSpec // in, none, converted, nullable + var carg1 C.GValue // out, transfer: none, C Pointers: 0, Name: Value, caller-allocates + var cret C.gboolean // return + + carg2 = (*C.gchar)(unsafe.Pointer(C.CString(src))) + defer C.free(unsafe.Pointer(carg2)) + if pspec != nil { + carg3 = (*C.GParamSpec)(gobject.UnsafeParamSpecToGlibNone(pspec)) + } + + cret = C.gst_value_deserialize_with_pspec(&carg1, carg2, carg3) + runtime.KeepAlive(src) + runtime.KeepAlive(pspec) + + var dest gobject.Value + var goret bool + + _ = dest + _ = carg1 + panic("unimplemented conversion of gobject.Value (GValue)") + if cret != 0 { + goret = true + } + + return dest, goret +} + // ValueFixate wraps gst_value_fixate // // The function takes the following parameters: @@ -11904,6 +12077,22 @@ type ChildProxy interface { // // Gets the number of child objects this parent contains. GetChildrenCount() uint + // Lookup wraps gst_child_proxy_lookup + // + // The function takes the following parameters: + // + // - name string: name of the property to look up + // + // The function returns the following values: + // + // - target gobject.Object: pointer to a #GObject that + // takes the real object to set property on + // - pspec *gobject.ParamSpec: pointer to take the #GParamSpec + // describing the property + // - goret bool + // + // Looks up which object and #GParamSpec would be effected by the given @name. + Lookup(string) (gobject.Object, *gobject.ParamSpec, bool) // ConnectChildAdded connects the provided callback to the "child-added" signal // // Will be emitted after the @object was added to the @child_proxy. @@ -12132,6 +12321,49 @@ func (parent *ChildProxyInstance) GetChildrenCount() uint { return goret } +// Lookup wraps gst_child_proxy_lookup +// +// The function takes the following parameters: +// +// - name string: name of the property to look up +// +// The function returns the following values: +// +// - target gobject.Object: pointer to a #GObject that +// takes the real object to set property on +// - pspec *gobject.ParamSpec: pointer to take the #GParamSpec +// describing the property +// - goret bool +// +// Looks up which object and #GParamSpec would be effected by the given @name. +func (object *ChildProxyInstance) Lookup(name string) (gobject.Object, *gobject.ParamSpec, bool) { + var carg0 *C.GstChildProxy // in, none, converted + var carg1 *C.gchar // in, none, string + var carg2 *C.GObject // out, full, converted + var carg3 *C.GParamSpec // out, none, converted + var cret C.gboolean // return + + carg0 = (*C.GstChildProxy)(UnsafeChildProxyToGlibNone(object)) + carg1 = (*C.gchar)(unsafe.Pointer(C.CString(name))) + defer C.free(unsafe.Pointer(carg1)) + + cret = C.gst_child_proxy_lookup(carg0, carg1, &carg2, &carg3) + runtime.KeepAlive(object) + runtime.KeepAlive(name) + + var target gobject.Object + var pspec *gobject.ParamSpec + var goret bool + + target = gobject.UnsafeObjectFromGlibFull(unsafe.Pointer(carg2)) + pspec = gobject.UnsafeParamSpecFromGlibNone(unsafe.Pointer(carg3)) + if cret != 0 { + goret = true + } + + return target, pspec, goret +} + // ConnectChildAdded connects the provided callback to the "child-added" signal // // Will be emitted after the @object was added to the @child_proxy. @@ -12960,7 +13192,7 @@ func UnsafeApplyPresetOverrides[Instance Preset](gclass unsafe.Pointer, override value, goret = overrides.GetMeta(preset, name, tag) - carg3 = (*C.gchar)(unsafe.Pointer(C.CString(value))) + *carg3 = (*C.gchar)(unsafe.Pointer(C.CString(value))) if goret { cret = C.TRUE } @@ -14139,6 +14371,12 @@ type Object interface { // // MT safe. Grabs and releases @object's lock. Unparent() + // ConnectDeepNotify connects the provided callback to the "deep-notify" signal + // + // The deep notify signal is used to be notified of property changes. It is + // typically attached to the toplevel bin to receive notifications from all + // the elements contained in that bin. + ConnectDeepNotify(func(Object, Object, gobject.ParamSpec)) gobject.SignalHandle } func unsafeWrapObject(base *gobject.ObjectInstance) *ObjectInstance { @@ -14177,6 +14415,44 @@ func UnsafeObjectToGlibFull(c Object) unsafe.Pointer { return gobject.UnsafeObjectToGlibFull(c) } +// ObjectDefaultDeepNotify wraps gst_object_default_deep_notify +// +// The function takes the following parameters: +// +// - object gobject.Object: the #GObject that signalled the notify. +// - orig Object: a #GstObject that initiated the notify. +// - pspec *gobject.ParamSpec: a #GParamSpec of the property. +// - excludedProps []string (nullable): +// a set of user-specified properties to exclude or %NULL to show +// all changes. +// +// A default deep_notify signal callback for an object. The user data +// should contain a pointer to an array of strings that should be excluded +// from the notify. The default handler will print the new value of the property +// using g_print. +// +// MT safe. This function grabs and releases @object's LOCK for getting its +// path string. +func ObjectDefaultDeepNotify(object gobject.Object, orig Object, pspec *gobject.ParamSpec, excludedProps []string) { + var carg1 *C.GObject // in, none, converted + var carg2 *C.GstObject // in, none, converted + var carg3 *C.GParamSpec // in, none, converted + var carg4 **C.gchar // in, transfer: none, C Pointers: 2, Name: array[utf8], nullable, array (inner: *typesystem.StringPrimitive, zero-terminated) + + carg1 = (*C.GObject)(gobject.UnsafeObjectToGlibNone(object)) + carg2 = (*C.GstObject)(UnsafeObjectToGlibNone(orig)) + carg3 = (*C.GParamSpec)(gobject.UnsafeParamSpecToGlibNone(pspec)) + _ = excludedProps + _ = carg4 + panic("unimplemented conversion of []string (gchar**)") + + C.gst_object_default_deep_notify(carg1, carg2, carg3, carg4) + runtime.KeepAlive(object) + runtime.KeepAlive(orig) + runtime.KeepAlive(pspec) + runtime.KeepAlive(excludedProps) +} + // AddControlBinding wraps gst_object_add_control_binding // // The function takes the following parameters: @@ -14776,18 +15052,54 @@ func (object *ObjectInstance) Unparent() { runtime.KeepAlive(object) } +// ConnectDeepNotify connects the provided callback to the "deep-notify" signal +// +// The deep notify signal is used to be notified of property changes. It is +// typically attached to the toplevel bin to receive notifications from all +// the elements contained in that bin. +func (o *ObjectInstance) ConnectDeepNotify(fn func(Object, Object, gobject.ParamSpec)) gobject.SignalHandle { + return o.Connect("deep-notify", fn) +} + // ObjectOverrides is the struct used to override the default implementation of virtual methods. // it is generic over the extending instance type. type ObjectOverrides[Instance Object] struct { // gobject.InitiallyUnownedOverrides allows you to override virtual methods from the parent class gobject.InitiallyUnowned gobject.InitiallyUnownedOverrides[Instance] + // DeepNotify allows you to override the implementation of the virtual method deep_notify. + // The function takes the following parameters: + // + // - orig Object + // - pspec *gobject.ParamSpec + DeepNotify func(Instance, Object, *gobject.ParamSpec) } // UnsafeApplyObjectOverrides applies the overrides to init the gclass by setting the trampoline functions. // This is used by the bindings internally and only exported for visibility to other bindings code. func UnsafeApplyObjectOverrides[Instance Object](gclass unsafe.Pointer, overrides ObjectOverrides[Instance]) { gobject.UnsafeApplyInitiallyUnownedOverrides(gclass, overrides.InitiallyUnownedOverrides) + + pclass := (*C.GstObjectClass)(gclass) + + if overrides.DeepNotify != nil { + pclass.deep_notify = (*[0]byte)(C._gotk4_gst1_Object_deep_notify) + classdata.StoreVirtualMethod( + unsafe.Pointer(pclass), + "_gotk4_gst1_Object_deep_notify", + func(carg0 *C.GstObject, carg1 *C.GstObject, carg2 *C.GParamSpec) { + var object Instance // go GstObject subclass + var orig Object // in, none, converted + var pspec *gobject.ParamSpec // in, none, converted + + object = UnsafeObjectFromGlibNone(unsafe.Pointer(carg0)).(Instance) + orig = UnsafeObjectFromGlibNone(unsafe.Pointer(carg1)) + pspec = gobject.UnsafeParamSpecFromGlibNone(unsafe.Pointer(carg2)) + + overrides.DeepNotify(object, orig, pspec) + }, + ) + } } // RegisterObjectSubClass is used to register a go subclass of GstObject. For this to work safely please implement the @@ -22041,6 +22353,11 @@ type StreamCollection interface { // // Returns the upstream id of the @collection. GetUpstreamID() string + // ConnectStreamNotify connects the provided callback to the "stream-notify" signal + // + // The stream notify signal is used to be notified of property changes to + // streams within the collection. + ConnectStreamNotify(func(StreamCollection, Stream, gobject.ParamSpec)) gobject.SignalHandle } func unsafeWrapStreamCollection(base *gobject.ObjectInstance) *StreamCollectionInstance { @@ -22225,18 +22542,53 @@ func (collection *StreamCollectionInstance) GetUpstreamID() string { return goret } +// ConnectStreamNotify connects the provided callback to the "stream-notify" signal +// +// The stream notify signal is used to be notified of property changes to +// streams within the collection. +func (o *StreamCollectionInstance) ConnectStreamNotify(fn func(StreamCollection, Stream, gobject.ParamSpec)) gobject.SignalHandle { + return o.Connect("stream-notify", fn) +} + // StreamCollectionOverrides is the struct used to override the default implementation of virtual methods. // it is generic over the extending instance type. type StreamCollectionOverrides[Instance StreamCollection] struct { // ObjectOverrides allows you to override virtual methods from the parent class Object ObjectOverrides[Instance] + // StreamNotify allows you to override the implementation of the virtual method stream_notify. + // The function takes the following parameters: + // + // - stream Stream + // - pspec *gobject.ParamSpec + StreamNotify func(Instance, Stream, *gobject.ParamSpec) } // UnsafeApplyStreamCollectionOverrides applies the overrides to init the gclass by setting the trampoline functions. // This is used by the bindings internally and only exported for visibility to other bindings code. func UnsafeApplyStreamCollectionOverrides[Instance StreamCollection](gclass unsafe.Pointer, overrides StreamCollectionOverrides[Instance]) { UnsafeApplyObjectOverrides(gclass, overrides.ObjectOverrides) + + pclass := (*C.GstStreamCollectionClass)(gclass) + + if overrides.StreamNotify != nil { + pclass.stream_notify = (*[0]byte)(C._gotk4_gst1_StreamCollection_stream_notify) + classdata.StoreVirtualMethod( + unsafe.Pointer(pclass), + "_gotk4_gst1_StreamCollection_stream_notify", + func(carg0 *C.GstStreamCollection, carg1 *C.GstStream, carg2 *C.GParamSpec) { + var collection Instance // go GstStreamCollection subclass + var stream Stream // in, none, converted + var pspec *gobject.ParamSpec // in, none, converted + + collection = UnsafeStreamCollectionFromGlibNone(unsafe.Pointer(carg0)).(Instance) + stream = UnsafeStreamFromGlibNone(unsafe.Pointer(carg1)) + pspec = gobject.UnsafeParamSpecFromGlibNone(unsafe.Pointer(carg2)) + + overrides.StreamNotify(collection, stream, pspec) + }, + ) + } } // RegisterStreamCollectionSubClass is used to register a go subclass of GstStreamCollection. For this to work safely please implement the @@ -53448,133 +53800,6 @@ func (p *PadTemplateClass) ParentClass() *ObjectClass { return parent } -// ParamSpecArray wraps GstParamSpecArray -// -// A GParamSpec derived structure for arrays of values. -type ParamSpecArray struct { - *paramSpecArray -} - -// paramSpecArray is the struct that's finalized -type paramSpecArray struct { - native *C.GstParamSpecArray -} - -// UnsafeParamSpecArrayFromGlibBorrow is used to convert raw C.GstParamSpecArray pointers to go. This is used by the bindings internally. -func UnsafeParamSpecArrayFromGlibBorrow(p unsafe.Pointer) *ParamSpecArray { - return &ParamSpecArray{¶mSpecArray{(*C.GstParamSpecArray)(p)}} -} - -// UnsafeParamSpecArrayFromGlibNone is used to convert raw C.GstParamSpecArray pointers to go without transferring ownership. This is used by the bindings internally. -func UnsafeParamSpecArrayFromGlibNone(p unsafe.Pointer) *ParamSpecArray { - // FIXME: this has no ref function, what should we do here? - wrapped := UnsafeParamSpecArrayFromGlibBorrow(p) - runtime.SetFinalizer( - wrapped.paramSpecArray, - func (intern *paramSpecArray) { - C.free(unsafe.Pointer(intern.native)) - }, - ) - return wrapped -} - -// UnsafeParamSpecArrayFromGlibFull is used to convert raw C.GstParamSpecArray pointers to go while taking ownership. This is used by the bindings internally. -func UnsafeParamSpecArrayFromGlibFull(p unsafe.Pointer) *ParamSpecArray { - wrapped := UnsafeParamSpecArrayFromGlibBorrow(p) - runtime.SetFinalizer( - wrapped.paramSpecArray, - func (intern *paramSpecArray) { - C.free(unsafe.Pointer(intern.native)) - }, - ) - return wrapped -} - -// UnsafeParamSpecArrayFree unrefs/frees the underlying resource. This is used by the bindings internally. -// -// After this is called, no other method on [ParamSpecArray] is expected to work anymore. -func UnsafeParamSpecArrayFree(p *ParamSpecArray) { - C.free(unsafe.Pointer(p.native)) -} - -// UnsafeParamSpecArrayToGlibNone returns the underlying C pointer. This is used by the bindings internally. -func UnsafeParamSpecArrayToGlibNone(p *ParamSpecArray) unsafe.Pointer { - return unsafe.Pointer(p.native) -} - -// UnsafeParamSpecArrayToGlibFull returns the underlying C pointer and gives up ownership. -// This is used by the bindings internally. -func UnsafeParamSpecArrayToGlibFull(p *ParamSpecArray) unsafe.Pointer { - runtime.SetFinalizer(p.paramSpecArray, nil) - _p := unsafe.Pointer(p.native) - p.native = nil // ParamSpecArray is invalid from here on - return _p -} - -// ParamSpecFraction wraps GstParamSpecFraction -// -// A GParamSpec derived structure that contains the meta data for fractional -// properties. -type ParamSpecFraction struct { - *paramSpecFraction -} - -// paramSpecFraction is the struct that's finalized -type paramSpecFraction struct { - native *C.GstParamSpecFraction -} - -// UnsafeParamSpecFractionFromGlibBorrow is used to convert raw C.GstParamSpecFraction pointers to go. This is used by the bindings internally. -func UnsafeParamSpecFractionFromGlibBorrow(p unsafe.Pointer) *ParamSpecFraction { - return &ParamSpecFraction{¶mSpecFraction{(*C.GstParamSpecFraction)(p)}} -} - -// UnsafeParamSpecFractionFromGlibNone is used to convert raw C.GstParamSpecFraction pointers to go without transferring ownership. This is used by the bindings internally. -func UnsafeParamSpecFractionFromGlibNone(p unsafe.Pointer) *ParamSpecFraction { - // FIXME: this has no ref function, what should we do here? - wrapped := UnsafeParamSpecFractionFromGlibBorrow(p) - runtime.SetFinalizer( - wrapped.paramSpecFraction, - func (intern *paramSpecFraction) { - C.free(unsafe.Pointer(intern.native)) - }, - ) - return wrapped -} - -// UnsafeParamSpecFractionFromGlibFull is used to convert raw C.GstParamSpecFraction pointers to go while taking ownership. This is used by the bindings internally. -func UnsafeParamSpecFractionFromGlibFull(p unsafe.Pointer) *ParamSpecFraction { - wrapped := UnsafeParamSpecFractionFromGlibBorrow(p) - runtime.SetFinalizer( - wrapped.paramSpecFraction, - func (intern *paramSpecFraction) { - C.free(unsafe.Pointer(intern.native)) - }, - ) - return wrapped -} - -// UnsafeParamSpecFractionFree unrefs/frees the underlying resource. This is used by the bindings internally. -// -// After this is called, no other method on [ParamSpecFraction] is expected to work anymore. -func UnsafeParamSpecFractionFree(p *ParamSpecFraction) { - C.free(unsafe.Pointer(p.native)) -} - -// UnsafeParamSpecFractionToGlibNone returns the underlying C pointer. This is used by the bindings internally. -func UnsafeParamSpecFractionToGlibNone(p *ParamSpecFraction) unsafe.Pointer { - return unsafe.Pointer(p.native) -} - -// UnsafeParamSpecFractionToGlibFull returns the underlying C pointer and gives up ownership. -// This is used by the bindings internally. -func UnsafeParamSpecFractionToGlibFull(p *ParamSpecFraction) unsafe.Pointer { - runtime.SetFinalizer(p.paramSpecFraction, nil) - _p := unsafe.Pointer(p.native) - p.native = nil // ParamSpecFraction is invalid from here on - return _p -} - // ParentBufferMeta wraps GstParentBufferMeta // // The #GstParentBufferMeta is a #GstMeta which can be attached to a #GstBuffer diff --git a/pkg/gst/gst_export.gen.go b/pkg/gst/gst_export.gen.go index 6dcc4e9..9e028dc 100644 --- a/pkg/gst/gst_export.gen.go +++ b/pkg/gst/gst_export.gen.go @@ -838,6 +838,18 @@ func _gotk4_gst1_URIHandler_set_uri(carg0 *C.GstURIHandler, carg1 *C.gchar, _cer return fn(carg0, carg1, _cerr) } +//export _gotk4_gst1_Object_deep_notify +func _gotk4_gst1_Object_deep_notify(carg0 *C.GstObject, carg1 *C.GstObject, carg2 *C.GParamSpec) { + var fn func(carg0 *C.GstObject, carg1 *C.GstObject, carg2 *C.GParamSpec) + { + fn = classdata.LoadVirtualMethodFromInstance(unsafe.Pointer(carg0), "_gotk4_gst1_Object_deep_notify").(func(carg0 *C.GstObject, carg1 *C.GstObject, carg2 *C.GParamSpec)) + if fn == nil { + panic("_gotk4_gst1_Object_deep_notify: no function pointer found") + } + } + fn(carg0, carg1, carg2) +} + //export _gotk4_gst1_Pad_linked func _gotk4_gst1_Pad_linked(carg0 *C.GstPad, carg1 *C.GstPad) { var fn func(carg0 *C.GstPad, carg1 *C.GstPad) @@ -874,6 +886,18 @@ func _gotk4_gst1_PadTemplate_pad_created(carg0 *C.GstPadTemplate, carg1 *C.GstPa fn(carg0, carg1) } +//export _gotk4_gst1_StreamCollection_stream_notify +func _gotk4_gst1_StreamCollection_stream_notify(carg0 *C.GstStreamCollection, carg1 *C.GstStream, carg2 *C.GParamSpec) { + var fn func(carg0 *C.GstStreamCollection, carg1 *C.GstStream, carg2 *C.GParamSpec) + { + fn = classdata.LoadVirtualMethodFromInstance(unsafe.Pointer(carg0), "_gotk4_gst1_StreamCollection_stream_notify").(func(carg0 *C.GstStreamCollection, carg1 *C.GstStream, carg2 *C.GParamSpec)) + if fn == nil { + panic("_gotk4_gst1_StreamCollection_stream_notify: no function pointer found") + } + } + fn(carg0, carg1, carg2) +} + //export _gotk4_gst1_TaskPool_cleanup func _gotk4_gst1_TaskPool_cleanup(carg0 *C.GstTaskPool) { var fn func(carg0 *C.GstTaskPool) diff --git a/pkg/gst/param_flags.go b/pkg/gst/param_flags.go new file mode 100644 index 0000000..5469d11 --- /dev/null +++ b/pkg/gst/param_flags.go @@ -0,0 +1,37 @@ +package gst + +import "github.com/diamondburned/gotk4/pkg/gobject/v2" + +// #cgo pkg-config: gstreamer-1.0 +// #cgo CFLAGS: -Wno-deprecated-declarations +// #include +import "C" + +const ( + // ParamConditionallyAvailable is used on GObject properties of GstObject to indicate that + // they might not be available depending on environment such as OS, device, etc, so such properties + // will be installed conditionally only if the GstObject is able to support it. + ParamConditionallyAvailable gobject.ParamFlags = gobject.ParamFlags(C.GST_PARAM_CONDITIONALLY_AVAILABLE) + + // ParamControllable is used on GObject properties to signal they can make sense to be controlled over time. + // This hint is used by the GstController. + ParamControllable gobject.ParamFlags = gobject.ParamFlags(C.GST_PARAM_CONTROLLABLE) + + // ParamDocShowDefault is used on GObject properties of GstObject to indicate that during gst-inspect and friends, + // the default value should be used as default instead of the current value. + ParamDocShowDefault gobject.ParamFlags = gobject.ParamFlags(C.GST_PARAM_DOC_SHOW_DEFAULT) + + // ParamMutablePaused is used on GObject properties of GstElements to indicate that they can be changed when the element is in the PAUSED or lower state. + // This flag implies GST_PARAM_MUTABLE_READY. + ParamMutablePaused gobject.ParamFlags = gobject.ParamFlags(C.GST_PARAM_MUTABLE_PAUSED) + // ParamMutablePlaying is used on GObject properties of GstElements to indicate that they can be changed when the element is in the PLAYING or lower state. + // This flag implies GST_PARAM_MUTABLE_PAUSED. + ParamMutablePlaying gobject.ParamFlags = gobject.ParamFlags(C.GST_PARAM_MUTABLE_PLAYING) + + // ParamMutableReady is used on GObject properties of GstElements to indicate that they can be changed when the element is in the READY or lower state. + ParamMutableReady gobject.ParamFlags = gobject.ParamFlags(C.GST_PARAM_MUTABLE_READY) + + // ParamUserShift is used on GObject properties of GstElements to indicate that they can be changed when the element is in the READY or lower state. + // Bits based on GST_PARAM_USER_SHIFT can be used by 3rd party applications. + ParamUserShift gobject.ParamFlags = gobject.ParamFlags(C.GST_PARAM_USER_SHIFT) +) diff --git a/pkg/gstallocators/gstallocators.gen.go b/pkg/gstallocators/gstallocators.gen.go index e4f6377..09589f9 100644 --- a/pkg/gstallocators/gstallocators.gen.go +++ b/pkg/gstallocators/gstallocators.gen.go @@ -7,7 +7,6 @@ import ( "strings" "unsafe" - "github.com/diamondburned/gotk4/pkg/core/classdata" "github.com/diamondburned/gotk4/pkg/gobject/v2" "github.com/go-gst/go-gst/pkg/gst" ) diff --git a/pkg/gstcheck/gstcheck.gen.go b/pkg/gstcheck/gstcheck.gen.go index c1c68e1..af6673d 100644 --- a/pkg/gstcheck/gstcheck.gen.go +++ b/pkg/gstcheck/gstcheck.gen.go @@ -6,7 +6,6 @@ import ( "runtime" "unsafe" - "github.com/diamondburned/gotk4/pkg/core/classdata" "github.com/diamondburned/gotk4/pkg/core/userdata" "github.com/diamondburned/gotk4/pkg/glib/v2" "github.com/diamondburned/gotk4/pkg/gobject/v2" diff --git a/pkg/gstcontroller/gstcontroller.gen.go b/pkg/gstcontroller/gstcontroller.gen.go index bfd29ca..aace77a 100644 --- a/pkg/gstcontroller/gstcontroller.gen.go +++ b/pkg/gstcontroller/gstcontroller.gen.go @@ -7,7 +7,6 @@ import ( "runtime" "unsafe" - "github.com/diamondburned/gotk4/pkg/core/classdata" "github.com/diamondburned/gotk4/pkg/glib/v2" "github.com/diamondburned/gotk4/pkg/gobject/v2" "github.com/go-gst/go-gst/pkg/gst" diff --git a/pkg/gstnet/gstnet.gen.go b/pkg/gstnet/gstnet.gen.go index d30a3cb..4641778 100644 --- a/pkg/gstnet/gstnet.gen.go +++ b/pkg/gstnet/gstnet.gen.go @@ -6,7 +6,6 @@ import ( "runtime" "unsafe" - "github.com/diamondburned/gotk4/pkg/core/classdata" "github.com/diamondburned/gotk4/pkg/core/userdata" "github.com/diamondburned/gotk4/pkg/gio/v2" "github.com/diamondburned/gotk4/pkg/glib/v2" diff --git a/pkg/gstplay/gstplay.gen.go b/pkg/gstplay/gstplay.gen.go index 90417bf..7fee5d9 100644 --- a/pkg/gstplay/gstplay.gen.go +++ b/pkg/gstplay/gstplay.gen.go @@ -7,7 +7,6 @@ import ( "runtime" "unsafe" - "github.com/diamondburned/gotk4/pkg/core/classdata" "github.com/diamondburned/gotk4/pkg/glib/v2" "github.com/diamondburned/gotk4/pkg/gobject/v2" "github.com/go-gst/go-gst/pkg/gst" diff --git a/pkg/gstplayer/gstplayer.gen.go b/pkg/gstplayer/gstplayer.gen.go index 527dc54..4ee7e4a 100644 --- a/pkg/gstplayer/gstplayer.gen.go +++ b/pkg/gstplayer/gstplayer.gen.go @@ -7,7 +7,6 @@ import ( "runtime" "unsafe" - "github.com/diamondburned/gotk4/pkg/core/classdata" "github.com/diamondburned/gotk4/pkg/glib/v2" "github.com/diamondburned/gotk4/pkg/gobject/v2" "github.com/go-gst/go-gst/pkg/gst" diff --git a/pkg/gstwebrtc/gstwebrtc.gen.go b/pkg/gstwebrtc/gstwebrtc.gen.go index 419131d..387eff0 100644 --- a/pkg/gstwebrtc/gstwebrtc.gen.go +++ b/pkg/gstwebrtc/gstwebrtc.gen.go @@ -2791,9 +2791,7 @@ func UnsafeApplyWebRTCICEOverrides[Instance WebRTCICE](gclass unsafe.Pointer, ov ice = UnsafeWebRTCICEFromGlibNone(unsafe.Pointer(carg0)).(Instance) _ = fn _ = carg1 - _ = _ _ = carg2 - _ = notify _ = carg3 panic("unimplemented conversion of WebRTCICEOnCandidateFunc (GstWebRTCICEOnCandidateFunc)")