forked from bluenviron/gortsplib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrack_h265_test.go
73 lines (65 loc) · 1.72 KB
/
track_h265_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
package gortsplib
import (
"testing"
psdp "github.com/pion/sdp/v3"
"github.com/stretchr/testify/require"
)
func TestTrackH265Attributes(t *testing.T) {
track := &TrackH265{
PayloadType: 96,
VPS: []byte{0x01, 0x02},
SPS: []byte{0x03, 0x04},
PPS: []byte{0x05, 0x06},
}
require.Equal(t, 90000, track.ClockRate())
require.Equal(t, "", track.GetControl())
require.Equal(t, []byte{0x01, 0x02}, track.SafeVPS())
require.Equal(t, []byte{0x03, 0x04}, track.SafeSPS())
require.Equal(t, []byte{0x05, 0x06}, track.SafePPS())
track.SafeSetVPS([]byte{0x07, 0x08})
track.SafeSetSPS([]byte{0x09, 0x0A})
track.SafeSetPPS([]byte{0x0B, 0x0C})
require.Equal(t, []byte{0x07, 0x08}, track.SafeVPS())
require.Equal(t, []byte{0x09, 0x0A}, track.SafeSPS())
require.Equal(t, []byte{0x0B, 0x0C}, track.SafePPS())
}
func TestTrackH265Clone(t *testing.T) {
track := &TrackH265{
PayloadType: 96,
VPS: []byte{0x01, 0x02},
SPS: []byte{0x03, 0x04},
PPS: []byte{0x05, 0x06},
}
clone := track.clone()
require.NotSame(t, track, clone)
require.Equal(t, track, clone)
}
func TestTrackH265MediaDescription(t *testing.T) {
track := &TrackH265{
PayloadType: 96,
VPS: []byte{0x01, 0x02},
SPS: []byte{0x03, 0x04},
PPS: []byte{0x05, 0x06},
}
require.Equal(t, &psdp.MediaDescription{
MediaName: psdp.MediaName{
Media: "video",
Protos: []string{"RTP", "AVP"},
Formats: []string{"96"},
},
Attributes: []psdp.Attribute{
{
Key: "rtpmap",
Value: "96 H265/90000",
},
{
Key: "fmtp",
Value: "96 sprop-vps=AQI=; sprop-sps=AwQ=; sprop-pps=BQY=",
},
{
Key: "control",
Value: "",
},
},
}, track.MediaDescription())
}