mirror of
https://github.com/aler9/gortsplib
synced 2025-10-13 02:43:53 +08:00
merge format and formatdecenc into formats (#222)
This commit is contained in:
@@ -1,62 +0,0 @@
|
||||
package format
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/pion/rtp"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestH265Attributes(t *testing.T) {
|
||||
format := &H265{
|
||||
PayloadTyp: 96,
|
||||
VPS: []byte{0x01, 0x02},
|
||||
SPS: []byte{0x03, 0x04},
|
||||
PPS: []byte{0x05, 0x06},
|
||||
}
|
||||
require.Equal(t, "H265", format.String())
|
||||
require.Equal(t, 90000, format.ClockRate())
|
||||
require.Equal(t, uint8(96), format.PayloadType())
|
||||
require.Equal(t, true, format.PTSEqualsDTS(&rtp.Packet{}))
|
||||
require.Equal(t, []byte{0x01, 0x02}, format.SafeVPS())
|
||||
require.Equal(t, []byte{0x03, 0x04}, format.SafeSPS())
|
||||
require.Equal(t, []byte{0x05, 0x06}, format.SafePPS())
|
||||
|
||||
format.SafeSetVPS([]byte{0x07, 0x08})
|
||||
format.SafeSetSPS([]byte{0x09, 0x0A})
|
||||
format.SafeSetPPS([]byte{0x0B, 0x0C})
|
||||
require.Equal(t, []byte{0x07, 0x08}, format.SafeVPS())
|
||||
require.Equal(t, []byte{0x09, 0x0A}, format.SafeSPS())
|
||||
require.Equal(t, []byte{0x0B, 0x0C}, format.SafePPS())
|
||||
}
|
||||
|
||||
func TestH265MediaDescription(t *testing.T) {
|
||||
format := &H265{
|
||||
PayloadTyp: 96,
|
||||
VPS: []byte{0x01, 0x02},
|
||||
SPS: []byte{0x03, 0x04},
|
||||
PPS: []byte{0x05, 0x06},
|
||||
}
|
||||
|
||||
rtpmap, fmtp := format.Marshal()
|
||||
require.Equal(t, "H265/90000", rtpmap)
|
||||
require.Equal(t, map[string]string{
|
||||
"sprop-vps": "AQI=",
|
||||
"sprop-sps": "AwQ=",
|
||||
"sprop-pps": "BQY=",
|
||||
}, fmtp)
|
||||
}
|
||||
|
||||
func TestH265DecEncoder(t *testing.T) {
|
||||
format := &H265{}
|
||||
|
||||
enc := format.CreateEncoder()
|
||||
pkts, err := enc.Encode([][]byte{{0x01, 0x02, 0x03, 0x04}}, 0)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, format.PayloadType(), pkts[0].PayloadType)
|
||||
|
||||
dec := format.CreateDecoder()
|
||||
byts, _, err := dec.Decode(pkts[0])
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, [][]byte{{0x01, 0x02, 0x03, 0x04}}, byts)
|
||||
}
|
Reference in New Issue
Block a user