From 427fea30ed56b53e18478fd72a2ff4767fe512c4 Mon Sep 17 00:00:00 2001 From: Alessandro Ros Date: Sun, 9 Jun 2024 23:18:47 +0200 Subject: [PATCH] fix webrtc/VP9 tests (#3443) --- internal/servers/webrtc/server_test.go | 17 ++++++++--------- internal/servers/webrtc/session.go | 11 ++++++++--- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/internal/servers/webrtc/server_test.go b/internal/servers/webrtc/server_test.go index 74e41f00..c5682c34 100644 --- a/internal/servers/webrtc/server_test.go +++ b/internal/servers/webrtc/server_test.go @@ -26,10 +26,6 @@ import ( "github.com/stretchr/testify/require" ) -func uint16Ptr(v uint16) *uint16 { - return &v -} - func checkClose(t *testing.T, closeFunc func() error) { require.NoError(t, closeFunc()) } @@ -357,8 +353,7 @@ func TestServerRead(t *testing.T) { }, []byte{0, 2, 1, 2}, }, - // TODO: check why this doesn't work - /*{ + { "vp9", []*description.Media{{ Type: description.MediaTypeVideo, @@ -367,10 +362,14 @@ func TestServerRead(t *testing.T) { }}, }}, &unit.VP9{ - Frame: []byte{1, 2}, + Frame: []byte{0x82, 0x49, 0x83, 0x42, 0x0, 0x77, 0xf0, 0x32, 0x34}, }, - []byte{1, 2}, - },*/ + []byte{ + 0x8f, 0xa0, 0xfd, 0x18, 0x07, 0x80, 0x03, 0x24, + 0x01, 0x14, 0x01, 0x82, 0x49, 0x83, 0x42, 0x00, + 0x77, 0xf0, 0x32, 0x34, + }, + }, { "vp8", []*description.Media{{ diff --git a/internal/servers/webrtc/session.go b/internal/servers/webrtc/session.go index 2a574c21..ea7f1a49 100644 --- a/internal/servers/webrtc/session.go +++ b/internal/servers/webrtc/session.go @@ -35,10 +35,14 @@ import ( ) var errNoSupportedCodecs = errors.New( - "the stream doesn't contain any supported codec, which are currently AV1, VP9, VP8, H264, Opus, G722, G711") + "the stream doesn't contain any supported codec, which are currently AV1, VP9, VP8, H264, Opus, G722, G711, LPCM") type setupStreamFunc func(*webrtc.OutgoingTrack) error +func uint16Ptr(v uint16) *uint16 { + return &v +} + func findVideoTrack( stream *stream.Stream, writer *asyncwriter.Writer, @@ -87,8 +91,9 @@ func findVideoTrack( if vp9Format != nil { return vp9Format, func(track *webrtc.OutgoingTrack) error { encoder := &rtpvp9.Encoder{ - PayloadType: 96, - PayloadMaxSize: webrtcPayloadMaxSize, + PayloadType: 96, + PayloadMaxSize: webrtcPayloadMaxSize, + InitialPictureID: uint16Ptr(8445), } err := encoder.Init() if err != nil {