use Track.String() instead of reflect for getting track names

This commit is contained in:
aler9 2022-11-28 11:16:31 +01:00
parent e605727c78
commit 7ed0a873f5
2 changed files with 3 additions and 6 deletions

View File

@ -231,7 +231,7 @@ func TestAPIPathsList(t *testing.T) {
Type: "rtspSession", Type: "rtspSession",
}, },
SourceReady: true, SourceReady: true,
Tracks: []string{"H264", "MPEG4Audio"}, Tracks: []string{"H264", "MPEG4-audio"},
BytesReceived: 16, BytesReceived: 16,
}, },
}, },
@ -291,7 +291,7 @@ func TestAPIPathsList(t *testing.T) {
Type: "rtspsSession", Type: "rtspsSession",
}, },
SourceReady: true, SourceReady: true,
Tracks: []string{"H264", "MPEG4Audio"}, Tracks: []string{"H264", "MPEG4-audio"},
}, },
}, },
}, out) }, out)

View File

@ -2,7 +2,6 @@ package core
import ( import (
"fmt" "fmt"
"reflect"
"strings" "strings"
"github.com/aler9/gortsplib" "github.com/aler9/gortsplib"
@ -20,9 +19,7 @@ type source interface {
func sourceTrackNames(tracks gortsplib.Tracks) []string { func sourceTrackNames(tracks gortsplib.Tracks) []string {
ret := make([]string, len(tracks)) ret := make([]string, len(tracks))
for i, t := range tracks { for i, t := range tracks {
n := reflect.TypeOf(t).Elem().Name() ret[i] = t.String()
n = n[len("Track"):]
ret[i] = n
} }
return ret return ret
} }