Display SRT url on web page

This commit is contained in:
Alexandre Iooss 2020-10-04 11:45:16 +02:00
parent 3f5d317250
commit 5cdb5282ef
No known key found for this signature in database
GPG Key ID: 6C79278F3FCDCC02
4 changed files with 16 additions and 6 deletions

View File

@ -4,6 +4,7 @@ package main
import ( import (
"log" "log"
"net"
"strings" "strings"
"github.com/spf13/viper" "github.com/spf13/viper"
@ -66,6 +67,14 @@ func loadConfiguration() {
// Copy STUN configuration to clients // Copy STUN configuration to clients
viper.Set("Web.STUNServers", viper.Get("WebRTC.STUNServers")) 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() { func main() {

View File

@ -21,11 +21,11 @@
<ul> <ul>
<li> <li>
<b>Serveur :</b> <b>Serveur :</b>
<code>srt://{{.Cfg.Hostname}}:9710</code>, <code>srt://{{.Cfg.Hostname}}:{{.Cfg.SRTServerPort}}</code>,
</li> </li>
<li> <li>
<b>Clé de stream :</b> <b>Clé de stream :</b>
<code>IDENTIFIANT?pass=MOT_DE_PASSE</code> <code>IDENTIFIANT:MOT_DE_PASSE</code>
avec <code>IDENTIFIANT</code> et <code>MOT_DE_PASSE</code> avec <code>IDENTIFIANT</code> et <code>MOT_DE_PASSE</code>
vos identifiants. vos identifiants.
</li> </li>
@ -48,7 +48,7 @@
{{/* FIXME replace with good SRT params */}} {{/* FIXME replace with good SRT params */}}
ffmpeg -re -i mavideo.webm -vcodec libx264 -vprofile baseline ffmpeg -re -i mavideo.webm -vcodec libx264 -vprofile baseline
-acodec aac -strict -2 -f flv -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
</code> </code>
</p> </p>

View File

@ -8,16 +8,16 @@
<!-- Links under video --> <!-- Links under video -->
<p> <p>
<!--<svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-box-arrow-up-right" fill="currentColor" <svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-box-arrow-up-right" fill="currentColor"
xmlns="http://www.w3.org/2000/svg"> xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" <path fill-rule="evenodd"
d="M1.5 13A1.5 1.5 0 0 0 3 14.5h8a1.5 1.5 0 0 0 1.5-1.5V9a.5.5 0 0 0-1 0v4a.5.5 0 0 1-.5.5H3a.5.5 0 0 1-.5-.5V5a.5.5 0 0 1 .5-.5h4a.5.5 0 0 0 0-1H3A1.5 1.5 0 0 0 1.5 5v8zm7-11a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 .5.5v5a.5.5 0 0 1-1 0V2.5H9a.5.5 0 0 1-.5-.5z" /> d="M1.5 13A1.5 1.5 0 0 0 3 14.5h8a1.5 1.5 0 0 0 1.5-1.5V9a.5.5 0 0 0-1 0v4a.5.5 0 0 1-.5.5H3a.5.5 0 0 1-.5-.5V5a.5.5 0 0 1 .5-.5h4a.5.5 0 0 0 0-1H3A1.5 1.5 0 0 0 1.5 5v8zm7-11a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 .5.5v5a.5.5 0 0 1-1 0V2.5H9a.5.5 0 0 1-.5-.5z" />
<path fill-rule="evenodd" <path fill-rule="evenodd"
d="M14.354 1.646a.5.5 0 0 1 0 .708l-8 8a.5.5 0 0 1-.708-.708l8-8a.5.5 0 0 1 .708 0z" /> d="M14.354 1.646a.5.5 0 0 1 0 .708l-8 8a.5.5 0 0 1-.708-.708l8-8a.5.5 0 0 1 .708 0z" />
</svg> </svg>
<code>rtmps://{{.Cfg.Hostname}}:1935/play/{{.Path}}</code>--> <code>srt://{{.Cfg.Hostname}}:{{.Cfg.SRTServerPort}}?streamid={{.Path}}</code>
<svg width="1em" height="1em" viewBox="0 0 20 20" fill="#d7d7d7" xmlns="http://www.w3.org/2000/svg"> <svg class="ml-1" width="1em" height="1em" viewBox="0 0 20 20" fill="#d7d7d7" xmlns="http://www.w3.org/2000/svg">
<path d="M10 11c-5.92 0-8 3-8 5v3h16v-3c0-2-2.08-5-8-5z"/> <path d="M10 11c-5.92 0-8 3-8 5v3h16v-3c0-2-2.08-5-8-5z"/>
<circle cx="10" cy="5.5" r="4.5"/> <circle cx="10" cy="5.5" r="4.5"/>
</svg> </svg>

View File

@ -19,6 +19,7 @@ type Options struct {
Name string Name string
Hostname string Hostname string
Favicon string Favicon string
SRTServerPort string
WidgetURL string WidgetURL string
ViewersCounterRefreshPeriod int ViewersCounterRefreshPeriod int