Files
go-gst/examples/plugins/basetransform/main.go
2025-09-16 22:36:09 +02:00

54 lines
853 B
Go

package main
import (
"context"
"fmt"
"os"
"os/signal"
"runtime"
"time"
"github.com/go-gst/go-gst/examples/plugins/basetransform/internal/customtransform"
"github.com/go-gst/go-gst/pkg/gst"
)
func run(ctx context.Context) error {
ctx, cancel := signal.NotifyContext(ctx, os.Interrupt)
defer cancel()
gst.Init()
customtransform.Register()
ret, err := gst.ParseLaunch("audiotestsrc ! gocustomtransform ! fakesink")
if err != nil {
return err
}
pipeline := ret.(gst.Pipeline)
pipeline.SetState(gst.StatePlaying)
<-ctx.Done()
pipeline.BlockSetState(gst.StateNull, gst.ClockTime(time.Second))
return ctx.Err()
}
func main() {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
err := run(ctx)
for range 10 {
runtime.GC()
}
if err != nil {
fmt.Fprintln(os.Stderr, err)
}
}