Remove CodecInst pt.3
Finally remove CodecInst from common_types.h, including remaining code referencing it.
TBR=kwiberg
Bug: webrtc:7626
Change-Id: I5e6b949ae9093641e33972af8438d1126fc48556
Reviewed-on: https://webrtc-review.googlesource.com/c/114546
Commit-Queue: Fredrik Solenberg <solenberg@webrtc.org>
Reviewed-by: Oskar Sundbom <ossu@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26036}
diff --git a/common_types.h b/common_types.h
index 848b899..c6d4c94 100644
--- a/common_types.h
+++ b/common_types.h
@@ -14,12 +14,10 @@
#include <stddef.h> // For size_t
#include <cstdint>
-#include "absl/strings/match.h"
// TODO(sprang): Remove this include when all usage includes it directly.
#include "api/video/video_bitrate_allocation.h"
// TODO(bugs.webrtc.org/7660): Delete include once downstream code is updated.
#include "api/video/video_codec_type.h"
-#include "rtc_base/checks.h"
#if defined(_MSC_VER)
// Disable "new behavior: elements of array will be default initialized"
@@ -158,29 +156,6 @@
virtual void OnOverheadChanged(size_t overhead_bytes_per_packet) = 0;
};
-// ==================================================================
-// Voice specific types
-// ==================================================================
-
-// Each codec supported can be described by this structure.
-struct CodecInst {
- int pltype;
- char plname[RTP_PAYLOAD_NAME_SIZE];
- int plfreq;
- int pacsize;
- size_t channels;
- int rate; // bits/sec unlike {start,min,max}Bitrate elsewhere in this file!
-
- bool operator==(const CodecInst& other) const {
- return pltype == other.pltype &&
- absl::EqualsIgnoreCase(plname, other.plname) &&
- plfreq == other.plfreq && pacsize == other.pacsize &&
- channels == other.channels && rate == other.rate;
- }
-
- bool operator!=(const CodecInst& other) const { return !(*this == other); }
-};
-
// RTP
enum { kRtpCsrcSize = 15 }; // RFC 3550 page 13
diff --git a/media/base/h264_profile_level_id.cc b/media/base/h264_profile_level_id.cc
index 65a6cf0..32fa02c 100644
--- a/media/base/h264_profile_level_id.cc
+++ b/media/base/h264_profile_level_id.cc
@@ -15,6 +15,7 @@
#include <cstring>
#include "rtc_base/arraysize.h"
+#include "rtc_base/checks.h"
namespace webrtc {
namespace H264 {
diff --git a/modules/audio_coding/BUILD.gn b/modules/audio_coding/BUILD.gn
index e2a13f3..86a5fc9 100644
--- a/modules/audio_coding/BUILD.gn
+++ b/modules/audio_coding/BUILD.gn
@@ -14,24 +14,6 @@
visibility = [ ":*" ]
-rtc_static_library("audio_format_conversion") {
- visibility += webrtc_default_visibility
- sources = [
- "codecs/audio_format_conversion.cc",
- "codecs/audio_format_conversion.h",
- ]
- deps = [
- "../..:webrtc_common",
- "../../api:array_view",
- "../../api/audio_codecs:audio_codecs_api",
- "../../rtc_base:checks",
- "../../rtc_base:rtc_base_approved",
- "../../rtc_base:sanitizer",
- "//third_party/abseil-cpp/absl/strings",
- "//third_party/abseil-cpp/absl/types:optional",
- ]
-}
-
rtc_source_set("audio_coding_module_typedefs") {
sources = [
"include/audio_coding_module_typedefs.h",
@@ -1319,7 +1301,6 @@
":audio_coding",
":audio_coding_module_typedefs",
":audio_encoder_cng",
- ":audio_format_conversion",
":pcm16b_c",
":red",
":webrtc_opus_c",
@@ -1398,7 +1379,6 @@
deps = audio_coding_deps + [
"..:module_api",
":audio_coding",
- ":audio_format_conversion",
"../../api/audio_codecs:audio_codecs_api",
"../../api/audio_codecs:builtin_audio_decoder_factory",
":neteq_tools",
@@ -1422,7 +1402,6 @@
"../../api/audio:audio_frame_api",
"../../rtc_base:checks",
":audio_coding",
- ":audio_format_conversion",
":neteq_tools",
"../../api/audio_codecs:builtin_audio_decoder_factory",
"../../api/audio_codecs:builtin_audio_encoder_factory",
@@ -2041,7 +2020,6 @@
":audio_coding",
":audio_coding_module_typedefs",
":audio_encoder_cng",
- ":audio_format_conversion",
":audio_network_adaptor",
":g711",
":ilbc",
diff --git a/modules/audio_coding/codecs/audio_format_conversion.cc b/modules/audio_coding/codecs/audio_format_conversion.cc
deleted file mode 100644
index f068301..0000000
--- a/modules/audio_coding/codecs/audio_format_conversion.cc
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
- *
- * Use of this source code is governed by a BSD-style license
- * that can be found in the LICENSE file in the root of the source
- * tree. An additional intellectual property rights grant can be found
- * in the file PATENTS. All contributing project authors may
- * be found in the AUTHORS file in the root of the source tree.
- */
-
-#include "modules/audio_coding/codecs/audio_format_conversion.h"
-
-#include <string.h>
-#include <string>
-#include <utility>
-
-#include "absl/strings/match.h"
-#include "api/array_view.h"
-#include "rtc_base/checks.h"
-#include "rtc_base/sanitizer.h"
-
-namespace webrtc {
-
-namespace {
-
-CodecInst MakeCodecInst(int payload_type,
- const char* name,
- int sample_rate,
- size_t num_channels) {
- // Create a CodecInst with some fields set. The remaining fields are zeroed,
- // but we tell MSan to consider them uninitialized.
- CodecInst ci = {0};
- rtc::MsanMarkUninitialized(rtc::MakeArrayView(&ci, 1));
- ci.pltype = payload_type;
- strncpy(ci.plname, name, sizeof(ci.plname));
- ci.plname[sizeof(ci.plname) - 1] = '\0';
- ci.plfreq = sample_rate;
- ci.channels = num_channels;
- return ci;
-}
-
-} // namespace
-
-SdpAudioFormat CodecInstToSdp(const CodecInst& ci) {
- 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 (absl::EqualsIgnoreCase(ci.plname, "opus")) {
- RTC_CHECK_EQ(48000, ci.plfreq);
- RTC_CHECK(ci.channels == 1 || ci.channels == 2);
- return ci.channels == 1
- ? SdpAudioFormat("opus", 48000, 2)
- : SdpAudioFormat("opus", 48000, 2, {{"stereo", "1"}});
- } else {
- return {ci.plname, ci.plfreq, ci.channels};
- }
-}
-
-CodecInst SdpToCodecInst(int payload_type, const SdpAudioFormat& audio_format) {
- 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 (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 = [&] {
- auto stereo = audio_format.parameters.find("stereo");
- if (stereo != audio_format.parameters.end()) {
- if (stereo->second == "0") {
- return 1;
- } else if (stereo->second == "1") {
- return 2;
- } else {
- RTC_CHECK(false); // Bad stereo parameter.
- }
- }
- return 1; // Default to mono.
- }();
- return MakeCodecInst(payload_type, "opus", 48000, num_channels);
- } else {
- return MakeCodecInst(payload_type, audio_format.name.c_str(),
- audio_format.clockrate_hz, audio_format.num_channels);
- }
-}
-
-} // namespace webrtc
diff --git a/modules/audio_coding/codecs/audio_format_conversion.h b/modules/audio_coding/codecs/audio_format_conversion.h
deleted file mode 100644
index d981741..0000000
--- a/modules/audio_coding/codecs/audio_format_conversion.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
- *
- * Use of this source code is governed by a BSD-style license
- * that can be found in the LICENSE file in the root of the source
- * tree. An additional intellectual property rights grant can be found
- * in the file PATENTS. All contributing project authors may
- * be found in the AUTHORS file in the root of the source tree.
- */
-
-#ifndef MODULES_AUDIO_CODING_CODECS_AUDIO_FORMAT_CONVERSION_H_
-#define MODULES_AUDIO_CODING_CODECS_AUDIO_FORMAT_CONVERSION_H_
-
-#include "api/audio_codecs/audio_format.h"
-#include "common_types.h" // NOLINT(build/include)
-
-namespace webrtc {
-
-SdpAudioFormat CodecInstToSdp(const CodecInst& codec_inst);
-CodecInst SdpToCodecInst(int payload_type, const SdpAudioFormat& audio_format);
-
-} // namespace webrtc
-
-#endif // MODULES_AUDIO_CODING_CODECS_AUDIO_FORMAT_CONVERSION_H_
diff --git a/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc b/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc
index dce1635..fd560e4 100644
--- a/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc
+++ b/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc
@@ -12,25 +12,11 @@
#include <cstdint>
-#include "common_types.h"
#include "modules/audio_coding/codecs/g711/g711_interface.h"
#include "rtc_base/checks.h"
namespace webrtc {
-namespace {
-
-template <typename T>
-typename T::Config CreateConfig(const CodecInst& codec_inst) {
- typename T::Config config;
- config.frame_size_ms = codec_inst.pacsize / 8;
- config.num_channels = codec_inst.channels;
- config.payload_type = codec_inst.pltype;
- return config;
-}
-
-} // namespace
-
bool AudioEncoderPcm::Config::IsOk() const {
return (frame_size_ms % 10 == 0) && (num_channels >= 1);
}
@@ -103,9 +89,6 @@
speech_buffer_.clear();
}
-AudioEncoderPcmA::AudioEncoderPcmA(const CodecInst& codec_inst)
- : AudioEncoderPcmA(CreateConfig<AudioEncoderPcmA>(codec_inst)) {}
-
size_t AudioEncoderPcmA::EncodeCall(const int16_t* audio,
size_t input_len,
uint8_t* encoded) {
@@ -120,9 +103,6 @@
return AudioEncoder::CodecType::kPcmA;
}
-AudioEncoderPcmU::AudioEncoderPcmU(const CodecInst& codec_inst)
- : AudioEncoderPcmU(CreateConfig<AudioEncoderPcmU>(codec_inst)) {}
-
size_t AudioEncoderPcmU::EncodeCall(const int16_t* audio,
size_t input_len,
uint8_t* encoded) {
diff --git a/modules/audio_coding/codecs/g711/audio_encoder_pcm.h b/modules/audio_coding/codecs/g711/audio_encoder_pcm.h
index 37b67cf..88668d9 100644
--- a/modules/audio_coding/codecs/g711/audio_encoder_pcm.h
+++ b/modules/audio_coding/codecs/g711/audio_encoder_pcm.h
@@ -69,8 +69,6 @@
uint32_t first_timestamp_in_buffer_;
};
-struct CodecInst;
-
class AudioEncoderPcmA final : public AudioEncoderPcm {
public:
struct Config : public AudioEncoderPcm::Config {
@@ -79,7 +77,6 @@
explicit AudioEncoderPcmA(const Config& config)
: AudioEncoderPcm(config, kSampleRateHz) {}
- explicit AudioEncoderPcmA(const CodecInst& codec_inst);
protected:
size_t EncodeCall(const int16_t* audio,
@@ -103,7 +100,6 @@
explicit AudioEncoderPcmU(const Config& config)
: AudioEncoderPcm(config, kSampleRateHz) {}
- explicit AudioEncoderPcmU(const CodecInst& codec_inst);
protected:
size_t EncodeCall(const int16_t* audio,
diff --git a/modules/audio_coding/codecs/g722/audio_encoder_g722.cc b/modules/audio_coding/codecs/g722/audio_encoder_g722.cc
index e63d590..d293163 100644
--- a/modules/audio_coding/codecs/g722/audio_encoder_g722.cc
+++ b/modules/audio_coding/codecs/g722/audio_encoder_g722.cc
@@ -12,7 +12,6 @@
#include <cstdint>
-#include "common_types.h"
#include "modules/audio_coding/codecs/g722/g722_interface.h"
#include "rtc_base/checks.h"
#include "rtc_base/numerics/safe_conversions.h"
@@ -23,13 +22,6 @@
const size_t kSampleRateHz = 16000;
-AudioEncoderG722Config CreateConfig(const CodecInst& codec_inst) {
- AudioEncoderG722Config config;
- config.num_channels = rtc::dchecked_cast<int>(codec_inst.channels);
- config.frame_size_ms = codec_inst.pacsize / 16;
- return config;
-}
-
} // namespace
AudioEncoderG722Impl::AudioEncoderG722Impl(const AudioEncoderG722Config& config,
@@ -52,9 +44,6 @@
Reset();
}
-AudioEncoderG722Impl::AudioEncoderG722Impl(const CodecInst& codec_inst)
- : AudioEncoderG722Impl(CreateConfig(codec_inst), codec_inst.pltype) {}
-
AudioEncoderG722Impl::~AudioEncoderG722Impl() = default;
int AudioEncoderG722Impl::SampleRateHz() const {
diff --git a/modules/audio_coding/codecs/g722/audio_encoder_g722.h b/modules/audio_coding/codecs/g722/audio_encoder_g722.h
index 3cf1439..d0d23ca 100644
--- a/modules/audio_coding/codecs/g722/audio_encoder_g722.h
+++ b/modules/audio_coding/codecs/g722/audio_encoder_g722.h
@@ -21,12 +21,9 @@
namespace webrtc {
-struct CodecInst;
-
class AudioEncoderG722Impl final : public AudioEncoder {
public:
AudioEncoderG722Impl(const AudioEncoderG722Config& config, int payload_type);
- explicit AudioEncoderG722Impl(const CodecInst& codec_inst);
~AudioEncoderG722Impl() override;
int SampleRateHz() const override;
diff --git a/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.cc b/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.cc
index 8801fd5..ac9214b 100644
--- a/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.cc
+++ b/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.cc
@@ -13,7 +13,6 @@
#include <algorithm>
#include <cstdint>
-#include "common_types.h"
#include "modules/audio_coding/codecs/ilbc/ilbc.h"
#include "rtc_base/checks.h"
#include "rtc_base/numerics/safe_conversions.h"
@@ -24,12 +23,6 @@
const int kSampleRateHz = 8000;
-AudioEncoderIlbcConfig CreateConfig(const CodecInst& codec_inst) {
- AudioEncoderIlbcConfig config;
- config.frame_size_ms = codec_inst.pacsize / 8;
- return config;
-}
-
int GetIlbcBitrate(int ptime) {
switch (ptime) {
case 20:
@@ -58,9 +51,6 @@
Reset();
}
-AudioEncoderIlbcImpl::AudioEncoderIlbcImpl(const CodecInst& codec_inst)
- : AudioEncoderIlbcImpl(CreateConfig(codec_inst), codec_inst.pltype) {}
-
AudioEncoderIlbcImpl::~AudioEncoderIlbcImpl() {
RTC_CHECK_EQ(0, WebRtcIlbcfix_EncoderFree(encoder_));
}
diff --git a/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.h b/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.h
index a238689..675dc7d 100644
--- a/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.h
+++ b/modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.h
@@ -18,12 +18,9 @@
namespace webrtc {
-struct CodecInst;
-
class AudioEncoderIlbcImpl final : public AudioEncoder {
public:
AudioEncoderIlbcImpl(const AudioEncoderIlbcConfig& config, int payload_type);
- explicit AudioEncoderIlbcImpl(const CodecInst& codec_inst);
~AudioEncoderIlbcImpl() override;
int SampleRateHz() const override;
diff --git a/modules/audio_coding/codecs/isac/audio_encoder_isac_t.h b/modules/audio_coding/codecs/isac/audio_encoder_isac_t.h
index 541b90c..2989898 100644
--- a/modules/audio_coding/codecs/isac/audio_encoder_isac_t.h
+++ b/modules/audio_coding/codecs/isac/audio_encoder_isac_t.h
@@ -20,8 +20,6 @@
namespace webrtc {
-struct CodecInst;
-
template <typename T>
class AudioEncoderIsacT final : public AudioEncoder {
public:
@@ -52,9 +50,6 @@
};
explicit AudioEncoderIsacT(const Config& config);
- explicit AudioEncoderIsacT(
- const CodecInst& codec_inst,
- const rtc::scoped_refptr<LockedIsacBandwidthInfo>& bwinfo);
~AudioEncoderIsacT() override;
int SampleRateHz() const override;
diff --git a/modules/audio_coding/codecs/isac/audio_encoder_isac_t_impl.h b/modules/audio_coding/codecs/isac/audio_encoder_isac_t_impl.h
index cbf15fc..3448139 100644
--- a/modules/audio_coding/codecs/isac/audio_encoder_isac_t_impl.h
+++ b/modules/audio_coding/codecs/isac/audio_encoder_isac_t_impl.h
@@ -11,28 +11,11 @@
#ifndef MODULES_AUDIO_CODING_CODECS_ISAC_AUDIO_ENCODER_ISAC_T_IMPL_H_
#define MODULES_AUDIO_CODING_CODECS_ISAC_AUDIO_ENCODER_ISAC_T_IMPL_H_
-#include "common_types.h" // NOLINT(build/include)
#include "rtc_base/checks.h"
namespace webrtc {
template <typename T>
-typename AudioEncoderIsacT<T>::Config CreateIsacConfig(
- const CodecInst& codec_inst,
- const rtc::scoped_refptr<LockedIsacBandwidthInfo>& bwinfo) {
- typename AudioEncoderIsacT<T>::Config config;
- config.bwinfo = bwinfo;
- config.payload_type = codec_inst.pltype;
- config.sample_rate_hz = codec_inst.plfreq;
- config.frame_size_ms =
- rtc::CheckedDivExact(1000 * codec_inst.pacsize, config.sample_rate_hz);
- config.adaptive_mode = (codec_inst.rate == -1);
- if (codec_inst.rate != -1)
- config.bit_rate = codec_inst.rate;
- return config;
-}
-
-template <typename T>
bool AudioEncoderIsacT<T>::Config::IsOk() const {
if (max_bit_rate < 32000 && max_bit_rate != -1)
return false;
@@ -67,12 +50,6 @@
}
template <typename T>
-AudioEncoderIsacT<T>::AudioEncoderIsacT(
- const CodecInst& codec_inst,
- const rtc::scoped_refptr<LockedIsacBandwidthInfo>& bwinfo)
- : AudioEncoderIsacT(CreateIsacConfig<T>(codec_inst, bwinfo)) {}
-
-template <typename T>
AudioEncoderIsacT<T>::~AudioEncoderIsacT() {
RTC_CHECK_EQ(0, T::Free(isac_state_));
}
diff --git a/modules/audio_coding/codecs/opus/audio_encoder_opus.cc b/modules/audio_coding/codecs/opus/audio_encoder_opus.cc
index 1a88acf..a5c4380 100644
--- a/modules/audio_coding/codecs/opus/audio_encoder_opus.cc
+++ b/modules/audio_coding/codecs/opus/audio_encoder_opus.cc
@@ -16,7 +16,6 @@
#include "absl/memory/memory.h"
#include "absl/strings/match.h"
-#include "common_types.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"
@@ -334,19 +333,6 @@
return absl::nullopt;
}
-AudioEncoderOpusConfig AudioEncoderOpusImpl::CreateConfig(
- const CodecInst& codec_inst) {
- AudioEncoderOpusConfig config;
- config.frame_size_ms = rtc::CheckedDivExact(codec_inst.pacsize, 48);
- config.num_channels = codec_inst.channels;
- config.bitrate_bps = codec_inst.rate;
- config.application = config.num_channels == 1
- ? AudioEncoderOpusConfig::ApplicationMode::kVoip
- : AudioEncoderOpusConfig::ApplicationMode::kAudio;
- config.supported_frame_lengths_ms.push_back(config.frame_size_ms);
- return config;
-}
-
absl::optional<AudioEncoderOpusConfig> AudioEncoderOpusImpl::SdpToConfig(
const SdpAudioFormat& format) {
if (!absl::EqualsIgnoreCase(format.name, "opus") ||
@@ -494,9 +480,6 @@
SetProjectedPacketLossRate(packet_loss_rate_);
}
-AudioEncoderOpusImpl::AudioEncoderOpusImpl(const CodecInst& codec_inst)
- : AudioEncoderOpusImpl(CreateConfig(codec_inst), codec_inst.pltype) {}
-
AudioEncoderOpusImpl::AudioEncoderOpusImpl(int payload_type,
const SdpAudioFormat& format)
: AudioEncoderOpusImpl(*SdpToConfig(format), payload_type) {}
diff --git a/modules/audio_coding/codecs/opus/audio_encoder_opus.h b/modules/audio_coding/codecs/opus/audio_encoder_opus.h
index 150423f..7d051d5 100644
--- a/modules/audio_coding/codecs/opus/audio_encoder_opus.h
+++ b/modules/audio_coding/codecs/opus/audio_encoder_opus.h
@@ -30,8 +30,6 @@
class RtcEventLog;
-struct CodecInst;
-
class AudioEncoderOpusImpl final : public AudioEncoder {
public:
class NewPacketLossRateOptimizer {
@@ -54,8 +52,6 @@
RTC_DISALLOW_COPY_AND_ASSIGN(NewPacketLossRateOptimizer);
};
- static AudioEncoderOpusConfig CreateConfig(const CodecInst& codec_inst);
-
// Returns empty if the current bitrate falls within the hysteresis window,
// defined by complexity_threshold_bps +/- complexity_threshold_window_bps.
// Otherwise, returns the current complexity depending on whether the
@@ -83,7 +79,6 @@
const AudioNetworkAdaptorCreator& audio_network_adaptor_creator,
std::unique_ptr<SmoothingFilter> bitrate_smoother);
- explicit AudioEncoderOpusImpl(const CodecInst& codec_inst);
AudioEncoderOpusImpl(int payload_type, const SdpAudioFormat& format);
~AudioEncoderOpusImpl() override;
diff --git a/modules/audio_coding/codecs/opus/audio_encoder_opus_unittest.cc b/modules/audio_coding/codecs/opus/audio_encoder_opus_unittest.cc
index d5c2c84..a0e24da 100644
--- a/modules/audio_coding/codecs/opus/audio_encoder_opus_unittest.cc
+++ b/modules/audio_coding/codecs/opus/audio_encoder_opus_unittest.cc
@@ -15,7 +15,6 @@
#include "absl/memory/memory.h"
#include "api/audio_codecs/opus/audio_encoder_opus.h"
#include "common_audio/mocks/mock_smoothing_filter.h"
-#include "common_types.h" // NOLINT(build/include)
#include "modules/audio_coding/audio_network_adaptor/mock/mock_audio_network_adaptor.h"
#include "modules/audio_coding/codecs/opus/audio_encoder_opus.h"
#include "modules/audio_coding/codecs/opus/opus_interface.h"
@@ -33,21 +32,11 @@
namespace {
-const CodecInst kDefaultOpusSettings = {105, "opus", 48000, 960, 1, 32000};
+constexpr int kDefaultOpusPayloadType = 105;
+constexpr int kDefaultOpusRate = 32000;
+constexpr int kDefaultOpusPacSize = 960;
constexpr int64_t kInitialTimeUs = 12345678;
-AudioEncoderOpusConfig CreateConfig(const CodecInst& codec_inst) {
- AudioEncoderOpusConfig config;
- config.frame_size_ms = rtc::CheckedDivExact(codec_inst.pacsize, 48);
- config.num_channels = codec_inst.channels;
- config.bitrate_bps = codec_inst.rate;
- config.application = config.num_channels == 1
- ? AudioEncoderOpusConfig::ApplicationMode::kVoip
- : AudioEncoderOpusConfig::ApplicationMode::kAudio;
- config.supported_frame_lengths_ms.push_back(config.frame_size_ms);
- return config;
-}
-
AudioEncoderOpusConfig CreateConfigWithParameters(
const SdpAudioFormat::Parameters& params) {
const SdpAudioFormat format("opus", 48000, 2, params);
@@ -79,15 +68,22 @@
return adaptor;
};
- CodecInst codec_inst = kDefaultOpusSettings;
- codec_inst.channels = num_channels;
- states->config = CreateConfig(codec_inst);
+ AudioEncoderOpusConfig config;
+ config.frame_size_ms = rtc::CheckedDivExact(kDefaultOpusPacSize, 48);
+ config.num_channels = num_channels;
+ config.bitrate_bps = kDefaultOpusRate;
+ config.application = num_channels == 1
+ ? AudioEncoderOpusConfig::ApplicationMode::kVoip
+ : AudioEncoderOpusConfig::ApplicationMode::kAudio;
+ config.supported_frame_lengths_ms.push_back(config.frame_size_ms);
+ states->config = config;
+
std::unique_ptr<MockSmoothingFilter> bitrate_smoother(
new MockSmoothingFilter());
states->mock_bitrate_smoother = bitrate_smoother.get();
states->encoder.reset(new AudioEncoderOpusImpl(
- states->config, codec_inst.pltype, std::move(creator),
+ states->config, kDefaultOpusPayloadType, std::move(creator),
std::move(bitrate_smoother)));
return states;
}
@@ -436,12 +432,12 @@
auto states = CreateCodec(2);
- states->encoder->OnReceivedUplinkBandwidth(kDefaultOpusSettings.rate * 2,
+ states->encoder->OnReceivedUplinkBandwidth(kDefaultOpusRate * 2,
absl::nullopt);
// Since |OnReceivedOverhead| has not been called, the codec bitrate should
// not change.
- EXPECT_EQ(kDefaultOpusSettings.rate, states->encoder->GetTargetBitrate());
+ EXPECT_EQ(kDefaultOpusRate, states->encoder->GetTargetBitrate());
}
TEST(AudioEncoderOpusTest, OverheadRemovedFromTargetAudioBitrate) {
@@ -456,7 +452,7 @@
constexpr int kTargetBitrateBps = 40000;
states->encoder->OnReceivedUplinkBandwidth(kTargetBitrateBps, absl::nullopt);
- int packet_rate = rtc::CheckedDivExact(48000, kDefaultOpusSettings.pacsize);
+ int packet_rate = rtc::CheckedDivExact(48000, kDefaultOpusPacSize);
EXPECT_EQ(kTargetBitrateBps -
8 * static_cast<int>(kOverheadBytesPerPacket) * packet_rate,
states->encoder->GetTargetBitrate());
@@ -474,7 +470,7 @@
constexpr size_t kOverheadBytesPerPacket = 64;
states->encoder->OnReceivedOverhead(kOverheadBytesPerPacket);
- int packet_rate = rtc::CheckedDivExact(48000, kDefaultOpusSettings.pacsize);
+ int packet_rate = rtc::CheckedDivExact(48000, kDefaultOpusPacSize);
// Set a target rate that is smaller than |kMinBitrateBps| when overhead is
// subtracted. The eventual codec rate should be bounded by |kMinBitrateBps|.
diff --git a/modules/audio_coding/codecs/pcm16b/audio_encoder_pcm16b.cc b/modules/audio_coding/codecs/pcm16b/audio_encoder_pcm16b.cc
index 106ab16..9445b1e 100644
--- a/modules/audio_coding/codecs/pcm16b/audio_encoder_pcm16b.cc
+++ b/modules/audio_coding/codecs/pcm16b/audio_encoder_pcm16b.cc
@@ -10,7 +10,6 @@
#include "modules/audio_coding/codecs/pcm16b/audio_encoder_pcm16b.h"
-#include "common_types.h"
#include "modules/audio_coding/codecs/pcm16b/pcm16b.h"
#include "rtc_base/checks.h"
@@ -30,20 +29,6 @@
return CodecType::kOther;
}
-namespace {
-
-AudioEncoderPcm16B::Config CreateConfig(const CodecInst& codec_inst) {
- AudioEncoderPcm16B::Config config;
- config.num_channels = codec_inst.channels;
- config.sample_rate_hz = codec_inst.plfreq;
- config.frame_size_ms = rtc::CheckedDivExact(
- codec_inst.pacsize, rtc::CheckedDivExact(config.sample_rate_hz, 1000));
- config.payload_type = codec_inst.pltype;
- return config;
-}
-
-} // namespace
-
bool AudioEncoderPcm16B::Config::IsOk() const {
if ((sample_rate_hz != 8000) && (sample_rate_hz != 16000) &&
(sample_rate_hz != 32000) && (sample_rate_hz != 48000))
@@ -51,7 +36,4 @@
return AudioEncoderPcm::Config::IsOk();
}
-AudioEncoderPcm16B::AudioEncoderPcm16B(const CodecInst& codec_inst)
- : AudioEncoderPcm16B(CreateConfig(codec_inst)) {}
-
} // namespace webrtc
diff --git a/modules/audio_coding/codecs/pcm16b/audio_encoder_pcm16b.h b/modules/audio_coding/codecs/pcm16b/audio_encoder_pcm16b.h
index d6fd6e1..6a20843 100644
--- a/modules/audio_coding/codecs/pcm16b/audio_encoder_pcm16b.h
+++ b/modules/audio_coding/codecs/pcm16b/audio_encoder_pcm16b.h
@@ -16,8 +16,6 @@
namespace webrtc {
-struct CodecInst;
-
class AudioEncoderPcm16B final : public AudioEncoderPcm {
public:
struct Config : public AudioEncoderPcm::Config {
@@ -30,7 +28,6 @@
explicit AudioEncoderPcm16B(const Config& config)
: AudioEncoderPcm(config, config.sample_rate_hz) {}
- explicit AudioEncoderPcm16B(const CodecInst& codec_inst);
protected:
size_t EncodeCall(const int16_t* audio,
diff --git a/modules/video_coding/utility/simulcast_rate_allocator_unittest.cc b/modules/video_coding/utility/simulcast_rate_allocator_unittest.cc
index bbe3f19..bcfc4a8 100644
--- a/modules/video_coding/utility/simulcast_rate_allocator_unittest.cc
+++ b/modules/video_coding/utility/simulcast_rate_allocator_unittest.cc
@@ -16,6 +16,7 @@
#include <vector>
#include "api/video_codecs/vp8_temporal_layers.h"
+#include "rtc_base/checks.h"
#include "test/field_trial.h"
#include "test/gmock.h"
#include "test/gtest.h"
diff --git a/pc/peerconnection.cc b/pc/peerconnection.cc
index 9434b0b..06fbae1 100644
--- a/pc/peerconnection.cc
+++ b/pc/peerconnection.cc
@@ -18,6 +18,7 @@
#include <vector>
#include "absl/memory/memory.h"
+#include "absl/strings/match.h"
#include "api/jsepicecandidate.h"
#include "api/jsepsessiondescription.h"
#include "api/mediastreamproxy.h"