Take control over your live stream video by running it yourself. Streaming + chat out of the box.
HTML activitypubbroadcastingchatdecentralizedfederationfediversegolanghacktoberfesthlslivelivestreamowncastrtmpself-hostedstreaming-videovideo
package yp
import (
"encoding/json"
"net/http"
log "github.com/sirupsen/logrus"
"github.com/owncast/owncast/models"
"github.com/owncast/owncast/utils"
)
type ypDetailsResponse struct {
LastConnectTime *utils.NullTime `json:"lastConnectTime"`
Name string `json:"name"`
Description string `json:"description"`
StreamTitle string `json:"streamTitle,omitempty"`
Logo string `json:"logo"`
Tags []string `json:"tags"`
Social []models.SocialHandle `json:"social"`
ViewerCount int `json:"viewerCount"`
OverallMaxViewerCount int `json:"overallMaxViewerCount"`
SessionMaxViewerCount int `json:"sessionMaxViewerCount"`
NSFW bool `json:"nsfw"`
Online bool `json:"online"`
}
// GetYPResponse gets the status of the server for YP purposes.
func (yp *YP) GetYPResponse(w http.ResponseWriter, r *http.Request) {
if yp.directoryAvailable != nil && !yp.directoryAvailable() {
w.WriteHeader(http.StatusNotFound)
return
}
if !yp.configRepository.GetDirectoryEnabled() {
w.WriteHeader(http.StatusNotFound)
return
}
status := yp.getStatus()
streamTitle := yp.configRepository.GetStreamTitle()
response := ypDetailsResponse{
Name: yp.configRepository.GetServerName(),
Description: yp.configRepository.GetServerSummary(),
StreamTitle: streamTitle,
Logo: "/logo",
NSFW: yp.configRepository.GetNSFW(),
Tags: yp.configRepository.GetServerMetadataTags(),
Online: status.Online,
ViewerCount: status.ViewerCount,
OverallMaxViewerCount: status.OverallMaxViewerCount,
SessionMaxViewerCount: status.SessionMaxViewerCount,
LastConnectTime: status.LastConnectTime,
Social: yp.configRepository.GetSocialHandles(),
}
w.Header().Set("Content-Type", "application/json")
err := json.NewEncoder(w).Encode(response)
if err != nil {
log.Errorln(err)
}
}