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"
|
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) {
|
2020-10-26 17:14:05 +01:00
|
|
|
var videoQualityVariants = make([]config.StreamQuality, 0)
|
|
|
|
for _, variant := range config.Config.GetVideoStreamQualities() {
|
|
|
|
videoQualityVariants = append(videoQualityVariants, config.StreamQuality{
|
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,
|
|
|
|
})
|
|
|
|
}
|
2020-10-02 09:02:42 +02:00
|
|
|
response := serverConfigAdminResponse{
|
|
|
|
InstanceDetails: config.Config.InstanceDetails,
|
|
|
|
FFmpegPath: config.Config.GetFFMpegPath(),
|
2020-10-26 06:17:56 +01:00
|
|
|
StreamKey: config.Config.VideoSettings.StreamingKey,
|
2020-10-02 09:02:42 +02:00
|
|
|
WebServerPort: config.Config.GetPublicWebServerPort(),
|
|
|
|
VideoSettings: videoSettings{
|
2020-10-26 17:14:05 +01:00
|
|
|
VideoQualityVariants: videoQualityVariants,
|
2020-10-02 09:02:42 +02:00
|
|
|
SegmentLengthSeconds: config.Config.GetVideoSegmentSecondsLength(),
|
|
|
|
NumberOfPlaylistItems: config.Config.GetMaxNumberOfReferencedSegmentsInPlaylist(),
|
|
|
|
},
|
2020-10-08 07:42:14 +02:00
|
|
|
YP: config.Config.YP,
|
2020-10-02 09:02:42 +02:00
|
|
|
S3: config.Config.S3,
|
|
|
|
}
|
|
|
|
|
|
|
|
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 {
|
|
|
|
InstanceDetails config.InstanceDetails `json:"instanceDetails"`
|
|
|
|
FFmpegPath string `json:"ffmpegPath"`
|
2020-10-26 06:17:56 +01:00
|
|
|
StreamKey string `json:"streamKey"`
|
2020-10-02 09:02:42 +02:00
|
|
|
WebServerPort int `json:"webServerPort"`
|
|
|
|
S3 config.S3 `json:"s3"`
|
|
|
|
VideoSettings videoSettings `json:"videoSettings"`
|
2020-10-08 07:42:14 +02:00
|
|
|
YP config.YP `json:"yp"`
|
2020-10-02 09:02:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
type videoSettings struct {
|
|
|
|
VideoQualityVariants []config.StreamQuality `json:"videoQualityVariants"`
|
|
|
|
SegmentLengthSeconds int `json:"segmentLengthSeconds"`
|
|
|
|
NumberOfPlaylistItems int `json:"numberOfPlaylistItems"`
|
|
|
|
}
|