@@ -13,19 +13,22 @@ func TestBasic(t *testing.T) {
13
13
}
14
14
15
15
rawPkt := []byte {
16
- 0x80 , 0x60 , 0x69 , 0x8f , 0xd9 , 0xc2 , 0x93 , 0xda , 0x1c , 0x64 ,
17
- 0x27 , 0x82 , 0x98 , 0x36 , 0xbe , 0x88 , 0x9e ,
16
+ 0x90 , 0x60 , 0x69 , 0x8f , 0xd9 , 0xc2 , 0x93 , 0xda , 0x1c , 0x64 ,
17
+ 0x27 , 0x82 , 0x00 , 0x01 , 0x00 , 0x01 , 0xFF , 0xFF , 0xFF , 0xFF , 0x98 , 0x36 , 0xbe , 0x88 , 0x9e ,
18
18
}
19
19
parsedPacket := & Packet {
20
- Raw : rawPkt ,
21
- Version : 2 ,
22
- PayloadOffset : 12 ,
23
- PayloadType : 96 ,
24
- SequenceNumber : 27023 ,
25
- Timestamp : 3653407706 ,
26
- SSRC : 476325762 ,
27
- Payload : rawPkt [12 :],
28
- CSRC : []uint32 {},
20
+ Raw : rawPkt ,
21
+ Extension : true ,
22
+ ExtensionProfile : 1 ,
23
+ ExtensionPayload : []byte {0xFF , 0xFF , 0xFF , 0xFF },
24
+ Version : 2 ,
25
+ PayloadOffset : 20 ,
26
+ PayloadType : 96 ,
27
+ SequenceNumber : 27023 ,
28
+ Timestamp : 3653407706 ,
29
+ SSRC : 476325762 ,
30
+ Payload : rawPkt [20 :],
31
+ CSRC : []uint32 {},
29
32
}
30
33
31
34
if err := p .Unmarshal (rawPkt ); err != nil {
@@ -41,3 +44,24 @@ func TestBasic(t *testing.T) {
41
44
t .Errorf ("TestBasic marshal: got %#v, want %#v" , raw , rawPkt )
42
45
}
43
46
}
47
+
48
+ func TestExtension (t * testing.T ) {
49
+ p := & Packet {}
50
+
51
+ missingExtensionPkt := []byte {
52
+ 0x90 , 0x60 , 0x69 , 0x8f , 0xd9 , 0xc2 , 0x93 , 0xda , 0x1c , 0x64 ,
53
+ 0x27 , 0x82 ,
54
+ }
55
+ if err := p .Unmarshal (missingExtensionPkt ); err == nil {
56
+ t .Fatal ("Unmarshal did not error on packet with missing extension data" )
57
+ }
58
+
59
+ invalidExtensionLengthPkt := []byte {
60
+ 0x90 , 0x60 , 0x69 , 0x8f , 0xd9 , 0xc2 , 0x93 , 0xda , 0x1c , 0x64 ,
61
+ 0x27 , 0x82 , 0x99 , 0x99 , 0x99 , 0x99 ,
62
+ }
63
+ if err := p .Unmarshal (invalidExtensionLengthPkt ); err == nil {
64
+ t .Fatal ("Unmarshal did not error on packet with invalid extension length" )
65
+ }
66
+
67
+ }
0 commit comments