mediamtx/internal/core/source.go

41 lines
727 B
Go

package core
import (
"fmt"
"reflect"
"strings"
"github.com/aler9/gortsplib"
)
// source is an entity that can provide a stream.
// it can be:
// - a publisher
// - sourceStatic
// - sourceRedirect
type source interface {
apiSourceDescribe() interface{}
}
func sourceTrackNames(tracks gortsplib.Tracks) []string {
ret := make([]string, len(tracks))
for i, t := range tracks {
n := reflect.TypeOf(t).Elem().Name()
n = n[len("Track"):]
ret[i] = n
}
return ret
}
func sourceTrackInfo(tracks gortsplib.Tracks) string {
return fmt.Sprintf("%d %s (%s)",
len(tracks),
func() string {
if len(tracks) == 1 {
return "track"
}
return "tracks"
}(),
strings.Join(sourceTrackNames(tracks), ", "))
}