mirror of
https://github.com/aler9/gortsplib
synced 2025-10-06 15:46:51 +08:00
add RTP/MPEG-2 audio decoder and encoder (#257)
This commit is contained in:
@@ -13,3 +13,43 @@ func TestMPEG2AudioAttributes(t *testing.T) {
|
||||
require.Equal(t, 90000, format.ClockRate())
|
||||
require.Equal(t, true, format.PTSEqualsDTS(&rtp.Packet{}))
|
||||
}
|
||||
|
||||
func TestMPEG2AudioDecEncoder(t *testing.T) {
|
||||
format := &MPEG2Audio{}
|
||||
|
||||
enc := format.CreateEncoder()
|
||||
pkts, err := enc.Encode([][]byte{{
|
||||
0xff, 0xfb, 0x14, 0x64, 0x00, 0x0f, 0xf0, 0x00,
|
||||
0x00, 0x69, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00,
|
||||
0x0d, 0x20, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01,
|
||||
0xa4, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x34,
|
||||
0x80, 0x00, 0x00, 0x04, 0x4c, 0x41, 0x4d, 0x45,
|
||||
0x33, 0x2e, 0x31, 0x30, 0x30, 0x55, 0x55, 0x55,
|
||||
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
|
||||
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
|
||||
0x55, 0xc0, 0x65, 0xf4, 0xa0, 0x31, 0x8f, 0xce,
|
||||
0x8d, 0x46, 0xfc, 0x8c, 0x73, 0xb9, 0x34, 0x3e,
|
||||
0xb5, 0x03, 0x39, 0xc0, 0x04, 0x01, 0x98, 0x44,
|
||||
0x38, 0xe0, 0x98, 0x10, 0x9b, 0xa8, 0x0f, 0xa8,
|
||||
}}, 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{{
|
||||
0xff, 0xfb, 0x14, 0x64, 0x00, 0x0f, 0xf0, 0x00,
|
||||
0x00, 0x69, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00,
|
||||
0x0d, 0x20, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01,
|
||||
0xa4, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x34,
|
||||
0x80, 0x00, 0x00, 0x04, 0x4c, 0x41, 0x4d, 0x45,
|
||||
0x33, 0x2e, 0x31, 0x30, 0x30, 0x55, 0x55, 0x55,
|
||||
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
|
||||
0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
|
||||
0x55, 0xc0, 0x65, 0xf4, 0xa0, 0x31, 0x8f, 0xce,
|
||||
0x8d, 0x46, 0xfc, 0x8c, 0x73, 0xb9, 0x34, 0x3e,
|
||||
0xb5, 0x03, 0x39, 0xc0, 0x04, 0x01, 0x98, 0x44,
|
||||
0x38, 0xe0, 0x98, 0x10, 0x9b, 0xa8, 0x0f, 0xa8,
|
||||
}}, byts)
|
||||
}
|
||||
|
Reference in New Issue
Block a user