Take control over your live stream video by running it yourself. Streaming + chat out of the box.
HTML activitypubbroadcastingchatdecentralizedfederationfediversegolanghacktoberfesthlslivelivestreamowncastrtmpself-hostedstreaming-videovideo
Replace admin broadcaster with status api
Gabe Kangas821532cd653f
diff --git a/config-example.yaml b/config-example.yamlindex addb4798ae..35b0d7ad94 100644--- a/config-example.yaml+++ b/config-example.yaml@@ -26,3 +26,5 @@ videoSettings:# Change this value and keep it secure. Treat it like a password to your live stream.streamingKey: abc123+# Set to true if you don't want the service checking for future releases.+disableUpgradeChecks: falsediff --git a/config/config.go b/config/config.goindex 420164226d..49d5c4a10d 100644--- a/config/config.go+++ b/config/config.go@@ -14,17 +14,18 @@ var Config *configvar _default configtype config struct {- DatabaseFilePath string `yaml:"databaseFile"`- EnableDebugFeatures bool `yaml:"-"`- FFMpegPath string `yaml:"ffmpegPath"`- Files files `yaml:"files"`- InstanceDetails InstanceDetails `yaml:"instanceDetails"`- S3 S3 `yaml:"s3"`- VersionInfo string `yaml:"-"` // For storing the version/build number- VersionNumber string `yaml:"-"`- VideoSettings videoSettings `yaml:"videoSettings"`- WebServerPort int `yaml:"webServerPort"`- YP YP `yaml:"yp"`+ DatabaseFilePath string `yaml:"databaseFile"`+ EnableDebugFeatures bool `yaml:"-"`+ FFMpegPath string `yaml:"ffmpegPath"`+ Files files `yaml:"files"`+ InstanceDetails InstanceDetails `yaml:"instanceDetails"`+ S3 S3 `yaml:"s3"`+ VersionInfo string `yaml:"-"` // For storing the version/build number+ VersionNumber string `yaml:"-"`+ VideoSettings videoSettings `yaml:"videoSettings"`+ WebServerPort int `yaml:"webServerPort"`+ DisableUpgradeChecks bool `yaml:"disableUpgradeChecks"`+ YP YP `yaml:"yp"`}// InstanceDetails defines the user-visible information about this particular instance.diff --git a/controllers/admin/inboundBroadcasterDetails.go b/controllers/admin/inboundBroadcasterDetails.godeleted file mode 100644index 83581e19db..0000000000--- a/controllers/admin/inboundBroadcasterDetails.go+++ /dev/null@@ -1,35 +0,0 @@-package admin--import (- "encoding/json"- "net/http"-- "github.com/owncast/owncast/controllers"- "github.com/owncast/owncast/core"- "github.com/owncast/owncast/models"-)--// GetInboundBroadasterDetails gets the details of the inbound broadcaster-func GetInboundBroadasterDetails(w http.ResponseWriter, r *http.Request) {- broadcaster := core.GetBroadcaster()- if broadcaster == nil {- controllers.WriteSimpleResponse(w, false, "no broadcaster connected")- return- }-- response := inboundBroadasterDetailsResponse{- models.BaseAPIResponse{- true,- "",- },- broadcaster,- }-- w.Header().Set("Content-Type", "application/json")- json.NewEncoder(w).Encode(response)-}--type inboundBroadasterDetailsResponse struct {- models.BaseAPIResponse- Broadcaster *models.Broadcaster `json:"broadcaster"`-}diff --git a/controllers/admin/status.go b/controllers/admin/status.gonew file mode 100644index 0000000000..50bcba868b--- /dev/null+++ b/controllers/admin/status.go@@ -0,0 +1,40 @@+package admin++import (+ "encoding/json"+ "net/http"++ "github.com/owncast/owncast/config"+ "github.com/owncast/owncast/core"+ "github.com/owncast/owncast/models"+)++// Status gets the details of the inbound broadcaster+func Status(w http.ResponseWriter, r *http.Request) {+ broadcaster := core.GetBroadcaster()+ status := core.GetStatus()++ response := adminStatusResponse{+ Broadcaster: broadcaster,+ Online: status.Online,+ ViewerCount: status.ViewerCount,+ OverallPeakViewerCount: status.OverallMaxViewerCount,+ SessionPeakViewerCount: status.SessionMaxViewerCount,+ VersionNumber: status.VersionNumber,+ DisableUpgradeChecks: config.Config.DisableUpgradeChecks,+ }++ w.Header().Set("Content-Type", "application/json")+ json.NewEncoder(w).Encode(response)+}++type adminStatusResponse struct {+ Broadcaster *models.Broadcaster `json:"broadcaster"`+ Online bool `json:"online"`+ ViewerCount int `json:"viewerCount"`+ OverallPeakViewerCount int `json:"overallPeakViewerCount"`+ SessionPeakViewerCount int `json:"sessionPeakViewerCount"`++ VersionNumber string `json:"versionNumber"`+ DisableUpgradeChecks bool `json:"disableUpgradeChecks"`+}diff --git a/controllers/status.go b/controllers/status.goindex 93f81eb47f..14aa886243 100644--- a/controllers/status.go+++ b/controllers/status.go@@ -17,11 +17,3 @@ func GetStatus(w http.ResponseWriter, r *http.Request) {json.NewEncoder(w).Encode(status)}--//GetStatus gets the status of the server-func GetAdminStatus(w http.ResponseWriter, r *http.Request) {- status := core.GetStatus()- w.Header().Set("Content-Type", "application/json")-- json.NewEncoder(w).Encode(status)-}diff --git a/router/router.go b/router/router.goindex 2423a467a0..4622410fc0 100644--- a/router/router.go+++ b/router/router.go@@ -44,11 +44,8 @@ func Start() error {// Authenticated admin requests- // status of the system- http.HandleFunc("/api/admin/status", middleware.RequireAdminAuth(controllers.GetAdminStatus))-// Current inbound broadcaster- http.HandleFunc("/api/admin/broadcaster", middleware.RequireAdminAuth(admin.GetInboundBroadasterDetails))+ http.HandleFunc("/api/admin/status", middleware.RequireAdminAuth(admin.Status))// Disconnect inbound streamhttp.HandleFunc("/api/admin/disconnect", middleware.RequireAdminAuth(admin.DisconnectInboundConnection))