Add server config admin endpoint (#207)
* Add support for ending the inbound stream. Closes #191 * Add a simple success response to API requests * Add server config admin endpoint
This commit is contained in:
parent
9b7784634b
commit
d8c43d2c56
@ -22,7 +22,7 @@ type config struct {
|
||||
InstanceDetails InstanceDetails `yaml:"instanceDetails"`
|
||||
PrivateHLSPath string `yaml:"privateHLSPath"`
|
||||
PublicHLSPath string `yaml:"publicHLSPath"`
|
||||
S3 s3 `yaml:"s3"`
|
||||
S3 S3 `yaml:"s3"`
|
||||
VersionInfo string `yaml:"-"`
|
||||
VideoSettings videoSettings `yaml:"videoSettings"`
|
||||
WebServerPort int `yaml:"webServerPort"`
|
||||
@ -72,35 +72,35 @@ type StreamQuality struct {
|
||||
// Enable passthrough to copy the video and/or audio directly from the
|
||||
// incoming stream and disable any transcoding. It will ignore any of
|
||||
// the below settings.
|
||||
IsVideoPassthrough bool `yaml:"videoPassthrough"`
|
||||
IsAudioPassthrough bool `yaml:"audioPassthrough"`
|
||||
IsVideoPassthrough bool `yaml:"videoPassthrough" json:"videoPassthrough"`
|
||||
IsAudioPassthrough bool `yaml:"audioPassthrough" json:"audioPassthrough"`
|
||||
|
||||
VideoBitrate int `yaml:"videoBitrate"`
|
||||
AudioBitrate int `yaml:"audioBitrate"`
|
||||
VideoBitrate int `yaml:"videoBitrate" json:"videoBitrate"`
|
||||
AudioBitrate int `yaml:"audioBitrate" json:"audioBitrate"`
|
||||
|
||||
// Set only one of these in order to keep your current aspect ratio.
|
||||
// Or set neither to not scale the video.
|
||||
ScaledWidth int `yaml:"scaledWidth"`
|
||||
ScaledHeight int `yaml:"scaledHeight"`
|
||||
ScaledWidth int `yaml:"scaledWidth" json:"scaledWidth,omitempty"`
|
||||
ScaledHeight int `yaml:"scaledHeight" json:"scaledHeight,omitempty"`
|
||||
|
||||
Framerate int `yaml:"framerate"`
|
||||
EncoderPreset string `yaml:"encoderPreset"`
|
||||
Framerate int `yaml:"framerate" json:"framerate"`
|
||||
EncoderPreset string `yaml:"encoderPreset" json:"encoderPreset"`
|
||||
}
|
||||
|
||||
type files struct {
|
||||
MaxNumberInPlaylist int `yaml:"maxNumberInPlaylist"`
|
||||
}
|
||||
|
||||
//s3 is for configuring the s3 integration
|
||||
type s3 struct {
|
||||
Enabled bool `yaml:"enabled"`
|
||||
Endpoint string `yaml:"endpoint"`
|
||||
ServingEndpoint string `yaml:"servingEndpoint"`
|
||||
AccessKey string `yaml:"accessKey"`
|
||||
Secret string `yaml:"secret"`
|
||||
Bucket string `yaml:"bucket"`
|
||||
Region string `yaml:"region"`
|
||||
ACL string `yaml:"acl"`
|
||||
//S3 is for configuring the S3 integration
|
||||
type S3 struct {
|
||||
Enabled bool `yaml:"enabled" json:"enabled"`
|
||||
Endpoint string `yaml:"endpoint" json:"endpoint,omitempty"`
|
||||
ServingEndpoint string `yaml:"servingEndpoint" json:"servingEndpoint,omitempty"`
|
||||
AccessKey string `yaml:"accessKey" json:"accessKey,omitempty"`
|
||||
Secret string `yaml:"secret" json:"secret,omitempty"`
|
||||
Bucket string `yaml:"bucket" json:"bucket,omitempty"`
|
||||
Region string `yaml:"region" json:"region,omitempty"`
|
||||
ACL string `yaml:"acl" json:"acl,omitempty"`
|
||||
}
|
||||
|
||||
func (c *config) load(filePath string) error {
|
||||
|
@ -1,6 +1,9 @@
|
||||
package config
|
||||
|
||||
import "sort"
|
||||
import (
|
||||
"encoding/json"
|
||||
"sort"
|
||||
)
|
||||
|
||||
func findHighestQuality(qualities []StreamQuality) int {
|
||||
type IndexedQuality struct {
|
||||
@ -32,3 +35,15 @@ func findHighestQuality(qualities []StreamQuality) int {
|
||||
|
||||
return indexedQualities[0].index
|
||||
}
|
||||
|
||||
// MarshalJSON is a custom JSON marshal function for video stream qualities
|
||||
func (q *StreamQuality) MarshalJSON() ([]byte, error) {
|
||||
type Alias StreamQuality
|
||||
return json.Marshal(&struct {
|
||||
Framerate int `json:"framerate"`
|
||||
*Alias
|
||||
}{
|
||||
Framerate: q.GetFramerate(),
|
||||
Alias: (*Alias)(q),
|
||||
})
|
||||
}
|
||||
|
40
controllers/serverConfig.go
Normal file
40
controllers/serverConfig.go
Normal file
@ -0,0 +1,40 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"github.com/gabek/owncast/config"
|
||||
)
|
||||
|
||||
// GetServerConfig gets the config details of the server
|
||||
func GetServerConfig(w http.ResponseWriter, r *http.Request) {
|
||||
response := serverConfigAdminResponse{
|
||||
InstanceDetails: config.Config.InstanceDetails,
|
||||
FFmpegPath: config.Config.GetFFMpegPath(),
|
||||
WebServerPort: config.Config.GetPublicWebServerPort(),
|
||||
VideoSettings: videoSettings{
|
||||
VideoQualityVariants: config.Config.GetVideoStreamQualities(),
|
||||
SegmentLengthSeconds: config.Config.GetVideoSegmentSecondsLength(),
|
||||
NumberOfPlaylistItems: config.Config.GetMaxNumberOfReferencedSegmentsInPlaylist(),
|
||||
},
|
||||
S3: config.Config.S3,
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(response)
|
||||
}
|
||||
|
||||
type serverConfigAdminResponse struct {
|
||||
InstanceDetails config.InstanceDetails `json:"instanceDetails"`
|
||||
FFmpegPath string `json:"ffmpegPath"`
|
||||
WebServerPort int `json:"webServerPort"`
|
||||
S3 config.S3 `json:"s3"`
|
||||
VideoSettings videoSettings `json:"videoSettings"`
|
||||
}
|
||||
|
||||
type videoSettings struct {
|
||||
VideoQualityVariants []config.StreamQuality `json:"videoQualityVariants"`
|
||||
SegmentLengthSeconds int `json:"segmentLengthSeconds"`
|
||||
NumberOfPlaylistItems int `json:"numberOfPlaylistItems"`
|
||||
}
|
@ -57,6 +57,9 @@ func Start() error {
|
||||
// Change the current streaming key in memory
|
||||
http.HandleFunc("/api/admin/changekey", middleware.RequireAdminAuth(admin.ChangeStreamKey))
|
||||
|
||||
// Server config
|
||||
http.HandleFunc("/api/admin/serverconfig", middleware.RequireAdminAuth(controllers.GetServerConfig))
|
||||
|
||||
port := config.Config.GetPublicWebServerPort()
|
||||
|
||||
log.Infof("Web server running on port: %d", port)
|
||||
|
Loading…
x
Reference in New Issue
Block a user