From 5cdb5282ef7039ab363c494604f152b9269a70c6 Mon Sep 17 00:00:00 2001
From: Alexandre Iooss
Date: Sun, 4 Oct 2020 11:45:16 +0200
Subject: [PATCH] Display SRT url on web page
---
main.go | 9 +++++++++
web/template/index.html | 6 +++---
web/template/viewer.html | 6 +++---
web/web.go | 1 +
4 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/main.go b/main.go
index 8eb2ab3..163154a 100644
--- a/main.go
+++ b/main.go
@@ -4,6 +4,7 @@ package main
import (
"log"
+ "net"
"strings"
"github.com/spf13/viper"
@@ -66,6 +67,14 @@ func loadConfiguration() {
// Copy STUN configuration to clients
viper.Set("Web.STUNServers", viper.Get("WebRTC.STUNServers"))
+
+ // Copy SRT server port to display it on web page
+ hostport := viper.GetString("Srt.ListenAddress")
+ _, srtPort, err := net.SplitHostPort(hostport)
+ if err != nil {
+ log.Fatalf("Failed to split host and port from %s", hostport)
+ }
+ viper.Set("Web.SRTServerPort", srtPort)
}
func main() {
diff --git a/web/template/index.html b/web/template/index.html
index dc0b306..60eb3f7 100644
--- a/web/template/index.html
+++ b/web/template/index.html
@@ -21,11 +21,11 @@
-
Serveur :
-
srt://{{.Cfg.Hostname}}:9710
,
+ srt://{{.Cfg.Hostname}}:{{.Cfg.SRTServerPort}}
,
-
Clé de stream :
-
IDENTIFIANT?pass=MOT_DE_PASSE
+ IDENTIFIANT:MOT_DE_PASSE
avec IDENTIFIANT
et MOT_DE_PASSE
vos identifiants.
@@ -48,7 +48,7 @@
{{/* FIXME replace with good SRT params */}}
ffmpeg -re -i mavideo.webm -vcodec libx264 -vprofile baseline
-acodec aac -strict -2 -f flv
- srt://{{.Cfg.Hostname}}:9710/IDENTIFIANT?pass=MOT_DE_PASSE
+ srt://{{.Cfg.Hostname}}:{{.Cfg.SRTServerPort}}?streamid=IDENTIFIANT:MOT_DE_PASSE
diff --git a/web/template/viewer.html b/web/template/viewer.html
index 74c3189..a9a20ba 100644
--- a/web/template/viewer.html
+++ b/web/template/viewer.html
@@ -8,16 +8,16 @@
-
+ srt://{{.Cfg.Hostname}}:{{.Cfg.SRTServerPort}}?streamid={{.Path}}
-