From 8d6f6287aaa841e101ce322d8c31360b9edd894c Mon Sep 17 00:00:00 2001 From: David Colburn Date: Thu, 14 Sep 2023 12:19:55 -0700 Subject: [PATCH] split name first --- pkg/pipeline/builder/stream.go | 5 +---- pkg/pipeline/watch.go | 4 +++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/pkg/pipeline/builder/stream.go b/pkg/pipeline/builder/stream.go index be6af961..f129ad74 100644 --- a/pkg/pipeline/builder/stream.go +++ b/pkg/pipeline/builder/stream.go @@ -16,7 +16,6 @@ package builder import ( "fmt" - "strings" "sync" "github.com/tinyzimmer/go-gst/gst" @@ -98,9 +97,7 @@ func BuildStreamBin(pipeline *gstreamer.Pipeline, p *config.PipelineConfig) (*St return sb, b, nil } -func (sb *StreamBin) GetStreamUrl(element string) (string, error) { - name := strings.Split(element, "_")[1] - +func (sb *StreamBin) GetStreamUrl(name string) (string, error) { sb.mu.RLock() url, ok := sb.urls[name] sb.mu.RUnlock() diff --git a/pkg/pipeline/watch.go b/pkg/pipeline/watch.go index c1bfc0b0..4d7d20a6 100644 --- a/pkg/pipeline/watch.go +++ b/pkg/pipeline/watch.go @@ -164,9 +164,11 @@ func (c *Controller) handleMessageError(gErr *gst.GError) error { switch { case element == elementGstRtmp2Sink: + name = strings.Split(name, "_")[1] + if strings.HasPrefix(gErr.Error(), "Connection error") && !c.eos.IsBroken() { // try reconnecting - ok, err := c.streamBin.ResetStream(name[10:], gErr) + ok, err := c.streamBin.ResetStream(name, gErr) if err != nil { logger.Errorw("failed to reset stream", err) } else if ok {