feat: Add Echo web API and integrate NDI monitoring

This commit is contained in:
gari 2025-04-12 19:45:03 +02:00
parent 3f6d52f3bd
commit f6be41cb9e
7 changed files with 157 additions and 135 deletions

View file

@ -1,34 +1,12 @@
package gstreamer
import (
"context"
"fmt"
"github.com/go-gst/go-gst/gst"
"github.com/goccy/go-graphviz"
"github.com/goccy/go-graphviz/cgraph"
)
func gstreamerBinToPNG(bin *gst.Bin, filename string) error {
ctx := context.Background()
g, err := graphviz.New(ctx)
if err != nil {
return fmt.Errorf("error creating graphviz context: %w", err)
}
dotString := bin.DebugBinToDotData(gst.DebugGraphShowAll)
graph, err := cgraph.ParseBytes([]byte(dotString))
if err != nil {
return err
}
//graph.SetDPI(150)
//setFontSize(graph, 20)
if err := g.RenderFilename(ctx, graph, graphviz.PNG, filename); err != nil {
return fmt.Errorf("error rendering graph: %w", err)
}
return nil
func gstreamerBinToDot(bin *gst.Bin) string {
return bin.DebugBinToDotData(gst.DebugGraphShowAll)
}
func setFontSize(graph *cgraph.Graph, fontSize float64) {

View file

@ -3,7 +3,6 @@ package gstreamer
import (
"fmt"
"git.entr0py.de/garionion/catie/internal/config"
"github.com/go-gst/go-glib/glib"
"github.com/go-gst/go-gst/gst"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
@ -24,17 +23,11 @@ type Gstreamer struct {
outputCfg []config.Output
pipeline *gst.Pipeline
mainLoop *glib.MainLoop
}
func New(pipelineCfg config.Pipeline, outputCfg []config.Output, debug bool) (*Gstreamer, error) {
logger := log.Logger.With().Str("module", "gstreamer").Logger()
gst.Init(nil)
mainLoop := glib.NewMainLoop(glib.MainContextDefault(), false)
go mainLoop.Run()
pipeline, err := gst.NewPipeline("graphix")
if err != nil {
return nil, fmt.Errorf("creating pipeline: %w", err)
@ -48,7 +41,6 @@ func New(pipelineCfg config.Pipeline, outputCfg []config.Output, debug bool) (*G
outputCfg: outputCfg,
pipeline: pipeline,
mainLoop: mainLoop,
}
go g.pipelineWatcher()
@ -186,9 +178,7 @@ func New(pipelineCfg config.Pipeline, outputCfg []config.Output, debug bool) (*G
if debug {
logger.Debug().Msg("create png of pipeline")
if err := gstreamerBinToPNG(pipeline.Bin, "pipeline.png"); err != nil {
logger.Error().Err(err).Msg("creating png of pipeline")
}
//dot := gstreamerBinToDot(pipeline.Bin)
}
return g, nil
@ -211,14 +201,12 @@ func (g *Gstreamer) pipelineWatcher() {
if err != nil {
return false
}
g.mainLoop.Quit()
case gst.MessageError: // Error messages are always fatal
err := msg.ParseError()
g.logger.Error().Err(err)
if debug := err.DebugString(); debug != "" {
g.logger.Debug().Msg(debug)
}
g.mainLoop.Quit()
default:
if g.debug {
g.logger.Debug().Msg(msg.String())