mirror of
https://github.com/go-gst/go-gst.git
synced 2025-10-05 07:56:51 +08:00
add custom transform example and remove calls to deprecated methods
This commit is contained in:
46
examples/plugins/basetransform/main.go
Normal file
46
examples/plugins/basetransform/main.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
|
||||
"github.com/go-gst/go-gst/examples/plugins/basetransform/internal/customtransform"
|
||||
"github.com/go-gst/go-gst/gst"
|
||||
)
|
||||
|
||||
func run(ctx context.Context) error {
|
||||
ctx, cancel := signal.NotifyContext(ctx, os.Interrupt)
|
||||
defer cancel()
|
||||
|
||||
gst.Init(nil)
|
||||
|
||||
customtransform.Register()
|
||||
|
||||
pipeline, err := gst.NewPipelineFromString("audiotestsrc ! gocustomtransform ! fakesink")
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
pipeline.SetState(gst.StatePlaying)
|
||||
|
||||
<-ctx.Done()
|
||||
|
||||
pipeline.BlockSetState(gst.StateNull)
|
||||
|
||||
gst.Deinit()
|
||||
|
||||
return ctx.Err()
|
||||
}
|
||||
|
||||
func main() {
|
||||
ctx := context.Background()
|
||||
|
||||
err := run(ctx)
|
||||
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user