From 087d6eee3bba9d5a070a3c77f64813c1c1800d20 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Fri, 2 Oct 2020 22:39:38 +0200 Subject: [PATCH] Use : as more conventional separator for user:password --- README.md | 4 ++-- stream/forwarding/forwarding_test.go | 2 +- stream/srt/srt.go | 8 +++++--- stream/srt/srt_test.go | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 143d19a..8885035 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ As stated by OBS wiki, when streaming you should adapt the latency to `2.5 * (th As OBS uses FFMpeg, you need to have FFMpeg compiled with SRT support. To check if SR is available, run `ffmpeg -protocols | grep srt`. On Windows and MacOS, OBS comes with his own FFMpeg that will work. -In OBS, go to "Settings" -> "Stream" and change "Service" to "Custom..." and "Server" to `srt://127.0.0.1:9710?streamid=demo|demo`. +In OBS, go to "Settings" -> "Stream" and change "Service" to "Custom..." and "Server" to `srt://127.0.0.1:9710?streamid=demo:demo`. ### With GStreamer @@ -56,7 +56,7 @@ gst-launch-1.0 ximagesrc startx=0 show-pointer=true use-damage=0 \ ! videoconvert \ ! x264enc bitrate=32000 tune=zerolatency speed-preset=veryfast byte-stream=true threads=1 key-int-max=15 intra-refresh=true ! video/x-h264, profile=baseline, framerate=30/1 \ ! mpegtsmux \ -! srtserversink uri=srt://127.0.0.1:9710/ latency=1000000 streamid=demo|demo +! srtserversink uri=srt://127.0.0.1:9710/ latency=1000000 streamid=demo:demo ``` ## References diff --git a/stream/forwarding/forwarding_test.go b/stream/forwarding/forwarding_test.go index fbbcdd0..ab8af06 100644 --- a/stream/forwarding/forwarding_test.go +++ b/stream/forwarding/forwarding_test.go @@ -63,7 +63,7 @@ func TestForwardStream(t *testing.T) { ffmpeg := exec.Command("ffmpeg", "-re", "-f", "lavfi", "-i", "testsrc=size=640x480:rate=10", - "-f", "flv", "srt://127.0.0.1:9712?streamid=demo|") + "-f", "flv", "srt://127.0.0.1:9712?streamid=demo:") output, err := ffmpeg.StdoutPipe() errOutput, err := ffmpeg.StderrPipe() diff --git a/stream/srt/srt.go b/stream/srt/srt.go index 6baa5e3..9729164 100644 --- a/stream/srt/srt.go +++ b/stream/srt/srt.go @@ -59,6 +59,7 @@ func Serve(cfg *Options, backend auth.Backend, forwarding chan Packet) { options := make(map[string]string) options["transtype"] = "live" + options["mode"] = "listener" // Start SRT in listen mode log.Printf("SRT server listening on %s", cfg.ListenAddress) @@ -135,11 +136,12 @@ func authenticateSocket(s *srtgo.SrtSocket) (string, error) { if err != nil { return "", fmt.Errorf("error while fetching stream key: %s", err) } - if !strings.Contains(streamID, "|") { - return streamID, fmt.Errorf("warning: stream id must be at the format streamID|password. Input: %s", streamID) + log.Println(s.GetSockOptString(C.SRTO_PASSPHRASE)) + if !strings.Contains(streamID, ":") { + return streamID, fmt.Errorf("warning: stream id must be at the format streamID:password. Input: %s", streamID) } - splittedStreamID := strings.SplitN(streamID, "|", 2) + splittedStreamID := strings.SplitN(streamID, ":", 2) streamName, password := splittedStreamID[0], splittedStreamID[1] loggedIn, err := authBackend.Login(streamName, password) if !loggedIn { diff --git a/stream/srt/srt_test.go b/stream/srt/srt_test.go index 885a347..b3572db 100644 --- a/stream/srt/srt_test.go +++ b/stream/srt/srt_test.go @@ -40,7 +40,7 @@ func TestServeSRT(t *testing.T) { ffmpeg := exec.Command("ffmpeg", "-i", "http://ftp.crans.org/events/Blender%20OpenMovies/big_buck_bunny_480p_stereo.ogg", - "-f", "flv", "srt://127.0.0.1:9711?streamid=demo|") + "-f", "flv", "srt://127.0.0.1:9711?streamid=demo:") output, err := ffmpeg.StdoutPipe() errOutput, err := ffmpeg.StderrPipe()