examples compiling again

This commit is contained in:
RSWilli
2025-09-16 22:36:07 +02:00
parent ca3249e47b
commit e1b00764a8
55 changed files with 7642 additions and 1654 deletions

View File

@@ -1,51 +1,46 @@
package customtransform
import (
"github.com/diamondburned/gotk4/pkg/core/glib"
"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 {
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>",
)
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>",
// )
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"),
))
}),
)
// 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.Type(),
// )
}

View File

@@ -25,7 +25,7 @@ func run(ctx context.Context) error {
return err
}
pipeline := ret.(*gst.Pipeline)
pipeline := ret.(gst.Pipeline)
pipeline.SetState(gst.StatePlaying)

View File

@@ -8,9 +8,9 @@ import (
type customBin struct {
gst.Bin // parent object must be first embedded field
source1 gst.Elementer
source2 gst.Elementer
mixer gst.Elementer
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.
@@ -31,12 +31,12 @@ func (bin *customBin) init() {
bin.mixer,
)
srcpad := bin.mixer.StaticPad("src")
srcpad := bin.mixer.GetStaticPad("src")
ghostpad := gst.NewGhostPadFromTemplate("src", srcpad, bin.PadTemplate("src"))
ghostpad := gst.NewGhostPadFromTemplate("src", srcpad, bin.GetPadTemplate("src"))
bin.source1.Link(bin.mixer)
bin.source2.Link(bin.mixer)
bin.AddPad(&ghostpad.Pad)
bin.AddPad(ghostpad)
}

View File

@@ -1,45 +1,41 @@
package custombin
import (
"github.com/diamondburned/gotk4/pkg/core/glib"
"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 {
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 <bartel.wilhelm@gmail.com>",
)
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 <bartel.wilhelm@gmail.com>",
// )
bc.ParentClass().AddPadTemplate(gst.NewPadTemplate(
"src",
gst.PadSrc,
gst.PadAlways,
gst.CapsFromString("audio/x-raw,channels=2,rate=48000"),
))
}),
)
// 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),
// // The GoElement implementation for the element
// registered.Type(),
// )
}

View File

@@ -15,8 +15,8 @@ const samplerate = 48000
type customSrc struct {
gst.Bin // parent must be embedded as the first field
source gst.Elementer
volume gst.Elementer
source gst.Element
volume gst.Element
Duration time.Duration `glib:"duration"`
}
@@ -31,16 +31,16 @@ func (bin *customSrc) init() {
bin.volume,
)
srcpad := bin.volume.StaticPad("src")
srcpad := bin.volume.GetStaticPad("src")
ghostpad := gst.NewGhostPadFromTemplate("src", srcpad, bin.PadTemplate("src"))
ghostpad := gst.NewGhostPadFromTemplate("src", srcpad, bin.GetPadTemplate("src"))
gst.LinkMany(
bin.source,
bin.volume,
)
bin.AddPad(&ghostpad.Pad)
bin.AddPad(ghostpad)
bin.updateSource()
}

View File

@@ -1,44 +1,40 @@
package customsrc
import (
"github.com/diamondburned/gotk4/pkg/core/glib"
"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 {
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 <bartel.wilhelm@gmail.com>",
)
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 <bartel.wilhelm@gmail.com>",
// )
bc.ParentClass().AddPadTemplate(gst.NewPadTemplate(
"src",
gst.PadSrc,
gst.PadAlways,
gst.CapsFromString("audio/x-raw,channels=2,rate=48000"),
))
}),
)
// 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
"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.Type(),
// )
}

View File

@@ -8,7 +8,6 @@ import (
"path/filepath"
"time"
"github.com/diamondburned/gotk4/pkg/glib/v2"
"github.com/go-gst/go-gst/examples/plugins/registered_elements/internal/custombin"
"github.com/go-gst/go-gst/examples/plugins/registered_elements/internal/customsrc"
"github.com/go-gst/go-gst/pkg/gst"
@@ -37,54 +36,50 @@ func run(ctx context.Context) error {
return err
}
pipeline := ret.(*gst.Pipeline)
pipeline := ret.(gst.Pipeline)
pipeline.UseClock(systemclock)
bus := pipeline.Bus()
mainloop := glib.NewMainLoop(glib.MainContextDefault(), false)
bus := pipeline.GetBus()
pipeline.SetState(gst.StatePlaying)
bus.AddWatch(0, func(bus *gst.Bus, msg *gst.Message) bool {
switch msg.Type() {
case gst.MessageStateChanged:
old, new, _ := msg.ParseStateChanged()
dot := gst.DebugBinToDotData(&pipeline.Bin, gst.DebugGraphShowVerbose)
go func() {
for msg := range bus.Messages(ctx) {
switch msg.Type() {
case gst.MessageStateChanged:
old, new, _ := msg.ParseStateChanged()
dot := pipeline.DebugBinToDotData(gst.DebugGraphShowVerbose)
f, err := os.OpenFile(filepath.Join(wd, fmt.Sprintf("pipeline-%s-to-%s.dot", old, new)), os.O_TRUNC|os.O_CREATE|os.O_RDWR, 0600)
f, err := os.OpenFile(filepath.Join(wd, fmt.Sprintf("pipeline-%s-to-%s.dot", old, new)), os.O_TRUNC|os.O_CREATE|os.O_RDWR, 0600)
if err != nil {
if err != nil {
cancel()
return
}
defer f.Close()
_, err = f.Write([]byte(dot))
if err != nil {
fmt.Println(err)
cancel()
return
}
case gst.MessageEos:
fmt.Println("reached EOS")
cancel()
return false
return
}
defer f.Close()
_, err = f.Write([]byte(dot))
if err != nil {
fmt.Println(err)
cancel()
return false
}
case gst.MessageEos:
fmt.Println("reached EOS")
cancel()
return false
return
}
return true
})
go mainloop.Run()
}()
<-ctx.Done()
mainloop.Quit()
pipeline.BlockSetState(gst.StateNull, gst.ClockTime(time.Second))
gst.Deinit()