Take control over your live stream video by running it yourself. Streaming + chat out of the box.
HTML activitypubbroadcastingchatdecentralizedfederationfediversegolanghacktoberfesthlslivelivestreamowncastrtmpself-hostedstreaming-videovideo
Stop rtmp from reaching back into core (#290)
Gabe Kangas56b3d469eae7
diff --git a/core/core.go b/core/core.goindex e67dc15d59..62f2a9e736 100644--- a/core/core.go+++ b/core/core.go@@ -11,6 +11,7 @@ import ("github.com/owncast/owncast/config""github.com/owncast/owncast/core/chat""github.com/owncast/owncast/core/ffmpeg"+ "github.com/owncast/owncast/core/rtmp""github.com/owncast/owncast/models""github.com/owncast/owncast/utils""github.com/owncast/owncast/yp"@@ -61,6 +62,9 @@ func Start() error {chat.Setup(ChatListenerImpl{})+ // start the rtmp server+ go rtmp.Start(setStreamAsConnected, setBroadcaster)+return nil}diff --git a/core/rtmp/broadcaster.go b/core/rtmp/broadcaster.goindex 3645bf5a0a..702f074bae 100644--- a/core/rtmp/broadcaster.go+++ b/core/rtmp/broadcaster.go@@ -4,7 +4,6 @@ import ("time""github.com/nareix/joy5/format/flv/flvio"- "github.com/owncast/owncast/core""github.com/owncast/owncast/models"log "github.com/sirupsen/logrus")@@ -31,5 +30,5 @@ func setCurrentBroadcasterInfo(t flvio.Tag, remoteAddr string) {},}- core.SetBroadcaster(broadcaster)+ _setBroadcaster(broadcaster)}diff --git a/core/rtmp/rtmp.go b/core/rtmp/rtmp.goindex a93c9576bd..90cbdf7028 100644--- a/core/rtmp/rtmp.go+++ b/core/rtmp/rtmp.go@@ -16,7 +16,7 @@ import ("github.com/nareix/joy5/format/rtmp""github.com/owncast/owncast/config"- "github.com/owncast/owncast/core"+ "github.com/owncast/owncast/models""github.com/owncast/owncast/utils")@@ -27,8 +27,14 @@ var (var _pipe *os.Filevar _rtmpConnection net.Conn+var _setStreamAsConnected func()+var _setBroadcaster func(models.Broadcaster)+//Start starts the rtmp service, listening on port 1935-func Start() {+func Start(setStreamAsConnected func(), setBroadcaster func(models.Broadcaster)) {+ _setStreamAsConnected = setStreamAsConnected+ _setBroadcaster = setBroadcaster+port := 1935s := rtmp.NewServer()var lis net.Listener@@ -87,7 +93,7 @@ func HandleConn(c *rtmp.Conn, nc net.Conn) {syscall.Mkfifo(pipePath, 0666)_hasInboundRTMPConnection = true- core.SetStreamAsConnected()+ _setStreamAsConnected()_rtmpConnection = ncf, err := os.OpenFile(pipePath, os.O_RDWR, os.ModeNamedPipe)@@ -129,6 +135,6 @@ func Disconnect() {return}- log.Infoln("Inbound stream disconnect requested.")+ log.Traceln("Inbound stream disconnect requested.")handleDisconnect(_rtmpConnection)}diff --git a/core/status.go b/core/status.goindex 6c0854f41d..1d336f793d 100644--- a/core/status.go+++ b/core/status.go@@ -20,8 +20,8 @@ func GetStatus() models.Status {}}-// SetBroadcaster will store the current inbound broadcasting details-func SetBroadcaster(broadcaster models.Broadcaster) {+// setBroadcaster will store the current inbound broadcasting details+func setBroadcaster(broadcaster models.Broadcaster) {_broadcaster = &broadcaster}diff --git a/core/streamState.go b/core/streamState.goindex fce11793b3..abd346a1ee 100644--- a/core/streamState.go+++ b/core/streamState.go@@ -11,6 +11,7 @@ import ("github.com/owncast/owncast/config""github.com/owncast/owncast/core/ffmpeg"+ "github.com/owncast/owncast/core/rtmp""github.com/owncast/owncast/utils""github.com/grafov/m3u8"@@ -22,8 +23,8 @@ var _offlineCleanupTimer *time.Timer// While a stream takes place cleanup old HLS content every N min.var _onlineCleanupTicker *time.Ticker-//SetStreamAsConnected sets the stream as connected-func SetStreamAsConnected() {+//setStreamAsConnected sets the stream as connected+func setStreamAsConnected() {_stats.StreamConnected = true_stats.LastConnectTime = utils.NullTime{time.Now(), true}_stats.LastDisconnectTime = utils.NullTime{time.Now(), false}@@ -62,6 +63,8 @@ func SetStreamAsDisconnected() {offlineFilePath := "static/" + offlineFilenameffmpeg.StopThumbnailGenerator()+ rtmp.Disconnect()+if _yp != nil {_yp.Stop()}diff --git a/router/router.go b/router/router.goindex 25b5623bab..6da168066e 100644--- a/router/router.go+++ b/router/router.go@@ -10,16 +10,12 @@ import ("github.com/owncast/owncast/controllers""github.com/owncast/owncast/controllers/admin""github.com/owncast/owncast/core/chat"- "github.com/owncast/owncast/core/rtmp""github.com/owncast/owncast/router/middleware""github.com/owncast/owncast/yp")//Start starts the router for the http, ws, and rtmpfunc Start() error {- // start the rtmp server- go rtmp.Start()-// static fileshttp.HandleFunc("/", controllers.IndexHandler)