From eaae7aee39c2e4210cb466e2925cfc227ed09877 Mon Sep 17 00:00:00 2001 From: Alex X Date: Wed, 19 Jun 2024 06:52:49 +0300 Subject: [PATCH] Fix stream info for publishing RTMP --- internal/rtmp/rtmp.go | 2 +- pkg/rtmp/client.go | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/internal/rtmp/rtmp.go b/internal/rtmp/rtmp.go index afc363a9..b3d7f932 100644 --- a/internal/rtmp/rtmp.go +++ b/internal/rtmp/rtmp.go @@ -133,7 +133,7 @@ func streamsHandle(url string) (core.Producer, error) { func streamsConsumerHandle(url string) (core.Consumer, func(), error) { cons := flv.NewConsumer() run := func() { - wr, err := rtmp.DialPublish(url) + wr, err := rtmp.DialPublish(url, cons) if err != nil { return } diff --git a/pkg/rtmp/client.go b/pkg/rtmp/client.go index 138d727d..c9e9ad17 100644 --- a/pkg/rtmp/client.go +++ b/pkg/rtmp/client.go @@ -35,7 +35,7 @@ func DialPlay(rawURL string) (*flv.Producer, error) { return client.Producer() } -func DialPublish(rawURL string) (io.Writer, error) { +func DialPublish(rawURL string, cons *flv.Consumer) (io.Writer, error) { u, err := url.Parse(rawURL) if err != nil { return nil, err @@ -55,6 +55,11 @@ func DialPublish(rawURL string) (io.Writer, error) { return nil, err } + cons.FormatName = "rtmp" + cons.Protocol = "rtmp" + cons.RemoteAddr = conn.RemoteAddr().String() + cons.URL = rawURL + return client, nil }