support fragmented MPEG-2 audio frames (#259)

This commit is contained in:
Alessandro Ros
2023-04-26 00:56:11 +02:00
committed by GitHub
parent 2ac93dadbd
commit 4d594cfe6b
34 changed files with 584 additions and 260 deletions

View File

@@ -2,7 +2,6 @@ package rtplpcm
import (
"testing"
"time"
"github.com/pion/rtp"
"github.com/stretchr/testify/require"
@@ -18,32 +17,12 @@ func TestDecode(t *testing.T) {
}
d.Init()
// send an initial packet downstream
// in order to compute the right timestamp,
// that is relative to the initial packet
pkt := rtp.Packet{
Header: rtp.Header{
Version: 2,
Marker: false,
PayloadType: 0,
SequenceNumber: 17645,
Timestamp: 2289526357,
SSRC: 0x9dbb7812,
},
Payload: []byte{0x01, 0x02, 0x03, 0x04, 0x05, 0x06},
}
_, _, err := d.Decode(&pkt)
require.NoError(t, err)
var samples []byte
expPTS := ca.pts
for _, pkt := range ca.pkts {
partial, pts, err := d.Decode(pkt)
partial, _, err := d.Decode(pkt)
require.NoError(t, err)
require.Equal(t, expPTS, pts)
samples = append(samples, partial...)
expPTS += time.Duration(len(partial)/(24*2/8)) * time.Second / 48000
}
require.Equal(t, ca.samples, samples)