Add codec comparison function to SdpVideoFormat

SdpVideoFormat is used to configure video encoder and decoders.
This CL adds support for comparing two SdpVideoFormat objects
to determine if they specify the same video codec.

This functionality previously only existed in media/base/codec.h
which made the code sensitive to circular dependencies. Once
downstream projects stop using cricket::IsSameCodec, this code
can be removed.

Bug: chromium:1187565
Change-Id: I242069aa6af07917637384c80ee4820887defc7d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/213427
Commit-Queue: Johannes Kron <kron@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33794}
This commit is contained in:
Johannes Kron
2021-04-20 15:53:52 +02:00
committed by Commit Bot
parent 86ee89f73e
commit 20ee02c49f
9 changed files with 160 additions and 51 deletions

View File

@ -26,18 +26,6 @@ namespace webrtc {
namespace {
bool IsFormatSupported(const std::vector<SdpVideoFormat>& supported_formats,
const SdpVideoFormat& format) {
for (const SdpVideoFormat& supported_format : supported_formats) {
if (cricket::IsSameCodec(format.name, format.parameters,
supported_format.name,
supported_format.parameters)) {
return true;
}
}
return false;
}
// This class wraps the internal factory and adds simulcast.
class BuiltinVideoEncoderFactory : public VideoEncoderFactory {
public:
@ -47,8 +35,8 @@ class BuiltinVideoEncoderFactory : public VideoEncoderFactory {
VideoEncoderFactory::CodecInfo QueryVideoEncoder(
const SdpVideoFormat& format) const override {
// Format must be one of the internal formats.
RTC_DCHECK(IsFormatSupported(
internal_encoder_factory_->GetSupportedFormats(), format));
RTC_DCHECK(
format.IsCodecInList(internal_encoder_factory_->GetSupportedFormats()));
VideoEncoderFactory::CodecInfo info;
return info;
}
@ -57,8 +45,8 @@ class BuiltinVideoEncoderFactory : public VideoEncoderFactory {
const SdpVideoFormat& format) override {
// Try creating internal encoder.
std::unique_ptr<VideoEncoder> internal_encoder;
if (IsFormatSupported(internal_encoder_factory_->GetSupportedFormats(),
format)) {
if (format.IsCodecInList(
internal_encoder_factory_->GetSupportedFormats())) {
internal_encoder = std::make_unique<EncoderSimulcastProxy>(
internal_encoder_factory_.get(), format);
}