mirror of
https://github.com/aler9/rtsp-simple-server
synced 2025-10-18 21:44:42 +08:00
rtmp: add message reader / writer
This commit is contained in:
35
internal/rtmp/chunk/chunk1_test.go
Normal file
35
internal/rtmp/chunk/chunk1_test.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package chunk
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
var chunk1enc = []byte{
|
||||
0x59, 0xb1, 0xa1, 0x91, 0x0, 0x0, 0x14, 0x14,
|
||||
0x1, 0x2, 0x3, 0x4,
|
||||
}
|
||||
|
||||
var chunk1dec = Chunk1{
|
||||
ChunkStreamID: 25,
|
||||
TimestampDelta: 11641233,
|
||||
Type: MessageTypeCommandAMF0,
|
||||
BodyLen: 20,
|
||||
Body: []byte{0x01, 0x02, 0x03, 0x04},
|
||||
}
|
||||
|
||||
func TestChunk1Read(t *testing.T) {
|
||||
var chunk1 Chunk1
|
||||
err := chunk1.Read(bytes.NewReader(chunk1enc), 4)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, chunk1dec, chunk1)
|
||||
}
|
||||
|
||||
func TestChunk1Write(t *testing.T) {
|
||||
var buf bytes.Buffer
|
||||
err := chunk1dec.Write(&buf)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, chunk1enc, buf.Bytes())
|
||||
}
|
Reference in New Issue
Block a user