0

fix video variant sorting (#1150)

This commit is contained in:
Meisam 2021-07-02 03:17:50 +02:00 committed by GitHub
parent 1f05923545
commit 3b6ef78ff7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,6 +18,11 @@ type variantsResponse struct {
// GetVideoStreamOutputVariants will return the video variants available.
func GetVideoStreamOutputVariants(w http.ResponseWriter, r *http.Request) {
outputVariants := data.GetStreamOutputVariants()
sort.Slice(outputVariants, func(i, j int) bool {
return outputVariants[j].VideoBitrate < outputVariants[i].VideoBitrate
})
result := make([]variantsResponse, len(outputVariants))
for i, variant := range outputVariants {
@ -28,9 +33,5 @@ func GetVideoStreamOutputVariants(w http.ResponseWriter, r *http.Request) {
result[i] = variantResponse
}
sort.Slice(result, func(i, j int) bool {
return outputVariants[j].VideoBitrate < outputVariants[i].VideoBitrate
})
WriteResponse(w, result)
}