From edbcd3e73624f18e9a2cf97794c457b4654fa013 Mon Sep 17 00:00:00 2001 From: Alex X Date: Fri, 3 May 2024 11:30:39 +0300 Subject: [PATCH] Skip non-media codecs in webrtc module --- pkg/webrtc/helpers.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/pkg/webrtc/helpers.go b/pkg/webrtc/helpers.go index 9a494792..90dd72a1 100644 --- a/pkg/webrtc/helpers.go +++ b/pkg/webrtc/helpers.go @@ -47,6 +47,9 @@ func UnmarshalMedias(descriptions []*sdp.MediaDescription) (medias []*core.Media continue } + // skip non-media codecs to avoid confusing users in info and logs + media.Codecs = SkipNonMediaCodecs(media.Codecs) + medias = append(medias, media) } } @@ -54,6 +57,21 @@ func UnmarshalMedias(descriptions []*sdp.MediaDescription) (medias []*core.Media return } +func SkipNonMediaCodecs(input []*core.Codec) (output []*core.Codec) { + for _, codec := range input { + switch codec.Name { + case "RTX", "RED", "ULPFEC", "FLEXFEC-03": + continue + case "CN", "TELEPHONE-EVENT": + continue // https://datatracker.ietf.org/doc/html/rfc7874 + } + // VP8, VP9, H264, H265, AV1 + // OPUS, G722, PCMU, PCMA + output = append(output, codec) + } + return +} + // WithResampling - will add for consumer: PCMA/0, PCMU/0, PCM/0, PCML/0 // so it can add resampling for PCMA/PCMU and repack for PCM/PCML func WithResampling(medias []*core.Media) []*core.Media {