mirror of
https://github.com/aler9/rtsp-simple-server
synced 2025-10-05 15:46:58 +08:00
37
internal/formatprocessor/lpcm_test.go
Normal file
37
internal/formatprocessor/lpcm_test.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package formatprocessor
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/bluenviron/gortsplib/v4/pkg/format"
|
||||
"github.com/bluenviron/mediamtx/internal/unit"
|
||||
"github.com/pion/rtp"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestLPCMEncode(t *testing.T) {
|
||||
forma := &format.LPCM{
|
||||
PayloadTyp: 96,
|
||||
BitDepth: 16,
|
||||
ChannelCount: 2,
|
||||
}
|
||||
|
||||
p, err := New(1472, forma, true)
|
||||
require.NoError(t, err)
|
||||
|
||||
unit := &unit.LPCM{
|
||||
Samples: []byte{1, 2, 3, 4},
|
||||
}
|
||||
|
||||
err = p.ProcessUnit(unit)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, []*rtp.Packet{{
|
||||
Header: rtp.Header{
|
||||
Version: 2,
|
||||
PayloadType: 96,
|
||||
SequenceNumber: unit.RTPPackets[0].SequenceNumber,
|
||||
SSRC: unit.RTPPackets[0].SSRC,
|
||||
},
|
||||
Payload: []byte{1, 2, 3, 4},
|
||||
}}, unit.RTPPackets)
|
||||
}
|
Reference in New Issue
Block a user