forked from bluenviron/gortsplib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
track_generic_test.go
79 lines (72 loc) · 2.03 KB
/
track_generic_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package gortsplib
import (
"testing"
psdp "github.com/pion/sdp/v3"
"github.com/stretchr/testify/require"
)
func TestTrackGenericNew(t *testing.T) {
track, err := NewTrackGeneric(
"video",
[]string{"100", "101"},
"98 H265/90000",
"98 profile-id=1; sprop-vps=QAEMAf//AWAAAAMAAAMAAAMAAAMAlqwJ; "+
"sprop-sps=QgEBAWAAAAMAAAMAAAMAAAMAlqADwIAQ5Za5JMmuWcBSSgAAB9AAAHUwgkA=; sprop-pps=RAHgdrAwxmQ=",
)
require.NoError(t, err)
require.Equal(t, "", track.GetControl())
require.Equal(t, 90000, track.ClockRate())
}
func TestTrackGenericNewErrors(t *testing.T) {
_, err := NewTrackGeneric(
"video",
[]string{"100", "101"},
"98 H265/",
"",
)
require.EqualError(t, err, "unable to get clock rate: strconv.ParseInt: parsing \"\": invalid syntax")
}
func TestTrackGenericClone(t *testing.T) {
track, err := NewTrackGeneric(
"video",
[]string{"100", "101"},
"98 H265/90000",
"98 profile-id=1; sprop-vps=QAEMAf//AWAAAAMAAAMAAAMAAAMAlqwJ; "+
"sprop-sps=QgEBAWAAAAMAAAMAAAMAAAMAlqADwIAQ5Za5JMmuWcBSSgAAB9AAAHUwgkA=; sprop-pps=RAHgdrAwxmQ=",
)
require.NoError(t, err)
clone := track.clone()
require.NotSame(t, track, clone)
require.Equal(t, track, clone)
}
func TestTrackGenericMediaDescription(t *testing.T) {
track, err := NewTrackGeneric(
"video",
[]string{"100", "101"},
"98 H265/90000",
"98 profile-id=1; sprop-vps=QAEMAf//AWAAAAMAAAMAAAMAAAMAlqwJ; "+
"sprop-sps=QgEBAWAAAAMAAAMAAAMAAAMAlqADwIAQ5Za5JMmuWcBSSgAAB9AAAHUwgkA=; sprop-pps=RAHgdrAwxmQ=",
)
require.NoError(t, err)
require.Equal(t, &psdp.MediaDescription{
MediaName: psdp.MediaName{
Media: "video",
Protos: []string{"RTP", "AVP"},
Formats: []string{"100", "101"},
},
Attributes: []psdp.Attribute{
{
Key: "rtpmap",
Value: "98 H265/90000",
},
{
Key: "fmtp",
Value: "98 profile-id=1; sprop-vps=QAEMAf//AWAAAAMAAAMAAAMAAAMAlqwJ; " +
"sprop-sps=QgEBAWAAAAMAAAMAAAMAAAMAlqADwIAQ5Za5JMmuWcBSSgAAB9AAAHUwgkA=; sprop-pps=RAHgdrAwxmQ=",
},
{
Key: "control",
Value: "",
},
},
}, track.MediaDescription())
}