diff --git a/BUILD.gn b/BUILD.gn index e7d4aa9c84..1fcc310669 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -434,10 +434,6 @@ rtc_source_set("webrtc_common") { "api/video:video_bitrate_allocation", "rtc_base:checks", "rtc_base:deprecation", - - # TODO(nisse): Delete both of these together with STR_CASE_CMP and - # STR_NCASE_CMP. - "rtc_base:stringutils", "//third_party/abseil-cpp/absl/strings", ] diff --git a/api/audio_codecs/L16/BUILD.gn b/api/audio_codecs/L16/BUILD.gn index a7d56d0c72..34ec2e4208 100644 --- a/api/audio_codecs/L16/BUILD.gn +++ b/api/audio_codecs/L16/BUILD.gn @@ -21,12 +21,12 @@ rtc_static_library("audio_encoder_L16") { ] deps = [ "..:audio_codecs_api", - "../../..:webrtc_common", "../../../modules/audio_coding:pcm16b", "../../../rtc_base:rtc_base_approved", "../../../rtc_base:safe_minmax", "../../../rtc_base/system:rtc_export", "//third_party/abseil-cpp/absl/memory", + "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/types:optional", ] } @@ -40,11 +40,11 @@ rtc_static_library("audio_decoder_L16") { ] deps = [ "..:audio_codecs_api", - "../../..:webrtc_common", "../../../modules/audio_coding:pcm16b", "../../../rtc_base:rtc_base_approved", "../../../rtc_base/system:rtc_export", "//third_party/abseil-cpp/absl/memory", + "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/types:optional", ] } diff --git a/api/audio_codecs/L16/audio_decoder_L16.cc b/api/audio_codecs/L16/audio_decoder_L16.cc index a71e308700..be0c6b56b2 100644 --- a/api/audio_codecs/L16/audio_decoder_L16.cc +++ b/api/audio_codecs/L16/audio_decoder_L16.cc @@ -11,7 +11,7 @@ #include "api/audio_codecs/L16/audio_decoder_L16.h" #include "absl/memory/memory.h" -#include "common_types.h" // NOLINT(build/include) +#include "absl/strings/match.h" #include "modules/audio_coding/codecs/pcm16b/audio_decoder_pcm16b.h" #include "modules/audio_coding/codecs/pcm16b/pcm16b_common.h" #include "rtc_base/numerics/safe_conversions.h" @@ -23,7 +23,7 @@ absl::optional AudioDecoderL16::SdpToConfig( Config config; config.sample_rate_hz = format.clockrate_hz; config.num_channels = rtc::checked_cast(format.num_channels); - return STR_CASE_CMP(format.name.c_str(), "L16") == 0 && config.IsOk() + return absl::EqualsIgnoreCase(format.name, "L16") && config.IsOk() ? absl::optional(config) : absl::nullopt; } diff --git a/api/audio_codecs/L16/audio_encoder_L16.cc b/api/audio_codecs/L16/audio_encoder_L16.cc index b516f62863..1bb552bc5c 100644 --- a/api/audio_codecs/L16/audio_encoder_L16.cc +++ b/api/audio_codecs/L16/audio_encoder_L16.cc @@ -11,7 +11,7 @@ #include "api/audio_codecs/L16/audio_encoder_L16.h" #include "absl/memory/memory.h" -#include "common_types.h" // NOLINT(build/include) +#include "absl/strings/match.h" #include "modules/audio_coding/codecs/pcm16b/audio_encoder_pcm16b.h" #include "modules/audio_coding/codecs/pcm16b/pcm16b_common.h" #include "rtc_base/numerics/safe_conversions.h" @@ -35,7 +35,7 @@ absl::optional AudioEncoderL16::SdpToConfig( config.frame_size_ms = rtc::SafeClamp(10 * (*ptime / 10), 10, 60); } } - return STR_CASE_CMP(format.name.c_str(), "L16") == 0 && config.IsOk() + return absl::EqualsIgnoreCase(format.name, "L16") && config.IsOk() ? absl::optional(config) : absl::nullopt; } diff --git a/api/audio_codecs/audio_format.cc b/api/audio_codecs/audio_format.cc index bd2d3f2b5a..11788b91e8 100644 --- a/api/audio_codecs/audio_format.cc +++ b/api/audio_codecs/audio_format.cc @@ -10,7 +10,7 @@ #include "api/audio_codecs/audio_format.h" -#include "common_types.h" // NOLINT(build/include) +#include "absl/strings/match.h" namespace webrtc { @@ -32,7 +32,7 @@ SdpAudioFormat::SdpAudioFormat(absl::string_view name, parameters(param) {} bool SdpAudioFormat::Matches(const SdpAudioFormat& o) const { - return STR_CASE_CMP(name.c_str(), o.name.c_str()) == 0 && + return absl::EqualsIgnoreCase(name, o.name) && clockrate_hz == o.clockrate_hz && num_channels == o.num_channels; } @@ -41,7 +41,7 @@ SdpAudioFormat& SdpAudioFormat::operator=(const SdpAudioFormat&) = default; SdpAudioFormat& SdpAudioFormat::operator=(SdpAudioFormat&&) = default; bool operator==(const SdpAudioFormat& a, const SdpAudioFormat& b) { - return STR_CASE_CMP(a.name.c_str(), b.name.c_str()) == 0 && + return absl::EqualsIgnoreCase(a.name, b.name) && a.clockrate_hz == b.clockrate_hz && a.num_channels == b.num_channels && a.parameters == b.parameters; } diff --git a/api/audio_codecs/g711/BUILD.gn b/api/audio_codecs/g711/BUILD.gn index ebd0b3299f..3b8f23c1bc 100644 --- a/api/audio_codecs/g711/BUILD.gn +++ b/api/audio_codecs/g711/BUILD.gn @@ -21,12 +21,12 @@ rtc_static_library("audio_encoder_g711") { ] deps = [ "..:audio_codecs_api", - "../../..:webrtc_common", "../../../modules/audio_coding:g711", "../../../rtc_base:rtc_base_approved", "../../../rtc_base:safe_minmax", "../../../rtc_base/system:rtc_export", "//third_party/abseil-cpp/absl/memory", + "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/types:optional", ] } @@ -40,11 +40,11 @@ rtc_static_library("audio_decoder_g711") { ] deps = [ "..:audio_codecs_api", - "../../..:webrtc_common", "../../../modules/audio_coding:g711", "../../../rtc_base:rtc_base_approved", "../../../rtc_base/system:rtc_export", "//third_party/abseil-cpp/absl/memory", + "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/types:optional", ] } diff --git a/api/audio_codecs/g711/audio_decoder_g711.cc b/api/audio_codecs/g711/audio_decoder_g711.cc index cb16584cde..91599c416a 100644 --- a/api/audio_codecs/g711/audio_decoder_g711.cc +++ b/api/audio_codecs/g711/audio_decoder_g711.cc @@ -14,7 +14,7 @@ #include #include "absl/memory/memory.h" -#include "common_types.h" // NOLINT(build/include) +#include "absl/strings/match.h" #include "modules/audio_coding/codecs/g711/audio_decoder_pcm.h" #include "rtc_base/numerics/safe_conversions.h" @@ -22,8 +22,8 @@ namespace webrtc { absl::optional AudioDecoderG711::SdpToConfig( const SdpAudioFormat& format) { - const bool is_pcmu = STR_CASE_CMP(format.name.c_str(), "PCMU") == 0; - const bool is_pcma = STR_CASE_CMP(format.name.c_str(), "PCMA") == 0; + const bool is_pcmu = absl::EqualsIgnoreCase(format.name, "PCMU"); + const bool is_pcma = absl::EqualsIgnoreCase(format.name, "PCMA"); if (format.clockrate_hz == 8000 && format.num_channels >= 1 && (is_pcmu || is_pcma)) { Config config; diff --git a/api/audio_codecs/g711/audio_encoder_g711.cc b/api/audio_codecs/g711/audio_encoder_g711.cc index 1d5e541276..0cc8dc4ddd 100644 --- a/api/audio_codecs/g711/audio_encoder_g711.cc +++ b/api/audio_codecs/g711/audio_encoder_g711.cc @@ -14,7 +14,7 @@ #include #include "absl/memory/memory.h" -#include "common_types.h" // NOLINT(build/include) +#include "absl/strings/match.h" #include "modules/audio_coding/codecs/g711/audio_encoder_pcm.h" #include "rtc_base/numerics/safe_conversions.h" #include "rtc_base/numerics/safe_minmax.h" @@ -24,8 +24,8 @@ namespace webrtc { absl::optional AudioEncoderG711::SdpToConfig( const SdpAudioFormat& format) { - const bool is_pcmu = STR_CASE_CMP(format.name.c_str(), "PCMU") == 0; - const bool is_pcma = STR_CASE_CMP(format.name.c_str(), "PCMA") == 0; + const bool is_pcmu = absl::EqualsIgnoreCase(format.name, "PCMU"); + const bool is_pcma = absl::EqualsIgnoreCase(format.name, "PCMA"); if (format.clockrate_hz == 8000 && format.num_channels >= 1 && (is_pcmu || is_pcma)) { Config config; diff --git a/api/audio_codecs/g722/BUILD.gn b/api/audio_codecs/g722/BUILD.gn index 101c7a994d..e4321d2993 100644 --- a/api/audio_codecs/g722/BUILD.gn +++ b/api/audio_codecs/g722/BUILD.gn @@ -29,12 +29,12 @@ rtc_static_library("audio_encoder_g722") { deps = [ ":audio_encoder_g722_config", "..:audio_codecs_api", - "../../..:webrtc_common", "../../../modules/audio_coding:g722", "../../../rtc_base:rtc_base_approved", "../../../rtc_base:safe_minmax", "../../../rtc_base/system:rtc_export", "//third_party/abseil-cpp/absl/memory", + "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/types:optional", ] } @@ -48,11 +48,11 @@ rtc_static_library("audio_decoder_g722") { ] deps = [ "..:audio_codecs_api", - "../../..:webrtc_common", "../../../modules/audio_coding:g722", "../../../rtc_base:rtc_base_approved", "../../../rtc_base/system:rtc_export", "//third_party/abseil-cpp/absl/memory", + "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/types:optional", ] } diff --git a/api/audio_codecs/g722/audio_decoder_g722.cc b/api/audio_codecs/g722/audio_decoder_g722.cc index f1e2afbab5..2cc16c37d9 100644 --- a/api/audio_codecs/g722/audio_decoder_g722.cc +++ b/api/audio_codecs/g722/audio_decoder_g722.cc @@ -14,7 +14,7 @@ #include #include "absl/memory/memory.h" -#include "common_types.h" // NOLINT(build/include) +#include "absl/strings/match.h" #include "modules/audio_coding/codecs/g722/audio_decoder_g722.h" #include "rtc_base/numerics/safe_conversions.h" @@ -22,7 +22,7 @@ namespace webrtc { absl::optional AudioDecoderG722::SdpToConfig( const SdpAudioFormat& format) { - return STR_CASE_CMP(format.name.c_str(), "G722") == 0 && + return absl::EqualsIgnoreCase(format.name, "G722") && format.clockrate_hz == 8000 && (format.num_channels == 1 || format.num_channels == 2) ? absl::optional( diff --git a/api/audio_codecs/g722/audio_encoder_g722.cc b/api/audio_codecs/g722/audio_encoder_g722.cc index 0cf71639bf..6374ae802f 100644 --- a/api/audio_codecs/g722/audio_encoder_g722.cc +++ b/api/audio_codecs/g722/audio_encoder_g722.cc @@ -14,7 +14,7 @@ #include #include "absl/memory/memory.h" -#include "common_types.h" // NOLINT(build/include) +#include "absl/strings/match.h" #include "modules/audio_coding/codecs/g722/audio_encoder_g722.h" #include "rtc_base/numerics/safe_conversions.h" #include "rtc_base/numerics/safe_minmax.h" @@ -24,7 +24,7 @@ namespace webrtc { absl::optional AudioEncoderG722::SdpToConfig( const SdpAudioFormat& format) { - if (STR_CASE_CMP(format.name.c_str(), "g722") != 0 || + if (!absl::EqualsIgnoreCase(format.name, "g722") || format.clockrate_hz != 8000) { return absl::nullopt; } diff --git a/api/audio_codecs/ilbc/BUILD.gn b/api/audio_codecs/ilbc/BUILD.gn index d4f504fd4f..d766fa4a97 100644 --- a/api/audio_codecs/ilbc/BUILD.gn +++ b/api/audio_codecs/ilbc/BUILD.gn @@ -29,11 +29,11 @@ rtc_static_library("audio_encoder_ilbc") { deps = [ ":audio_encoder_ilbc_config", "..:audio_codecs_api", - "../../..:webrtc_common", "../../../modules/audio_coding:ilbc", "../../../rtc_base:rtc_base_approved", "../../../rtc_base:safe_minmax", "//third_party/abseil-cpp/absl/memory", + "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/types:optional", ] } @@ -47,10 +47,10 @@ rtc_static_library("audio_decoder_ilbc") { ] deps = [ "..:audio_codecs_api", - "../../..:webrtc_common", "../../../modules/audio_coding:ilbc", "../../../rtc_base:rtc_base_approved", "//third_party/abseil-cpp/absl/memory", + "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/types:optional", ] } diff --git a/api/audio_codecs/ilbc/audio_decoder_ilbc.cc b/api/audio_codecs/ilbc/audio_decoder_ilbc.cc index 1f4c475c40..4a00f8dbf0 100644 --- a/api/audio_codecs/ilbc/audio_decoder_ilbc.cc +++ b/api/audio_codecs/ilbc/audio_decoder_ilbc.cc @@ -14,14 +14,14 @@ #include #include "absl/memory/memory.h" -#include "common_types.h" // NOLINT(build/include) +#include "absl/strings/match.h" #include "modules/audio_coding/codecs/ilbc/audio_decoder_ilbc.h" namespace webrtc { absl::optional AudioDecoderIlbc::SdpToConfig( const SdpAudioFormat& format) { - return STR_CASE_CMP(format.name.c_str(), "ILBC") == 0 && + return absl::EqualsIgnoreCase(format.name, "ILBC") && format.clockrate_hz == 8000 && format.num_channels == 1 ? absl::optional(Config()) : absl::nullopt; diff --git a/api/audio_codecs/ilbc/audio_encoder_ilbc.cc b/api/audio_codecs/ilbc/audio_encoder_ilbc.cc index efcef382ff..896ed238cc 100644 --- a/api/audio_codecs/ilbc/audio_encoder_ilbc.cc +++ b/api/audio_codecs/ilbc/audio_encoder_ilbc.cc @@ -14,7 +14,7 @@ #include #include "absl/memory/memory.h" -#include "common_types.h" // NOLINT(build/include) +#include "absl/strings/match.h" #include "modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.h" #include "rtc_base/numerics/safe_conversions.h" #include "rtc_base/numerics/safe_minmax.h" @@ -40,7 +40,7 @@ int GetIlbcBitrate(int ptime) { absl::optional AudioEncoderIlbc::SdpToConfig( const SdpAudioFormat& format) { - if (STR_CASE_CMP(format.name.c_str(), "ILBC") != 0 || + if (!absl::EqualsIgnoreCase(format.name.c_str(), "ILBC") || format.clockrate_hz != 8000 || format.num_channels != 1) { return absl::nullopt; } diff --git a/api/audio_codecs/isac/BUILD.gn b/api/audio_codecs/isac/BUILD.gn index 9025360f2f..c7d6e43271 100644 --- a/api/audio_codecs/isac/BUILD.gn +++ b/api/audio_codecs/isac/BUILD.gn @@ -77,10 +77,10 @@ rtc_static_library("audio_encoder_isac_fix") { ] deps = [ "..:audio_codecs_api", - "../../..:webrtc_common", "../../../modules/audio_coding:isac_fix", "../../../rtc_base:rtc_base_approved", "//third_party/abseil-cpp/absl/memory", + "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/types:optional", ] } @@ -94,10 +94,10 @@ rtc_static_library("audio_decoder_isac_fix") { ] deps = [ "..:audio_codecs_api", - "../../..:webrtc_common", "../../../modules/audio_coding:isac_fix", "../../../rtc_base:rtc_base_approved", "//third_party/abseil-cpp/absl/memory", + "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/types:optional", ] } @@ -111,11 +111,11 @@ rtc_static_library("audio_encoder_isac_float") { ] deps = [ "..:audio_codecs_api", - "../../..:webrtc_common", "../../../modules/audio_coding:isac", "../../../rtc_base:rtc_base_approved", "../../../rtc_base/system:rtc_export", "//third_party/abseil-cpp/absl/memory", + "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/types:optional", ] } @@ -129,11 +129,11 @@ rtc_static_library("audio_decoder_isac_float") { ] deps = [ "..:audio_codecs_api", - "../../..:webrtc_common", "../../../modules/audio_coding:isac", "../../../rtc_base:rtc_base_approved", "../../../rtc_base/system:rtc_export", "//third_party/abseil-cpp/absl/memory", + "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/types:optional", ] } diff --git a/api/audio_codecs/isac/audio_decoder_isac_fix.cc b/api/audio_codecs/isac/audio_decoder_isac_fix.cc index 446640ff70..51ae572fa9 100644 --- a/api/audio_codecs/isac/audio_decoder_isac_fix.cc +++ b/api/audio_codecs/isac/audio_decoder_isac_fix.cc @@ -11,14 +11,14 @@ #include "api/audio_codecs/isac/audio_decoder_isac_fix.h" #include "absl/memory/memory.h" -#include "common_types.h" // NOLINT(build/include) +#include "absl/strings/match.h" #include "modules/audio_coding/codecs/isac/fix/include/audio_decoder_isacfix.h" namespace webrtc { absl::optional AudioDecoderIsacFix::SdpToConfig( const SdpAudioFormat& format) { - return STR_CASE_CMP(format.name.c_str(), "ISAC") == 0 && + return absl::EqualsIgnoreCase(format.name, "ISAC") && format.clockrate_hz == 16000 && format.num_channels == 1 ? absl::optional(Config()) : absl::nullopt; diff --git a/api/audio_codecs/isac/audio_decoder_isac_float.cc b/api/audio_codecs/isac/audio_decoder_isac_float.cc index 1c1926f1a1..d9de3a08b3 100644 --- a/api/audio_codecs/isac/audio_decoder_isac_float.cc +++ b/api/audio_codecs/isac/audio_decoder_isac_float.cc @@ -11,14 +11,14 @@ #include "api/audio_codecs/isac/audio_decoder_isac_float.h" #include "absl/memory/memory.h" -#include "common_types.h" // NOLINT(build/include) +#include "absl/strings/match.h" #include "modules/audio_coding/codecs/isac/main/include/audio_decoder_isac.h" namespace webrtc { absl::optional AudioDecoderIsacFloat::SdpToConfig(const SdpAudioFormat& format) { - if (STR_CASE_CMP(format.name.c_str(), "ISAC") == 0 && + if (absl::EqualsIgnoreCase(format.name, "ISAC") && (format.clockrate_hz == 16000 || format.clockrate_hz == 32000) && format.num_channels == 1) { Config config; diff --git a/api/audio_codecs/isac/audio_encoder_isac_fix.cc b/api/audio_codecs/isac/audio_encoder_isac_fix.cc index cd8975398b..a10d1ee61a 100644 --- a/api/audio_codecs/isac/audio_encoder_isac_fix.cc +++ b/api/audio_codecs/isac/audio_encoder_isac_fix.cc @@ -11,7 +11,7 @@ #include "api/audio_codecs/isac/audio_encoder_isac_fix.h" #include "absl/memory/memory.h" -#include "common_types.h" // NOLINT(build/include) +#include "absl/strings/match.h" #include "modules/audio_coding/codecs/isac/fix/include/audio_encoder_isacfix.h" #include "rtc_base/string_to_number.h" @@ -19,7 +19,7 @@ namespace webrtc { absl::optional AudioEncoderIsacFix::SdpToConfig( const SdpAudioFormat& format) { - if (STR_CASE_CMP(format.name.c_str(), "ISAC") == 0 && + if (absl::EqualsIgnoreCase(format.name, "ISAC") && format.clockrate_hz == 16000 && format.num_channels == 1) { Config config; const auto ptime_iter = format.parameters.find("ptime"); diff --git a/api/audio_codecs/isac/audio_encoder_isac_float.cc b/api/audio_codecs/isac/audio_encoder_isac_float.cc index 83d1faff2f..37982b1f15 100644 --- a/api/audio_codecs/isac/audio_encoder_isac_float.cc +++ b/api/audio_codecs/isac/audio_encoder_isac_float.cc @@ -11,7 +11,7 @@ #include "api/audio_codecs/isac/audio_encoder_isac_float.h" #include "absl/memory/memory.h" -#include "common_types.h" // NOLINT(build/include) +#include "absl/strings/match.h" #include "modules/audio_coding/codecs/isac/main/include/audio_encoder_isac.h" #include "rtc_base/string_to_number.h" @@ -19,7 +19,7 @@ namespace webrtc { absl::optional AudioEncoderIsacFloat::SdpToConfig(const SdpAudioFormat& format) { - if (STR_CASE_CMP(format.name.c_str(), "ISAC") == 0 && + if (absl::EqualsIgnoreCase(format.name, "ISAC") && (format.clockrate_hz == 16000 || format.clockrate_hz == 32000) && format.num_channels == 1) { Config config; diff --git a/api/audio_codecs/opus/BUILD.gn b/api/audio_codecs/opus/BUILD.gn index af3cd7fc44..5552c21fa5 100644 --- a/api/audio_codecs/opus/BUILD.gn +++ b/api/audio_codecs/opus/BUILD.gn @@ -46,6 +46,7 @@ rtc_source_set("audio_encoder_opus") { "../../../modules/audio_coding:webrtc_opus", "../../../rtc_base:rtc_base_approved", "../../../rtc_base/system:rtc_export", + "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/types:optional", ] } @@ -59,11 +60,11 @@ rtc_static_library("audio_decoder_opus") { ] deps = [ "..:audio_codecs_api", - "../../..:webrtc_common", "../../../modules/audio_coding:webrtc_opus", "../../../rtc_base:rtc_base_approved", "../../../rtc_base/system:rtc_export", "//third_party/abseil-cpp/absl/memory", + "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/types:optional", ] } diff --git a/api/audio_codecs/opus/audio_decoder_opus.cc b/api/audio_codecs/opus/audio_decoder_opus.cc index 41397f04d2..2f1668b825 100644 --- a/api/audio_codecs/opus/audio_decoder_opus.cc +++ b/api/audio_codecs/opus/audio_decoder_opus.cc @@ -15,7 +15,7 @@ #include #include "absl/memory/memory.h" -#include "common_types.h" // NOLINT(build/include) +#include "absl/strings/match.h" #include "modules/audio_coding/codecs/opus/audio_decoder_opus.h" namespace webrtc { @@ -35,7 +35,7 @@ absl::optional AudioDecoderOpus::SdpToConfig( } return 1; // Default to mono. }(); - if (STR_CASE_CMP(format.name.c_str(), "opus") == 0 && + if (absl::EqualsIgnoreCase(format.name, "opus") && format.clockrate_hz == 48000 && format.num_channels == 2 && num_channels) { return Config{*num_channels}; diff --git a/common_types.h b/common_types.h index 37e6e2522a..30a2b3a93e 100644 --- a/common_types.h +++ b/common_types.h @@ -15,7 +15,6 @@ #include #include #include -// TODO(nisse): Delete include together with STR_CASE_CMP #include "absl/strings/match.h" #include "api/array_view.h" // TODO(sprang): Remove this include when all usage includes it directly. @@ -31,18 +30,6 @@ #define RTP_PAYLOAD_NAME_SIZE 32u -// Compares two strings without regard to case. -// TODO(nisse): Delete, implementation using EqualsIgnoreCase is misleading -// since this can't be used for sorting. -#define STR_CASE_CMP(s1, s2) (absl::EqualsIgnoreCase(s1, s2) ? 0 : 1) - -#if defined(WEBRTC_WIN) || defined(WIN32) -// Compares characters of two strings without regard to case. -#define STR_NCASE_CMP(s1, s2, n) ::_strnicmp(s1, s2, n) -#else -#define STR_NCASE_CMP(s1, s2, n) ::strncasecmp(s1, s2, n) -#endif - namespace webrtc { enum FrameType { @@ -210,7 +197,7 @@ struct CodecInst { bool operator==(const CodecInst& other) const { return pltype == other.pltype && - (STR_CASE_CMP(plname, other.plname) == 0) && + absl::EqualsIgnoreCase(plname, other.plname) && plfreq == other.plfreq && pacsize == other.pacsize && channels == other.channels && rate == other.rate; } diff --git a/media/engine/webrtcvoiceengine.cc b/media/engine/webrtcvoiceengine.cc index baad232a87..03cc543947 100644 --- a/media/engine/webrtcvoiceengine.cc +++ b/media/engine/webrtcvoiceengine.cc @@ -968,8 +968,8 @@ class WebRtcVoiceMediaChannel::WebRtcAudioSendStream RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); const bool is_opus = config_.send_codec_spec && - !STR_CASE_CMP(config_.send_codec_spec->format.name.c_str(), - kOpusCodecName); + absl::EqualsIgnoreCase(config_.send_codec_spec->format.name, + kOpusCodecName); if (is_opus && webrtc::field_trial::IsEnabled("WebRTC-Audio-SendSideBwe")) { config_.min_bitrate_bps = kOpusMinBitrateBps; diff --git a/media/engine/webrtcvoiceengine_unittest.cc b/media/engine/webrtcvoiceengine_unittest.cc index 095d8b240b..eefa6f0822 100644 --- a/media/engine/webrtcvoiceengine_unittest.cc +++ b/media/engine/webrtcvoiceengine_unittest.cc @@ -11,6 +11,7 @@ #include #include +#include "absl/strings/match.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h" #include "api/rtpparameters.h" @@ -3467,7 +3468,7 @@ TEST(WebRtcVoiceEngineTest, HasCorrectPayloadTypeMapping) { engine.Init(); for (const cricket::AudioCodec& codec : engine.send_codecs()) { auto is_codec = [&codec](const char* name, int clockrate = 0) { - return STR_CASE_CMP(codec.name.c_str(), name) == 0 && + return absl::EqualsIgnoreCase(codec.name, name) && (clockrate == 0 || codec.clockrate == clockrate); }; if (is_codec("CN", 16000)) { @@ -3616,7 +3617,7 @@ TEST(WebRtcVoiceEngineTest, CollectRecvCodecs) { auto find_codec = [&codecs](const webrtc::SdpAudioFormat& format) -> int { for (size_t i = 0; i != codecs.size(); ++i) { const cricket::AudioCodec& codec = codecs[i]; - if (STR_CASE_CMP(codec.name.c_str(), format.name.c_str()) == 0 && + if (absl::EqualsIgnoreCase(codec.name, format.name) && codec.clockrate == format.clockrate_hz && codec.channels == format.num_channels) { return rtc::checked_cast(i); diff --git a/modules/audio_coding/BUILD.gn b/modules/audio_coding/BUILD.gn index 2ba551f511..01a0e939d5 100644 --- a/modules/audio_coding/BUILD.gn +++ b/modules/audio_coding/BUILD.gn @@ -53,6 +53,7 @@ rtc_static_library("audio_format_conversion") { "../../rtc_base:checks", "../../rtc_base:rtc_base_approved", "../../rtc_base:sanitizer", + "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/types:optional", ] } @@ -74,6 +75,7 @@ rtc_static_library("rent_a_codec") { deps = [ "../../rtc_base:checks", "../../api:array_view", + "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/types:optional", "../../api/audio_codecs:audio_codecs_api", "../..:webrtc_common", @@ -136,6 +138,7 @@ rtc_static_library("audio_coding") { ":rent_a_codec", "../../rtc_base:audio_format_to_string", "../../rtc_base:rtc_base_approved", + "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/types:optional", "../../logging:rtc_event_log_api", ] @@ -829,6 +832,7 @@ rtc_static_library("webrtc_opus") { "../../rtc_base:safe_minmax", "../../system_wrappers:field_trial", "//third_party/abseil-cpp/absl/memory", + "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/types:optional", ] public_deps = [ @@ -1068,6 +1072,7 @@ rtc_static_library("neteq") { "../../rtc_base/system:fallthrough", "../../system_wrappers:field_trial", "../../system_wrappers:metrics", + "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/types:optional", ] } @@ -1362,6 +1367,7 @@ if (rtc_include_tests) { "../../system_wrappers", "../../test:fileutils", "../../test:test_support", + "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/types:optional", ] defines = audio_coding_defines diff --git a/modules/audio_coding/acm2/acm_codec_database.cc b/modules/audio_coding/acm2/acm_codec_database.cc index 311af2df3f..e109cc7e02 100644 --- a/modules/audio_coding/acm2/acm_codec_database.cc +++ b/modules/audio_coding/acm2/acm_codec_database.cc @@ -17,6 +17,7 @@ // references, where appropriate. #include "modules/audio_coding/acm2/acm_codec_database.h" +#include "absl/strings/match.h" #include "rtc_base/checks.h" #if ((defined WEBRTC_CODEC_ISAC) && (defined WEBRTC_CODEC_ISACFX)) @@ -239,12 +240,12 @@ int ACMCodecDB::CodecNumber(const CodecInst& codec_inst) { } // Comfort Noise is special case, packet-size & rate is not checked. - if (STR_CASE_CMP(database_[codec_id].plname, "CN") == 0) { + if (absl::EqualsIgnoreCase(database_[codec_id].plname, "CN")) { return codec_id; } // RED is special case, packet-size & rate is not checked. - if (STR_CASE_CMP(database_[codec_id].plname, "red") == 0) { + if (absl::EqualsIgnoreCase(database_[codec_id].plname, "red")) { return codec_id; } @@ -272,12 +273,12 @@ int ACMCodecDB::CodecNumber(const CodecInst& codec_inst) { // Check the validity of rate. Codecs with multiple rates have their own // function for this. - if (STR_CASE_CMP("isac", codec_inst.plname) == 0) { + if (absl::EqualsIgnoreCase("isac", codec_inst.plname)) { return IsISACRateValid(codec_inst.rate) ? codec_id : kInvalidRate; - } else if (STR_CASE_CMP("ilbc", codec_inst.plname) == 0) { + } else if (absl::EqualsIgnoreCase("ilbc", codec_inst.plname)) { return IsILBCRateValid(codec_inst.rate, codec_inst.pacsize) ? codec_id : kInvalidRate; - } else if (STR_CASE_CMP("opus", codec_inst.plname) == 0) { + } else if (absl::EqualsIgnoreCase("opus", codec_inst.plname)) { return IsOpusRateValid(codec_inst.rate) ? codec_id : kInvalidRate; } @@ -304,10 +305,10 @@ int ACMCodecDB::CodecId(const char* payload_name, // Payload name, sampling frequency and number of channels need to match. // NOTE! If |frequency| is -1, the frequency is not applicable, and is // always treated as true, like for RED. - name_match = (STR_CASE_CMP(ci.plname, payload_name) == 0); + name_match = absl::EqualsIgnoreCase(ci.plname, payload_name); frequency_match = (frequency == ci.plfreq) || (frequency == -1); // The number of channels must match for all codecs but Opus. - if (STR_CASE_CMP(payload_name, "opus") != 0) { + if (!absl::EqualsIgnoreCase(payload_name, "opus")) { channels_match = (channels == ci.channels); } else { // For opus we just check that number of channels is valid. diff --git a/modules/audio_coding/acm2/acm_receive_test.cc b/modules/audio_coding/acm2/acm_receive_test.cc index 2d7f2960de..c149ec1b0b 100644 --- a/modules/audio_coding/acm2/acm_receive_test.cc +++ b/modules/audio_coding/acm2/acm_receive_test.cc @@ -14,6 +14,7 @@ #include +#include "absl/strings/match.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "modules/audio_coding/codecs/audio_format_conversion.h" #include "modules/audio_coding/include/audio_coding_module.h" @@ -30,11 +31,11 @@ namespace { // Returns true if the codec should be registered, otherwise false. Changes // the number of channels for the Opus codec to always be 1. bool ModifyAndUseThisCodec(CodecInst* codec_param) { - if (STR_CASE_CMP(codec_param->plname, "CN") == 0 && + if (absl::EqualsIgnoreCase(codec_param->plname, "CN") && codec_param->plfreq == 48000) return false; // Skip 48 kHz comfort noise. - if (STR_CASE_CMP(codec_param->plname, "telephone-event") == 0) + if (absl::EqualsIgnoreCase(codec_param->plname, "telephone-event")) return false; // Skip DTFM. return true; @@ -65,39 +66,43 @@ bool RemapPltypeAndUseThisCodec(const char* plname, return false; // Don't use non-mono codecs. // Re-map pltypes to those used in the NetEq test files. - if (STR_CASE_CMP(plname, "PCMU") == 0 && plfreq == 8000) { + if (absl::EqualsIgnoreCase(plname, "PCMU") && plfreq == 8000) { *pltype = 0; - } else if (STR_CASE_CMP(plname, "PCMA") == 0 && plfreq == 8000) { + } else if (absl::EqualsIgnoreCase(plname, "PCMA") && plfreq == 8000) { *pltype = 8; - } else if (STR_CASE_CMP(plname, "CN") == 0 && plfreq == 8000) { + } else if (absl::EqualsIgnoreCase(plname, "CN") && plfreq == 8000) { *pltype = 13; - } else if (STR_CASE_CMP(plname, "CN") == 0 && plfreq == 16000) { + } else if (absl::EqualsIgnoreCase(plname, "CN") && plfreq == 16000) { *pltype = 98; - } else if (STR_CASE_CMP(plname, "CN") == 0 && plfreq == 32000) { + } else if (absl::EqualsIgnoreCase(plname, "CN") && plfreq == 32000) { *pltype = 99; - } else if (STR_CASE_CMP(plname, "ILBC") == 0) { + } else if (absl::EqualsIgnoreCase(plname, "ILBC")) { *pltype = 102; - } else if (STR_CASE_CMP(plname, "ISAC") == 0 && plfreq == 16000) { + } else if (absl::EqualsIgnoreCase(plname, "ISAC") && plfreq == 16000) { *pltype = 103; - } else if (STR_CASE_CMP(plname, "ISAC") == 0 && plfreq == 32000) { + } else if (absl::EqualsIgnoreCase(plname, "ISAC") && plfreq == 32000) { *pltype = 104; - } else if (STR_CASE_CMP(plname, "telephone-event") == 0 && plfreq == 8000) { + } else if (absl::EqualsIgnoreCase(plname, "telephone-event") && + plfreq == 8000) { *pltype = 106; - } else if (STR_CASE_CMP(plname, "telephone-event") == 0 && plfreq == 16000) { + } else if (absl::EqualsIgnoreCase(plname, "telephone-event") && + plfreq == 16000) { *pltype = 114; - } else if (STR_CASE_CMP(plname, "telephone-event") == 0 && plfreq == 32000) { + } else if (absl::EqualsIgnoreCase(plname, "telephone-event") && + plfreq == 32000) { *pltype = 115; - } else if (STR_CASE_CMP(plname, "telephone-event") == 0 && plfreq == 48000) { + } else if (absl::EqualsIgnoreCase(plname, "telephone-event") && + plfreq == 48000) { *pltype = 116; - } else if (STR_CASE_CMP(plname, "red") == 0) { + } else if (absl::EqualsIgnoreCase(plname, "red")) { *pltype = 117; - } else if (STR_CASE_CMP(plname, "L16") == 0 && plfreq == 8000) { + } else if (absl::EqualsIgnoreCase(plname, "L16") && plfreq == 8000) { *pltype = 93; - } else if (STR_CASE_CMP(plname, "L16") == 0 && plfreq == 16000) { + } else if (absl::EqualsIgnoreCase(plname, "L16") && plfreq == 16000) { *pltype = 94; - } else if (STR_CASE_CMP(plname, "L16") == 0 && plfreq == 32000) { + } else if (absl::EqualsIgnoreCase(plname, "L16") && plfreq == 32000) { *pltype = 95; - } else if (STR_CASE_CMP(plname, "G722") == 0) { + } else if (absl::EqualsIgnoreCase(plname, "G722")) { *pltype = 9; } else { // Don't use any other codecs. diff --git a/modules/audio_coding/acm2/acm_receiver.cc b/modules/audio_coding/acm2/acm_receiver.cc index f631746b88..93fa27cb8a 100644 --- a/modules/audio_coding/acm2/acm_receiver.cc +++ b/modules/audio_coding/acm2/acm_receiver.cc @@ -15,9 +15,9 @@ #include // sort #include +#include "absl/strings/match.h" #include "api/audio_codecs/audio_decoder.h" #include "common_audio/signal_processing/include/signal_processing_library.h" -#include "common_types.h" // NOLINT(build/include) #include "modules/audio_coding/acm2/acm_resampler.h" #include "modules/audio_coding/acm2/call_statistics.h" #include "modules/audio_coding/acm2/rent_a_codec.h" @@ -92,7 +92,7 @@ int AcmReceiver::InsertPacket(const WebRtcRTPHeader& rtp_header, } receive_timestamp = NowInTimestamp(ci->plfreq); - if (STR_CASE_CMP(ci->plname, "cn") == 0) { + if (absl::EqualsIgnoreCase(ci->plname, "cn")) { if (last_audio_decoder_ && last_audio_decoder_->channels > 1) { // This is a CNG and the audio codec is not mono, so skip pushing in // packets into NetEq. @@ -391,7 +391,7 @@ const absl::optional AcmReceiver::RtpHeaderToDecoder( uint8_t first_payload_byte) const { const absl::optional ci = neteq_->GetDecoder(rtp_header.payloadType); - if (ci && STR_CASE_CMP(ci->plname, "red") == 0) { + if (ci && absl::EqualsIgnoreCase(ci->plname, "red")) { // This is a RED packet. Get the payload of the audio codec. return neteq_->GetDecoder(first_payload_byte & 0x7f); } else { diff --git a/modules/audio_coding/acm2/audio_coding_module.cc b/modules/audio_coding/acm2/audio_coding_module.cc index 60afeb69bd..d6752038da 100644 --- a/modules/audio_coding/acm2/audio_coding_module.cc +++ b/modules/audio_coding/acm2/audio_coding_module.cc @@ -12,6 +12,7 @@ #include +#include "absl/strings/match.h" #include "modules/audio_coding/acm2/acm_receiver.h" #include "modules/audio_coding/acm2/acm_resampler.h" #include "modules/audio_coding/acm2/codec_manager.h" @@ -990,7 +991,7 @@ int AudioCodingModuleImpl::RegisterReceiveCodecUnlocked( } AudioDecoder* isac_decoder = nullptr; - if (STR_CASE_CMP(codec.plname, "isac") == 0) { + if (absl::EqualsIgnoreCase(codec.plname, "isac")) { std::unique_ptr& saved_isac_decoder = codec.plfreq == 16000 ? isac_decoder_16k_ : isac_decoder_32k_; if (!saved_isac_decoder) { diff --git a/modules/audio_coding/acm2/codec_manager.cc b/modules/audio_coding/acm2/codec_manager.cc index f29e0f1a1e..5094e21f07 100644 --- a/modules/audio_coding/acm2/codec_manager.cc +++ b/modules/audio_coding/acm2/codec_manager.cc @@ -10,6 +10,7 @@ #include "modules/audio_coding/acm2/codec_manager.h" +#include "absl/strings/match.h" #include "rtc_base/checks.h" //#include "rtc_base/format_macros.h" #include "modules/audio_coding/acm2/rent_a_codec.h" @@ -35,7 +36,7 @@ int IsValidSendCodec(const CodecInst& send_codec) { } // Telephone-event cannot be a send codec. - if (!STR_CASE_CMP(send_codec.plname, "telephone-event")) { + if (absl::EqualsIgnoreCase(send_codec.plname, "telephone-event")) { RTC_LOG(LS_ERROR) << "telephone-event cannot be a send codec"; return -1; } @@ -53,7 +54,7 @@ int IsValidSendCodec(const CodecInst& send_codec) { bool IsOpus(const CodecInst& codec) { return #ifdef WEBRTC_CODEC_OPUS - !STR_CASE_CMP(codec.plname, "opus") || + absl::EqualsIgnoreCase(codec.plname, "opus") || #endif false; } diff --git a/modules/audio_coding/acm2/rent_a_codec.cc b/modules/audio_coding/acm2/rent_a_codec.cc index 0a9ce117e2..b904eb8d7d 100644 --- a/modules/audio_coding/acm2/rent_a_codec.cc +++ b/modules/audio_coding/acm2/rent_a_codec.cc @@ -13,10 +13,11 @@ #include #include +#include "absl/strings/match.h" #include "modules/audio_coding/codecs/cng/audio_encoder_cng.h" #include "modules/audio_coding/codecs/g711/audio_encoder_pcm.h" -#include "rtc_base/logging.h" #include "modules/audio_coding/codecs/g722/audio_encoder_g722.h" +#include "rtc_base/logging.h" #ifdef WEBRTC_CODEC_ILBC #include "modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.h" // nogncheck #endif @@ -109,7 +110,7 @@ absl::optional RentACodec::NetEqDecoderFromCodecId( RentACodec::RegistrationResult RentACodec::RegisterCngPayloadType( std::map* pt_map, const CodecInst& codec_inst) { - if (STR_CASE_CMP(codec_inst.plname, "CN") != 0) + if (!absl::EqualsIgnoreCase(codec_inst.plname, "CN")) return RegistrationResult::kSkip; switch (codec_inst.plfreq) { case 8000: @@ -126,7 +127,7 @@ RentACodec::RegistrationResult RentACodec::RegisterCngPayloadType( RentACodec::RegistrationResult RentACodec::RegisterRedPayloadType( std::map* pt_map, const CodecInst& codec_inst) { - if (STR_CASE_CMP(codec_inst.plname, "RED") != 0) + if (!absl::EqualsIgnoreCase(codec_inst.plname, "RED")) return RegistrationResult::kSkip; switch (codec_inst.plfreq) { case 8000: @@ -145,30 +146,30 @@ std::unique_ptr CreateEncoder( const CodecInst& speech_inst, const rtc::scoped_refptr& bwinfo) { #if defined(WEBRTC_CODEC_ISACFX) - if (STR_CASE_CMP(speech_inst.plname, "isac") == 0) + if (absl::EqualsIgnoreCase(speech_inst.plname, "isac")) return std::unique_ptr( new AudioEncoderIsacFixImpl(speech_inst, bwinfo)); #endif #if defined(WEBRTC_CODEC_ISAC) - if (STR_CASE_CMP(speech_inst.plname, "isac") == 0) + if (absl::EqualsIgnoreCase(speech_inst.plname, "isac")) return std::unique_ptr( new AudioEncoderIsacFloatImpl(speech_inst, bwinfo)); #endif #ifdef WEBRTC_CODEC_OPUS - if (STR_CASE_CMP(speech_inst.plname, "opus") == 0) + if (absl::EqualsIgnoreCase(speech_inst.plname, "opus")) return std::unique_ptr(new AudioEncoderOpusImpl(speech_inst)); #endif - if (STR_CASE_CMP(speech_inst.plname, "pcmu") == 0) + if (absl::EqualsIgnoreCase(speech_inst.plname, "pcmu")) return std::unique_ptr(new AudioEncoderPcmU(speech_inst)); - if (STR_CASE_CMP(speech_inst.plname, "pcma") == 0) + if (absl::EqualsIgnoreCase(speech_inst.plname, "pcma")) return std::unique_ptr(new AudioEncoderPcmA(speech_inst)); - if (STR_CASE_CMP(speech_inst.plname, "l16") == 0) + if (absl::EqualsIgnoreCase(speech_inst.plname, "l16")) return std::unique_ptr(new AudioEncoderPcm16B(speech_inst)); #ifdef WEBRTC_CODEC_ILBC - if (STR_CASE_CMP(speech_inst.plname, "ilbc") == 0) + if (absl::EqualsIgnoreCase(speech_inst.plname, "ilbc")) return std::unique_ptr(new AudioEncoderIlbcImpl(speech_inst)); #endif - if (STR_CASE_CMP(speech_inst.plname, "g722") == 0) + if (absl::EqualsIgnoreCase(speech_inst.plname, "g722")) return std::unique_ptr(new AudioEncoderG722Impl(speech_inst)); RTC_LOG_F(LS_ERROR) << "Could not create encoder of type " << speech_inst.plname; diff --git a/modules/audio_coding/codecs/audio_format_conversion.cc b/modules/audio_coding/codecs/audio_format_conversion.cc index e38aa33335..bf99f8a823 100644 --- a/modules/audio_coding/codecs/audio_format_conversion.cc +++ b/modules/audio_coding/codecs/audio_format_conversion.cc @@ -12,6 +12,7 @@ #include +#include "absl/strings/match.h" #include "absl/types/optional.h" #include "api/array_view.h" #include "rtc_base/checks.h" @@ -41,11 +42,11 @@ CodecInst MakeCodecInst(int payload_type, } // namespace SdpAudioFormat CodecInstToSdp(const CodecInst& ci) { - if (STR_CASE_CMP(ci.plname, "g722") == 0) { + if (absl::EqualsIgnoreCase(ci.plname, "g722")) { RTC_CHECK_EQ(16000, ci.plfreq); RTC_CHECK(ci.channels == 1 || ci.channels == 2); return {"g722", 8000, ci.channels}; - } else if (STR_CASE_CMP(ci.plname, "opus") == 0) { + } else if (absl::EqualsIgnoreCase(ci.plname, "opus")) { RTC_CHECK_EQ(48000, ci.plfreq); RTC_CHECK(ci.channels == 1 || ci.channels == 2); return ci.channels == 1 @@ -57,12 +58,12 @@ SdpAudioFormat CodecInstToSdp(const CodecInst& ci) { } CodecInst SdpToCodecInst(int payload_type, const SdpAudioFormat& audio_format) { - if (STR_CASE_CMP(audio_format.name.c_str(), "g722") == 0) { + if (absl::EqualsIgnoreCase(audio_format.name, "g722")) { RTC_CHECK_EQ(8000, audio_format.clockrate_hz); RTC_CHECK(audio_format.num_channels == 1 || audio_format.num_channels == 2); return MakeCodecInst(payload_type, "g722", 16000, audio_format.num_channels); - } else if (STR_CASE_CMP(audio_format.name.c_str(), "opus") == 0) { + } else if (absl::EqualsIgnoreCase(audio_format.name, "opus")) { RTC_CHECK_EQ(48000, audio_format.clockrate_hz); RTC_CHECK_EQ(2, audio_format.num_channels); const int num_channels = [&] { diff --git a/modules/audio_coding/codecs/opus/audio_encoder_opus.cc b/modules/audio_coding/codecs/opus/audio_encoder_opus.cc index c07abbe03f..f1aaf70b38 100644 --- a/modules/audio_coding/codecs/opus/audio_encoder_opus.cc +++ b/modules/audio_coding/codecs/opus/audio_encoder_opus.cc @@ -15,7 +15,7 @@ #include #include "absl/memory/memory.h" -#include "common_types.h" // NOLINT(build/include) +#include "absl/strings/match.h" #include "modules/audio_coding/audio_network_adaptor/audio_network_adaptor_impl.h" #include "modules/audio_coding/audio_network_adaptor/controller_manager.h" #include "modules/audio_coding/codecs/opus/opus_interface.h" @@ -316,7 +316,7 @@ std::unique_ptr AudioEncoderOpusImpl::MakeAudioEncoder( absl::optional AudioEncoderOpusImpl::QueryAudioEncoder( const SdpAudioFormat& format) { - if (STR_CASE_CMP(format.name.c_str(), GetPayloadName()) == 0 && + if (absl::EqualsIgnoreCase(format.name, GetPayloadName()) && format.clockrate_hz == 48000 && format.num_channels == 2) { const size_t num_channels = GetChannelCount(format); const int bitrate = @@ -348,7 +348,7 @@ AudioEncoderOpusConfig AudioEncoderOpusImpl::CreateConfig( absl::optional AudioEncoderOpusImpl::SdpToConfig( const SdpAudioFormat& format) { - if (STR_CASE_CMP(format.name.c_str(), "opus") != 0 || + if (!absl::EqualsIgnoreCase(format.name, "opus") || format.clockrate_hz != 48000 || format.num_channels != 2) { return absl::nullopt; } diff --git a/modules/audio_coding/neteq/decoder_database.cc b/modules/audio_coding/neteq/decoder_database.cc index 1fd8c03ca2..bd5d7197a9 100644 --- a/modules/audio_coding/neteq/decoder_database.cc +++ b/modules/audio_coding/neteq/decoder_database.cc @@ -12,6 +12,7 @@ #include // pair +#include "absl/strings/match.h" #include "api/audio_codecs/audio_decoder.h" #include "rtc_base/checks.h" #include "rtc_base/logging.h" @@ -101,7 +102,7 @@ AudioDecoder* DecoderDatabase::DecoderInfo::GetDecoder() const { } bool DecoderDatabase::DecoderInfo::IsType(const char* name) const { - return STR_CASE_CMP(audio_format_.name.c_str(), name) == 0; + return absl::EqualsIgnoreCase(audio_format_.name, name); } bool DecoderDatabase::DecoderInfo::IsType(const std::string& name) const { @@ -110,7 +111,7 @@ bool DecoderDatabase::DecoderInfo::IsType(const std::string& name) const { absl::optional DecoderDatabase::DecoderInfo::CngDecoder::Create(const SdpAudioFormat& format) { - if (STR_CASE_CMP(format.name.c_str(), "CN") == 0) { + if (absl::EqualsIgnoreCase(format.name, "CN")) { // CN has a 1:1 RTP clock rate to sample rate ratio. const int sample_rate_hz = format.clockrate_hz; RTC_DCHECK(sample_rate_hz == 8000 || sample_rate_hz == 16000 || @@ -123,11 +124,11 @@ DecoderDatabase::DecoderInfo::CngDecoder::Create(const SdpAudioFormat& format) { DecoderDatabase::DecoderInfo::Subtype DecoderDatabase::DecoderInfo::SubtypeFromFormat(const SdpAudioFormat& format) { - if (STR_CASE_CMP(format.name.c_str(), "CN") == 0) { + if (absl::EqualsIgnoreCase(format.name, "CN")) { return Subtype::kComfortNoise; - } else if (STR_CASE_CMP(format.name.c_str(), "telephone-event") == 0) { + } else if (absl::EqualsIgnoreCase(format.name, "telephone-event")) { return Subtype::kDtmf; - } else if (STR_CASE_CMP(format.name.c_str(), "red") == 0) { + } else if (absl::EqualsIgnoreCase(format.name, "red")) { return Subtype::kRed; } diff --git a/modules/audio_coding/test/EncodeDecodeTest.cc b/modules/audio_coding/test/EncodeDecodeTest.cc index c6f3f8c9f2..240836688c 100644 --- a/modules/audio_coding/test/EncodeDecodeTest.cc +++ b/modules/audio_coding/test/EncodeDecodeTest.cc @@ -14,9 +14,9 @@ #include #include +#include "absl/strings/match.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h" -#include "common_types.h" // NOLINT(build/include) #include "modules/audio_coding/codecs/audio_format_conversion.h" #include "modules/audio_coding/include/audio_coding_module.h" #include "modules/audio_coding/test/utility.h" @@ -248,11 +248,11 @@ void EncodeDecodeTest::Perform() { for (int n = 0; n < numCodecs; n++) { EXPECT_EQ(0, acm->Codec(n, &sendCodecTmp)); - if (STR_CASE_CMP(sendCodecTmp.plname, "telephone-event") == 0) { + if (absl::EqualsIgnoreCase(sendCodecTmp.plname, "telephone-event")) { numPars[n] = 0; - } else if (STR_CASE_CMP(sendCodecTmp.plname, "cn") == 0) { + } else if (absl::EqualsIgnoreCase(sendCodecTmp.plname, "cn")) { numPars[n] = 0; - } else if (STR_CASE_CMP(sendCodecTmp.plname, "red") == 0) { + } else if (absl::EqualsIgnoreCase(sendCodecTmp.plname, "red")) { numPars[n] = 0; } else if (sendCodecTmp.channels == 2) { numPars[n] = 0; diff --git a/modules/audio_coding/test/TestRedFec.cc b/modules/audio_coding/test/TestRedFec.cc index c56fed95da..4866118748 100644 --- a/modules/audio_coding/test/TestRedFec.cc +++ b/modules/audio_coding/test/TestRedFec.cc @@ -173,7 +173,7 @@ void TestRedFec::RegisterSendCodec( auto encoder = encoder_factory_->MakeAudioEncoder(payload_type, codec_format, absl::nullopt); EXPECT_NE(encoder, nullptr); - if (STR_CASE_CMP(codec_format.name.c_str(), "opus") != 0) { + if (!absl::EqualsIgnoreCase(codec_format.name, "opus")) { if (vad_mode.has_value()) { AudioEncoderCng::Config config; config.speech_encoder = std::move(encoder); diff --git a/modules/audio_coding/test/TestStereo.cc b/modules/audio_coding/test/TestStereo.cc index fd69fd2626..bf8e1894d0 100644 --- a/modules/audio_coding/test/TestStereo.cc +++ b/modules/audio_coding/test/TestStereo.cc @@ -12,9 +12,9 @@ #include +#include "absl/strings/match.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h" -#include "common_types.h" // NOLINT(build/include) #include "modules/audio_coding/codecs/audio_format_conversion.h" #include "modules/audio_coding/include/audio_coding_module_typedefs.h" #include "modules/audio_coding/test/utility.h" @@ -626,14 +626,14 @@ void TestStereo::RegisterSendCodec(char side, ASSERT_TRUE(my_acm != NULL); auto encoder_factory = CreateBuiltinAudioEncoderFactory(); - const int clockrate_hz = STR_CASE_CMP(codec_name, "g722") == 0 + const int clockrate_hz = absl::EqualsIgnoreCase(codec_name, "g722") ? sampling_freq_hz / 2 : sampling_freq_hz; const std::string ptime = rtc::ToString(rtc::CheckedDivExact( pack_size, rtc::CheckedDivExact(sampling_freq_hz, 1000))); SdpAudioFormat::Parameters params = {{"ptime", ptime}}; RTC_CHECK(channels == 1 || channels == 2); - if (STR_CASE_CMP(codec_name, "opus") == 0) { + if (absl::EqualsIgnoreCase(codec_name, "opus")) { if (channels == 2) { params["stereo"] = "1"; } diff --git a/modules/audio_coding/test/TestVADDTX.cc b/modules/audio_coding/test/TestVADDTX.cc index 4f02edaa83..aa91ee011a 100644 --- a/modules/audio_coding/test/TestVADDTX.cc +++ b/modules/audio_coding/test/TestVADDTX.cc @@ -12,6 +12,7 @@ #include +#include "absl/strings/match.h" #include "api/audio_codecs/audio_decoder_factory_template.h" #include "api/audio_codecs/audio_encoder_factory_template.h" #include "api/audio_codecs/ilbc/audio_decoder_ilbc.h" @@ -81,7 +82,7 @@ bool TestVadDtx::RegisterCodec(const SdpAudioFormat& codec_format, auto encoder = encoder_factory_->MakeAudioEncoder(payload_type, codec_format, absl::nullopt); if (vad_mode.has_value() && - STR_CASE_CMP(codec_format.name.c_str(), "opus") != 0) { + !absl::EqualsIgnoreCase(codec_format.name, "opus")) { AudioEncoderCng::Config config; config.speech_encoder = std::move(encoder); config.num_channels = 1; diff --git a/modules/audio_coding/test/iSACTest.cc b/modules/audio_coding/test/iSACTest.cc index a130ae3e66..c332fe08f1 100644 --- a/modules/audio_coding/test/iSACTest.cc +++ b/modules/audio_coding/test/iSACTest.cc @@ -23,6 +23,7 @@ #include #endif +#include "absl/strings/match.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/audio_codecs/isac/audio_encoder_isac_float.h" #include "modules/audio_coding/codecs/audio_format_conversion.h" @@ -92,12 +93,12 @@ void ISACTest::Setup() { for (codecCntr = 0; codecCntr < AudioCodingModule::NumberOfCodecs(); codecCntr++) { EXPECT_EQ(0, AudioCodingModule::Codec(codecCntr, &codecParam)); - if (!STR_CASE_CMP(codecParam.plname, "ISAC") && + if (absl::EqualsIgnoreCase(codecParam.plname, "ISAC") && codecParam.plfreq == 16000) { memcpy(&_paramISAC16kHz, &codecParam, sizeof(CodecInst)); _idISAC16kHz = codecCntr; } - if (!STR_CASE_CMP(codecParam.plname, "ISAC") && + if (absl::EqualsIgnoreCase(codecParam.plname, "ISAC") && codecParam.plfreq == 32000) { memcpy(&_paramISAC32kHz, &codecParam, sizeof(CodecInst)); _idISAC32kHz = codecCntr; diff --git a/modules/audio_coding/test/utility.cc b/modules/audio_coding/test/utility.cc index 83c25b537e..53f807790e 100644 --- a/modules/audio_coding/test/utility.cc +++ b/modules/audio_coding/test/utility.cc @@ -15,7 +15,7 @@ #include #include -#include "common_types.h" // NOLINT(build/include) +#include "absl/strings/match.h" #include "modules/audio_coding/include/audio_coding_module.h" #include "test/gtest.h" @@ -268,7 +268,7 @@ bool FixedPayloadTypeCodec(const char* payloadName) { "G722", "QCELP", "CN", "MPA", "G728", "G729"}; for (int n = 0; n < NUM_CODECS_WITH_FIXED_PAYLOAD_TYPE; n++) { - if (!STR_CASE_CMP(payloadName, fixPayloadTypeCodecs[n])) { + if (absl::EqualsIgnoreCase(payloadName, fixPayloadTypeCodecs[n])) { return true; } } diff --git a/pc/mediasession.cc b/pc/mediasession.cc index d4a80c03a5..d84166278a 100644 --- a/pc/mediasession.cc +++ b/pc/mediasession.cc @@ -18,9 +18,9 @@ #include #include +#include "absl/strings/match.h" #include "absl/types/optional.h" #include "api/cryptoparams.h" -#include "common_types.h" // NOLINT(build/include) #include "media/base/h264_profile_level_id.h" #include "media/base/mediaconstants.h" #include "p2p/base/p2pconstants.h" @@ -653,7 +653,7 @@ static bool ContainsRtxCodec(const std::vector& codecs) { template static bool IsRtxCodec(const C& codec) { - return STR_CASE_CMP(codec.name.c_str(), kRtxCodecName) == 0; + return absl::EqualsIgnoreCase(codec.name, kRtxCodecName); } template @@ -668,7 +668,7 @@ static bool ContainsFlexfecCodec(const std::vector& codecs) { template static bool IsFlexfecCodec(const C& codec) { - return STR_CASE_CMP(codec.name.c_str(), kFlexfecCodecName) == 0; + return absl::EqualsIgnoreCase(codec.name, kFlexfecCodecName); } // Create a media content to be offered for the given |sender_options|, @@ -1041,9 +1041,8 @@ static void NegotiateRtpHeaderExtensions( static void StripCNCodecs(AudioCodecs* audio_codecs) { audio_codecs->erase(std::remove_if(audio_codecs->begin(), audio_codecs->end(), [](const AudioCodec& codec) { - return STR_CASE_CMP( - codec.name.c_str(), - kComfortNoiseCodecName) == 0; + return absl::EqualsIgnoreCase( + codec.name, kComfortNoiseCodecName); }), audio_codecs->end()); } diff --git a/pc/peerconnectionendtoend_unittest.cc b/pc/peerconnectionendtoend_unittest.cc index 3e0c2c39eb..52c6bf2a75 100644 --- a/pc/peerconnectionendtoend_unittest.cc +++ b/pc/peerconnectionendtoend_unittest.cc @@ -11,6 +11,7 @@ #include #include "absl/memory/memory.h" +#include "absl/strings/match.h" #include "api/audio_codecs/L16/audio_decoder_L16.h" #include "api/audio_codecs/L16/audio_encoder_L16.h" #include "api/audio_codecs/audio_codec_pair_id.h" @@ -299,7 +300,7 @@ CreateForwardingMockDecoderFactory( struct AudioEncoderUnicornSparklesRainbow { using Config = webrtc::AudioEncoderL16::Config; static absl::optional SdpToConfig(webrtc::SdpAudioFormat format) { - if (STR_CASE_CMP(format.name.c_str(), "UnicornSparklesRainbow") == 0) { + if (absl::EqualsIgnoreCase(format.name, "UnicornSparklesRainbow")) { const webrtc::SdpAudioFormat::Parameters expected_params = { {"num_horns", "1"}}; EXPECT_EQ(expected_params, format.parameters); @@ -336,7 +337,7 @@ struct AudioEncoderUnicornSparklesRainbow { struct AudioDecoderUnicornSparklesRainbow { using Config = webrtc::AudioDecoderL16::Config; static absl::optional SdpToConfig(webrtc::SdpAudioFormat format) { - if (STR_CASE_CMP(format.name.c_str(), "UnicornSparklesRainbow") == 0) { + if (absl::EqualsIgnoreCase(format.name, "UnicornSparklesRainbow")) { const webrtc::SdpAudioFormat::Parameters expected_params = { {"num_horns", "1"}}; EXPECT_EQ(expected_params, format.parameters);