2020-10-02 09:06:14 +02:00
|
|
|
package admin
|
2020-10-02 09:02:42 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"net/http"
|
|
|
|
|
2020-10-05 19:07:09 +02:00
|
|
|
"github.com/owncast/owncast/config"
|
2021-02-19 08:05:52 +01:00
|
|
|
"github.com/owncast/owncast/core/data"
|
|
|
|
"github.com/owncast/owncast/models"
|
|
|
|
"github.com/owncast/owncast/utils"
|
2020-11-15 03:39:53 +01:00
|
|
|
log "github.com/sirupsen/logrus"
|
2020-10-02 09:02:42 +02:00
|
|
|
)
|
|
|
|
|
2020-11-13 00:14:59 +01:00
|
|
|
// GetServerConfig gets the config details of the server.
|
2020-10-02 09:02:42 +02:00
|
|
|
func GetServerConfig(w http.ResponseWriter, r *http.Request) {
|
2021-02-19 08:05:52 +01:00
|
|
|
var videoQualityVariants = make([]models.StreamOutputVariant, 0)
|
|
|
|
for _, variant := range data.GetStreamOutputVariants() {
|
|
|
|
videoQualityVariants = append(videoQualityVariants, models.StreamOutputVariant{
|
2020-11-20 07:07:28 +01:00
|
|
|
IsAudioPassthrough: variant.GetIsAudioPassthrough(),
|
2020-10-26 17:14:05 +01:00
|
|
|
IsVideoPassthrough: variant.IsVideoPassthrough,
|
|
|
|
Framerate: variant.GetFramerate(),
|
|
|
|
EncoderPreset: variant.GetEncoderPreset(),
|
|
|
|
VideoBitrate: variant.VideoBitrate,
|
|
|
|
AudioBitrate: variant.AudioBitrate,
|
2021-02-19 08:05:52 +01:00
|
|
|
CPUUsageLevel: variant.GetCPUUsageLevel(),
|
2020-10-26 17:14:05 +01:00
|
|
|
})
|
|
|
|
}
|
2020-10-02 09:02:42 +02:00
|
|
|
response := serverConfigAdminResponse{
|
2021-02-19 08:05:52 +01:00
|
|
|
InstanceDetails: webConfigResponse{
|
|
|
|
Name: data.GetServerName(),
|
|
|
|
Summary: data.GetServerSummary(),
|
|
|
|
Tags: data.GetServerMetadataTags(),
|
|
|
|
ExtraPageContent: data.GetExtraPageBodyContent(),
|
|
|
|
StreamTitle: data.GetStreamTitle(),
|
|
|
|
Logo: data.GetLogoPath(),
|
|
|
|
SocialHandles: data.GetSocialHandles(),
|
|
|
|
NSFW: data.GetNSFW(),
|
|
|
|
},
|
|
|
|
FFmpegPath: utils.ValidatedFfmpegPath(data.GetFfMpegPath()),
|
|
|
|
StreamKey: data.GetStreamKey(),
|
|
|
|
WebServerPort: config.WebServerPort,
|
|
|
|
RTMPServerPort: data.GetRTMPPortNumber(),
|
2020-10-02 09:02:42 +02:00
|
|
|
VideoSettings: videoSettings{
|
2021-02-19 08:05:52 +01:00
|
|
|
VideoQualityVariants: videoQualityVariants,
|
|
|
|
LatencyLevel: data.GetStreamLatencyLevel().Level,
|
|
|
|
},
|
|
|
|
YP: yp{
|
|
|
|
Enabled: data.GetDirectoryEnabled(),
|
|
|
|
InstanceURL: data.GetServerURL(),
|
2020-10-02 09:02:42 +02:00
|
|
|
},
|
2021-02-19 08:05:52 +01:00
|
|
|
S3: data.GetS3Config(),
|
2020-10-02 09:02:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
w.Header().Set("Content-Type", "application/json")
|
2020-11-15 03:39:53 +01:00
|
|
|
err := json.NewEncoder(w).Encode(response)
|
|
|
|
if err != nil {
|
|
|
|
log.Errorln(err)
|
|
|
|
}
|
2020-10-02 09:02:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
type serverConfigAdminResponse struct {
|
2021-02-19 08:05:52 +01:00
|
|
|
InstanceDetails webConfigResponse `json:"instanceDetails"`
|
|
|
|
FFmpegPath string `json:"ffmpegPath"`
|
|
|
|
StreamKey string `json:"streamKey"`
|
|
|
|
WebServerPort int `json:"webServerPort"`
|
|
|
|
RTMPServerPort int `json:"rtmpServerPort"`
|
|
|
|
S3 models.S3 `json:"s3"`
|
|
|
|
VideoSettings videoSettings `json:"videoSettings"`
|
|
|
|
LatencyLevel int `json:"latencyLevel"`
|
|
|
|
YP yp `json:"yp"`
|
2020-10-02 09:02:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
type videoSettings struct {
|
2021-02-19 08:05:52 +01:00
|
|
|
VideoQualityVariants []models.StreamOutputVariant `json:"videoQualityVariants"`
|
|
|
|
LatencyLevel int `json:"latencyLevel"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type webConfigResponse struct {
|
|
|
|
Name string `json:"name"`
|
|
|
|
Summary string `json:"summary"`
|
|
|
|
Logo string `json:"logo"`
|
|
|
|
Tags []string `json:"tags"`
|
|
|
|
Version string `json:"version"`
|
|
|
|
NSFW bool `json:"nsfw"`
|
|
|
|
ExtraPageContent string `json:"extraPageContent"`
|
|
|
|
StreamTitle string `json:"streamTitle"` // What's going on with the current stream
|
|
|
|
SocialHandles []models.SocialHandle `json:"socialHandles"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type yp struct {
|
|
|
|
Enabled bool `json:"enabled"`
|
|
|
|
InstanceURL string `json:"instanceUrl"` // The public URL the directory should link to
|
|
|
|
YPServiceURL string `json:"-"` // The base URL to the YP API to register with (optional)
|
2020-10-02 09:02:42 +02:00
|
|
|
}
|