mirror of
https://github.com/go-gst/go-gst.git
synced 2025-10-05 07:56:51 +08:00
regenerate, remove interface virtuals, manually implement BusSyncHandler
* correctly borrow Message Source * prevent leaks in Bus.Messages() by changing (un-)reffing
This commit is contained in:
@@ -1,5 +1,32 @@
|
||||
package customtransform
|
||||
|
||||
// type customBaseTransform struct {
|
||||
// gstbase.BaseTransform
|
||||
// }
|
||||
import (
|
||||
"github.com/go-gst/go-gst/pkg/gst"
|
||||
"github.com/go-gst/go-gst/pkg/gstbase"
|
||||
)
|
||||
|
||||
type customBaseTransform struct {
|
||||
gstbase.BaseTransformInstance
|
||||
}
|
||||
|
||||
func classInit(class *gstbase.BaseTransformClass) {
|
||||
class.ParentClass().SetStaticMetadata(
|
||||
"custom base transform",
|
||||
"Transform/demo",
|
||||
"custom base transform",
|
||||
"Wilhelm Bartel <bartel.wilhelm@gmail.com>",
|
||||
)
|
||||
|
||||
class.ParentClass().AddPadTemplate(gst.NewPadTemplate(
|
||||
"src",
|
||||
gst.PadSrc,
|
||||
gst.PadAlways,
|
||||
gst.CapsFromString("audio/x-raw,channels=2,rate=48000"),
|
||||
))
|
||||
class.ParentClass().AddPadTemplate(gst.NewPadTemplate(
|
||||
"sink",
|
||||
gst.PadSink,
|
||||
gst.PadAlways,
|
||||
gst.CapsFromString("audio/x-raw,channels=2,rate=48000"),
|
||||
))
|
||||
}
|
||||
|
@@ -1,46 +1,28 @@
|
||||
package customtransform
|
||||
|
||||
import (
|
||||
"github.com/go-gst/go-gst/pkg/gst"
|
||||
"github.com/go-gst/go-gst/pkg/gstbase"
|
||||
)
|
||||
|
||||
// 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[*customBaseTransform](
|
||||
// func() *customBaseTransform {
|
||||
// return &customBaseTransform{}
|
||||
// },
|
||||
// glib.WithOverrides[*customBaseTransform, gstbase.BaseTransformOverrides](func(b *customBaseTransform) gstbase.BaseTransformOverrides {
|
||||
// return gstbase.BaseTransformOverrides{}
|
||||
// }),
|
||||
// glib.WithClassInit[*gstbase.BaseTransformClass](func(class *gstbase.BaseTransformClass) {
|
||||
// class.ParentClass().SetStaticMetadata(
|
||||
// "custom base transform",
|
||||
// "Transform/demo",
|
||||
// "custom base transform",
|
||||
// "Wilhelm Bartel <bartel.wilhelm@gmail.com>",
|
||||
// )
|
||||
registered := gstbase.RegisterBaseTransformSubClass[*customBaseTransform](
|
||||
"gocustomtransform",
|
||||
classInit,
|
||||
nil, // no constructor
|
||||
gstbase.BaseTransformOverrides[*customBaseTransform]{},
|
||||
nil, // no signals
|
||||
)
|
||||
|
||||
// class.ParentClass().AddPadTemplate(gst.NewPadTemplate(
|
||||
// "src",
|
||||
// gst.PadSrc,
|
||||
// gst.PadAlways,
|
||||
// gst.CapsFromString("audio/x-raw,channels=2,rate=48000"),
|
||||
// ))
|
||||
// class.ParentClass().AddPadTemplate(gst.NewPadTemplate(
|
||||
// "sink",
|
||||
// gst.PadSink,
|
||||
// gst.PadAlways,
|
||||
// gst.CapsFromString("audio/x-raw,channels=2,rate=48000"),
|
||||
// ))
|
||||
// }),
|
||||
// )
|
||||
|
||||
// return gst.ElementRegister(
|
||||
// // no plugin:
|
||||
// nil,
|
||||
// // The name of the element
|
||||
// "gocustomtransform",
|
||||
// // The rank of the element
|
||||
// uint(gst.RankNone),
|
||||
// registered.Type(),
|
||||
// )
|
||||
return gst.ElementRegister(
|
||||
// no plugin:
|
||||
nil,
|
||||
// The name of the element
|
||||
"gocustomtransform",
|
||||
// The rank of the element
|
||||
uint(gst.RankNone),
|
||||
registered,
|
||||
)
|
||||
}
|
||||
|
@@ -5,8 +5,10 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
"github.com/diamondburned/gotk4/pkg/core/profile"
|
||||
"github.com/go-gst/go-gst/examples/plugins/basetransform/internal/customtransform"
|
||||
"github.com/go-gst/go-gst/pkg/gst"
|
||||
)
|
||||
@@ -37,10 +39,21 @@ func run(ctx context.Context) error {
|
||||
}
|
||||
|
||||
func main() {
|
||||
ctx := context.Background()
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
|
||||
err := run(ctx)
|
||||
|
||||
for range 10 {
|
||||
runtime.GC()
|
||||
}
|
||||
|
||||
if profile.Count() > 0 {
|
||||
fmt.Fprintf(os.Stderr, "Memory leak detected: %d objects still tracked\n", profile.Count())
|
||||
} else {
|
||||
fmt.Fprintln(os.Stderr, "No memory leaks detected")
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user