Revert of Remove various IDs (patchset #7 id:120001 of https://codereview.webrtc.org/3019543002/ )
Reason for revert:
Breaks downstream
Original issue's description:
> Remove various IDs:
>
> - AudioFrame
> - AudioCodingModule
>
> BUG=webrtc:4690
> TBR=kwiberg@webrtc.org
>
> Review-Url: https://codereview.webrtc.org/3019543002
> Cr-Commit-Position: refs/heads/master@{#20005}
> Committed: https://webrtc.googlesource.com/src/+/2d0f77585d556d8b11d6269d35149ae9ca14c472
TBR=henrik.lundin@webrtc.org,kwiberg@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:4690
Review-Url: https://codereview.webrtc.org/3014683002
Cr-Commit-Position: refs/heads/master@{#20008}
diff --git a/modules/audio_coding/acm2/acm_receive_test.cc b/modules/audio_coding/acm2/acm_receive_test.cc
index 082506a..6cfe464 100644
--- a/modules/audio_coding/acm2/acm_receive_test.cc
+++ b/modules/audio_coding/acm2/acm_receive_test.cc
@@ -110,6 +110,7 @@
Clock* clock,
rtc::scoped_refptr<AudioDecoderFactory> decoder_factory) {
AudioCodingModule::Config config;
+ config.id = 0;
config.clock = clock;
config.decoder_factory = std::move(decoder_factory);
return config;
diff --git a/modules/audio_coding/acm2/acm_send_test.cc b/modules/audio_coding/acm2/acm_send_test.cc
index 307c906..d5f196b 100644
--- a/modules/audio_coding/acm2/acm_send_test.cc
+++ b/modules/audio_coding/acm2/acm_send_test.cc
@@ -28,7 +28,7 @@
int source_rate_hz,
int test_duration_ms)
: clock_(0),
- acm_(webrtc::AudioCodingModule::Create(&clock_)),
+ acm_(webrtc::AudioCodingModule::Create(0, &clock_)),
audio_source_(audio_source),
source_rate_hz_(source_rate_hz),
input_block_size_samples_(
diff --git a/modules/audio_coding/acm2/audio_coding_module.cc b/modules/audio_coding/acm2/audio_coding_module.cc
index c48fbef..5997d12 100644
--- a/modules/audio_coding/acm2/audio_coding_module.cc
+++ b/modules/audio_coding/acm2/audio_coding_module.cc
@@ -269,6 +269,7 @@
rtc::CriticalSection acm_crit_sect_;
rtc::Buffer encode_buffer_ RTC_GUARDED_BY(acm_crit_sect_);
+ int id_; // TODO(henrik.lundin) Make const.
uint32_t expected_codec_ts_ RTC_GUARDED_BY(acm_crit_sect_);
uint32_t expected_in_ts_ RTC_GUARDED_BY(acm_crit_sect_);
acm2::ACMResampler resampler_ RTC_GUARDED_BY(acm_crit_sect_);
@@ -455,7 +456,8 @@
AudioCodingModuleImpl::AudioCodingModuleImpl(
const AudioCodingModule::Config& config)
- : expected_codec_ts_(0xD87F3F9F),
+ : id_(config.id),
+ expected_codec_ts_(0xD87F3F9F),
expected_in_ts_(0xD87F3F9F),
receiver_(config),
bitrate_logger_("WebRTC.Audio.TargetBitrateInKbps"),
@@ -1118,6 +1120,7 @@
LOG(LS_ERROR) << "PlayoutData failed, RecOut Failed";
return -1;
}
+ audio_frame->id_ = id_;
return 0;
}
@@ -1283,7 +1286,7 @@
} // namespace
AudioCodingModule::Config::Config()
- : neteq_config(), clock(Clock::GetRealTimeClock()) {
+ : id(0), neteq_config(), clock(Clock::GetRealTimeClock()) {
// Post-decode VAD is disabled by default in NetEq, however, Audio
// Conference Mixer relies on VAD decisions and fails without them.
neteq_config.enable_post_decode_vad = true;
@@ -1293,15 +1296,17 @@
AudioCodingModule::Config::~Config() = default;
// Create module
-AudioCodingModule* AudioCodingModule::Create() {
+AudioCodingModule* AudioCodingModule::Create(int id) {
Config config;
+ config.id = id;
config.clock = Clock::GetRealTimeClock();
config.decoder_factory = CreateBuiltinAudioDecoderFactory();
return Create(config);
}
-AudioCodingModule* AudioCodingModule::Create(Clock* clock) {
+AudioCodingModule* AudioCodingModule::Create(int id, Clock* clock) {
Config config;
+ config.id = id;
config.clock = clock;
config.decoder_factory = CreateBuiltinAudioDecoderFactory();
return Create(config);
diff --git a/modules/audio_coding/acm2/audio_coding_module_unittest.cc b/modules/audio_coding/acm2/audio_coding_module_unittest.cc
index a010619..80fc4d8 100644
--- a/modules/audio_coding/acm2/audio_coding_module_unittest.cc
+++ b/modules/audio_coding/acm2/audio_coding_module_unittest.cc
@@ -157,7 +157,8 @@
class AudioCodingModuleTestOldApi : public ::testing::Test {
protected:
AudioCodingModuleTestOldApi()
- : rtp_utility_(new RtpUtility(kFrameSizeSamples, kPayloadType)),
+ : id_(1),
+ rtp_utility_(new RtpUtility(kFrameSizeSamples, kPayloadType)),
clock_(Clock::GetRealTimeClock()) {}
~AudioCodingModuleTestOldApi() {}
@@ -165,7 +166,7 @@
void TearDown() {}
void SetUp() {
- acm_.reset(AudioCodingModule::Create(clock_));
+ acm_.reset(AudioCodingModule::Create(id_, clock_));
rtp_utility_->Populate(&rtp_header_);
@@ -229,6 +230,7 @@
VerifyEncoding();
}
+ const int id_;
std::unique_ptr<RtpUtility> rtp_utility_;
std::unique_ptr<AudioCodingModule> acm_;
PacketizationCallbackStubOldApi packet_cb_;
@@ -312,6 +314,7 @@
bool muted;
EXPECT_EQ(0, acm_->PlayoutData10Ms(kSampleRateHz, &audio_frame, &muted));
ASSERT_FALSE(muted);
+ EXPECT_EQ(id_, audio_frame.id_);
EXPECT_EQ(0u, audio_frame.timestamp_);
EXPECT_GT(audio_frame.num_channels_, 0u);
EXPECT_EQ(static_cast<size_t>(kSampleRateHz / 100),
diff --git a/modules/audio_coding/include/audio_coding_module.h b/modules/audio_coding/include/audio_coding_module.h
index 63af3ab..944ad60 100644
--- a/modules/audio_coding/include/audio_coding_module.h
+++ b/modules/audio_coding/include/audio_coding_module.h
@@ -70,6 +70,7 @@
Config(const Config&);
~Config();
+ int id;
NetEq::Config neteq_config;
Clock* clock;
rtc::scoped_refptr<AudioDecoderFactory> decoder_factory;
@@ -82,8 +83,8 @@
// injected into ACM. ACM will take the ownership of the object clock and
// delete it when destroyed.
//
- static AudioCodingModule* Create();
- static AudioCodingModule* Create(Clock* clock);
+ static AudioCodingModule* Create(int id);
+ static AudioCodingModule* Create(int id, Clock* clock);
static AudioCodingModule* Create(const Config& config);
virtual ~AudioCodingModule() = default;
diff --git a/modules/audio_coding/test/APITest.cc b/modules/audio_coding/test/APITest.cc
index b29e84e..5418342 100644
--- a/modules/audio_coding/test/APITest.cc
+++ b/modules/audio_coding/test/APITest.cc
@@ -48,8 +48,8 @@
}
APITest::APITest()
- : _acmA(AudioCodingModule::Create()),
- _acmB(AudioCodingModule::Create()),
+ : _acmA(AudioCodingModule::Create(1)),
+ _acmB(AudioCodingModule::Create(2)),
_channel_A2B(NULL),
_channel_B2A(NULL),
_writeToFile(true),
diff --git a/modules/audio_coding/test/EncodeDecodeTest.cc b/modules/audio_coding/test/EncodeDecodeTest.cc
index 2b6b4ac..8257ed9 100644
--- a/modules/audio_coding/test/EncodeDecodeTest.cc
+++ b/modules/audio_coding/test/EncodeDecodeTest.cc
@@ -281,7 +281,7 @@
codePars[1] = 0;
codePars[2] = 0;
- std::unique_ptr<AudioCodingModule> acm(AudioCodingModule::Create());
+ std::unique_ptr<AudioCodingModule> acm(AudioCodingModule::Create(0));
struct CodecInst sendCodecTmp;
numCodecs = acm->NumberOfCodecs();
@@ -337,7 +337,7 @@
int codeId,
int* codePars,
int testMode) {
- std::unique_ptr<AudioCodingModule> acm(AudioCodingModule::Create());
+ std::unique_ptr<AudioCodingModule> acm(AudioCodingModule::Create(1));
RTPFile rtpFile;
std::string fileName = webrtc::test::TempFilename(webrtc::test::OutputPath(),
"encode_decode_rtp");
diff --git a/modules/audio_coding/test/PacketLossTest.cc b/modules/audio_coding/test/PacketLossTest.cc
index a6c56fa7..c80615a 100644
--- a/modules/audio_coding/test/PacketLossTest.cc
+++ b/modules/audio_coding/test/PacketLossTest.cc
@@ -127,7 +127,7 @@
#ifndef WEBRTC_CODEC_OPUS
return;
#else
- std::unique_ptr<AudioCodingModule> acm(AudioCodingModule::Create());
+ std::unique_ptr<AudioCodingModule> acm(AudioCodingModule::Create(0));
int codec_id = acm->Codec("opus", 48000, channels_);
diff --git a/modules/audio_coding/test/TestAllCodecs.cc b/modules/audio_coding/test/TestAllCodecs.cc
index ff28a28..74319c2 100644
--- a/modules/audio_coding/test/TestAllCodecs.cc
+++ b/modules/audio_coding/test/TestAllCodecs.cc
@@ -104,8 +104,8 @@
}
TestAllCodecs::TestAllCodecs(int test_mode)
- : acm_a_(AudioCodingModule::Create()),
- acm_b_(AudioCodingModule::Create()),
+ : acm_a_(AudioCodingModule::Create(0)),
+ acm_b_(AudioCodingModule::Create(1)),
channel_a_to_b_(NULL),
test_count_(0),
packet_size_samples_(0),
diff --git a/modules/audio_coding/test/TestRedFec.cc b/modules/audio_coding/test/TestRedFec.cc
index 58561c6..3e88290 100644
--- a/modules/audio_coding/test/TestRedFec.cc
+++ b/modules/audio_coding/test/TestRedFec.cc
@@ -48,8 +48,8 @@
}
TestRedFec::TestRedFec()
- : _acmA(AudioCodingModule::Create()),
- _acmB(AudioCodingModule::Create()),
+ : _acmA(AudioCodingModule::Create(0)),
+ _acmB(AudioCodingModule::Create(1)),
_channelA2B(NULL),
_testCntr(0) {
}
diff --git a/modules/audio_coding/test/TestStereo.cc b/modules/audio_coding/test/TestStereo.cc
index eca81f8..d598191 100644
--- a/modules/audio_coding/test/TestStereo.cc
+++ b/modules/audio_coding/test/TestStereo.cc
@@ -108,8 +108,8 @@
}
TestStereo::TestStereo(int test_mode)
- : acm_a_(AudioCodingModule::Create()),
- acm_b_(AudioCodingModule::Create()),
+ : acm_a_(AudioCodingModule::Create(0)),
+ acm_b_(AudioCodingModule::Create(1)),
channel_a2b_(NULL),
test_cntr_(0),
pack_size_samp_(0),
diff --git a/modules/audio_coding/test/TestVADDTX.cc b/modules/audio_coding/test/TestVADDTX.cc
index 628582d..1aa00b5 100644
--- a/modules/audio_coding/test/TestVADDTX.cc
+++ b/modules/audio_coding/test/TestVADDTX.cc
@@ -62,8 +62,8 @@
}
TestVadDtx::TestVadDtx()
- : acm_send_(AudioCodingModule::Create()),
- acm_receive_(AudioCodingModule::Create()),
+ : acm_send_(AudioCodingModule::Create(0)),
+ acm_receive_(AudioCodingModule::Create(1)),
channel_(new Channel),
monitor_(new ActivityMonitor) {
EXPECT_EQ(0, acm_send_->RegisterTransportCallback(channel_.get()));
diff --git a/modules/audio_coding/test/TwoWayCommunication.cc b/modules/audio_coding/test/TwoWayCommunication.cc
index 8049436..addb717 100644
--- a/modules/audio_coding/test/TwoWayCommunication.cc
+++ b/modules/audio_coding/test/TwoWayCommunication.cc
@@ -34,14 +34,16 @@
#define MAX_FILE_NAME_LENGTH_BYTE 500
TwoWayCommunication::TwoWayCommunication(int testMode)
- : _acmA(AudioCodingModule::Create()),
- _acmRefA(AudioCodingModule::Create()),
+ : _acmA(AudioCodingModule::Create(1)),
+ _acmRefA(AudioCodingModule::Create(3)),
_testMode(testMode) {
AudioCodingModule::Config config;
// The clicks will be more obvious in FAX mode. TODO(henrik.lundin) Really?
config.neteq_config.playout_mode = kPlayoutFax;
+ config.id = 2;
config.decoder_factory = CreateBuiltinAudioDecoderFactory();
_acmB.reset(AudioCodingModule::Create(config));
+ config.id = 4;
_acmRefB.reset(AudioCodingModule::Create(config));
}
@@ -60,7 +62,7 @@
void TwoWayCommunication::ChooseCodec(uint8_t* codecID_A,
uint8_t* codecID_B) {
- std::unique_ptr<AudioCodingModule> tmpACM(AudioCodingModule::Create());
+ std::unique_ptr<AudioCodingModule> tmpACM(AudioCodingModule::Create(0));
uint8_t noCodec = tmpACM->NumberOfCodecs();
CodecInst codecInst;
printf("List of Supported Codecs\n");
diff --git a/modules/audio_coding/test/delay_test.cc b/modules/audio_coding/test/delay_test.cc
index 407f709..3f78ea6 100644
--- a/modules/audio_coding/test/delay_test.cc
+++ b/modules/audio_coding/test/delay_test.cc
@@ -64,8 +64,8 @@
class DelayTest {
public:
DelayTest()
- : acm_a_(AudioCodingModule::Create()),
- acm_b_(AudioCodingModule::Create()),
+ : acm_a_(AudioCodingModule::Create(0)),
+ acm_b_(AudioCodingModule::Create(1)),
channel_a2b_(new Channel),
test_cntr_(0),
encoding_sample_rate_hz_(8000) {}
diff --git a/modules/audio_coding/test/iSACTest.cc b/modules/audio_coding/test/iSACTest.cc
index a44259f..a14f795 100644
--- a/modules/audio_coding/test/iSACTest.cc
+++ b/modules/audio_coding/test/iSACTest.cc
@@ -67,8 +67,8 @@
}
ISACTest::ISACTest(int testMode)
- : _acmA(AudioCodingModule::Create()),
- _acmB(AudioCodingModule::Create()),
+ : _acmA(AudioCodingModule::Create(1)),
+ _acmB(AudioCodingModule::Create(2)),
_testMode(testMode) {}
ISACTest::~ISACTest() {}
diff --git a/modules/audio_coding/test/insert_packet_with_timing.cc b/modules/audio_coding/test/insert_packet_with_timing.cc
index 2c0e54b..500375c 100644
--- a/modules/audio_coding/test/insert_packet_with_timing.cc
+++ b/modules/audio_coding/test/insert_packet_with_timing.cc
@@ -61,8 +61,8 @@
InsertPacketWithTiming()
: sender_clock_(new SimulatedClock(0)),
receiver_clock_(new SimulatedClock(0)),
- send_acm_(AudioCodingModule::Create(sender_clock_)),
- receive_acm_(AudioCodingModule::Create(receiver_clock_)),
+ send_acm_(AudioCodingModule::Create(0, sender_clock_)),
+ receive_acm_(AudioCodingModule::Create(0, receiver_clock_)),
channel_(new Channel),
seq_num_fid_(fopen(FLAG_seq_num, "rt")),
send_ts_fid_(fopen(FLAG_send_ts, "rt")),
diff --git a/modules/audio_coding/test/opus_test.cc b/modules/audio_coding/test/opus_test.cc
index b7acc0f..7b54668 100644
--- a/modules/audio_coding/test/opus_test.cc
+++ b/modules/audio_coding/test/opus_test.cc
@@ -27,7 +27,7 @@
namespace webrtc {
OpusTest::OpusTest()
- : acm_receiver_(AudioCodingModule::Create()),
+ : acm_receiver_(AudioCodingModule::Create(0)),
channel_a2b_(NULL),
counter_(0),
payload_type_(255),
diff --git a/modules/audio_coding/test/target_delay_unittest.cc b/modules/audio_coding/test/target_delay_unittest.cc
index 03135da..2a75706 100644
--- a/modules/audio_coding/test/target_delay_unittest.cc
+++ b/modules/audio_coding/test/target_delay_unittest.cc
@@ -22,7 +22,7 @@
class TargetDelayTest : public ::testing::Test {
protected:
- TargetDelayTest() : acm_(AudioCodingModule::Create()) {}
+ TargetDelayTest() : acm_(AudioCodingModule::Create(0)) {}
~TargetDelayTest() {}
diff --git a/modules/audio_mixer/audio_mixer_impl_unittest.cc b/modules/audio_mixer/audio_mixer_impl_unittest.cc
index 4461e6e..678f625 100644
--- a/modules/audio_mixer/audio_mixer_impl_unittest.cc
+++ b/modules/audio_mixer/audio_mixer_impl_unittest.cc
@@ -35,10 +35,12 @@
namespace {
constexpr int kDefaultSampleRateHz = 48000;
+constexpr int kId = 1;
// Utility function that resets the frame member variables with
// sensible defaults.
void ResetFrame(AudioFrame* frame) {
+ frame->id_ = kId;
frame->sample_rate_hz_ = kDefaultSampleRateHz;
frame->num_channels_ = 1;
diff --git a/modules/audio_mixer/frame_combiner.cc b/modules/audio_mixer/frame_combiner.cc
index 8000904..9e9bcfa 100644
--- a/modules/audio_mixer/frame_combiner.cc
+++ b/modules/audio_mixer/frame_combiner.cc
@@ -193,7 +193,7 @@
// value '0', because it is only supported in the one channel case and
// is then updated in the helper functions.
audio_frame_for_mixing->UpdateFrame(
- 0, nullptr, samples_per_channel, sample_rate, AudioFrame::kUndefined,
+ -1, 0, nullptr, samples_per_channel, sample_rate, AudioFrame::kUndefined,
AudioFrame::kVadUnknown, number_of_channels);
const bool use_limiter_this_round = use_apm_limiter_ && number_of_streams > 1;
diff --git a/modules/audio_mixer/frame_combiner_unittest.cc b/modules/audio_mixer/frame_combiner_unittest.cc
index 490e99e..5681436 100644
--- a/modules/audio_mixer/frame_combiner_unittest.cc
+++ b/modules/audio_mixer/frame_combiner_unittest.cc
@@ -53,7 +53,8 @@
void SetUpFrames(int sample_rate_hz, int number_of_channels) {
for (auto* frame : {&frame1, &frame2}) {
- frame->UpdateFrame(0, nullptr, rtc::CheckedDivExact(sample_rate_hz, 100),
+ frame->UpdateFrame(-1, 0, nullptr,
+ rtc::CheckedDivExact(sample_rate_hz, 100),
sample_rate_hz, AudioFrame::kNormalSpeech,
AudioFrame::kVadActive, number_of_channels);
}
diff --git a/modules/include/module_common_types.h b/modules/include/module_common_types.h
index c3ad993..bc5c347 100644
--- a/modules/include/module_common_types.h
+++ b/modules/include/module_common_types.h
@@ -330,18 +330,7 @@
// ResetWithoutMuting() to skip this wasteful zeroing.
void ResetWithoutMuting();
- // TODO(solenberg): Remove once downstream users of AudioFrame have updated.
- RTC_DEPRECATED
- void UpdateFrame(int id, uint32_t timestamp, const int16_t* data,
- size_t samples_per_channel, int sample_rate_hz,
- SpeechType speech_type, VADActivity vad_activity,
- size_t num_channels = 1) {
- RTC_UNUSED(id);
- UpdateFrame(timestamp, data, samples_per_channel, sample_rate_hz,
- speech_type, vad_activity, num_channels);
- }
-
- void UpdateFrame(uint32_t timestamp, const int16_t* data,
+ void UpdateFrame(int id, uint32_t timestamp, const int16_t* data,
size_t samples_per_channel, int sample_rate_hz,
SpeechType speech_type, VADActivity vad_activity,
size_t num_channels = 1);
@@ -377,6 +366,7 @@
RTC_DEPRECATED AudioFrame& operator>>=(const int rhs);
RTC_DEPRECATED AudioFrame& operator+=(const AudioFrame& rhs);
+ int id_;
// RTP timestamp of the first sample in the AudioFrame.
uint32_t timestamp_ = 0;
// Time since the first frame in milliseconds.
@@ -424,6 +414,7 @@
}
inline void AudioFrame::ResetWithoutMuting() {
+ id_ = -1;
// TODO(wu): Zero is a valid value for |timestamp_|. We should initialize
// to an invalid value, or add a new member to indicate invalidity.
timestamp_ = 0;
@@ -437,13 +428,15 @@
profile_timestamp_ms_ = 0;
}
-inline void AudioFrame::UpdateFrame(uint32_t timestamp,
+inline void AudioFrame::UpdateFrame(int id,
+ uint32_t timestamp,
const int16_t* data,
size_t samples_per_channel,
int sample_rate_hz,
SpeechType speech_type,
VADActivity vad_activity,
size_t num_channels) {
+ id_ = id;
timestamp_ = timestamp;
samples_per_channel_ = samples_per_channel;
sample_rate_hz_ = sample_rate_hz;
@@ -464,6 +457,7 @@
inline void AudioFrame::CopyFrom(const AudioFrame& src) {
if (this == &src) return;
+ id_ = src.id_;
timestamp_ = src.timestamp_;
elapsed_time_ms_ = src.elapsed_time_ms_;
ntp_time_ms_ = src.ntp_time_ms_;
diff --git a/modules/module_common_types_unittest.cc b/modules/module_common_types_unittest.cc
index c8bb5f9..f601a59 100644
--- a/modules/module_common_types_unittest.cc
+++ b/modules/module_common_types_unittest.cc
@@ -28,6 +28,7 @@
return true;
}
+constexpr int kId = 16;
constexpr uint32_t kTimestamp = 27;
constexpr int kSampleRateHz = 16000;
constexpr size_t kNumChannels = 1;
@@ -63,9 +64,10 @@
TEST(AudioFrameTest, UpdateFrame) {
AudioFrame frame;
int16_t samples[kNumChannels * kSamplesPerChannel] = {17};
- frame.UpdateFrame(kTimestamp, samples, kSamplesPerChannel, kSampleRateHz,
+ frame.UpdateFrame(kId, kTimestamp, samples, kSamplesPerChannel, kSampleRateHz,
AudioFrame::kPLC, AudioFrame::kVadActive, kNumChannels);
+ EXPECT_EQ(kId, frame.id_);
EXPECT_EQ(kTimestamp, frame.timestamp_);
EXPECT_EQ(kSamplesPerChannel, frame.samples_per_channel_);
EXPECT_EQ(kSampleRateHz, frame.sample_rate_hz_);
@@ -76,7 +78,7 @@
EXPECT_FALSE(frame.muted());
EXPECT_EQ(0, memcmp(samples, frame.data(), sizeof(samples)));
- frame.UpdateFrame(kTimestamp, nullptr /* data*/, kSamplesPerChannel,
+ frame.UpdateFrame(kId, kTimestamp, nullptr /* data*/, kSamplesPerChannel,
kSampleRateHz, AudioFrame::kPLC, AudioFrame::kVadActive,
kNumChannels);
EXPECT_TRUE(frame.muted());
@@ -88,11 +90,12 @@
AudioFrame frame2;
int16_t samples[kNumChannels * kSamplesPerChannel] = {17};
- frame2.UpdateFrame(kTimestamp, samples, kSamplesPerChannel,
+ frame2.UpdateFrame(kId, kTimestamp, samples, kSamplesPerChannel,
kSampleRateHz, AudioFrame::kPLC, AudioFrame::kVadActive,
kNumChannels);
frame1.CopyFrom(frame2);
+ EXPECT_EQ(frame2.id_, frame1.id_);
EXPECT_EQ(frame2.timestamp_, frame1.timestamp_);
EXPECT_EQ(frame2.samples_per_channel_, frame1.samples_per_channel_);
EXPECT_EQ(frame2.sample_rate_hz_, frame1.sample_rate_hz_);
@@ -103,7 +106,7 @@
EXPECT_EQ(frame2.muted(), frame1.muted());
EXPECT_EQ(0, memcmp(frame2.data(), frame1.data(), sizeof(samples)));
- frame2.UpdateFrame(kTimestamp, nullptr /* data */, kSamplesPerChannel,
+ frame2.UpdateFrame(kId, kTimestamp, nullptr /* data */, kSamplesPerChannel,
kSampleRateHz, AudioFrame::kPLC, AudioFrame::kVadActive,
kNumChannels);
frame1.CopyFrom(frame2);
diff --git a/voice_engine/channel.cc b/voice_engine/channel.cc
index 875454a..4dff3de 100644
--- a/voice_engine/channel.cc
+++ b/voice_engine/channel.cc
@@ -646,6 +646,8 @@
AudioFrameOperations::Mute(audio_frame);
}
+ // Convert module ID to internal VoE channel ID
+ audio_frame->id_ = VoEChannelId(audio_frame->id_);
// Store speech type for dead-or-alive detection
_outputSpeechType = audio_frame->speech_type_;
@@ -794,6 +796,7 @@
WEBRTC_TRACE(kTraceMemory, kTraceVoice, VoEId(_instanceId, _channelId),
"Channel::Channel() - ctor");
AudioCodingModule::Config acm_config(config.acm_config);
+ acm_config.id = VoEModuleId(instanceId, channelId);
acm_config.neteq_config.enable_muted_state = true;
audio_coding_.reset(AudioCodingModule::Create(acm_config));
@@ -1639,6 +1642,7 @@
// TODO(henrika): try to avoid copying by moving ownership of audio frame
// either into pool of frames or into the task itself.
audio_frame->CopyFrom(audio_input);
+ audio_frame->id_ = ChannelId();
encoder_queue_->PostTask(std::unique_ptr<rtc::QueuedTask>(
new ProcessAndEncodeAudioTask(std::move(audio_frame), this)));
}
@@ -1655,6 +1659,7 @@
CodecInst codec;
const int result = GetSendCodec(codec);
std::unique_ptr<AudioFrame> audio_frame(new AudioFrame());
+ audio_frame->id_ = ChannelId();
// TODO(ossu): Investigate how this could happen. b/62909493
if (result == 0) {
audio_frame->sample_rate_hz_ = std::min(codec.plfreq, sample_rate);
@@ -1675,6 +1680,7 @@
RTC_DCHECK_RUN_ON(encoder_queue_);
RTC_DCHECK_GT(audio_input->samples_per_channel_, 0);
RTC_DCHECK_LE(audio_input->num_channels_, 2);
+ RTC_DCHECK_EQ(audio_input->id_, ChannelId());
bool is_muted = InputMute();
AudioFrameOperations::Mute(audio_input, previous_frame_muted_, is_muted);
diff --git a/voice_engine/voice_engine_defines.h b/voice_engine/voice_engine_defines.h
index 4397662..bc5eb1b 100644
--- a/voice_engine/voice_engine_defines.h
+++ b/voice_engine/voice_engine_defines.h
@@ -16,13 +16,23 @@
#ifndef VOICE_ENGINE_VOICE_ENGINE_DEFINES_H_
#define VOICE_ENGINE_VOICE_ENGINE_DEFINES_H_
+#include "common_types.h" // NOLINT(build/include)
#include "modules/audio_processing/include/audio_processing.h"
+#include "typedefs.h" // NOLINT(build/include)
namespace webrtc {
// VolumeControl
enum { kMinVolumeLevel = 0 };
enum { kMaxVolumeLevel = 255 };
+// Min scale factor for per-channel volume scaling
+const float kMinOutputVolumeScaling = 0.0f;
+// Max scale factor for per-channel volume scaling
+const float kMaxOutputVolumeScaling = 10.0f;
+// Min scale factor for output volume panning
+const float kMinOutputVolumePanning = 0.0f;
+// Max scale factor for output volume panning
+const float kMaxOutputVolumePanning = 1.0f;
// Audio processing
const NoiseSuppression::Level kDefaultNsMode = NoiseSuppression::kModerate;
@@ -38,6 +48,7 @@
#else
true;
#endif
+const GainControl::Mode kDefaultRxAgcMode = GainControl::kAdaptiveDigital;
// VideoSync
// Lowest minimum playout delay
@@ -57,6 +68,15 @@
return (int)((veId << 16) + chId);
}
+inline int VoEModuleId(int veId, int chId) {
+ return (int)((veId << 16) + chId);
+}
+
+// Convert module ID to internal VoE channel ID
+inline int VoEChannelId(int moduleId) {
+ return (int)(moduleId & 0xffff);
+}
+
} // namespace webrtc
#if defined(_WIN32)