mirror of
https://github.com/aler9/gortsplib
synced 2025-10-05 23:26:54 +08:00
rename pkg/formats into pkt/format
This commit is contained in:
59
pkg/format/rtpmjpeg/decoder_test.go
Normal file
59
pkg/format/rtpmjpeg/decoder_test.go
Normal file
@@ -0,0 +1,59 @@
|
||||
package rtpmjpeg
|
||||
|
||||
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{}
|
||||
err := d.Init()
|
||||
require.NoError(t, err)
|
||||
|
||||
for _, pkt := range ca.pkts {
|
||||
image, _, err := d.Decode(pkt)
|
||||
if err == ErrMorePacketsNeeded {
|
||||
continue
|
||||
}
|
||||
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, ca.image, image)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func FuzzDecoder(f *testing.F) {
|
||||
f.Fuzz(func(t *testing.T, a []byte, am bool, b []byte, bm bool) {
|
||||
d := &Decoder{}
|
||||
d.Init() //nolint:errcheck
|
||||
|
||||
d.Decode(&rtp.Packet{ //nolint:errcheck
|
||||
Header: rtp.Header{
|
||||
Version: 2,
|
||||
Marker: am,
|
||||
PayloadType: 96,
|
||||
SequenceNumber: 17645,
|
||||
Timestamp: 2289527317,
|
||||
SSRC: 0x9dbb7812,
|
||||
},
|
||||
Payload: a,
|
||||
})
|
||||
|
||||
d.Decode(&rtp.Packet{ //nolint:errcheck
|
||||
Header: rtp.Header{
|
||||
Version: 2,
|
||||
Marker: bm,
|
||||
PayloadType: 96,
|
||||
SequenceNumber: 17645,
|
||||
Timestamp: 2289527317,
|
||||
SSRC: 0x9dbb7812,
|
||||
},
|
||||
Payload: b,
|
||||
})
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user