2021-03-11 21:51:43 +01:00
|
|
|
package controllers
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
"sort"
|
|
|
|
|
|
|
|
"github.com/owncast/owncast/core/data"
|
|
|
|
)
|
|
|
|
|
|
|
|
type variantsResponse struct {
|
|
|
|
Name string `json:"name"`
|
|
|
|
Index int `json:"index"`
|
|
|
|
}
|
|
|
|
|
2021-06-29 19:21:00 +02:00
|
|
|
// GetVideoStreamOutputVariants will return the video variants available.
|
2021-03-11 21:51:43 +01:00
|
|
|
func GetVideoStreamOutputVariants(w http.ResponseWriter, r *http.Request) {
|
|
|
|
outputVariants := data.GetStreamOutputVariants()
|
2021-07-02 03:17:50 +02:00
|
|
|
|
|
|
|
sort.Slice(outputVariants, func(i, j int) bool {
|
|
|
|
return outputVariants[j].VideoBitrate < outputVariants[i].VideoBitrate
|
|
|
|
})
|
|
|
|
|
2021-03-11 21:51:43 +01:00
|
|
|
result := make([]variantsResponse, len(outputVariants))
|
|
|
|
|
|
|
|
for i, variant := range outputVariants {
|
|
|
|
variantResponse := variantsResponse{
|
|
|
|
Index: i,
|
|
|
|
Name: variant.GetName(),
|
|
|
|
}
|
|
|
|
result[i] = variantResponse
|
|
|
|
}
|
|
|
|
|
|
|
|
WriteResponse(w, result)
|
|
|
|
}
|