Propagate muted parameter to VoE::Channel
Deleted the temporary ACM method without the muted parameter, and had to modify several tests for this. The muted parameter is not yet propagated to the AudioConferenceMixer; this is the next step. BUG=webrtc:5609 TBR=perkj@webrtc.org Review-Url: https://codereview.webrtc.org/1985743002 Cr-Commit-Position: refs/heads/master@{#12779}
This commit is contained in:
parent
e305d956c0
commit
d4ccb00b9e
@ -205,7 +205,9 @@ class AudioCodingModuleTestOldApi : public ::testing::Test {
|
||||
|
||||
virtual void PullAudio() {
|
||||
AudioFrame audio_frame;
|
||||
ASSERT_EQ(0, acm_->PlayoutData10Ms(-1, &audio_frame));
|
||||
bool muted;
|
||||
ASSERT_EQ(0, acm_->PlayoutData10Ms(-1, &audio_frame, &muted));
|
||||
ASSERT_FALSE(muted);
|
||||
}
|
||||
|
||||
virtual void InsertAudio() {
|
||||
@ -296,7 +298,9 @@ TEST_F(AudioCodingModuleTestOldApi, MAYBE_NetEqCalls) {
|
||||
TEST_F(AudioCodingModuleTestOldApi, VerifyOutputFrame) {
|
||||
AudioFrame audio_frame;
|
||||
const int kSampleRateHz = 32000;
|
||||
EXPECT_EQ(0, acm_->PlayoutData10Ms(kSampleRateHz, &audio_frame));
|
||||
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);
|
||||
@ -307,7 +311,8 @@ TEST_F(AudioCodingModuleTestOldApi, VerifyOutputFrame) {
|
||||
|
||||
TEST_F(AudioCodingModuleTestOldApi, FailOnZeroDesiredFrequency) {
|
||||
AudioFrame audio_frame;
|
||||
EXPECT_EQ(-1, acm_->PlayoutData10Ms(0, &audio_frame));
|
||||
bool muted;
|
||||
EXPECT_EQ(-1, acm_->PlayoutData10Ms(0, &audio_frame, &muted));
|
||||
}
|
||||
|
||||
// Checks that the transport callback is invoked once for each speech packet.
|
||||
@ -806,8 +811,13 @@ class AcmReRegisterIsacMtTestOldApi : public AudioCodingModuleTestOldApi {
|
||||
// Pull audio.
|
||||
for (int i = 0; i < rtc::CheckedDivExact(kPacketSizeMs, 10); ++i) {
|
||||
AudioFrame audio_frame;
|
||||
bool muted;
|
||||
EXPECT_EQ(0, acm_->PlayoutData10Ms(-1 /* default output frequency */,
|
||||
&audio_frame));
|
||||
&audio_frame, &muted));
|
||||
if (muted) {
|
||||
ADD_FAILURE();
|
||||
return false;
|
||||
}
|
||||
fake_clock_->AdvanceTimeMilliseconds(10);
|
||||
}
|
||||
rtp_utility_->Forward(&rtp_header_);
|
||||
|
||||
@ -323,7 +323,8 @@ bool APITest::APIThreadB(void* obj) {
|
||||
bool APITest::PullAudioRunA() {
|
||||
_pullEventA->Wait(100);
|
||||
AudioFrame audioFrame;
|
||||
if (_acmA->PlayoutData10Ms(_outFreqHzA, &audioFrame) < 0) {
|
||||
bool muted;
|
||||
if (_acmA->PlayoutData10Ms(_outFreqHzA, &audioFrame, &muted) < 0) {
|
||||
bool thereIsDecoder;
|
||||
{
|
||||
ReadLockScoped rl(_apiTestRWLock);
|
||||
@ -343,7 +344,8 @@ bool APITest::PullAudioRunA() {
|
||||
bool APITest::PullAudioRunB() {
|
||||
_pullEventB->Wait(100);
|
||||
AudioFrame audioFrame;
|
||||
if (_acmB->PlayoutData10Ms(_outFreqHzB, &audioFrame) < 0) {
|
||||
bool muted;
|
||||
if (_acmB->PlayoutData10Ms(_outFreqHzB, &audioFrame, &muted) < 0) {
|
||||
bool thereIsDecoder;
|
||||
{
|
||||
ReadLockScoped rl(_apiTestRWLock);
|
||||
|
||||
@ -208,8 +208,12 @@ bool Receiver::IncomingPacket() {
|
||||
|
||||
bool Receiver::PlayoutData() {
|
||||
AudioFrame audioFrame;
|
||||
|
||||
int32_t ok =_acm->PlayoutData10Ms(_frequency, &audioFrame);
|
||||
bool muted;
|
||||
int32_t ok = _acm->PlayoutData10Ms(_frequency, &audioFrame, &muted);
|
||||
if (muted) {
|
||||
ADD_FAILURE();
|
||||
return false;
|
||||
}
|
||||
EXPECT_EQ(0, ok);
|
||||
if (ok < 0){
|
||||
return false;
|
||||
|
||||
@ -452,7 +452,9 @@ void TestAllCodecs::Run(TestPack* channel) {
|
||||
}
|
||||
|
||||
// Run received side of ACM.
|
||||
CHECK_ERROR(acm_b_->PlayoutData10Ms(out_freq_hz, &audio_frame));
|
||||
bool muted;
|
||||
CHECK_ERROR(acm_b_->PlayoutData10Ms(out_freq_hz, &audio_frame, &muted));
|
||||
ASSERT_FALSE(muted);
|
||||
|
||||
// Write output speech to file.
|
||||
outfile_b_.Write10MsData(audio_frame.data_,
|
||||
|
||||
@ -461,7 +461,9 @@ void TestRedFec::Run() {
|
||||
while (!_inFileA.EndOfFile()) {
|
||||
EXPECT_GT(_inFileA.Read10MsData(audioFrame), 0);
|
||||
EXPECT_GE(_acmA->Add10MsData(audioFrame), 0);
|
||||
EXPECT_EQ(0, _acmB->PlayoutData10Ms(outFreqHzB, &audioFrame));
|
||||
bool muted;
|
||||
EXPECT_EQ(0, _acmB->PlayoutData10Ms(outFreqHzB, &audioFrame, &muted));
|
||||
ASSERT_FALSE(muted);
|
||||
_outFileB.Write10MsData(audioFrame.data_, audioFrame.samples_per_channel_);
|
||||
}
|
||||
_inFileA.Rewind();
|
||||
|
||||
@ -792,7 +792,9 @@ void TestStereo::Run(TestPackStereo* channel, int in_channels, int out_channels,
|
||||
}
|
||||
|
||||
// Run received side of ACM
|
||||
EXPECT_EQ(0, acm_b_->PlayoutData10Ms(out_freq_hz_b, &audio_frame));
|
||||
bool muted;
|
||||
EXPECT_EQ(0, acm_b_->PlayoutData10Ms(out_freq_hz_b, &audio_frame, &muted));
|
||||
ASSERT_FALSE(muted);
|
||||
|
||||
// Write output speech to file
|
||||
out_file_.Write10MsData(
|
||||
|
||||
@ -108,7 +108,9 @@ void TestVadDtx::Run(std::string in_filename, int frequency, int channels,
|
||||
audio_frame.timestamp_ = time_stamp;
|
||||
time_stamp += frame_size_samples;
|
||||
EXPECT_GE(acm_send_->Add10MsData(audio_frame), 0);
|
||||
acm_receive_->PlayoutData10Ms(kOutputFreqHz, &audio_frame);
|
||||
bool muted;
|
||||
acm_receive_->PlayoutData10Ms(kOutputFreqHz, &audio_frame, &muted);
|
||||
ASSERT_FALSE(muted);
|
||||
out_file.Write10MsData(audio_frame);
|
||||
}
|
||||
|
||||
|
||||
@ -261,13 +261,18 @@ void TwoWayCommunication::Perform() {
|
||||
|
||||
EXPECT_GE(_acmB->Add10MsData(audioFrame), 0);
|
||||
EXPECT_GE(_acmRefB->Add10MsData(audioFrame), 0);
|
||||
EXPECT_EQ(0, _acmA->PlayoutData10Ms(outFreqHzA, &audioFrame));
|
||||
bool muted;
|
||||
EXPECT_EQ(0, _acmA->PlayoutData10Ms(outFreqHzA, &audioFrame, &muted));
|
||||
ASSERT_FALSE(muted);
|
||||
_outFileA.Write10MsData(audioFrame);
|
||||
EXPECT_EQ(0, _acmRefA->PlayoutData10Ms(outFreqHzA, &audioFrame));
|
||||
EXPECT_EQ(0, _acmRefA->PlayoutData10Ms(outFreqHzA, &audioFrame, &muted));
|
||||
ASSERT_FALSE(muted);
|
||||
_outFileRefA.Write10MsData(audioFrame);
|
||||
EXPECT_EQ(0, _acmB->PlayoutData10Ms(outFreqHzB, &audioFrame));
|
||||
EXPECT_EQ(0, _acmB->PlayoutData10Ms(outFreqHzB, &audioFrame, &muted));
|
||||
ASSERT_FALSE(muted);
|
||||
_outFileB.Write10MsData(audioFrame);
|
||||
EXPECT_EQ(0, _acmRefB->PlayoutData10Ms(outFreqHzB, &audioFrame));
|
||||
EXPECT_EQ(0, _acmRefB->PlayoutData10Ms(outFreqHzB, &audioFrame, &muted));
|
||||
ASSERT_FALSE(muted);
|
||||
_outFileRefB.Write10MsData(audioFrame);
|
||||
|
||||
// Update time counters each time a second of data has passed.
|
||||
|
||||
@ -204,7 +204,10 @@ class DelayTest {
|
||||
|
||||
in_file_a_.Read10MsData(audio_frame);
|
||||
ASSERT_GE(acm_a_->Add10MsData(audio_frame), 0);
|
||||
ASSERT_EQ(0, acm_b_->PlayoutData10Ms(out_freq_hz_b, &audio_frame));
|
||||
bool muted;
|
||||
ASSERT_EQ(0,
|
||||
acm_b_->PlayoutData10Ms(out_freq_hz_b, &audio_frame, &muted));
|
||||
RTC_DCHECK(!muted);
|
||||
out_file_b_.Write10MsData(
|
||||
audio_frame.data_,
|
||||
audio_frame.samples_per_channel_ * audio_frame.num_channels_);
|
||||
|
||||
@ -198,9 +198,12 @@ void ISACTest::Run10ms() {
|
||||
EXPECT_GT(_inFileA.Read10MsData(audioFrame), 0);
|
||||
EXPECT_GE(_acmA->Add10MsData(audioFrame), 0);
|
||||
EXPECT_GE(_acmB->Add10MsData(audioFrame), 0);
|
||||
EXPECT_EQ(0, _acmA->PlayoutData10Ms(32000, &audioFrame));
|
||||
bool muted;
|
||||
EXPECT_EQ(0, _acmA->PlayoutData10Ms(32000, &audioFrame, &muted));
|
||||
ASSERT_FALSE(muted);
|
||||
_outFileA.Write10MsData(audioFrame);
|
||||
EXPECT_EQ(0, _acmB->PlayoutData10Ms(32000, &audioFrame));
|
||||
EXPECT_EQ(0, _acmB->PlayoutData10Ms(32000, &audioFrame, &muted));
|
||||
ASSERT_FALSE(muted);
|
||||
_outFileB.Write10MsData(audioFrame);
|
||||
}
|
||||
|
||||
|
||||
@ -141,8 +141,10 @@ class InsertPacketWithTiming {
|
||||
// Is it time to pull audio?
|
||||
if (time_to_playout_audio_ms_ == 0) {
|
||||
time_to_playout_audio_ms_ = kPlayoutPeriodMs;
|
||||
bool muted;
|
||||
receive_acm_->PlayoutData10Ms(static_cast<int>(FLAGS_output_fs_hz),
|
||||
&frame_);
|
||||
&frame_, &muted);
|
||||
ASSERT_FALSE(muted);
|
||||
fwrite(frame_.data_, sizeof(frame_.data_[0]),
|
||||
frame_.samples_per_channel_ * frame_.num_channels_, pcm_out_fid_);
|
||||
*action |= kAudioPlayedOut;
|
||||
|
||||
@ -336,7 +336,10 @@ void OpusTest::Run(TestPackStereo* channel, size_t channels, int bitrate,
|
||||
}
|
||||
|
||||
// Run received side of ACM.
|
||||
ASSERT_EQ(0, acm_receiver_->PlayoutData10Ms(out_freq_hz_b, &audio_frame));
|
||||
bool muted;
|
||||
ASSERT_EQ(
|
||||
0, acm_receiver_->PlayoutData10Ms(out_freq_hz_b, &audio_frame, &muted));
|
||||
ASSERT_FALSE(muted);
|
||||
|
||||
// Write output speech to file.
|
||||
out_file_.Write10MsData(
|
||||
|
||||
@ -150,8 +150,10 @@ class TargetDelayTest : public ::testing::Test {
|
||||
// Pull audio equivalent to the amount of audio in one RTP packet.
|
||||
void Pull() {
|
||||
AudioFrame frame;
|
||||
bool muted;
|
||||
for (int k = 0; k < kNum10msPerFrame; ++k) { // Pull one frame.
|
||||
ASSERT_EQ(0, acm_->PlayoutData10Ms(-1, &frame));
|
||||
ASSERT_EQ(0, acm_->PlayoutData10Ms(-1, &frame, &muted));
|
||||
ASSERT_FALSE(muted);
|
||||
// Had to use ASSERT_TRUE, ASSERT_EQ generated error.
|
||||
ASSERT_TRUE(kSampleRateHz == frame.sample_rate_hz_);
|
||||
ASSERT_EQ(1u, frame.num_channels_);
|
||||
|
||||
@ -13,9 +13,18 @@
|
||||
#include "webrtc/modules/utility/source/coder.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace {
|
||||
AudioCodingModule::Config GetAcmConfig(uint32_t id) {
|
||||
AudioCodingModule::Config config;
|
||||
// This class does not handle muted output.
|
||||
config.neteq_config.enable_muted_state = false;
|
||||
config.id = id;
|
||||
return config;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
AudioCoder::AudioCoder(uint32_t instance_id)
|
||||
: acm_(AudioCodingModule::Create(instance_id)),
|
||||
: acm_(AudioCodingModule::Create(GetAcmConfig(instance_id))),
|
||||
receive_codec_(),
|
||||
encode_timestamp_(0),
|
||||
encoded_data_(nullptr),
|
||||
@ -54,12 +63,19 @@ int32_t AudioCoder::Decode(AudioFrame& decoded_audio,
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return acm_->PlayoutData10Ms((uint16_t)samp_freq_hz, &decoded_audio);
|
||||
bool muted;
|
||||
int32_t ret =
|
||||
acm_->PlayoutData10Ms((uint16_t)samp_freq_hz, &decoded_audio, &muted);
|
||||
RTC_DCHECK(!muted);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t AudioCoder::PlayoutData(AudioFrame& decoded_audio,
|
||||
uint16_t& samp_freq_hz) {
|
||||
return acm_->PlayoutData10Ms(samp_freq_hz, &decoded_audio);
|
||||
bool muted;
|
||||
int32_t ret = acm_->PlayoutData10Ms(samp_freq_hz, &decoded_audio, &muted);
|
||||
RTC_DCHECK(!muted);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t AudioCoder::Encode(const AudioFrame& audio,
|
||||
|
||||
@ -483,8 +483,9 @@ int32_t Channel::GetAudioFrame(int32_t id, AudioFrame* audioFrame) {
|
||||
event_log_->LogAudioPlayout(ssrc);
|
||||
}
|
||||
// Get 10ms raw PCM data from the ACM (mixer limits output frequency)
|
||||
if (audio_coding_->PlayoutData10Ms(audioFrame->sample_rate_hz_, audioFrame) ==
|
||||
-1) {
|
||||
bool muted;
|
||||
if (audio_coding_->PlayoutData10Ms(audioFrame->sample_rate_hz_, audioFrame,
|
||||
&muted) == -1) {
|
||||
WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, _channelId),
|
||||
"Channel::GetAudioFrame() PlayoutData10Ms() failed!");
|
||||
// In all likelihood, the audio in this frame is garbage. We return an
|
||||
@ -493,6 +494,7 @@ int32_t Channel::GetAudioFrame(int32_t id, AudioFrame* audioFrame) {
|
||||
// irrelevant.
|
||||
return -1;
|
||||
}
|
||||
RTC_DCHECK(!muted);
|
||||
|
||||
if (_RxVadDetection) {
|
||||
UpdateRxVadDetection(*audioFrame);
|
||||
@ -811,6 +813,7 @@ Channel::Channel(int32_t channelId,
|
||||
}
|
||||
acm_config.neteq_config.enable_fast_accelerate =
|
||||
config.Get<NetEqFastAccelerate>().enabled;
|
||||
acm_config.neteq_config.enable_muted_state = false;
|
||||
audio_coding_.reset(AudioCodingModule::Create(acm_config));
|
||||
|
||||
_outputAudioLevel.Clear();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user