mirror of
https://gitlab.crans.org/nounous/ghostream.git
synced 2024-12-22 04:32:19 +00:00
Use config file for OME broadcasting
This commit is contained in:
parent
cfcde6f530
commit
3d8ba0623d
@ -36,7 +36,7 @@
|
|||||||
</Domain>
|
</Domain>
|
||||||
<Applications>
|
<Applications>
|
||||||
<Application>
|
<Application>
|
||||||
<Name>app</Name>
|
<Name>play</Name>
|
||||||
<Type>live</Type>
|
<Type>live</Type>
|
||||||
<Encodes>
|
<Encodes>
|
||||||
<Encode>
|
<Encode>
|
||||||
|
@ -51,7 +51,7 @@ services:
|
|||||||
labels:
|
labels:
|
||||||
- "traefik.http.middlewares.sslheader.headers.customrequestheaders.X-Forwarded-Proto=https"
|
- "traefik.http.middlewares.sslheader.headers.customrequestheaders.X-Forwarded-Proto=https"
|
||||||
|
|
||||||
- "traefik.http.routers.ovenmediaengine.rule=Host(`stream.example.com`) && PathPrefix(`/app/`)"
|
- "traefik.http.routers.ovenmediaengine.rule=Host(`stream.example.com`) && PathPrefix(`/play/`)"
|
||||||
- "traefik.http.routers.ovenmediaengine.priority=101"
|
- "traefik.http.routers.ovenmediaengine.priority=101"
|
||||||
- "traefik.http.routers.ovenmediaengine.entrypoints=websecure"
|
- "traefik.http.routers.ovenmediaengine.entrypoints=websecure"
|
||||||
- "traefik.http.routers.ovenmediaengine.tls.certresolver=mytlschallenge"
|
- "traefik.http.routers.ovenmediaengine.tls.certresolver=mytlschallenge"
|
||||||
@ -59,7 +59,7 @@ services:
|
|||||||
- "traefik.http.routers.ovenmediaengine.service=ovenmediaengine"
|
- "traefik.http.routers.ovenmediaengine.service=ovenmediaengine"
|
||||||
- "traefik.http.routers.ovenmediaengine.middlewares=sslheader"
|
- "traefik.http.routers.ovenmediaengine.middlewares=sslheader"
|
||||||
|
|
||||||
- "traefik.http.routers.ovenmediaengine-hls.rule=Host(`stream.example.com`) && Path(`/app/{app_name:.*}/{filename:.*}.{ext:(m3u8|mpd|ts)}`)"
|
- "traefik.http.routers.ovenmediaengine-hls.rule=Host(`stream.example.com`) && Path(`/play/{app_name:.*}/{filename:.*}.{ext:(m3u8|mpd|ts)}`)"
|
||||||
- "traefik.http.routers.ovenmediaengine-hls.priority=102"
|
- "traefik.http.routers.ovenmediaengine-hls.priority=102"
|
||||||
- "traefik.http.routers.ovenmediaengine-hls.entrypoints=websecure"
|
- "traefik.http.routers.ovenmediaengine-hls.entrypoints=websecure"
|
||||||
- "traefik.http.routers.ovenmediaengine-hls.tls.certresolver=mytlschallenge"
|
- "traefik.http.routers.ovenmediaengine-hls.tls.certresolver=mytlschallenge"
|
||||||
|
@ -49,7 +49,6 @@ forwarding:
|
|||||||
# - rtmp://live-cdg.twitch.tv/app/STREAM_KEY
|
# - rtmp://live-cdg.twitch.tv/app/STREAM_KEY
|
||||||
# - rtmp://a.rtmp.youtube.com/live2/STREAM_KEY
|
# - rtmp://a.rtmp.youtube.com/live2/STREAM_KEY
|
||||||
# - /home/ghostream/lives/%name/live-%Y-%m-%d-%H-%M-%S.flv
|
# - /home/ghostream/lives/%name/live-%Y-%m-%d-%H-%M-%S.flv
|
||||||
# - rtmp://ovenmediaengine:1915/app/demo # For player
|
|
||||||
|
|
||||||
## Prometheus monitoring ##
|
## Prometheus monitoring ##
|
||||||
# Expose a monitoring endpoint for Prometheus
|
# Expose a monitoring endpoint for Prometheus
|
||||||
@ -62,6 +61,19 @@ monitoring:
|
|||||||
# To limit access to only localhost, use 127.0.0.1:2112
|
# To limit access to only localhost, use 127.0.0.1:2112
|
||||||
#listenAddress: :2112
|
#listenAddress: :2112
|
||||||
|
|
||||||
|
## OvenMediaEngine ##
|
||||||
|
# Send the stream data to OvenMediaEngine to handle properly the web client
|
||||||
|
ome:
|
||||||
|
# If you disable OME module, the laggy webrtc client will be used.
|
||||||
|
#
|
||||||
|
#enabled: true
|
||||||
|
#
|
||||||
|
# The URL where OME listens RTMP, without the prefix.
|
||||||
|
#url: ovenmediaengine:1915
|
||||||
|
#
|
||||||
|
# The OME app where OME is waiting for the data of Ghostream.
|
||||||
|
#app: play
|
||||||
|
|
||||||
## SRT server ##
|
## SRT server ##
|
||||||
# The SRT server receive incoming stream and can also serve video to clients.
|
# The SRT server receive incoming stream and can also serve video to clients.
|
||||||
srt:
|
srt:
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"gitlab.crans.org/nounous/ghostream/stream/ovenmediaengine"
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
"github.com/sherifabdlnaby/configuro"
|
"github.com/sherifabdlnaby/configuro"
|
||||||
@ -23,6 +24,7 @@ type Config struct {
|
|||||||
Auth auth.Options
|
Auth auth.Options
|
||||||
Forwarding forwarding.Options
|
Forwarding forwarding.Options
|
||||||
Monitoring monitoring.Options
|
Monitoring monitoring.Options
|
||||||
|
OME ovenmediaengine.Options
|
||||||
Srt srt.Options
|
Srt srt.Options
|
||||||
Telnet telnet.Options
|
Telnet telnet.Options
|
||||||
Transcoder transcoder.Options
|
Transcoder transcoder.Options
|
||||||
@ -49,6 +51,11 @@ func New() *Config {
|
|||||||
Enabled: true,
|
Enabled: true,
|
||||||
ListenAddress: ":2112",
|
ListenAddress: ":2112",
|
||||||
},
|
},
|
||||||
|
OME: ovenmediaengine.Options{
|
||||||
|
Enabled: true,
|
||||||
|
URL: "ovenmediaengine:1915",
|
||||||
|
App: "play",
|
||||||
|
},
|
||||||
Srt: srt.Options{
|
Srt: srt.Options{
|
||||||
Enabled: true,
|
Enabled: true,
|
||||||
ListenAddress: ":9710",
|
ListenAddress: ":9710",
|
||||||
|
4
main.go
4
main.go
@ -5,6 +5,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"gitlab.crans.org/nounous/ghostream/stream/ovenmediaengine"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/pkg/profile"
|
"github.com/pkg/profile"
|
||||||
@ -49,9 +50,10 @@ func main() {
|
|||||||
go transcoder.Init(streams, &cfg.Transcoder)
|
go transcoder.Init(streams, &cfg.Transcoder)
|
||||||
go forwarding.Serve(streams, cfg.Forwarding)
|
go forwarding.Serve(streams, cfg.Forwarding)
|
||||||
go monitoring.Serve(&cfg.Monitoring)
|
go monitoring.Serve(&cfg.Monitoring)
|
||||||
|
go ovenmediaengine.Serve(streams, &cfg.OME)
|
||||||
go srt.Serve(streams, authBackend, &cfg.Srt)
|
go srt.Serve(streams, authBackend, &cfg.Srt)
|
||||||
go telnet.Serve(streams, &cfg.Telnet)
|
go telnet.Serve(streams, &cfg.Telnet)
|
||||||
go web.Serve(streams, &cfg.Web)
|
go web.Serve(streams, &cfg.Web, &cfg.OME)
|
||||||
go webrtc.Serve(streams, &cfg.WebRTC)
|
go webrtc.Serve(streams, &cfg.WebRTC)
|
||||||
|
|
||||||
// Wait for routines
|
// Wait for routines
|
||||||
|
17
stream/ovenmediaengine/ovenmediaengine.go
Normal file
17
stream/ovenmediaengine/ovenmediaengine.go
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// Package ovenmediaengine provides the forwarding to an ovenmediaengine server to handle the web client
|
||||||
|
package ovenmediaengine
|
||||||
|
|
||||||
|
import "gitlab.crans.org/nounous/ghostream/messaging"
|
||||||
|
|
||||||
|
// Options holds ovenmediaengine package configuration
|
||||||
|
type Options struct {
|
||||||
|
Enabled bool
|
||||||
|
URL string
|
||||||
|
App string
|
||||||
|
}
|
||||||
|
|
||||||
|
func Serve(streams *messaging.Streams, cfg *Options) {
|
||||||
|
if !cfg.Enabled {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
@ -61,7 +61,8 @@ func viewerHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
Cfg *Options
|
Cfg *Options
|
||||||
Path string
|
Path string
|
||||||
WidgetURL string
|
WidgetURL string
|
||||||
}{Path: path, Cfg: cfg, WidgetURL: ""}
|
OMEApp string
|
||||||
|
}{Path: path, Cfg: cfg, WidgetURL: "", OMEApp: omeCfg.App}
|
||||||
|
|
||||||
// Load widget is user does not disable it with ?nowidget
|
// Load widget is user does not disable it with ?nowidget
|
||||||
if _, ok := r.URL.Query()["nowidget"]; !ok {
|
if _, ok := r.URL.Query()["nowidget"]; !ok {
|
||||||
|
@ -4,10 +4,11 @@ import { ViewerCounter } from "./modules/viewerCounter.js";
|
|||||||
* Initialize viewer page
|
* Initialize viewer page
|
||||||
*
|
*
|
||||||
* @param {String} stream
|
* @param {String} stream
|
||||||
|
* @param {String} omeApp
|
||||||
* @param {Number} viewersCounterRefreshPeriod
|
* @param {Number} viewersCounterRefreshPeriod
|
||||||
* @param {String} posterUrl
|
* @param {String} posterUrl
|
||||||
*/
|
*/
|
||||||
export function initViewerPage(stream, viewersCounterRefreshPeriod, posterUrl) {
|
export function initViewerPage(stream, omeApp, viewersCounterRefreshPeriod, posterUrl) {
|
||||||
// Create viewer counter
|
// Create viewer counter
|
||||||
const viewerCounter = new ViewerCounter(
|
const viewerCounter = new ViewerCounter(
|
||||||
document.getElementById("connected-people"),
|
document.getElementById("connected-people"),
|
||||||
@ -41,13 +42,13 @@ export function initViewerPage(stream, viewersCounterRefreshPeriod, posterUrl) {
|
|||||||
expandFullScreenUI: true,
|
expandFullScreenUI: true,
|
||||||
sources: [
|
sources: [
|
||||||
{
|
{
|
||||||
"file": "wss://" + window.location.host + "/app/" + stream,
|
"file": "wss://" + window.location.host + "/" + omeApp + "/" + stream,
|
||||||
"type": "webrtc",
|
"type": "webrtc",
|
||||||
"label": " WebRTC - Source"
|
"label": " WebRTC - Source"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "hls",
|
"type": "hls",
|
||||||
"file": "https://" + window.location.host + "/app/" + stream + "_bypass/playlist.m3u8",
|
"file": "https://" + window.location.host + "/" + omeApp + "/" + stream + "_bypass/playlist.m3u8",
|
||||||
"label": " HLS"
|
"label": " HLS"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -50,6 +50,6 @@
|
|||||||
"{{$value}}",
|
"{{$value}}",
|
||||||
{{end}}
|
{{end}}
|
||||||
]
|
]
|
||||||
initViewerPage(stream, /*stunServers,*/ viewersCounterRefreshPeriod, {{.Cfg.PlayerPoster}})
|
initViewerPage(stream, {{.OMEApp}}, /*stunServers,*/ viewersCounterRefreshPeriod, {{.Cfg.PlayerPoster}})
|
||||||
</script>
|
</script>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
package web
|
package web
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"gitlab.crans.org/nounous/ghostream/stream/ovenmediaengine"
|
||||||
"html/template"
|
"html/template"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
@ -32,6 +33,8 @@ type Options struct {
|
|||||||
var (
|
var (
|
||||||
cfg *Options
|
cfg *Options
|
||||||
|
|
||||||
|
omeCfg *ovenmediaengine.Options
|
||||||
|
|
||||||
// Preload templates
|
// Preload templates
|
||||||
templates *template.Template
|
templates *template.Template
|
||||||
|
|
||||||
@ -70,9 +73,10 @@ func loadTemplates() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Serve HTTP server
|
// Serve HTTP server
|
||||||
func Serve(s *messaging.Streams, c *Options) {
|
func Serve(s *messaging.Streams, c *Options, ome *ovenmediaengine.Options) {
|
||||||
streams = s
|
streams = s
|
||||||
cfg = c
|
cfg = c
|
||||||
|
omeCfg = ome
|
||||||
|
|
||||||
if !cfg.Enabled {
|
if !cfg.Enabled {
|
||||||
// Web server is not enabled, ignore
|
// Web server is not enabled, ignore
|
||||||
|
Loading…
Reference in New Issue
Block a user