mirror of
https://github.com/bluenviron/mediamtx
synced 2025-01-23 15:34:28 +00:00
c778c049ce
Fixes #1103 gortsplib/v2 supports multiple formats inside a single track (media). This allows to apply the resizing algorithm to single formats inside medias. For instance, if a media contains a a proprietary format and an H264 format, and the latter has oversized packets, they can now be resized.
46 lines
883 B
Go
46 lines
883 B
Go
package core
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"github.com/aler9/gortsplib/v2/pkg/media"
|
|
)
|
|
|
|
// source is an entity that can provide a stream.
|
|
// it can be:
|
|
// - a publisher
|
|
// - sourceStatic
|
|
// - sourceRedirect
|
|
type source interface {
|
|
apiSourceDescribe() interface{}
|
|
}
|
|
|
|
func mediaDescription(media *media.Media) string {
|
|
ret := make([]string, len(media.Formats))
|
|
for i, forma := range media.Formats {
|
|
ret[i] = forma.String()
|
|
}
|
|
return strings.Join(ret, "/")
|
|
}
|
|
|
|
func mediasDescription(medias media.Medias) []string {
|
|
ret := make([]string, len(medias))
|
|
for i, media := range medias {
|
|
ret[i] = mediaDescription(media)
|
|
}
|
|
return ret
|
|
}
|
|
|
|
func sourceMediaInfo(medias media.Medias) string {
|
|
return fmt.Sprintf("%d %s (%s)",
|
|
len(medias),
|
|
func() string {
|
|
if len(medias) == 1 {
|
|
return "track"
|
|
}
|
|
return "tracks"
|
|
}(),
|
|
strings.Join(mediasDescription(medias), ", "))
|
|
}
|