From 51b11e233f021df71b7998af30e47f1cf6746e88 Mon Sep 17 00:00:00 2001 From: eduard256 Date: Fri, 3 Apr 2026 20:33:30 +0000 Subject: [PATCH] Add RTMP protocol support Register rtmp, rtmps, rtmpx stream handlers using go2rtc pkg/rtmp.DialPlay for TCP connect, handshake, and play. --- pkg/tester/source.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/tester/source.go b/pkg/tester/source.go index 558b046..dc4e226 100644 --- a/pkg/tester/source.go +++ b/pkg/tester/source.go @@ -6,6 +6,7 @@ import ( "github.com/AlexxIT/go2rtc/pkg/bubble" "github.com/AlexxIT/go2rtc/pkg/core" + "github.com/AlexxIT/go2rtc/pkg/rtmp" "github.com/AlexxIT/go2rtc/pkg/rtsp" ) @@ -30,6 +31,9 @@ func init() { RegisterSource("rtsps", rtspHandler) RegisterSource("rtspx", rtspHandler) RegisterSource("bubble", bubbleHandler) + RegisterSource("rtmp", rtmpHandler) + RegisterSource("rtmps", rtmpHandler) + RegisterSource("rtmpx", rtmpHandler) } // bubbleHandler -- Dial handles TCP connect, HTTP handshake, XML parsing, and auth. @@ -38,6 +42,12 @@ func bubbleHandler(rawURL string) (core.Producer, error) { return bubble.Dial(rawURL) } +// rtmpHandler -- DialPlay handles TCP connect, RTMP handshake, and play command. +// ex. "rtmp://admin:pass@192.168.1.100:1935/bcs/channel0_main.bcs?channel=0&stream=0" +func rtmpHandler(rawURL string) (core.Producer, error) { + return rtmp.DialPlay(rawURL) +} + // rtspHandler -- Dial + Describe. Proves: port open, RTSP responds, auth OK, SDP received. func rtspHandler(rawURL string) (core.Producer, error) { rawURL, _, _ = strings.Cut(rawURL, "#")