Web handler adapts its configuration wherever OME support is enabled or not

This commit is contained in:
Yohann D'ANELLO 2020-11-09 17:31:58 +01:00
parent a20c6202fd
commit 6ca354f44f
2 changed files with 18 additions and 9 deletions

View File

@ -13,6 +13,7 @@ import (
"github.com/markbates/pkger"
"gitlab.crans.org/nounous/ghostream/internal/monitoring"
"gitlab.crans.org/nounous/ghostream/stream/ovenmediaengine"
"gitlab.crans.org/nounous/ghostream/stream/webrtc"
)
@ -61,8 +62,8 @@ func viewerHandler(w http.ResponseWriter, r *http.Request) {
Cfg *Options
Path string
WidgetURL string
OMEApp string
}{Path: path, Cfg: cfg, WidgetURL: "", OMEApp: omeCfg.App}
OMECfg *ovenmediaengine.Options
}{Path: path, Cfg: cfg, WidgetURL: "", OMECfg: omeCfg}
// Load widget is user does not disable it with ?nowidget
if _, ok := r.URL.Query()["nowidget"]; !ok {

View File

@ -34,13 +34,17 @@
{{end}}
</div>
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
<script src="/static/ovenplayer/ovenplayer.js"></script>
<script src="/static/js/ovenplayer.js"></script>
{{if .OMECfg.Enabled}}
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
<script src="/static/ovenplayer/ovenplayer.js"></script>
<script src="/static/js/ovenplayer.js"></script>
{{end}}
<script type="module">
// import { initViewerPage } from "/static/js/viewer.js";
import { initViewerPage } from "/static/js/ovenplayer.js";
{{if .OMECfg.Enabled}}
import { initViewerPage } from "/static/js/ovenplayer.js";
{{else}}
import { initViewerPage } from "/static/js/viewer.js";
{{end}}
// Some variables that need to be fixed by web page
const viewersCounterRefreshPeriod = Number("{{.Cfg.ViewersCounterRefreshPeriod}}");
@ -50,6 +54,10 @@
"{{$value}}",
{{end}}
]
initViewerPage(stream, {{.OMEApp}}, /*stunServers,*/ viewersCounterRefreshPeriod, {{.Cfg.PlayerPoster}})
{{if .OMECfg.Enabled}}
initViewerPage(stream, {{.OMECfg.App}}, viewersCounterRefreshPeriod, {{.Cfg.PlayerPoster}})
{{else}}
initViewerPage(stream, stunServers, viewersCounterRefreshPeriod)
{{end}}
</script>
{{end}}