forked from External/mediamtx
rtmp: fix decoding of chunk3 + chunk3
This commit is contained in:
parent
9e6abc6e9f
commit
f7c08f577a
3 changed files with 197 additions and 299 deletions
|
|
@ -12,151 +12,7 @@ import (
|
|||
)
|
||||
|
||||
func TestWriter(t *testing.T) {
|
||||
for _, ca := range []struct {
|
||||
name string
|
||||
messages []*Message
|
||||
chunks []chunk.Chunk
|
||||
chunkSizes []uint32
|
||||
}{
|
||||
{
|
||||
"chunk0 + chunk1",
|
||||
[]*Message{
|
||||
{
|
||||
ChunkStreamID: 27,
|
||||
Timestamp: 18576 * time.Millisecond,
|
||||
Type: chunk.MessageTypeSetPeerBandwidth,
|
||||
MessageStreamID: 3123,
|
||||
Body: bytes.Repeat([]byte{0x03}, 64),
|
||||
},
|
||||
{
|
||||
ChunkStreamID: 27,
|
||||
Timestamp: (18576 + 15) * time.Millisecond,
|
||||
Type: chunk.MessageTypeSetWindowAckSize,
|
||||
MessageStreamID: 3123,
|
||||
Body: bytes.Repeat([]byte{0x04}, 64),
|
||||
},
|
||||
},
|
||||
[]chunk.Chunk{
|
||||
&chunk.Chunk0{
|
||||
ChunkStreamID: 27,
|
||||
Timestamp: 18576,
|
||||
Type: chunk.MessageTypeSetPeerBandwidth,
|
||||
MessageStreamID: 3123,
|
||||
BodyLen: 64,
|
||||
Body: bytes.Repeat([]byte{0x03}, 64),
|
||||
},
|
||||
&chunk.Chunk1{
|
||||
ChunkStreamID: 27,
|
||||
TimestampDelta: 15,
|
||||
Type: chunk.MessageTypeSetWindowAckSize,
|
||||
BodyLen: 64,
|
||||
Body: bytes.Repeat([]byte{0x04}, 64),
|
||||
},
|
||||
},
|
||||
[]uint32{
|
||||
128,
|
||||
128,
|
||||
},
|
||||
},
|
||||
{
|
||||
"chunk0 + chunk2 + chunk3",
|
||||
[]*Message{
|
||||
{
|
||||
ChunkStreamID: 27,
|
||||
Timestamp: 18576 * time.Millisecond,
|
||||
Type: chunk.MessageTypeSetPeerBandwidth,
|
||||
MessageStreamID: 3123,
|
||||
Body: bytes.Repeat([]byte{0x03}, 64),
|
||||
},
|
||||
{
|
||||
ChunkStreamID: 27,
|
||||
Timestamp: (18576 + 15) * time.Millisecond,
|
||||
Type: chunk.MessageTypeSetPeerBandwidth,
|
||||
MessageStreamID: 3123,
|
||||
Body: bytes.Repeat([]byte{0x04}, 64),
|
||||
},
|
||||
{
|
||||
ChunkStreamID: 27,
|
||||
Timestamp: (18576 + 15 + 15) * time.Millisecond,
|
||||
Type: chunk.MessageTypeSetPeerBandwidth,
|
||||
MessageStreamID: 3123,
|
||||
Body: bytes.Repeat([]byte{0x05}, 64),
|
||||
},
|
||||
},
|
||||
[]chunk.Chunk{
|
||||
&chunk.Chunk0{
|
||||
ChunkStreamID: 27,
|
||||
Timestamp: 18576,
|
||||
Type: chunk.MessageTypeSetPeerBandwidth,
|
||||
MessageStreamID: 3123,
|
||||
BodyLen: 64,
|
||||
Body: bytes.Repeat([]byte{0x03}, 64),
|
||||
},
|
||||
&chunk.Chunk2{
|
||||
ChunkStreamID: 27,
|
||||
TimestampDelta: 15,
|
||||
Body: bytes.Repeat([]byte{0x04}, 64),
|
||||
},
|
||||
&chunk.Chunk3{
|
||||
ChunkStreamID: 27,
|
||||
Body: bytes.Repeat([]byte{0x05}, 64),
|
||||
},
|
||||
},
|
||||
[]uint32{
|
||||
128,
|
||||
64,
|
||||
64,
|
||||
},
|
||||
},
|
||||
{
|
||||
"chunk0 + chunk3 + chunk2 + chunk3",
|
||||
[]*Message{
|
||||
{
|
||||
ChunkStreamID: 27,
|
||||
Timestamp: 18576 * time.Millisecond,
|
||||
Type: chunk.MessageTypeSetPeerBandwidth,
|
||||
MessageStreamID: 3123,
|
||||
Body: bytes.Repeat([]byte{0x03}, 192),
|
||||
},
|
||||
{
|
||||
ChunkStreamID: 27,
|
||||
Timestamp: 18591 * time.Millisecond,
|
||||
Type: chunk.MessageTypeSetPeerBandwidth,
|
||||
MessageStreamID: 3123,
|
||||
Body: bytes.Repeat([]byte{0x04}, 192),
|
||||
},
|
||||
},
|
||||
[]chunk.Chunk{
|
||||
&chunk.Chunk0{
|
||||
ChunkStreamID: 27,
|
||||
Timestamp: 18576,
|
||||
Type: chunk.MessageTypeSetPeerBandwidth,
|
||||
MessageStreamID: 3123,
|
||||
BodyLen: 192,
|
||||
Body: bytes.Repeat([]byte{0x03}, 128),
|
||||
},
|
||||
&chunk.Chunk3{
|
||||
ChunkStreamID: 27,
|
||||
Body: bytes.Repeat([]byte{0x03}, 64),
|
||||
},
|
||||
&chunk.Chunk2{
|
||||
ChunkStreamID: 27,
|
||||
TimestampDelta: 15,
|
||||
Body: bytes.Repeat([]byte{0x04}, 128),
|
||||
},
|
||||
&chunk.Chunk3{
|
||||
ChunkStreamID: 27,
|
||||
Body: bytes.Repeat([]byte{0x04}, 64),
|
||||
},
|
||||
},
|
||||
[]uint32{
|
||||
128,
|
||||
64,
|
||||
128,
|
||||
64,
|
||||
},
|
||||
},
|
||||
} {
|
||||
for _, ca := range cases {
|
||||
t.Run(ca.name, func(t *testing.T) {
|
||||
var buf bytes.Buffer
|
||||
w := NewWriter(bytecounter.NewWriter(&buf), true)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue