Skip to content

Commit

Permalink
Skip non-media codecs in webrtc module
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed May 3, 2024
1 parent 9c98f5e commit edbcd3e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions pkg/webrtc/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,31 @@ 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)
}
}

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 {
Expand Down

0 comments on commit edbcd3e

Please sign in to comment.