2020-10-02 10:06:14 +03:00
|
|
|
package admin
|
2020-10-02 10:02:42 +03:00
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"net/http"
|
|
|
|
|
2020-10-05 20:07:09 +03:00
|
|
|
"github.com/owncast/owncast/config"
|
2021-02-19 10:05:52 +03:00
|
|
|
"github.com/owncast/owncast/core/data"
|
2021-04-15 23:55:51 +03:00
|
|
|
"github.com/owncast/owncast/core/transcoder"
|
2021-02-19 10:05:52 +03:00
|
|
|
"github.com/owncast/owncast/models"
|
|
|
|
"github.com/owncast/owncast/utils"
|
2020-11-15 05:39:53 +03:00
|
|
|
log "github.com/sirupsen/logrus"
|
2020-10-02 10:02:42 +03:00
|
|
|
)
|
|
|
|
|
2020-11-13 02:14:59 +03:00
|
|
|
// GetServerConfig gets the config details of the server.
|
2020-10-02 10:02:42 +03:00
|
|
|
func GetServerConfig(w http.ResponseWriter, r *http.Request) {
|
2021-04-15 23:55:51 +03:00
|
|
|
ffmpeg := utils.ValidatedFfmpegPath(data.GetFfMpegPath())
|
|
|
|
|
2021-02-19 10:05:52 +03:00
|
|
|
var videoQualityVariants = make([]models.StreamOutputVariant, 0)
|
|
|
|
for _, variant := range data.GetStreamOutputVariants() {
|
|
|
|
videoQualityVariants = append(videoQualityVariants, models.StreamOutputVariant{
|
2021-03-11 23:51:43 +03:00
|
|
|
Name: variant.GetName(),
|
2020-11-20 09:07:28 +03:00
|
|
|
IsAudioPassthrough: variant.GetIsAudioPassthrough(),
|
2020-10-26 19:14:05 +03:00
|
|
|
IsVideoPassthrough: variant.IsVideoPassthrough,
|
|
|
|
Framerate: variant.GetFramerate(),
|
|
|
|
VideoBitrate: variant.VideoBitrate,
|
|
|
|
AudioBitrate: variant.AudioBitrate,
|
2021-04-15 23:55:51 +03:00
|
|
|
CPUUsageLevel: variant.CPUUsageLevel,
|
2021-02-26 22:01:53 +03:00
|
|
|
ScaledWidth: variant.ScaledWidth,
|
|
|
|
ScaledHeight: variant.ScaledHeight,
|
2020-10-26 19:14:05 +03:00
|
|
|
})
|
|
|
|
}
|
2020-10-02 10:02:42 +03:00
|
|
|
response := serverConfigAdminResponse{
|
2021-02-19 10:05:52 +03:00
|
|
|
InstanceDetails: webConfigResponse{
|
|
|
|
Name: data.GetServerName(),
|
|
|
|
Summary: data.GetServerSummary(),
|
|
|
|
Tags: data.GetServerMetadataTags(),
|
|
|
|
ExtraPageContent: data.GetExtraPageBodyContent(),
|
|
|
|
StreamTitle: data.GetStreamTitle(),
|
2021-03-22 00:10:56 +03:00
|
|
|
WelcomeMessage: data.GetServerWelcomeMessage(),
|
2021-02-19 10:05:52 +03:00
|
|
|
Logo: data.GetLogoPath(),
|
|
|
|
SocialHandles: data.GetSocialHandles(),
|
|
|
|
NSFW: data.GetNSFW(),
|
2021-04-12 03:40:22 +03:00
|
|
|
CustomStyles: data.GetCustomStyles(),
|
2021-02-19 10:05:52 +03:00
|
|
|
},
|
2021-04-15 23:55:51 +03:00
|
|
|
FFmpegPath: ffmpeg,
|
2021-02-19 10:05:52 +03:00
|
|
|
StreamKey: data.GetStreamKey(),
|
|
|
|
WebServerPort: config.WebServerPort,
|
2021-05-25 02:13:49 +03:00
|
|
|
WebServerIP: config.WebServerIP,
|
2021-02-19 10:05:52 +03:00
|
|
|
RTMPServerPort: data.GetRTMPPortNumber(),
|
2021-03-14 21:46:27 +03:00
|
|
|
ChatDisabled: data.GetChatDisabled(),
|
2020-10-02 10:02:42 +03:00
|
|
|
VideoSettings: videoSettings{
|
2021-02-19 10:05:52 +03:00
|
|
|
VideoQualityVariants: videoQualityVariants,
|
|
|
|
LatencyLevel: data.GetStreamLatencyLevel().Level,
|
|
|
|
},
|
|
|
|
YP: yp{
|
|
|
|
Enabled: data.GetDirectoryEnabled(),
|
|
|
|
InstanceURL: data.GetServerURL(),
|
2020-10-02 10:02:42 +03:00
|
|
|
},
|
2021-05-23 07:50:34 +03:00
|
|
|
S3: data.GetS3Config(),
|
|
|
|
ExternalActions: data.GetExternalActions(),
|
|
|
|
SupportedCodecs: transcoder.GetCodecs(ffmpeg),
|
|
|
|
VideoCodec: data.GetVideoCodec(),
|
|
|
|
UsernameBlocklist: data.GetUsernameBlocklist(),
|
2020-10-02 10:02:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
w.Header().Set("Content-Type", "application/json")
|
2020-11-15 05:39:53 +03:00
|
|
|
err := json.NewEncoder(w).Encode(response)
|
|
|
|
if err != nil {
|
|
|
|
log.Errorln(err)
|
|
|
|
}
|
2020-10-02 10:02:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
type serverConfigAdminResponse struct {
|
2021-05-23 07:50:34 +03:00
|
|
|
InstanceDetails webConfigResponse `json:"instanceDetails"`
|
|
|
|
FFmpegPath string `json:"ffmpegPath"`
|
|
|
|
StreamKey string `json:"streamKey"`
|
|
|
|
WebServerPort int `json:"webServerPort"`
|
2021-05-25 02:13:49 +03:00
|
|
|
WebServerIP string `json:"webServerIP"`
|
2021-05-23 07:50:34 +03:00
|
|
|
RTMPServerPort int `json:"rtmpServerPort"`
|
|
|
|
S3 models.S3 `json:"s3"`
|
|
|
|
VideoSettings videoSettings `json:"videoSettings"`
|
|
|
|
YP yp `json:"yp"`
|
|
|
|
ChatDisabled bool `json:"chatDisabled"`
|
|
|
|
ExternalActions []models.ExternalAction `json:"externalActions"`
|
|
|
|
SupportedCodecs []string `json:"supportedCodecs"`
|
|
|
|
VideoCodec string `json:"videoCodec"`
|
|
|
|
UsernameBlocklist string `json:"usernameBlocklist"`
|
2020-10-02 10:02:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
type videoSettings struct {
|
2021-02-19 10:05:52 +03:00
|
|
|
VideoQualityVariants []models.StreamOutputVariant `json:"videoQualityVariants"`
|
|
|
|
LatencyLevel int `json:"latencyLevel"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type webConfigResponse struct {
|
|
|
|
Name string `json:"name"`
|
|
|
|
Summary string `json:"summary"`
|
2021-03-22 00:10:56 +03:00
|
|
|
WelcomeMessage string `json:"welcomeMessage"`
|
2021-02-19 10:05:52 +03:00
|
|
|
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"`
|
2021-04-12 03:40:22 +03:00
|
|
|
CustomStyles string `json:"customStyles"`
|
2021-02-19 10:05:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
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 10:02:42 +03:00
|
|
|
}
|