mirror of
https://github.com/aler9/gortsplib
synced 2025-10-09 09:00:44 +08:00
rename pkg/formats into pkt/format
This commit is contained in:
55
pkg/format/rtplpcm/decoder_test.go
Normal file
55
pkg/format/rtplpcm/decoder_test.go
Normal file
@@ -0,0 +1,55 @@
|
||||
package rtplpcm
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/pion/rtp"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestDecode(t *testing.T) {
|
||||
for _, ca := range cases {
|
||||
t.Run(ca.name, func(t *testing.T) {
|
||||
d := &Decoder{
|
||||
BitDepth: 24,
|
||||
SampleRate: 48000,
|
||||
ChannelCount: 2,
|
||||
}
|
||||
err := d.Init()
|
||||
require.NoError(t, err)
|
||||
|
||||
var samples []byte
|
||||
|
||||
for _, pkt := range ca.pkts {
|
||||
partial, _, err := d.Decode(pkt)
|
||||
require.NoError(t, err)
|
||||
samples = append(samples, partial...)
|
||||
}
|
||||
|
||||
require.Equal(t, ca.samples, samples)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func FuzzDecoder(f *testing.F) {
|
||||
f.Fuzz(func(t *testing.T, b []byte) {
|
||||
d := &Decoder{
|
||||
BitDepth: 24,
|
||||
SampleRate: 48000,
|
||||
ChannelCount: 2,
|
||||
}
|
||||
d.Init() //nolint:errcheck
|
||||
|
||||
d.Decode(&rtp.Packet{ //nolint:errcheck
|
||||
Header: rtp.Header{
|
||||
Version: 2,
|
||||
Marker: false,
|
||||
PayloadType: 96,
|
||||
SequenceNumber: 17645,
|
||||
Timestamp: 2289527317,
|
||||
SSRC: 0x9dbb7812,
|
||||
},
|
||||
Payload: b,
|
||||
})
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user