feat: implement initial configuration and gstreamer pipeline setup
This commit is contained in:
parent
d672f04be2
commit
4a6f36f1ef
9 changed files with 566 additions and 50 deletions
46
internal/gstreamer/debug.go
Normal file
46
internal/gstreamer/debug.go
Normal file
|
@ -0,0 +1,46 @@
|
|||
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 setFontSize(graph *cgraph.Graph, fontSize float64) {
|
||||
graph.SetFontSize(20)
|
||||
graph.Set("arrowSize", "3")
|
||||
for node, err := graph.FirstNode(); err == nil && node != nil; node, err = graph.NextNode(node) {
|
||||
node.SetFontSize(fontSize)
|
||||
for edge, err := graph.FirstEdge(node); err == nil && edge != nil; edge, err = graph.NextEdge(edge, node) {
|
||||
edge.SetFontSize(fontSize)
|
||||
}
|
||||
}
|
||||
//for subGraph, err := graph.FirstSubGraph(); err == nil && subGraph != nil; subGraph, err = graph.NextSubGraph() {
|
||||
// setFontSize(subGraph, fontSize)
|
||||
//}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue