Remove all use of AcmReceiver from WebRTC
The class itself and its unit test remains, for now, but will be removed later. Bug: webrtc:14867 Change-Id: I36cec8fca7913663f63c53622ed2760e5e048c2f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/362580 Reviewed-by: Jakob Ivarsson <jakobi@webrtc.org> Cr-Commit-Position: refs/heads/main@{#43023}
This commit is contained in:
parent
6e312e51d7
commit
8487d3248b
@ -64,8 +64,10 @@ rtc_library("audio_ingress") {
|
|||||||
"../../api/audio:audio_mixer_api",
|
"../../api/audio:audio_mixer_api",
|
||||||
"../../api/audio_codecs:audio_codecs_api",
|
"../../api/audio_codecs:audio_codecs_api",
|
||||||
"../../api/environment",
|
"../../api/environment",
|
||||||
|
"../../api/neteq:neteq_api",
|
||||||
"../../api/voip:voip_api",
|
"../../api/voip:voip_api",
|
||||||
"../../modules/audio_coding",
|
"../../modules/audio_coding",
|
||||||
|
"../../modules/audio_coding:default_neteq_factory",
|
||||||
"../../modules/rtp_rtcp",
|
"../../modules/rtp_rtcp",
|
||||||
"../../modules/rtp_rtcp:rtp_rtcp_format",
|
"../../modules/rtp_rtcp:rtp_rtcp_format",
|
||||||
"../../rtc_base:criticalsection",
|
"../../rtc_base:criticalsection",
|
||||||
|
|||||||
@ -18,6 +18,7 @@
|
|||||||
#include "api/audio_codecs/audio_format.h"
|
#include "api/audio_codecs/audio_format.h"
|
||||||
#include "audio/utility/audio_frame_operations.h"
|
#include "audio/utility/audio_frame_operations.h"
|
||||||
#include "modules/audio_coding/include/audio_coding_module.h"
|
#include "modules/audio_coding/include/audio_coding_module.h"
|
||||||
|
#include "modules/audio_coding/neteq/default_neteq_factory.h"
|
||||||
#include "modules/rtp_rtcp/source/byte_io.h"
|
#include "modules/rtp_rtcp/source/byte_io.h"
|
||||||
#include "modules/rtp_rtcp/source/rtcp_packet/common_header.h"
|
#include "modules/rtp_rtcp/source/rtcp_packet/common_header.h"
|
||||||
#include "modules/rtp_rtcp/source/rtcp_packet/receiver_report.h"
|
#include "modules/rtp_rtcp/source/rtcp_packet/receiver_report.h"
|
||||||
@ -30,12 +31,10 @@ namespace webrtc {
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
acm2::AcmReceiver::Config CreateAcmConfig(
|
NetEq::Config CreateNetEqConfig() {
|
||||||
rtc::scoped_refptr<AudioDecoderFactory> decoder_factory) {
|
NetEq::Config config;
|
||||||
acm2::AcmReceiver::Config acm_config;
|
config.enable_muted_state = true;
|
||||||
acm_config.neteq_config.enable_muted_state = true;
|
return config;
|
||||||
acm_config.decoder_factory = decoder_factory;
|
|
||||||
return acm_config;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
@ -51,7 +50,9 @@ AudioIngress::AudioIngress(
|
|||||||
first_rtp_timestamp_(-1),
|
first_rtp_timestamp_(-1),
|
||||||
rtp_receive_statistics_(receive_statistics),
|
rtp_receive_statistics_(receive_statistics),
|
||||||
rtp_rtcp_(rtp_rtcp),
|
rtp_rtcp_(rtp_rtcp),
|
||||||
acm_receiver_(env_, CreateAcmConfig(decoder_factory)),
|
neteq_(DefaultNetEqFactory().Create(env,
|
||||||
|
CreateNetEqConfig(),
|
||||||
|
decoder_factory)),
|
||||||
ntp_estimator_(&env_.clock()) {}
|
ntp_estimator_(&env_.clock()) {}
|
||||||
|
|
||||||
AudioIngress::~AudioIngress() = default;
|
AudioIngress::~AudioIngress() = default;
|
||||||
@ -63,13 +64,17 @@ AudioMixer::Source::AudioFrameInfo AudioIngress::GetAudioFrameWithInfo(
|
|||||||
|
|
||||||
// Get 10ms raw PCM data from the ACM.
|
// Get 10ms raw PCM data from the ACM.
|
||||||
bool muted = false;
|
bool muted = false;
|
||||||
if (acm_receiver_.GetAudio(sampling_rate, audio_frame, &muted) == -1) {
|
{
|
||||||
RTC_DLOG(LS_ERROR) << "GetAudio() failed!";
|
MutexLock lock(&lock_);
|
||||||
// In all likelihood, the audio in this frame is garbage. We return an
|
if ((neteq_->GetAudio(audio_frame, &muted) != NetEq::kOK) ||
|
||||||
// error so that the audio mixer module doesn't add it to the mix. As
|
!resampler_helper_.MaybeResample(sampling_rate, audio_frame)) {
|
||||||
// a result, it won't be played out and the actions skipped here are
|
RTC_DLOG(LS_ERROR) << "GetAudio() failed!";
|
||||||
// irrelevant.
|
// In all likelihood, the audio in this frame is garbage. We return an
|
||||||
return AudioMixer::Source::AudioFrameInfo::kError;
|
// error so that the audio mixer module doesn't add it to the mix. As
|
||||||
|
// a result, it won't be played out and the actions skipped here are
|
||||||
|
// irrelevant.
|
||||||
|
return AudioMixer::Source::AudioFrameInfo::kError;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (muted) {
|
if (muted) {
|
||||||
@ -103,10 +108,10 @@ AudioMixer::Source::AudioFrameInfo AudioIngress::GetAudioFrameWithInfo(
|
|||||||
}
|
}
|
||||||
// For clock rate, default to the playout sampling rate if we haven't
|
// For clock rate, default to the playout sampling rate if we haven't
|
||||||
// received any packets yet.
|
// received any packets yet.
|
||||||
std::optional<std::pair<int, SdpAudioFormat>> decoder =
|
std::optional<NetEq::DecoderFormat> decoder =
|
||||||
acm_receiver_.LastDecoder();
|
neteq_->GetCurrentDecoderFormat();
|
||||||
int clock_rate = decoder ? decoder->second.clockrate_hz
|
int clock_rate = decoder ? decoder->sdp_format.clockrate_hz
|
||||||
: acm_receiver_.last_output_sample_rate_hz();
|
: neteq_->last_output_sample_rate_hz();
|
||||||
RTC_DCHECK_GT(clock_rate, 0);
|
RTC_DCHECK_GT(clock_rate, 0);
|
||||||
audio_frame->elapsed_time_ms_ =
|
audio_frame->elapsed_time_ms_ =
|
||||||
(unwrap_timestamp - first_rtp_timestamp_) / (clock_rate / 1000);
|
(unwrap_timestamp - first_rtp_timestamp_) / (clock_rate / 1000);
|
||||||
@ -136,7 +141,7 @@ void AudioIngress::SetReceiveCodecs(
|
|||||||
receive_codec_info_[kv.first] = kv.second.clockrate_hz;
|
receive_codec_info_[kv.first] = kv.second.clockrate_hz;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
acm_receiver_.SetCodecs(codecs);
|
neteq_->SetCodecs(codecs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioIngress::ReceivedRTPPacket(rtc::ArrayView<const uint8_t> rtp_packet) {
|
void AudioIngress::ReceivedRTPPacket(rtc::ArrayView<const uint8_t> rtp_packet) {
|
||||||
@ -186,10 +191,12 @@ void AudioIngress::ReceivedRTPPacket(rtc::ArrayView<const uint8_t> rtp_packet) {
|
|||||||
auto data_view = rtc::ArrayView<const uint8_t>(payload, payload_data_length);
|
auto data_view = rtc::ArrayView<const uint8_t>(payload, payload_data_length);
|
||||||
|
|
||||||
// Push the incoming payload (parsed and ready for decoding) into the ACM.
|
// Push the incoming payload (parsed and ready for decoding) into the ACM.
|
||||||
if (acm_receiver_.InsertPacket(header, data_view,
|
if (data_view.empty()) {
|
||||||
env_.clock().CurrentTime()) != 0) {
|
neteq_->InsertEmptyPacket(header);
|
||||||
RTC_DLOG(LS_ERROR) << "AudioIngress::ReceivedRTPPacket() unable to "
|
} else if (neteq_->InsertPacket(header, data_view,
|
||||||
"push data to the ACM";
|
env_.clock().CurrentTime()) < 0) {
|
||||||
|
RTC_DLOG(LS_ERROR) << "ChannelReceive::OnReceivedPayloadData() unable to "
|
||||||
|
"insert packet into NetEq";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,16 +242,63 @@ void AudioIngress::ReceivedRTCPPacket(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NetworkStatistics AudioIngress::GetNetworkStatistics() const {
|
||||||
|
NetworkStatistics stats;
|
||||||
|
stats.currentExpandRate = 0;
|
||||||
|
stats.currentSpeechExpandRate = 0;
|
||||||
|
stats.currentPreemptiveRate = 0;
|
||||||
|
stats.currentAccelerateRate = 0;
|
||||||
|
stats.currentSecondaryDecodedRate = 0;
|
||||||
|
stats.currentSecondaryDiscardedRate = 0;
|
||||||
|
stats.meanWaitingTimeMs = -1;
|
||||||
|
stats.maxWaitingTimeMs = 1;
|
||||||
|
|
||||||
|
NetEqNetworkStatistics neteq_stat = neteq_->CurrentNetworkStatistics();
|
||||||
|
stats.currentBufferSize = neteq_stat.current_buffer_size_ms;
|
||||||
|
stats.preferredBufferSize = neteq_stat.preferred_buffer_size_ms;
|
||||||
|
stats.jitterPeaksFound = neteq_stat.jitter_peaks_found ? true : false;
|
||||||
|
|
||||||
|
NetEqLifetimeStatistics neteq_lifetime_stat = neteq_->GetLifetimeStatistics();
|
||||||
|
stats.totalSamplesReceived = neteq_lifetime_stat.total_samples_received;
|
||||||
|
stats.concealedSamples = neteq_lifetime_stat.concealed_samples;
|
||||||
|
stats.silentConcealedSamples = neteq_lifetime_stat.silent_concealed_samples;
|
||||||
|
stats.concealmentEvents = neteq_lifetime_stat.concealment_events;
|
||||||
|
stats.jitterBufferDelayMs = neteq_lifetime_stat.jitter_buffer_delay_ms;
|
||||||
|
stats.jitterBufferTargetDelayMs =
|
||||||
|
neteq_lifetime_stat.jitter_buffer_target_delay_ms;
|
||||||
|
stats.jitterBufferMinimumDelayMs =
|
||||||
|
neteq_lifetime_stat.jitter_buffer_minimum_delay_ms;
|
||||||
|
stats.jitterBufferEmittedCount =
|
||||||
|
neteq_lifetime_stat.jitter_buffer_emitted_count;
|
||||||
|
stats.delayedPacketOutageSamples =
|
||||||
|
neteq_lifetime_stat.delayed_packet_outage_samples;
|
||||||
|
stats.relativePacketArrivalDelayMs =
|
||||||
|
neteq_lifetime_stat.relative_packet_arrival_delay_ms;
|
||||||
|
stats.interruptionCount = neteq_lifetime_stat.interruption_count;
|
||||||
|
stats.totalInterruptionDurationMs =
|
||||||
|
neteq_lifetime_stat.total_interruption_duration_ms;
|
||||||
|
stats.insertedSamplesForDeceleration =
|
||||||
|
neteq_lifetime_stat.inserted_samples_for_deceleration;
|
||||||
|
stats.removedSamplesForAcceleration =
|
||||||
|
neteq_lifetime_stat.removed_samples_for_acceleration;
|
||||||
|
stats.fecPacketsReceived = neteq_lifetime_stat.fec_packets_received;
|
||||||
|
stats.fecPacketsDiscarded = neteq_lifetime_stat.fec_packets_discarded;
|
||||||
|
stats.totalProcessingDelayUs = neteq_lifetime_stat.total_processing_delay_us;
|
||||||
|
stats.packetsDiscarded = neteq_lifetime_stat.packets_discarded;
|
||||||
|
|
||||||
|
NetEqOperationsAndState neteq_operations_and_state =
|
||||||
|
neteq_->GetOperationsAndState();
|
||||||
|
stats.packetBufferFlushes = neteq_operations_and_state.packet_buffer_flushes;
|
||||||
|
|
||||||
|
return stats;
|
||||||
|
}
|
||||||
|
|
||||||
ChannelStatistics AudioIngress::GetChannelStatistics() {
|
ChannelStatistics AudioIngress::GetChannelStatistics() {
|
||||||
ChannelStatistics channel_stats;
|
ChannelStatistics channel_stats;
|
||||||
|
|
||||||
// Get clockrate for current decoder ahead of jitter calculation.
|
// Get clockrate for current decoder ahead of jitter calculation.
|
||||||
uint32_t clockrate_hz = 0;
|
auto decoder = neteq_->GetCurrentDecoderFormat();
|
||||||
std::optional<std::pair<int, SdpAudioFormat>> decoder =
|
const uint32_t clockrate_hz = decoder ? decoder->sdp_format.clockrate_hz : 0;
|
||||||
acm_receiver_.LastDecoder();
|
|
||||||
if (decoder) {
|
|
||||||
clockrate_hz = decoder->second.clockrate_hz;
|
|
||||||
}
|
|
||||||
|
|
||||||
StreamStatistician* statistician =
|
StreamStatistician* statistician =
|
||||||
rtp_receive_statistics_->GetStatistician(remote_ssrc_);
|
rtp_receive_statistics_->GetStatistician(remote_ssrc_);
|
||||||
|
|||||||
@ -20,12 +20,14 @@
|
|||||||
|
|
||||||
#include "api/array_view.h"
|
#include "api/array_view.h"
|
||||||
#include "api/audio/audio_mixer.h"
|
#include "api/audio/audio_mixer.h"
|
||||||
|
#include "api/audio_codecs/audio_decoder_factory.h"
|
||||||
#include "api/environment/environment.h"
|
#include "api/environment/environment.h"
|
||||||
|
#include "api/neteq/neteq.h"
|
||||||
#include "api/rtp_headers.h"
|
#include "api/rtp_headers.h"
|
||||||
#include "api/scoped_refptr.h"
|
#include "api/scoped_refptr.h"
|
||||||
#include "api/voip/voip_statistics.h"
|
#include "api/voip/voip_statistics.h"
|
||||||
#include "audio/audio_level.h"
|
#include "audio/audio_level.h"
|
||||||
#include "modules/audio_coding/acm2/acm_receiver.h"
|
#include "modules/audio_coding/acm2/acm_resampler.h"
|
||||||
#include "modules/audio_coding/include/audio_coding_module.h"
|
#include "modules/audio_coding/include/audio_coding_module.h"
|
||||||
#include "modules/rtp_rtcp/include/receive_statistics.h"
|
#include "modules/rtp_rtcp/include/receive_statistics.h"
|
||||||
#include "modules/rtp_rtcp/include/remote_ntp_time_estimator.h"
|
#include "modules/rtp_rtcp/include/remote_ntp_time_estimator.h"
|
||||||
@ -81,12 +83,7 @@ class AudioIngress : public AudioMixer::Source {
|
|||||||
return output_audio_level_.TotalDuration();
|
return output_audio_level_.TotalDuration();
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkStatistics GetNetworkStatistics() const {
|
NetworkStatistics GetNetworkStatistics() const;
|
||||||
NetworkStatistics stats;
|
|
||||||
acm_receiver_.GetNetworkStatistics(&stats,
|
|
||||||
/*get_and_clear_legacy_stats=*/false);
|
|
||||||
return stats;
|
|
||||||
}
|
|
||||||
|
|
||||||
ChannelStatistics GetChannelStatistics();
|
ChannelStatistics GetChannelStatistics();
|
||||||
|
|
||||||
@ -98,11 +95,14 @@ class AudioIngress : public AudioMixer::Source {
|
|||||||
return rtc::dchecked_cast<int>(remote_ssrc_.load());
|
return rtc::dchecked_cast<int>(remote_ssrc_.load());
|
||||||
}
|
}
|
||||||
int PreferredSampleRate() const override {
|
int PreferredSampleRate() const override {
|
||||||
|
std::optional<NetEq::DecoderFormat> decoder =
|
||||||
|
neteq_->GetCurrentDecoderFormat();
|
||||||
|
|
||||||
// If we haven't received any RTP packet from remote and thus
|
// If we haven't received any RTP packet from remote and thus
|
||||||
// last_packet_sampling_rate is not available then use NetEq's sampling
|
// last_packet_sampling_rate is not available then use NetEq's sampling
|
||||||
// rate as that would be what would be used for audio output sample.
|
// rate as that would be what would be used for audio output sample.
|
||||||
return std::max(acm_receiver_.last_packet_sample_rate_hz().value_or(0),
|
return std::max(decoder ? decoder->sample_rate_hz : 0,
|
||||||
acm_receiver_.last_output_sample_rate_hz());
|
neteq_->last_output_sample_rate_hz());
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -126,8 +126,8 @@ class AudioIngress : public AudioMixer::Source {
|
|||||||
// Synchronizaton is handled internally by RtpRtcpInterface.
|
// Synchronizaton is handled internally by RtpRtcpInterface.
|
||||||
RtpRtcpInterface* const rtp_rtcp_;
|
RtpRtcpInterface* const rtp_rtcp_;
|
||||||
|
|
||||||
// Synchronizaton is handled internally by acm2::AcmReceiver.
|
// Synchronizaton is handled internally by NetEq.
|
||||||
acm2::AcmReceiver acm_receiver_;
|
const std::unique_ptr<NetEq> neteq_;
|
||||||
|
|
||||||
// Synchronizaton is handled internally by voe::AudioLevel.
|
// Synchronizaton is handled internally by voe::AudioLevel.
|
||||||
voe::AudioLevel output_audio_level_;
|
voe::AudioLevel output_audio_level_;
|
||||||
@ -141,6 +141,9 @@ class AudioIngress : public AudioMixer::Source {
|
|||||||
std::map<int, int> receive_codec_info_ RTC_GUARDED_BY(lock_);
|
std::map<int, int> receive_codec_info_ RTC_GUARDED_BY(lock_);
|
||||||
|
|
||||||
RtpTimestampUnwrapper timestamp_wrap_handler_ RTC_GUARDED_BY(lock_);
|
RtpTimestampUnwrapper timestamp_wrap_handler_ RTC_GUARDED_BY(lock_);
|
||||||
|
|
||||||
|
// Resampler for the output audio.
|
||||||
|
acm2::ResamplerHelper resampler_helper_ RTC_GUARDED_BY(lock_);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|||||||
@ -1067,8 +1067,10 @@ if (rtc_include_tests) {
|
|||||||
"../../api/audio_codecs/opus:audio_encoder_opus",
|
"../../api/audio_codecs/opus:audio_encoder_opus",
|
||||||
"../../api/environment",
|
"../../api/environment",
|
||||||
"../../api/environment:environment_factory",
|
"../../api/environment:environment_factory",
|
||||||
|
"../../api/neteq:neteq_api",
|
||||||
"../../api/units:timestamp",
|
"../../api/units:timestamp",
|
||||||
"../../common_audio",
|
"../../common_audio",
|
||||||
|
"../../modules/audio_coding:default_neteq_factory",
|
||||||
"../../rtc_base:checks",
|
"../../rtc_base:checks",
|
||||||
"../../rtc_base:logging",
|
"../../rtc_base:logging",
|
||||||
"../../rtc_base:macromagic",
|
"../../rtc_base:macromagic",
|
||||||
@ -1126,6 +1128,8 @@ if (rtc_include_tests) {
|
|||||||
"../../api/audio_codecs:audio_codecs_api",
|
"../../api/audio_codecs:audio_codecs_api",
|
||||||
"../../api/audio_codecs:builtin_audio_decoder_factory",
|
"../../api/audio_codecs:builtin_audio_decoder_factory",
|
||||||
"../../api/environment:environment_factory",
|
"../../api/environment:environment_factory",
|
||||||
|
"../../api/neteq:neteq_api",
|
||||||
|
"../../modules/audio_coding:default_neteq_factory",
|
||||||
"../../test:test_support",
|
"../../test:test_support",
|
||||||
"//testing/gtest",
|
"//testing/gtest",
|
||||||
]
|
]
|
||||||
|
|||||||
@ -17,6 +17,7 @@
|
|||||||
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
|
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
|
||||||
#include "api/environment/environment_factory.h"
|
#include "api/environment/environment_factory.h"
|
||||||
#include "modules/audio_coding/include/audio_coding_module.h"
|
#include "modules/audio_coding/include/audio_coding_module.h"
|
||||||
|
#include "modules/audio_coding/neteq/default_neteq_factory.h"
|
||||||
#include "modules/audio_coding/neteq/tools/audio_sink.h"
|
#include "modules/audio_coding/neteq/tools/audio_sink.h"
|
||||||
#include "modules/audio_coding/neteq/tools/packet.h"
|
#include "modules/audio_coding/neteq/tools/packet.h"
|
||||||
#include "modules/audio_coding/neteq/tools/packet_source.h"
|
#include "modules/audio_coding/neteq/tools/packet_source.h"
|
||||||
@ -25,15 +26,6 @@
|
|||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
namespace test {
|
namespace test {
|
||||||
|
|
||||||
namespace {
|
|
||||||
acm2::AcmReceiver::Config MakeAcmConfig(
|
|
||||||
rtc::scoped_refptr<AudioDecoderFactory> decoder_factory) {
|
|
||||||
acm2::AcmReceiver::Config config;
|
|
||||||
config.decoder_factory = std::move(decoder_factory);
|
|
||||||
return config;
|
|
||||||
}
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
AcmReceiveTestOldApi::AcmReceiveTestOldApi(
|
AcmReceiveTestOldApi::AcmReceiveTestOldApi(
|
||||||
PacketSource* packet_source,
|
PacketSource* packet_source,
|
||||||
AudioSink* audio_sink,
|
AudioSink* audio_sink,
|
||||||
@ -41,9 +33,9 @@ AcmReceiveTestOldApi::AcmReceiveTestOldApi(
|
|||||||
NumOutputChannels exptected_output_channels,
|
NumOutputChannels exptected_output_channels,
|
||||||
rtc::scoped_refptr<AudioDecoderFactory> decoder_factory)
|
rtc::scoped_refptr<AudioDecoderFactory> decoder_factory)
|
||||||
: clock_(0),
|
: clock_(0),
|
||||||
acm_receiver_(std::make_unique<acm2::AcmReceiver>(
|
neteq_(DefaultNetEqFactory().Create(CreateEnvironment(&clock_),
|
||||||
CreateEnvironment(&clock_),
|
NetEq::Config(),
|
||||||
MakeAcmConfig(std::move(decoder_factory)))),
|
std::move(decoder_factory))),
|
||||||
packet_source_(packet_source),
|
packet_source_(packet_source),
|
||||||
audio_sink_(audio_sink),
|
audio_sink_(audio_sink),
|
||||||
output_freq_hz_(output_freq_hz),
|
output_freq_hz_(output_freq_hz),
|
||||||
@ -52,43 +44,43 @@ AcmReceiveTestOldApi::AcmReceiveTestOldApi(
|
|||||||
AcmReceiveTestOldApi::~AcmReceiveTestOldApi() = default;
|
AcmReceiveTestOldApi::~AcmReceiveTestOldApi() = default;
|
||||||
|
|
||||||
void AcmReceiveTestOldApi::RegisterDefaultCodecs() {
|
void AcmReceiveTestOldApi::RegisterDefaultCodecs() {
|
||||||
acm_receiver_->SetCodecs({{103, {"ISAC", 16000, 1}},
|
neteq_->SetCodecs({{103, {"ISAC", 16000, 1}},
|
||||||
{104, {"ISAC", 32000, 1}},
|
{104, {"ISAC", 32000, 1}},
|
||||||
{107, {"L16", 8000, 1}},
|
{107, {"L16", 8000, 1}},
|
||||||
{108, {"L16", 16000, 1}},
|
{108, {"L16", 16000, 1}},
|
||||||
{109, {"L16", 32000, 1}},
|
{109, {"L16", 32000, 1}},
|
||||||
{111, {"L16", 8000, 2}},
|
{111, {"L16", 8000, 2}},
|
||||||
{112, {"L16", 16000, 2}},
|
{112, {"L16", 16000, 2}},
|
||||||
{113, {"L16", 32000, 2}},
|
{113, {"L16", 32000, 2}},
|
||||||
{0, {"PCMU", 8000, 1}},
|
{0, {"PCMU", 8000, 1}},
|
||||||
{110, {"PCMU", 8000, 2}},
|
{110, {"PCMU", 8000, 2}},
|
||||||
{8, {"PCMA", 8000, 1}},
|
{8, {"PCMA", 8000, 1}},
|
||||||
{118, {"PCMA", 8000, 2}},
|
{118, {"PCMA", 8000, 2}},
|
||||||
{102, {"ILBC", 8000, 1}},
|
{102, {"ILBC", 8000, 1}},
|
||||||
{9, {"G722", 8000, 1}},
|
{9, {"G722", 8000, 1}},
|
||||||
{119, {"G722", 8000, 2}},
|
{119, {"G722", 8000, 2}},
|
||||||
{120, {"OPUS", 48000, 2, {{"stereo", "1"}}}},
|
{120, {"OPUS", 48000, 2, {{"stereo", "1"}}}},
|
||||||
{13, {"CN", 8000, 1}},
|
{13, {"CN", 8000, 1}},
|
||||||
{98, {"CN", 16000, 1}},
|
{98, {"CN", 16000, 1}},
|
||||||
{99, {"CN", 32000, 1}}});
|
{99, {"CN", 32000, 1}}});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remaps payload types from ACM's default to those used in the resource file
|
// Remaps payload types from ACM's default to those used in the resource file
|
||||||
// neteq_universal_new.rtp.
|
// neteq_universal_new.rtp.
|
||||||
void AcmReceiveTestOldApi::RegisterNetEqTestCodecs() {
|
void AcmReceiveTestOldApi::RegisterNetEqTestCodecs() {
|
||||||
acm_receiver_->SetCodecs({{103, {"ISAC", 16000, 1}},
|
neteq_->SetCodecs({{103, {"ISAC", 16000, 1}},
|
||||||
{104, {"ISAC", 32000, 1}},
|
{104, {"ISAC", 32000, 1}},
|
||||||
{93, {"L16", 8000, 1}},
|
{93, {"L16", 8000, 1}},
|
||||||
{94, {"L16", 16000, 1}},
|
{94, {"L16", 16000, 1}},
|
||||||
{95, {"L16", 32000, 1}},
|
{95, {"L16", 32000, 1}},
|
||||||
{0, {"PCMU", 8000, 1}},
|
{0, {"PCMU", 8000, 1}},
|
||||||
{8, {"PCMA", 8000, 1}},
|
{8, {"PCMA", 8000, 1}},
|
||||||
{102, {"ILBC", 8000, 1}},
|
{102, {"ILBC", 8000, 1}},
|
||||||
{9, {"G722", 8000, 1}},
|
{9, {"G722", 8000, 1}},
|
||||||
{120, {"OPUS", 48000, 2}},
|
{120, {"OPUS", 48000, 2}},
|
||||||
{13, {"CN", 8000, 1}},
|
{13, {"CN", 8000, 1}},
|
||||||
{98, {"CN", 16000, 1}},
|
{98, {"CN", 16000, 1}},
|
||||||
{99, {"CN", 32000, 1}}});
|
{99, {"CN", 32000, 1}}});
|
||||||
}
|
}
|
||||||
|
|
||||||
void AcmReceiveTestOldApi::Run() {
|
void AcmReceiveTestOldApi::Run() {
|
||||||
@ -98,8 +90,9 @@ void AcmReceiveTestOldApi::Run() {
|
|||||||
while (clock_.TimeInMilliseconds() < packet->time_ms()) {
|
while (clock_.TimeInMilliseconds() < packet->time_ms()) {
|
||||||
AudioFrame output_frame;
|
AudioFrame output_frame;
|
||||||
bool muted;
|
bool muted;
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output_frame, &muted));
|
||||||
0, acm_receiver_->GetAudio(output_freq_hz_, &output_frame, &muted));
|
EXPECT_TRUE(
|
||||||
|
resampler_helper_.MaybeResample(output_freq_hz_, &output_frame));
|
||||||
ASSERT_EQ(output_freq_hz_, output_frame.sample_rate_hz_);
|
ASSERT_EQ(output_freq_hz_, output_frame.sample_rate_hz_);
|
||||||
ASSERT_FALSE(muted);
|
ASSERT_FALSE(muted);
|
||||||
const size_t samples_per_block =
|
const size_t samples_per_block =
|
||||||
@ -119,7 +112,7 @@ void AcmReceiveTestOldApi::Run() {
|
|||||||
AfterGetAudio();
|
AfterGetAudio();
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPECT_EQ(0, acm_receiver_->InsertPacket(
|
EXPECT_EQ(0, neteq_->InsertPacket(
|
||||||
packet->header(),
|
packet->header(),
|
||||||
rtc::ArrayView<const uint8_t>(
|
rtc::ArrayView<const uint8_t>(
|
||||||
packet->payload(), packet->payload_length_bytes()),
|
packet->payload(), packet->payload_length_bytes()),
|
||||||
|
|||||||
@ -17,8 +17,9 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "api/audio_codecs/audio_decoder_factory.h"
|
#include "api/audio_codecs/audio_decoder_factory.h"
|
||||||
|
#include "api/neteq/neteq.h"
|
||||||
#include "api/scoped_refptr.h"
|
#include "api/scoped_refptr.h"
|
||||||
#include "modules/audio_coding/acm2/acm_receiver.h"
|
#include "modules/audio_coding/acm2/acm_resampler.h"
|
||||||
#include "system_wrappers/include/clock.h"
|
#include "system_wrappers/include/clock.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
@ -63,7 +64,8 @@ class AcmReceiveTestOldApi {
|
|||||||
virtual void AfterGetAudio() {}
|
virtual void AfterGetAudio() {}
|
||||||
|
|
||||||
SimulatedClock clock_;
|
SimulatedClock clock_;
|
||||||
std::unique_ptr<acm2::AcmReceiver> acm_receiver_;
|
std::unique_ptr<NetEq> neteq_;
|
||||||
|
acm2::ResamplerHelper resampler_helper_;
|
||||||
PacketSource* packet_source_;
|
PacketSource* packet_source_;
|
||||||
AudioSink* audio_sink_;
|
AudioSink* audio_sink_;
|
||||||
int output_freq_hz_;
|
int output_freq_hz_;
|
||||||
|
|||||||
@ -34,6 +34,7 @@
|
|||||||
#include "modules/audio_coding/codecs/g711/audio_decoder_pcm.h"
|
#include "modules/audio_coding/codecs/g711/audio_decoder_pcm.h"
|
||||||
#include "modules/audio_coding/codecs/g711/audio_encoder_pcm.h"
|
#include "modules/audio_coding/codecs/g711/audio_encoder_pcm.h"
|
||||||
#include "modules/audio_coding/include/audio_coding_module_typedefs.h"
|
#include "modules/audio_coding/include/audio_coding_module_typedefs.h"
|
||||||
|
#include "modules/audio_coding/neteq/default_neteq_factory.h"
|
||||||
#include "modules/audio_coding/neteq/tools/audio_checksum.h"
|
#include "modules/audio_coding/neteq/tools/audio_checksum.h"
|
||||||
#include "modules/audio_coding/neteq/tools/audio_loop.h"
|
#include "modules/audio_coding/neteq/tools/audio_loop.h"
|
||||||
#include "modules/audio_coding/neteq/tools/constant_pcm_packet_source.h"
|
#include "modules/audio_coding/neteq/tools/constant_pcm_packet_source.h"
|
||||||
@ -174,9 +175,8 @@ class AudioCodingModuleTestOldApi : public ::testing::Test {
|
|||||||
|
|
||||||
void SetUp() {
|
void SetUp() {
|
||||||
acm_ = AudioCodingModule::Create();
|
acm_ = AudioCodingModule::Create();
|
||||||
acm2::AcmReceiver::Config config;
|
neteq_ = DefaultNetEqFactory().Create(env_, NetEq::Config(),
|
||||||
config.decoder_factory = CreateBuiltinAudioDecoderFactory();
|
CreateBuiltinAudioDecoderFactory());
|
||||||
acm_receiver_ = std::make_unique<acm2::AcmReceiver>(env_, config);
|
|
||||||
|
|
||||||
rtp_utility_->Populate(&rtp_header_);
|
rtp_utility_->Populate(&rtp_header_);
|
||||||
|
|
||||||
@ -199,7 +199,7 @@ class AudioCodingModuleTestOldApi : public ::testing::Test {
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual void RegisterCodec() {
|
virtual void RegisterCodec() {
|
||||||
acm_receiver_->SetCodecs({{kPayloadType, *audio_format_}});
|
neteq_->SetCodecs({{kPayloadType, *audio_format_}});
|
||||||
acm_->SetEncoder(CreateBuiltinAudioEncoderFactory()->Create(
|
acm_->SetEncoder(CreateBuiltinAudioEncoderFactory()->Create(
|
||||||
env_, *audio_format_, {.payload_type = kPayloadType}));
|
env_, *audio_format_, {.payload_type = kPayloadType}));
|
||||||
}
|
}
|
||||||
@ -211,7 +211,7 @@ class AudioCodingModuleTestOldApi : public ::testing::Test {
|
|||||||
|
|
||||||
virtual void InsertPacket() {
|
virtual void InsertPacket() {
|
||||||
const uint8_t kPayload[kPayloadSizeBytes] = {0};
|
const uint8_t kPayload[kPayloadSizeBytes] = {0};
|
||||||
ASSERT_EQ(0, acm_receiver_->InsertPacket(
|
ASSERT_EQ(0, neteq_->InsertPacket(
|
||||||
rtp_header_,
|
rtp_header_,
|
||||||
rtc::ArrayView<const uint8_t>(kPayload, kPayloadSizeBytes),
|
rtc::ArrayView<const uint8_t>(kPayload, kPayloadSizeBytes),
|
||||||
/*receive_time=*/Timestamp::MinusInfinity()));
|
/*receive_time=*/Timestamp::MinusInfinity()));
|
||||||
@ -221,7 +221,7 @@ class AudioCodingModuleTestOldApi : public ::testing::Test {
|
|||||||
virtual void PullAudio() {
|
virtual void PullAudio() {
|
||||||
AudioFrame audio_frame;
|
AudioFrame audio_frame;
|
||||||
bool muted;
|
bool muted;
|
||||||
ASSERT_EQ(0, acm_receiver_->GetAudio(-1, &audio_frame, &muted));
|
ASSERT_EQ(0, neteq_->GetAudio(&audio_frame, &muted));
|
||||||
ASSERT_FALSE(muted);
|
ASSERT_FALSE(muted);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,7 +244,7 @@ class AudioCodingModuleTestOldApi : public ::testing::Test {
|
|||||||
Environment env_;
|
Environment env_;
|
||||||
std::unique_ptr<RtpData> rtp_utility_;
|
std::unique_ptr<RtpData> rtp_utility_;
|
||||||
std::unique_ptr<AudioCodingModule> acm_;
|
std::unique_ptr<AudioCodingModule> acm_;
|
||||||
std::unique_ptr<acm2::AcmReceiver> acm_receiver_;
|
std::unique_ptr<NetEq> neteq_;
|
||||||
PacketizationCallbackStubOldApi packet_cb_;
|
PacketizationCallbackStubOldApi packet_cb_;
|
||||||
RTPHeader rtp_header_;
|
RTPHeader rtp_header_;
|
||||||
AudioFrame input_frame_;
|
AudioFrame input_frame_;
|
||||||
@ -256,19 +256,6 @@ class AudioCodingModuleTestOldApi : public ::testing::Test {
|
|||||||
class AudioCodingModuleTestOldApiDeathTest
|
class AudioCodingModuleTestOldApiDeathTest
|
||||||
: public AudioCodingModuleTestOldApi {};
|
: public AudioCodingModuleTestOldApi {};
|
||||||
|
|
||||||
// The below test is temporarily disabled on Windows due to problems
|
|
||||||
// with clang debug builds.
|
|
||||||
// TODO(tommi): Re-enable when we've figured out what the problem is.
|
|
||||||
// http://crbug.com/615050
|
|
||||||
#if !defined(WEBRTC_WIN) && defined(__clang__) && RTC_DCHECK_IS_ON && \
|
|
||||||
GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID)
|
|
||||||
TEST_F(AudioCodingModuleTestOldApiDeathTest, FailOnZeroDesiredFrequency) {
|
|
||||||
AudioFrame audio_frame;
|
|
||||||
bool muted;
|
|
||||||
RTC_EXPECT_DEATH(acm_receiver_->GetAudio(0, &audio_frame, &muted), "");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Checks that the transport callback is invoked once for each speech packet.
|
// Checks that the transport callback is invoked once for each speech packet.
|
||||||
// Also checks that the frame type is kAudioFrameSpeech.
|
// Also checks that the frame type is kAudioFrameSpeech.
|
||||||
TEST_F(AudioCodingModuleTestOldApi, TransportCallbackIsInvokedForEachPacket) {
|
TEST_F(AudioCodingModuleTestOldApi, TransportCallbackIsInvokedForEachPacket) {
|
||||||
@ -297,8 +284,8 @@ class AudioCodingModuleTestWithComfortNoiseOldApi
|
|||||||
: public AudioCodingModuleTestOldApi {
|
: public AudioCodingModuleTestOldApi {
|
||||||
protected:
|
protected:
|
||||||
void RegisterCngCodec(int rtp_payload_type) {
|
void RegisterCngCodec(int rtp_payload_type) {
|
||||||
acm_receiver_->SetCodecs({{kPayloadType, *audio_format_},
|
neteq_->SetCodecs({{kPayloadType, *audio_format_},
|
||||||
{rtp_payload_type, {"cn", kSampleRateHz, 1}}});
|
{rtp_payload_type, {"cn", kSampleRateHz, 1}}});
|
||||||
acm_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* enc) {
|
acm_->ModifyEncoder([&](std::unique_ptr<AudioEncoder>* enc) {
|
||||||
AudioEncoderCngConfig config;
|
AudioEncoderCngConfig config;
|
||||||
config.speech_encoder = std::move(*enc);
|
config.speech_encoder = std::move(*enc);
|
||||||
|
|||||||
@ -82,7 +82,7 @@ int32_t Channel::SendData(AudioFrameType frameType,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = _receiverACM->InsertPacket(
|
status = _neteq->InsertPacket(
|
||||||
rtp_header, rtc::ArrayView<const uint8_t>(_payloadData, payloadDataSize),
|
rtp_header, rtc::ArrayView<const uint8_t>(_payloadData, payloadDataSize),
|
||||||
/*receive_time=*/Timestamp::MinusInfinity());
|
/*receive_time=*/Timestamp::MinusInfinity());
|
||||||
|
|
||||||
@ -187,7 +187,7 @@ void Channel::CalcStatistics(const RTPHeader& rtp_header, size_t payloadSize) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Channel::Channel(int16_t chID)
|
Channel::Channel(int16_t chID)
|
||||||
: _receiverACM(NULL),
|
: _neteq(NULL),
|
||||||
_seqNo(0),
|
_seqNo(0),
|
||||||
_bitStreamFile(NULL),
|
_bitStreamFile(NULL),
|
||||||
_saveBitStream(false),
|
_saveBitStream(false),
|
||||||
@ -229,8 +229,8 @@ Channel::Channel(int16_t chID)
|
|||||||
|
|
||||||
Channel::~Channel() {}
|
Channel::~Channel() {}
|
||||||
|
|
||||||
void Channel::RegisterReceiverACM(acm2::AcmReceiver* acm_receiver) {
|
void Channel::RegisterReceiverNetEq(NetEq* neteq) {
|
||||||
_receiverACM = acm_receiver;
|
_neteq = neteq;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "modules/audio_coding/acm2/acm_receiver.h"
|
#include "api/neteq/neteq.h"
|
||||||
#include "modules/audio_coding/include/audio_coding_module.h"
|
#include "modules/audio_coding/include/audio_coding_module.h"
|
||||||
#include "modules/include/module_common_types.h"
|
#include "modules/include/module_common_types.h"
|
||||||
#include "rtc_base/synchronization/mutex.h"
|
#include "rtc_base/synchronization/mutex.h"
|
||||||
@ -55,7 +55,7 @@ class Channel : public AudioPacketizationCallback {
|
|||||||
size_t payloadSize,
|
size_t payloadSize,
|
||||||
int64_t absolute_capture_timestamp_ms) override;
|
int64_t absolute_capture_timestamp_ms) override;
|
||||||
|
|
||||||
void RegisterReceiverACM(acm2::AcmReceiver* acm_receiver);
|
void RegisterReceiverNetEq(NetEq* neteq);
|
||||||
|
|
||||||
void ResetStats();
|
void ResetStats();
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ class Channel : public AudioPacketizationCallback {
|
|||||||
private:
|
private:
|
||||||
void CalcStatistics(const RTPHeader& rtp_header, size_t payloadSize);
|
void CalcStatistics(const RTPHeader& rtp_header, size_t payloadSize);
|
||||||
|
|
||||||
acm2::AcmReceiver* _receiverACM;
|
NetEq* _neteq;
|
||||||
uint16_t _seqNo;
|
uint16_t _seqNo;
|
||||||
// 60msec * 32 sample(max)/msec * 2 description (maybe) * 2 bytes/sample
|
// 60msec * 32 sample(max)/msec * 2 description (maybe) * 2 bytes/sample
|
||||||
uint8_t _payloadData[60 * 32 * 2 * 2];
|
uint8_t _payloadData[60 * 32 * 2 * 2];
|
||||||
|
|||||||
@ -21,6 +21,7 @@
|
|||||||
#include "api/environment/environment.h"
|
#include "api/environment/environment.h"
|
||||||
#include "api/environment/environment_factory.h"
|
#include "api/environment/environment_factory.h"
|
||||||
#include "modules/audio_coding/include/audio_coding_module.h"
|
#include "modules/audio_coding/include/audio_coding_module.h"
|
||||||
|
#include "modules/audio_coding/neteq/default_neteq_factory.h"
|
||||||
#include "rtc_base/strings/string_builder.h"
|
#include "rtc_base/strings/string_builder.h"
|
||||||
#include "test/gtest.h"
|
#include "test/gtest.h"
|
||||||
#include "test/testsupport/file_utils.h"
|
#include "test/testsupport/file_utils.h"
|
||||||
@ -105,32 +106,32 @@ Receiver::Receiver()
|
|||||||
: _playoutLengthSmpls(kWebRtc10MsPcmAudio),
|
: _playoutLengthSmpls(kWebRtc10MsPcmAudio),
|
||||||
_payloadSizeBytes(MAX_INCOMING_PAYLOAD) {}
|
_payloadSizeBytes(MAX_INCOMING_PAYLOAD) {}
|
||||||
|
|
||||||
void Receiver::Setup(acm2::AcmReceiver* acm_receiver,
|
void Receiver::Setup(NetEq* neteq,
|
||||||
RTPStream* rtpStream,
|
RTPStream* rtpStream,
|
||||||
absl::string_view out_file_name,
|
absl::string_view out_file_name,
|
||||||
size_t channels,
|
size_t channels,
|
||||||
int file_num) {
|
int file_num) {
|
||||||
if (channels == 1) {
|
if (channels == 1) {
|
||||||
acm_receiver->SetCodecs({{107, {"L16", 8000, 1}},
|
neteq->SetCodecs({{107, {"L16", 8000, 1}},
|
||||||
{108, {"L16", 16000, 1}},
|
{108, {"L16", 16000, 1}},
|
||||||
{109, {"L16", 32000, 1}},
|
{109, {"L16", 32000, 1}},
|
||||||
{0, {"PCMU", 8000, 1}},
|
{0, {"PCMU", 8000, 1}},
|
||||||
{8, {"PCMA", 8000, 1}},
|
{8, {"PCMA", 8000, 1}},
|
||||||
{102, {"ILBC", 8000, 1}},
|
{102, {"ILBC", 8000, 1}},
|
||||||
{9, {"G722", 8000, 1}},
|
{9, {"G722", 8000, 1}},
|
||||||
{120, {"OPUS", 48000, 2}},
|
{120, {"OPUS", 48000, 2}},
|
||||||
{13, {"CN", 8000, 1}},
|
{13, {"CN", 8000, 1}},
|
||||||
{98, {"CN", 16000, 1}},
|
{98, {"CN", 16000, 1}},
|
||||||
{99, {"CN", 32000, 1}}});
|
{99, {"CN", 32000, 1}}});
|
||||||
} else {
|
} else {
|
||||||
ASSERT_EQ(channels, 2u);
|
ASSERT_EQ(channels, 2u);
|
||||||
acm_receiver->SetCodecs({{111, {"L16", 8000, 2}},
|
neteq->SetCodecs({{111, {"L16", 8000, 2}},
|
||||||
{112, {"L16", 16000, 2}},
|
{112, {"L16", 16000, 2}},
|
||||||
{113, {"L16", 32000, 2}},
|
{113, {"L16", 32000, 2}},
|
||||||
{110, {"PCMU", 8000, 2}},
|
{110, {"PCMU", 8000, 2}},
|
||||||
{118, {"PCMA", 8000, 2}},
|
{118, {"PCMA", 8000, 2}},
|
||||||
{119, {"G722", 8000, 2}},
|
{119, {"G722", 8000, 2}},
|
||||||
{120, {"OPUS", 48000, 2, {{"stereo", "1"}}}}});
|
{120, {"OPUS", 48000, 2, {{"stereo", "1"}}}}});
|
||||||
}
|
}
|
||||||
|
|
||||||
int playSampFreq;
|
int playSampFreq;
|
||||||
@ -147,7 +148,7 @@ void Receiver::Setup(acm2::AcmReceiver* acm_receiver,
|
|||||||
_realPayloadSizeBytes = 0;
|
_realPayloadSizeBytes = 0;
|
||||||
_playoutBuffer = new int16_t[kWebRtc10MsPcmAudio];
|
_playoutBuffer = new int16_t[kWebRtc10MsPcmAudio];
|
||||||
_frequency = playSampFreq;
|
_frequency = playSampFreq;
|
||||||
_acm_receiver = acm_receiver;
|
_neteq = neteq;
|
||||||
_firstTime = true;
|
_firstTime = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,11 +173,11 @@ bool Receiver::IncomingPacket() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPECT_EQ(0, _acm_receiver->InsertPacket(
|
EXPECT_GE(
|
||||||
_rtpHeader,
|
0, _neteq->InsertPacket(_rtpHeader,
|
||||||
rtc::ArrayView<const uint8_t>(_incomingPayload,
|
rtc::ArrayView<const uint8_t>(
|
||||||
_realPayloadSizeBytes),
|
_incomingPayload, _realPayloadSizeBytes),
|
||||||
/*receive_time=*/Timestamp::Millis(_nextTime)));
|
/*receive_time=*/Timestamp::Millis(_nextTime)));
|
||||||
_realPayloadSizeBytes = _rtpStream->Read(&_rtpHeader, _incomingPayload,
|
_realPayloadSizeBytes = _rtpStream->Read(&_rtpHeader, _incomingPayload,
|
||||||
_payloadSizeBytes, &_nextTime);
|
_payloadSizeBytes, &_nextTime);
|
||||||
if (_realPayloadSizeBytes == 0 && _rtpStream->EndOfFile()) {
|
if (_realPayloadSizeBytes == 0 && _rtpStream->EndOfFile()) {
|
||||||
@ -189,18 +190,19 @@ bool Receiver::IncomingPacket() {
|
|||||||
bool Receiver::PlayoutData() {
|
bool Receiver::PlayoutData() {
|
||||||
AudioFrame audioFrame;
|
AudioFrame audioFrame;
|
||||||
bool muted;
|
bool muted;
|
||||||
int32_t ok = _acm_receiver->GetAudio(_frequency, &audioFrame, &muted);
|
int ok = _neteq->GetAudio(&audioFrame, &muted);
|
||||||
if (muted) {
|
if (muted) {
|
||||||
ADD_FAILURE();
|
ADD_FAILURE();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
EXPECT_EQ(0, ok);
|
EXPECT_EQ(NetEq::kOK, ok);
|
||||||
if (ok < 0) {
|
if (ok < 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (_playoutLengthSmpls == 0) {
|
if (_playoutLengthSmpls == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
EXPECT_TRUE(_resampler_helper.MaybeResample(_frequency, &audioFrame));
|
||||||
_pcmFile.Write10MsData(audioFrame.data(), audioFrame.samples_per_channel_ *
|
_pcmFile.Write10MsData(audioFrame.data(), audioFrame.samples_per_channel_ *
|
||||||
audioFrame.num_channels_);
|
audioFrame.num_channels_);
|
||||||
return true;
|
return true;
|
||||||
@ -264,12 +266,10 @@ void EncodeDecodeTest::Perform() {
|
|||||||
|
|
||||||
rtpFile.Open(fileName.c_str(), "rb");
|
rtpFile.Open(fileName.c_str(), "rb");
|
||||||
rtpFile.ReadHeader();
|
rtpFile.ReadHeader();
|
||||||
std::unique_ptr<acm2::AcmReceiver> acm_receiver =
|
std::unique_ptr<NetEq> neteq = DefaultNetEqFactory().Create(
|
||||||
std::make_unique<acm2::AcmReceiver>(
|
env, NetEq::Config(), CreateBuiltinAudioDecoderFactory());
|
||||||
env, acm2::AcmReceiver::Config(CreateBuiltinAudioDecoderFactory()));
|
|
||||||
Receiver receiver;
|
Receiver receiver;
|
||||||
receiver.Setup(acm_receiver.get(), &rtpFile, "encodeDecode_out", 1,
|
receiver.Setup(neteq.get(), &rtpFile, "encodeDecode_out", 1, file_num);
|
||||||
file_num);
|
|
||||||
receiver.Run();
|
receiver.Run();
|
||||||
receiver.Teardown();
|
receiver.Teardown();
|
||||||
rtpFile.Close();
|
rtpFile.Close();
|
||||||
|
|||||||
@ -16,7 +16,8 @@
|
|||||||
|
|
||||||
#include "absl/strings/string_view.h"
|
#include "absl/strings/string_view.h"
|
||||||
#include "api/environment/environment.h"
|
#include "api/environment/environment.h"
|
||||||
#include "modules/audio_coding/acm2/acm_receiver.h"
|
#include "api/neteq/neteq.h"
|
||||||
|
#include "modules/audio_coding/acm2/acm_resampler.h"
|
||||||
#include "modules/audio_coding/include/audio_coding_module.h"
|
#include "modules/audio_coding/include/audio_coding_module.h"
|
||||||
#include "modules/audio_coding/test/PCMFile.h"
|
#include "modules/audio_coding/test/PCMFile.h"
|
||||||
#include "modules/audio_coding/test/RTPFile.h"
|
#include "modules/audio_coding/test/RTPFile.h"
|
||||||
@ -76,7 +77,7 @@ class Receiver {
|
|||||||
public:
|
public:
|
||||||
Receiver();
|
Receiver();
|
||||||
virtual ~Receiver() {}
|
virtual ~Receiver() {}
|
||||||
void Setup(acm2::AcmReceiver* acm_receiver,
|
void Setup(NetEq* neteq,
|
||||||
RTPStream* rtpStream,
|
RTPStream* rtpStream,
|
||||||
absl::string_view out_file_name,
|
absl::string_view out_file_name,
|
||||||
size_t channels,
|
size_t channels,
|
||||||
@ -94,7 +95,8 @@ class Receiver {
|
|||||||
bool _firstTime;
|
bool _firstTime;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
acm2::AcmReceiver* _acm_receiver;
|
NetEq* _neteq;
|
||||||
|
acm2::ResamplerHelper _resampler_helper;
|
||||||
uint8_t _incomingPayload[MAX_INCOMING_PAYLOAD];
|
uint8_t _incomingPayload[MAX_INCOMING_PAYLOAD];
|
||||||
RTPStream* _rtpStream;
|
RTPStream* _rtpStream;
|
||||||
RTPHeader _rtpHeader;
|
RTPHeader _rtpHeader;
|
||||||
|
|||||||
@ -17,6 +17,7 @@
|
|||||||
#include "api/environment/environment.h"
|
#include "api/environment/environment.h"
|
||||||
#include "api/environment/environment_factory.h"
|
#include "api/environment/environment_factory.h"
|
||||||
#include "api/units/timestamp.h"
|
#include "api/units/timestamp.h"
|
||||||
|
#include "modules/audio_coding/neteq/default_neteq_factory.h"
|
||||||
#include "rtc_base/strings/string_builder.h"
|
#include "rtc_base/strings/string_builder.h"
|
||||||
#include "test/gtest.h"
|
#include "test/gtest.h"
|
||||||
#include "test/testsupport/file_utils.h"
|
#include "test/testsupport/file_utils.h"
|
||||||
@ -30,7 +31,7 @@ ReceiverWithPacketLoss::ReceiverWithPacketLoss()
|
|||||||
lost_packet_counter_(0),
|
lost_packet_counter_(0),
|
||||||
burst_lost_counter_(burst_length_) {}
|
burst_lost_counter_(burst_length_) {}
|
||||||
|
|
||||||
void ReceiverWithPacketLoss::Setup(acm2::AcmReceiver* acm_receiver,
|
void ReceiverWithPacketLoss::Setup(NetEq* neteq,
|
||||||
RTPStream* rtpStream,
|
RTPStream* rtpStream,
|
||||||
absl::string_view out_file_name,
|
absl::string_view out_file_name,
|
||||||
int channels,
|
int channels,
|
||||||
@ -42,7 +43,7 @@ void ReceiverWithPacketLoss::Setup(acm2::AcmReceiver* acm_receiver,
|
|||||||
burst_lost_counter_ = burst_length_; // To prevent first packet gets lost.
|
burst_lost_counter_ = burst_length_; // To prevent first packet gets lost.
|
||||||
rtc::StringBuilder ss;
|
rtc::StringBuilder ss;
|
||||||
ss << out_file_name << "_" << loss_rate_ << "_" << burst_length_ << "_";
|
ss << out_file_name << "_" << loss_rate_ << "_" << burst_length_ << "_";
|
||||||
Receiver::Setup(acm_receiver, rtpStream, ss.str(), channels, file_num);
|
Receiver::Setup(neteq, rtpStream, ss.str(), channels, file_num);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ReceiverWithPacketLoss::IncomingPacket() {
|
bool ReceiverWithPacketLoss::IncomingPacket() {
|
||||||
@ -61,10 +62,10 @@ bool ReceiverWithPacketLoss::IncomingPacket() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!PacketLost()) {
|
if (!PacketLost()) {
|
||||||
_acm_receiver->InsertPacket(_rtpHeader,
|
_neteq->InsertPacket(_rtpHeader,
|
||||||
rtc::ArrayView<const uint8_t>(
|
rtc::ArrayView<const uint8_t>(_incomingPayload,
|
||||||
_incomingPayload, _realPayloadSizeBytes),
|
_realPayloadSizeBytes),
|
||||||
Timestamp::Millis(_nextTime));
|
Timestamp::Millis(_nextTime));
|
||||||
}
|
}
|
||||||
packet_counter_++;
|
packet_counter_++;
|
||||||
_realPayloadSizeBytes = _rtpStream->Read(&_rtpHeader, _incomingPayload,
|
_realPayloadSizeBytes = _rtpStream->Read(&_rtpHeader, _incomingPayload,
|
||||||
@ -162,11 +163,10 @@ void PacketLossTest::Perform() {
|
|||||||
|
|
||||||
rtpFile.Open(fileName.c_str(), "rb");
|
rtpFile.Open(fileName.c_str(), "rb");
|
||||||
rtpFile.ReadHeader();
|
rtpFile.ReadHeader();
|
||||||
std::unique_ptr<acm2::AcmReceiver> acm_receiver =
|
std::unique_ptr<NetEq> neteq = DefaultNetEqFactory().Create(
|
||||||
std::make_unique<acm2::AcmReceiver>(
|
env, NetEq::Config(), CreateBuiltinAudioDecoderFactory());
|
||||||
env, acm2::AcmReceiver::Config(CreateBuiltinAudioDecoderFactory()));
|
|
||||||
ReceiverWithPacketLoss receiver;
|
ReceiverWithPacketLoss receiver;
|
||||||
receiver.Setup(acm_receiver.get(), &rtpFile, "packetLoss_out", channels_, 15,
|
receiver.Setup(neteq.get(), &rtpFile, "packetLoss_out", channels_, 15,
|
||||||
actual_loss_rate_, burst_length_);
|
actual_loss_rate_, burst_length_);
|
||||||
receiver.Run();
|
receiver.Run();
|
||||||
receiver.Teardown();
|
receiver.Teardown();
|
||||||
|
|||||||
@ -21,7 +21,7 @@ namespace webrtc {
|
|||||||
class ReceiverWithPacketLoss : public Receiver {
|
class ReceiverWithPacketLoss : public Receiver {
|
||||||
public:
|
public:
|
||||||
ReceiverWithPacketLoss();
|
ReceiverWithPacketLoss();
|
||||||
void Setup(acm2::AcmReceiver* acm_receiver,
|
void Setup(NetEq* neteq,
|
||||||
RTPStream* rtpStream,
|
RTPStream* rtpStream,
|
||||||
absl::string_view out_file_name,
|
absl::string_view out_file_name,
|
||||||
int channels,
|
int channels,
|
||||||
|
|||||||
@ -18,7 +18,10 @@
|
|||||||
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
|
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
|
||||||
#include "api/audio_codecs/builtin_audio_encoder_factory.h"
|
#include "api/audio_codecs/builtin_audio_encoder_factory.h"
|
||||||
#include "api/environment/environment_factory.h"
|
#include "api/environment/environment_factory.h"
|
||||||
|
#include "api/neteq/neteq.h"
|
||||||
|
#include "modules/audio_coding/acm2/acm_resampler.h"
|
||||||
#include "modules/audio_coding/include/audio_coding_module_typedefs.h"
|
#include "modules/audio_coding/include/audio_coding_module_typedefs.h"
|
||||||
|
#include "modules/audio_coding/neteq/default_neteq_factory.h"
|
||||||
#include "modules/include/module_common_types.h"
|
#include "modules/include/module_common_types.h"
|
||||||
#include "rtc_base/logging.h"
|
#include "rtc_base/logging.h"
|
||||||
#include "rtc_base/string_encode.h"
|
#include "rtc_base/string_encode.h"
|
||||||
@ -47,7 +50,7 @@ namespace webrtc {
|
|||||||
|
|
||||||
// Class for simulating packet handling.
|
// Class for simulating packet handling.
|
||||||
TestPack::TestPack()
|
TestPack::TestPack()
|
||||||
: receiver_acm_(NULL),
|
: neteq_(NULL),
|
||||||
sequence_number_(0),
|
sequence_number_(0),
|
||||||
timestamp_diff_(0),
|
timestamp_diff_(0),
|
||||||
last_in_timestamp_(0),
|
last_in_timestamp_(0),
|
||||||
@ -56,9 +59,8 @@ TestPack::TestPack()
|
|||||||
|
|
||||||
TestPack::~TestPack() {}
|
TestPack::~TestPack() {}
|
||||||
|
|
||||||
void TestPack::RegisterReceiverACM(acm2::AcmReceiver* acm_receiver) {
|
void TestPack::RegisterReceiverNetEq(NetEq* neteq) {
|
||||||
receiver_acm_ = acm_receiver;
|
neteq_ = neteq;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t TestPack::SendData(AudioFrameType frame_type,
|
int32_t TestPack::SendData(AudioFrameType frame_type,
|
||||||
@ -84,7 +86,7 @@ int32_t TestPack::SendData(AudioFrameType frame_type,
|
|||||||
// Only run mono for all test cases.
|
// Only run mono for all test cases.
|
||||||
memcpy(payload_data_, payload_data, payload_size);
|
memcpy(payload_data_, payload_data, payload_size);
|
||||||
|
|
||||||
status = receiver_acm_->InsertPacket(
|
status = neteq_->InsertPacket(
|
||||||
rtp_header, rtc::ArrayView<const uint8_t>(payload_data_, payload_size),
|
rtp_header, rtc::ArrayView<const uint8_t>(payload_data_, payload_size),
|
||||||
/*receive_time=*/Timestamp::MinusInfinity());
|
/*receive_time=*/Timestamp::MinusInfinity());
|
||||||
|
|
||||||
@ -110,9 +112,9 @@ void TestPack::reset_payload_size() {
|
|||||||
TestAllCodecs::TestAllCodecs()
|
TestAllCodecs::TestAllCodecs()
|
||||||
: env_(CreateEnvironment()),
|
: env_(CreateEnvironment()),
|
||||||
acm_a_(AudioCodingModule::Create()),
|
acm_a_(AudioCodingModule::Create()),
|
||||||
acm_b_(std::make_unique<acm2::AcmReceiver>(
|
neteq_(DefaultNetEqFactory().Create(env_,
|
||||||
env_,
|
NetEq::Config(),
|
||||||
acm2::AcmReceiver::Config(CreateBuiltinAudioDecoderFactory()))),
|
CreateBuiltinAudioDecoderFactory())),
|
||||||
channel_a_to_b_(NULL),
|
channel_a_to_b_(NULL),
|
||||||
test_count_(0),
|
test_count_(0),
|
||||||
packet_size_samples_(0),
|
packet_size_samples_(0),
|
||||||
@ -130,7 +132,7 @@ void TestAllCodecs::Perform() {
|
|||||||
webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
|
webrtc::test::ResourcePath("audio_coding/testfile32kHz", "pcm");
|
||||||
infile_a_.Open(file_name, 32000, "rb");
|
infile_a_.Open(file_name, 32000, "rb");
|
||||||
|
|
||||||
acm_b_->SetCodecs({{107, {"L16", 8000, 1}},
|
neteq_->SetCodecs({{107, {"L16", 8000, 1}},
|
||||||
{108, {"L16", 16000, 1}},
|
{108, {"L16", 16000, 1}},
|
||||||
{109, {"L16", 32000, 1}},
|
{109, {"L16", 32000, 1}},
|
||||||
{111, {"L16", 8000, 2}},
|
{111, {"L16", 8000, 2}},
|
||||||
@ -151,7 +153,7 @@ void TestAllCodecs::Perform() {
|
|||||||
// Create and connect the channel
|
// Create and connect the channel
|
||||||
channel_a_to_b_ = new TestPack;
|
channel_a_to_b_ = new TestPack;
|
||||||
acm_a_->RegisterTransportCallback(channel_a_to_b_);
|
acm_a_->RegisterTransportCallback(channel_a_to_b_);
|
||||||
channel_a_to_b_->RegisterReceiverACM(acm_b_.get());
|
channel_a_to_b_->RegisterReceiverNetEq(neteq_.get());
|
||||||
|
|
||||||
// All codecs are tested for all allowed sampling frequencies, rates and
|
// All codecs are tested for all allowed sampling frequencies, rates and
|
||||||
// packet sizes.
|
// packet sizes.
|
||||||
@ -330,6 +332,7 @@ void TestAllCodecs::RegisterSendCodec(char* codec_name,
|
|||||||
|
|
||||||
void TestAllCodecs::Run(TestPack* channel) {
|
void TestAllCodecs::Run(TestPack* channel) {
|
||||||
AudioFrame audio_frame;
|
AudioFrame audio_frame;
|
||||||
|
acm2::ResamplerHelper resampler_helper;
|
||||||
|
|
||||||
int32_t out_freq_hz = outfile_b_.SamplingFrequency();
|
int32_t out_freq_hz = outfile_b_.SamplingFrequency();
|
||||||
size_t receive_size;
|
size_t receive_size;
|
||||||
@ -367,8 +370,9 @@ void TestAllCodecs::Run(TestPack* channel) {
|
|||||||
|
|
||||||
// Run received side of ACM.
|
// Run received side of ACM.
|
||||||
bool muted;
|
bool muted;
|
||||||
CHECK_ERROR(acm_b_->GetAudio(out_freq_hz, &audio_frame, &muted));
|
CHECK_ERROR(neteq_->GetAudio(&audio_frame, &muted));
|
||||||
ASSERT_FALSE(muted);
|
ASSERT_FALSE(muted);
|
||||||
|
EXPECT_TRUE(resampler_helper.MaybeResample(out_freq_hz, &audio_frame));
|
||||||
|
|
||||||
// Write output speech to file.
|
// Write output speech to file.
|
||||||
outfile_b_.Write10MsData(audio_frame.data(),
|
outfile_b_.Write10MsData(audio_frame.data(),
|
||||||
|
|||||||
@ -14,18 +14,19 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "api/environment/environment.h"
|
#include "api/environment/environment.h"
|
||||||
#include "modules/audio_coding/acm2/acm_receiver.h"
|
|
||||||
#include "modules/audio_coding/include/audio_coding_module.h"
|
#include "modules/audio_coding/include/audio_coding_module.h"
|
||||||
#include "modules/audio_coding/test/PCMFile.h"
|
#include "modules/audio_coding/test/PCMFile.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
|
class NetEq;
|
||||||
|
|
||||||
class TestPack : public AudioPacketizationCallback {
|
class TestPack : public AudioPacketizationCallback {
|
||||||
public:
|
public:
|
||||||
TestPack();
|
TestPack();
|
||||||
~TestPack();
|
~TestPack();
|
||||||
|
|
||||||
void RegisterReceiverACM(acm2::AcmReceiver* acm_receiver);
|
void RegisterReceiverNetEq(NetEq* neteq);
|
||||||
|
|
||||||
int32_t SendData(AudioFrameType frame_type,
|
int32_t SendData(AudioFrameType frame_type,
|
||||||
uint8_t payload_type,
|
uint8_t payload_type,
|
||||||
@ -39,7 +40,7 @@ class TestPack : public AudioPacketizationCallback {
|
|||||||
void reset_payload_size();
|
void reset_payload_size();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
acm2::AcmReceiver* receiver_acm_;
|
NetEq* neteq_;
|
||||||
uint16_t sequence_number_;
|
uint16_t sequence_number_;
|
||||||
uint8_t payload_data_[60 * 32 * 2 * 2];
|
uint8_t payload_data_[60 * 32 * 2 * 2];
|
||||||
uint32_t timestamp_diff_;
|
uint32_t timestamp_diff_;
|
||||||
@ -71,7 +72,7 @@ class TestAllCodecs {
|
|||||||
|
|
||||||
const Environment env_;
|
const Environment env_;
|
||||||
std::unique_ptr<AudioCodingModule> acm_a_;
|
std::unique_ptr<AudioCodingModule> acm_a_;
|
||||||
std::unique_ptr<acm2::AcmReceiver> acm_b_;
|
std::unique_ptr<NetEq> neteq_;
|
||||||
TestPack* channel_a_to_b_;
|
TestPack* channel_a_to_b_;
|
||||||
PCMFile infile_a_;
|
PCMFile infile_a_;
|
||||||
PCMFile outfile_b_;
|
PCMFile outfile_b_;
|
||||||
|
|||||||
@ -28,6 +28,7 @@
|
|||||||
#include "modules/audio_coding/codecs/cng/audio_encoder_cng.h"
|
#include "modules/audio_coding/codecs/cng/audio_encoder_cng.h"
|
||||||
#include "modules/audio_coding/codecs/red/audio_encoder_copy_red.h"
|
#include "modules/audio_coding/codecs/red/audio_encoder_copy_red.h"
|
||||||
#include "modules/audio_coding/include/audio_coding_module_typedefs.h"
|
#include "modules/audio_coding/include/audio_coding_module_typedefs.h"
|
||||||
|
#include "modules/audio_coding/neteq/default_neteq_factory.h"
|
||||||
#include "rtc_base/strings/string_builder.h"
|
#include "rtc_base/strings/string_builder.h"
|
||||||
#include "test/gtest.h"
|
#include "test/gtest.h"
|
||||||
#include "test/testsupport/file_utils.h"
|
#include "test/testsupport/file_utils.h"
|
||||||
@ -45,9 +46,9 @@ TestRedFec::TestRedFec()
|
|||||||
AudioDecoderL16,
|
AudioDecoderL16,
|
||||||
AudioDecoderOpus>()),
|
AudioDecoderOpus>()),
|
||||||
_acmA(AudioCodingModule::Create()),
|
_acmA(AudioCodingModule::Create()),
|
||||||
_acm_receiver(std::make_unique<acm2::AcmReceiver>(
|
_neteq(DefaultNetEqFactory().Create(env_,
|
||||||
env_,
|
NetEq::Config(),
|
||||||
acm2::AcmReceiver::Config(decoder_factory_))),
|
decoder_factory_)),
|
||||||
_channelA2B(NULL),
|
_channelA2B(NULL),
|
||||||
_testCntr(0) {}
|
_testCntr(0) {}
|
||||||
|
|
||||||
@ -66,7 +67,7 @@ void TestRedFec::Perform() {
|
|||||||
// Create and connect the channel
|
// Create and connect the channel
|
||||||
_channelA2B = new Channel;
|
_channelA2B = new Channel;
|
||||||
_acmA->RegisterTransportCallback(_channelA2B);
|
_acmA->RegisterTransportCallback(_channelA2B);
|
||||||
_channelA2B->RegisterReceiverACM(_acm_receiver.get());
|
_channelA2B->RegisterReceiverNetEq(_neteq.get());
|
||||||
|
|
||||||
RegisterSendCodec(_acmA, {"L16", 8000, 1}, Vad::kVadAggressive, true);
|
RegisterSendCodec(_acmA, {"L16", 8000, 1}, Vad::kVadAggressive, true);
|
||||||
|
|
||||||
@ -166,7 +167,7 @@ void TestRedFec::RegisterSendCodec(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
acm->SetEncoder(std::move(encoder));
|
acm->SetEncoder(std::move(encoder));
|
||||||
_acm_receiver->SetCodecs(receive_codecs);
|
_neteq->SetCodecs(receive_codecs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestRedFec::Run() {
|
void TestRedFec::Run() {
|
||||||
@ -181,7 +182,8 @@ void TestRedFec::Run() {
|
|||||||
EXPECT_GT(_inFileA.Read10MsData(audioFrame), 0);
|
EXPECT_GT(_inFileA.Read10MsData(audioFrame), 0);
|
||||||
EXPECT_GE(_acmA->Add10MsData(audioFrame), 0);
|
EXPECT_GE(_acmA->Add10MsData(audioFrame), 0);
|
||||||
bool muted;
|
bool muted;
|
||||||
EXPECT_EQ(0, _acm_receiver->GetAudio(outFreqHzB, &audioFrame, &muted));
|
EXPECT_EQ(NetEq::kOK, _neteq->GetAudio(&audioFrame, &muted));
|
||||||
|
EXPECT_TRUE(_resampler_helper.MaybeResample(outFreqHzB, &audioFrame));
|
||||||
ASSERT_FALSE(muted);
|
ASSERT_FALSE(muted);
|
||||||
_outFileB.Write10MsData(audioFrame.data(), audioFrame.samples_per_channel_);
|
_outFileB.Write10MsData(audioFrame.data(), audioFrame.samples_per_channel_);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,8 +17,9 @@
|
|||||||
#include "api/audio_codecs/audio_decoder_factory.h"
|
#include "api/audio_codecs/audio_decoder_factory.h"
|
||||||
#include "api/audio_codecs/audio_encoder_factory.h"
|
#include "api/audio_codecs/audio_encoder_factory.h"
|
||||||
#include "api/environment/environment.h"
|
#include "api/environment/environment.h"
|
||||||
|
#include "api/neteq/neteq.h"
|
||||||
#include "common_audio/vad/include/vad.h"
|
#include "common_audio/vad/include/vad.h"
|
||||||
#include "modules/audio_coding/acm2/acm_receiver.h"
|
#include "modules/audio_coding/acm2/acm_resampler.h"
|
||||||
#include "modules/audio_coding/test/Channel.h"
|
#include "modules/audio_coding/test/Channel.h"
|
||||||
#include "modules/audio_coding/test/PCMFile.h"
|
#include "modules/audio_coding/test/PCMFile.h"
|
||||||
#include "test/scoped_key_value_config.h"
|
#include "test/scoped_key_value_config.h"
|
||||||
@ -45,7 +46,8 @@ class TestRedFec final {
|
|||||||
const rtc::scoped_refptr<AudioEncoderFactory> encoder_factory_;
|
const rtc::scoped_refptr<AudioEncoderFactory> encoder_factory_;
|
||||||
const rtc::scoped_refptr<AudioDecoderFactory> decoder_factory_;
|
const rtc::scoped_refptr<AudioDecoderFactory> decoder_factory_;
|
||||||
std::unique_ptr<AudioCodingModule> _acmA;
|
std::unique_ptr<AudioCodingModule> _acmA;
|
||||||
std::unique_ptr<acm2::AcmReceiver> _acm_receiver;
|
std::unique_ptr<NetEq> _neteq;
|
||||||
|
acm2::ResamplerHelper _resampler_helper;
|
||||||
|
|
||||||
Channel* _channelA2B;
|
Channel* _channelA2B;
|
||||||
|
|
||||||
|
|||||||
@ -17,6 +17,7 @@
|
|||||||
#include "api/audio_codecs/builtin_audio_encoder_factory.h"
|
#include "api/audio_codecs/builtin_audio_encoder_factory.h"
|
||||||
#include "api/environment/environment_factory.h"
|
#include "api/environment/environment_factory.h"
|
||||||
#include "modules/audio_coding/include/audio_coding_module_typedefs.h"
|
#include "modules/audio_coding/include/audio_coding_module_typedefs.h"
|
||||||
|
#include "modules/audio_coding/neteq/default_neteq_factory.h"
|
||||||
#include "modules/include/module_common_types.h"
|
#include "modules/include/module_common_types.h"
|
||||||
#include "rtc_base/strings/string_builder.h"
|
#include "rtc_base/strings/string_builder.h"
|
||||||
#include "test/gtest.h"
|
#include "test/gtest.h"
|
||||||
@ -26,7 +27,7 @@ namespace webrtc {
|
|||||||
|
|
||||||
// Class for simulating packet handling
|
// Class for simulating packet handling
|
||||||
TestPackStereo::TestPackStereo()
|
TestPackStereo::TestPackStereo()
|
||||||
: receiver_acm_(NULL),
|
: neteq_(NULL),
|
||||||
seq_no_(0),
|
seq_no_(0),
|
||||||
timestamp_diff_(0),
|
timestamp_diff_(0),
|
||||||
last_in_timestamp_(0),
|
last_in_timestamp_(0),
|
||||||
@ -36,8 +37,8 @@ TestPackStereo::TestPackStereo()
|
|||||||
|
|
||||||
TestPackStereo::~TestPackStereo() {}
|
TestPackStereo::~TestPackStereo() {}
|
||||||
|
|
||||||
void TestPackStereo::RegisterReceiverACM(acm2::AcmReceiver* acm_receiver) {
|
void TestPackStereo::RegisterReceiverNetEq(NetEq* neteq) {
|
||||||
receiver_acm_ = acm_receiver;
|
neteq_ = neteq;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,7 +62,7 @@ int32_t TestPackStereo::SendData(const AudioFrameType frame_type,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (lost_packet_ == false) {
|
if (lost_packet_ == false) {
|
||||||
status = receiver_acm_->InsertPacket(
|
status = neteq_->InsertPacket(
|
||||||
rtp_header, rtc::ArrayView<const uint8_t>(payload_data, payload_size),
|
rtp_header, rtc::ArrayView<const uint8_t>(payload_data, payload_size),
|
||||||
/*receive_time=*/Timestamp::MinusInfinity());
|
/*receive_time=*/Timestamp::MinusInfinity());
|
||||||
|
|
||||||
@ -101,9 +102,9 @@ void TestPackStereo::set_lost_packet(bool lost) {
|
|||||||
TestStereo::TestStereo()
|
TestStereo::TestStereo()
|
||||||
: env_(CreateEnvironment()),
|
: env_(CreateEnvironment()),
|
||||||
acm_a_(AudioCodingModule::Create()),
|
acm_a_(AudioCodingModule::Create()),
|
||||||
acm_b_(std::make_unique<acm2::AcmReceiver>(
|
neteq_(DefaultNetEqFactory().Create(env_,
|
||||||
env_,
|
NetEq::Config(),
|
||||||
acm2::AcmReceiver::Config(CreateBuiltinAudioDecoderFactory()))),
|
CreateBuiltinAudioDecoderFactory())),
|
||||||
channel_a2b_(NULL),
|
channel_a2b_(NULL),
|
||||||
test_cntr_(0),
|
test_cntr_(0),
|
||||||
pack_size_samp_(0),
|
pack_size_samp_(0),
|
||||||
@ -136,10 +137,10 @@ void TestStereo::Perform() {
|
|||||||
in_file_mono_->ReadStereo(false);
|
in_file_mono_->ReadStereo(false);
|
||||||
|
|
||||||
// Create and initialize two ACMs, one for each side of a one-to-one call.
|
// Create and initialize two ACMs, one for each side of a one-to-one call.
|
||||||
ASSERT_TRUE((acm_a_.get() != NULL) && (acm_b_.get() != NULL));
|
ASSERT_TRUE((acm_a_.get() != NULL) && (neteq_.get() != NULL));
|
||||||
acm_b_->FlushBuffers();
|
neteq_->FlushBuffers();
|
||||||
|
|
||||||
acm_b_->SetCodecs({{103, {"ISAC", 16000, 1}},
|
neteq_->SetCodecs({{103, {"ISAC", 16000, 1}},
|
||||||
{104, {"ISAC", 32000, 1}},
|
{104, {"ISAC", 32000, 1}},
|
||||||
{107, {"L16", 8000, 1}},
|
{107, {"L16", 8000, 1}},
|
||||||
{108, {"L16", 16000, 1}},
|
{108, {"L16", 16000, 1}},
|
||||||
@ -162,7 +163,7 @@ void TestStereo::Perform() {
|
|||||||
// Create and connect the channel.
|
// Create and connect the channel.
|
||||||
channel_a2b_ = new TestPackStereo;
|
channel_a2b_ = new TestPackStereo;
|
||||||
EXPECT_EQ(0, acm_a_->RegisterTransportCallback(channel_a2b_));
|
EXPECT_EQ(0, acm_a_->RegisterTransportCallback(channel_a2b_));
|
||||||
channel_a2b_->RegisterReceiverACM(acm_b_.get());
|
channel_a2b_->RegisterReceiverNetEq(neteq_.get());
|
||||||
|
|
||||||
char codec_pcma_temp[] = "PCMA";
|
char codec_pcma_temp[] = "PCMA";
|
||||||
RegisterSendCodec('A', codec_pcma_temp, 8000, 64000, 80, 2);
|
RegisterSendCodec('A', codec_pcma_temp, 8000, 64000, 80, 2);
|
||||||
@ -400,7 +401,7 @@ void TestStereo::Perform() {
|
|||||||
OpenOutFile(test_cntr_);
|
OpenOutFile(test_cntr_);
|
||||||
// Encode and decode in mono.
|
// Encode and decode in mono.
|
||||||
RegisterSendCodec('A', codec_opus, 48000, 32000, 960, codec_channels);
|
RegisterSendCodec('A', codec_opus, 48000, 32000, 960, codec_channels);
|
||||||
acm_b_->SetCodecs({{120, {"OPUS", 48000, 2}}});
|
neteq_->SetCodecs({{120, {"OPUS", 48000, 2}}});
|
||||||
Run(channel_a2b_, audio_channels, codec_channels);
|
Run(channel_a2b_, audio_channels, codec_channels);
|
||||||
|
|
||||||
// Encode in stereo, decode in mono.
|
// Encode in stereo, decode in mono.
|
||||||
@ -419,13 +420,13 @@ void TestStereo::Perform() {
|
|||||||
// Decode in stereo.
|
// Decode in stereo.
|
||||||
test_cntr_++;
|
test_cntr_++;
|
||||||
OpenOutFile(test_cntr_);
|
OpenOutFile(test_cntr_);
|
||||||
acm_b_->SetCodecs({{120, {"OPUS", 48000, 2, {{"stereo", "1"}}}}});
|
neteq_->SetCodecs({{120, {"OPUS", 48000, 2, {{"stereo", "1"}}}}});
|
||||||
Run(channel_a2b_, audio_channels, 2);
|
Run(channel_a2b_, audio_channels, 2);
|
||||||
out_file_.Close();
|
out_file_.Close();
|
||||||
// Decode in mono.
|
// Decode in mono.
|
||||||
test_cntr_++;
|
test_cntr_++;
|
||||||
OpenOutFile(test_cntr_);
|
OpenOutFile(test_cntr_);
|
||||||
acm_b_->SetCodecs({{120, {"OPUS", 48000, 2}}});
|
neteq_->SetCodecs({{120, {"OPUS", 48000, 2}}});
|
||||||
Run(channel_a2b_, audio_channels, codec_channels);
|
Run(channel_a2b_, audio_channels, codec_channels);
|
||||||
out_file_.Close();
|
out_file_.Close();
|
||||||
#endif
|
#endif
|
||||||
@ -468,7 +469,7 @@ void TestStereo::RegisterSendCodec(char side,
|
|||||||
case 'B': {
|
case 'B': {
|
||||||
// We no longer use this case. Refactor code to avoid the switch.
|
// We no longer use this case. Refactor code to avoid the switch.
|
||||||
ASSERT_TRUE(false);
|
ASSERT_TRUE(false);
|
||||||
// my_acm = acm_b_.get();
|
// my_acm = neteq_.get();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -571,7 +572,8 @@ void TestStereo::Run(TestPackStereo* channel,
|
|||||||
|
|
||||||
// Run receive side of ACM
|
// Run receive side of ACM
|
||||||
bool muted;
|
bool muted;
|
||||||
EXPECT_EQ(0, acm_b_->GetAudio(out_freq_hz_b, &audio_frame, &muted));
|
EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&audio_frame, &muted));
|
||||||
|
EXPECT_TRUE(resampler_helper_.MaybeResample(out_freq_hz_b, &audio_frame));
|
||||||
ASSERT_FALSE(muted);
|
ASSERT_FALSE(muted);
|
||||||
|
|
||||||
// Write output speech to file
|
// Write output speech to file
|
||||||
|
|||||||
@ -16,7 +16,8 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "api/environment/environment.h"
|
#include "api/environment/environment.h"
|
||||||
#include "modules/audio_coding/acm2/acm_receiver.h"
|
#include "api/neteq/neteq.h"
|
||||||
|
#include "modules/audio_coding/acm2/acm_resampler.h"
|
||||||
#include "modules/audio_coding/include/audio_coding_module.h"
|
#include "modules/audio_coding/include/audio_coding_module.h"
|
||||||
#include "modules/audio_coding/test/PCMFile.h"
|
#include "modules/audio_coding/test/PCMFile.h"
|
||||||
|
|
||||||
@ -31,7 +32,7 @@ class TestPackStereo : public AudioPacketizationCallback {
|
|||||||
TestPackStereo();
|
TestPackStereo();
|
||||||
~TestPackStereo();
|
~TestPackStereo();
|
||||||
|
|
||||||
void RegisterReceiverACM(acm2::AcmReceiver* acm_receiver);
|
void RegisterReceiverNetEq(NetEq* neteq);
|
||||||
|
|
||||||
int32_t SendData(AudioFrameType frame_type,
|
int32_t SendData(AudioFrameType frame_type,
|
||||||
uint8_t payload_type,
|
uint8_t payload_type,
|
||||||
@ -47,7 +48,7 @@ class TestPackStereo : public AudioPacketizationCallback {
|
|||||||
void set_lost_packet(bool lost);
|
void set_lost_packet(bool lost);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
acm2::AcmReceiver* receiver_acm_;
|
NetEq* neteq_;
|
||||||
int16_t seq_no_;
|
int16_t seq_no_;
|
||||||
uint32_t timestamp_diff_;
|
uint32_t timestamp_diff_;
|
||||||
uint32_t last_in_timestamp_;
|
uint32_t last_in_timestamp_;
|
||||||
@ -84,7 +85,8 @@ class TestStereo {
|
|||||||
|
|
||||||
const Environment env_;
|
const Environment env_;
|
||||||
std::unique_ptr<AudioCodingModule> acm_a_;
|
std::unique_ptr<AudioCodingModule> acm_a_;
|
||||||
std::unique_ptr<acm2::AcmReceiver> acm_b_;
|
std::unique_ptr<NetEq> neteq_;
|
||||||
|
acm2::ResamplerHelper resampler_helper_;
|
||||||
|
|
||||||
TestPackStereo* channel_a2b_;
|
TestPackStereo* channel_a2b_;
|
||||||
|
|
||||||
|
|||||||
@ -22,6 +22,7 @@
|
|||||||
#include "api/audio_codecs/opus/audio_encoder_opus.h"
|
#include "api/audio_codecs/opus/audio_encoder_opus.h"
|
||||||
#include "api/environment/environment_factory.h"
|
#include "api/environment/environment_factory.h"
|
||||||
#include "modules/audio_coding/codecs/cng/audio_encoder_cng.h"
|
#include "modules/audio_coding/codecs/cng/audio_encoder_cng.h"
|
||||||
|
#include "modules/audio_coding/neteq/default_neteq_factory.h"
|
||||||
#include "modules/audio_coding/test/PCMFile.h"
|
#include "modules/audio_coding/test/PCMFile.h"
|
||||||
#include "rtc_base/strings/string_builder.h"
|
#include "rtc_base/strings/string_builder.h"
|
||||||
#include "test/gtest.h"
|
#include "test/gtest.h"
|
||||||
@ -73,16 +74,16 @@ TestVadDtx::TestVadDtx()
|
|||||||
decoder_factory_(
|
decoder_factory_(
|
||||||
CreateAudioDecoderFactory<AudioDecoderIlbc, AudioDecoderOpus>()),
|
CreateAudioDecoderFactory<AudioDecoderIlbc, AudioDecoderOpus>()),
|
||||||
acm_send_(AudioCodingModule::Create()),
|
acm_send_(AudioCodingModule::Create()),
|
||||||
acm_receive_(std::make_unique<acm2::AcmReceiver>(
|
neteq_(DefaultNetEqFactory().Create(env_,
|
||||||
env_,
|
NetEq::Config(),
|
||||||
acm2::AcmReceiver::Config(decoder_factory_))),
|
decoder_factory_)),
|
||||||
channel_(std::make_unique<Channel>()),
|
channel_(std::make_unique<Channel>()),
|
||||||
packetization_callback_(
|
packetization_callback_(
|
||||||
std::make_unique<MonitoringAudioPacketizationCallback>(
|
std::make_unique<MonitoringAudioPacketizationCallback>(
|
||||||
channel_.get())) {
|
channel_.get())) {
|
||||||
EXPECT_EQ(
|
EXPECT_EQ(
|
||||||
0, acm_send_->RegisterTransportCallback(packetization_callback_.get()));
|
0, acm_send_->RegisterTransportCallback(packetization_callback_.get()));
|
||||||
channel_->RegisterReceiverACM(acm_receive_.get());
|
channel_->RegisterReceiverNetEq(neteq_.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TestVadDtx::RegisterCodec(const SdpAudioFormat& codec_format,
|
bool TestVadDtx::RegisterCodec(const SdpAudioFormat& codec_format,
|
||||||
@ -106,7 +107,7 @@ bool TestVadDtx::RegisterCodec(const SdpAudioFormat& codec_format,
|
|||||||
acm_send_->SetEncoder(std::move(encoder));
|
acm_send_->SetEncoder(std::move(encoder));
|
||||||
|
|
||||||
std::map<int, SdpAudioFormat> receive_codecs = {{payload_type, codec_format}};
|
std::map<int, SdpAudioFormat> receive_codecs = {{payload_type, codec_format}};
|
||||||
acm_receive_->SetCodecs(receive_codecs);
|
neteq_->SetCodecs(receive_codecs);
|
||||||
|
|
||||||
return added_comfort_noise;
|
return added_comfort_noise;
|
||||||
}
|
}
|
||||||
@ -145,7 +146,8 @@ void TestVadDtx::Run(absl::string_view in_filename,
|
|||||||
time_stamp_ += frame_size_samples;
|
time_stamp_ += frame_size_samples;
|
||||||
EXPECT_GE(acm_send_->Add10MsData(audio_frame), 0);
|
EXPECT_GE(acm_send_->Add10MsData(audio_frame), 0);
|
||||||
bool muted;
|
bool muted;
|
||||||
acm_receive_->GetAudio(kOutputFreqHz, &audio_frame, &muted);
|
neteq_->GetAudio(&audio_frame, &muted);
|
||||||
|
resampler_helper_.MaybeResample(kOutputFreqHz, &audio_frame);
|
||||||
ASSERT_FALSE(muted);
|
ASSERT_FALSE(muted);
|
||||||
out_file.Write10MsData(audio_frame);
|
out_file.Write10MsData(audio_frame);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,8 +17,9 @@
|
|||||||
#include "api/audio_codecs/audio_decoder_factory.h"
|
#include "api/audio_codecs/audio_decoder_factory.h"
|
||||||
#include "api/audio_codecs/audio_encoder_factory.h"
|
#include "api/audio_codecs/audio_encoder_factory.h"
|
||||||
#include "api/environment/environment.h"
|
#include "api/environment/environment.h"
|
||||||
|
#include "api/neteq/neteq.h"
|
||||||
#include "common_audio/vad/include/vad.h"
|
#include "common_audio/vad/include/vad.h"
|
||||||
#include "modules/audio_coding/acm2/acm_receiver.h"
|
#include "modules/audio_coding/acm2/acm_resampler.h"
|
||||||
#include "modules/audio_coding/include/audio_coding_module.h"
|
#include "modules/audio_coding/include/audio_coding_module.h"
|
||||||
#include "modules/audio_coding/include/audio_coding_module_typedefs.h"
|
#include "modules/audio_coding/include/audio_coding_module_typedefs.h"
|
||||||
#include "modules/audio_coding/test/Channel.h"
|
#include "modules/audio_coding/test/Channel.h"
|
||||||
@ -87,7 +88,8 @@ class TestVadDtx {
|
|||||||
const rtc::scoped_refptr<AudioEncoderFactory> encoder_factory_;
|
const rtc::scoped_refptr<AudioEncoderFactory> encoder_factory_;
|
||||||
const rtc::scoped_refptr<AudioDecoderFactory> decoder_factory_;
|
const rtc::scoped_refptr<AudioDecoderFactory> decoder_factory_;
|
||||||
std::unique_ptr<AudioCodingModule> acm_send_;
|
std::unique_ptr<AudioCodingModule> acm_send_;
|
||||||
std::unique_ptr<acm2::AcmReceiver> acm_receive_;
|
std::unique_ptr<NetEq> neteq_;
|
||||||
|
acm2::ResamplerHelper resampler_helper_;
|
||||||
std::unique_ptr<Channel> channel_;
|
std::unique_ptr<Channel> channel_;
|
||||||
std::unique_ptr<MonitoringAudioPacketizationCallback> packetization_callback_;
|
std::unique_ptr<MonitoringAudioPacketizationCallback> packetization_callback_;
|
||||||
uint32_t time_stamp_ = 0x12345678;
|
uint32_t time_stamp_ = 0x12345678;
|
||||||
|
|||||||
@ -16,6 +16,7 @@
|
|||||||
#include "api/environment/environment_factory.h"
|
#include "api/environment/environment_factory.h"
|
||||||
#include "modules/audio_coding/codecs/opus/opus_interface.h"
|
#include "modules/audio_coding/codecs/opus/opus_interface.h"
|
||||||
#include "modules/audio_coding/include/audio_coding_module_typedefs.h"
|
#include "modules/audio_coding/include/audio_coding_module_typedefs.h"
|
||||||
|
#include "modules/audio_coding/neteq/default_neteq_factory.h"
|
||||||
#include "modules/audio_coding/test/TestStereo.h"
|
#include "modules/audio_coding/test/TestStereo.h"
|
||||||
#include "test/gtest.h"
|
#include "test/gtest.h"
|
||||||
#include "test/testsupport/file_utils.h"
|
#include "test/testsupport/file_utils.h"
|
||||||
@ -23,9 +24,9 @@
|
|||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
OpusTest::OpusTest()
|
OpusTest::OpusTest()
|
||||||
: acm_receiver_(std::make_unique<acm2::AcmReceiver>(
|
: neteq_(DefaultNetEqFactory().Create(CreateEnvironment(),
|
||||||
CreateEnvironment(),
|
NetEq::Config(),
|
||||||
acm2::AcmReceiver::Config(CreateBuiltinAudioDecoderFactory()))),
|
CreateBuiltinAudioDecoderFactory())),
|
||||||
channel_a2b_(NULL),
|
channel_a2b_(NULL),
|
||||||
counter_(0),
|
counter_(0),
|
||||||
payload_type_(255),
|
payload_type_(255),
|
||||||
@ -84,18 +85,18 @@ void OpusTest::Perform() {
|
|||||||
WebRtcOpus_DecoderInit(opus_mono_decoder_);
|
WebRtcOpus_DecoderInit(opus_mono_decoder_);
|
||||||
WebRtcOpus_DecoderInit(opus_stereo_decoder_);
|
WebRtcOpus_DecoderInit(opus_stereo_decoder_);
|
||||||
|
|
||||||
ASSERT_TRUE(acm_receiver_.get() != NULL);
|
ASSERT_TRUE(neteq_.get() != NULL);
|
||||||
acm_receiver_->FlushBuffers();
|
neteq_->FlushBuffers();
|
||||||
|
|
||||||
// Register Opus stereo as receiving codec.
|
// Register Opus stereo as receiving codec.
|
||||||
constexpr int kOpusPayloadType = 120;
|
constexpr int kOpusPayloadType = 120;
|
||||||
const SdpAudioFormat kOpusFormatStereo("opus", 48000, 2, {{"stereo", "1"}});
|
const SdpAudioFormat kOpusFormatStereo("opus", 48000, 2, {{"stereo", "1"}});
|
||||||
payload_type_ = kOpusPayloadType;
|
payload_type_ = kOpusPayloadType;
|
||||||
acm_receiver_->SetCodecs({{kOpusPayloadType, kOpusFormatStereo}});
|
neteq_->SetCodecs({{kOpusPayloadType, kOpusFormatStereo}});
|
||||||
|
|
||||||
// Create and connect the channel.
|
// Create and connect the channel.
|
||||||
channel_a2b_ = new TestPackStereo;
|
channel_a2b_ = new TestPackStereo;
|
||||||
channel_a2b_->RegisterReceiverACM(acm_receiver_.get());
|
channel_a2b_->RegisterReceiverNetEq(neteq_.get());
|
||||||
|
|
||||||
//
|
//
|
||||||
// Test Stereo.
|
// Test Stereo.
|
||||||
@ -156,7 +157,7 @@ void OpusTest::Perform() {
|
|||||||
|
|
||||||
// Register Opus mono as receiving codec.
|
// Register Opus mono as receiving codec.
|
||||||
const SdpAudioFormat kOpusFormatMono("opus", 48000, 2);
|
const SdpAudioFormat kOpusFormatMono("opus", 48000, 2);
|
||||||
acm_receiver_->SetCodecs({{kOpusPayloadType, kOpusFormatMono}});
|
neteq_->SetCodecs({{kOpusPayloadType, kOpusFormatMono}});
|
||||||
|
|
||||||
// Run Opus with 2.5 ms frame size.
|
// Run Opus with 2.5 ms frame size.
|
||||||
Run(channel_a2b_, audio_channels, 32000, 120);
|
Run(channel_a2b_, audio_channels, 32000, 120);
|
||||||
@ -355,8 +356,8 @@ void OpusTest::Run(TestPackStereo* channel,
|
|||||||
|
|
||||||
// Run received side of ACM.
|
// Run received side of ACM.
|
||||||
bool muted;
|
bool muted;
|
||||||
ASSERT_EQ(0, acm_receiver_->GetAudio(out_freq_hz_b, &audio_frame, &muted));
|
ASSERT_EQ(NetEq::kOK, neteq_->GetAudio(&audio_frame, &muted));
|
||||||
ASSERT_FALSE(muted);
|
ASSERT_TRUE(resampler_helper_.MaybeResample(out_freq_hz_b, &audio_frame));
|
||||||
|
|
||||||
// Write output speech to file.
|
// Write output speech to file.
|
||||||
out_file_.Write10MsData(
|
out_file_.Write10MsData(
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "modules/audio_coding/acm2/acm_receiver.h"
|
#include "api/neteq/neteq.h"
|
||||||
#include "modules/audio_coding/acm2/acm_resampler.h"
|
#include "modules/audio_coding/acm2/acm_resampler.h"
|
||||||
#include "modules/audio_coding/codecs/opus/opus_interface.h"
|
#include "modules/audio_coding/codecs/opus/opus_interface.h"
|
||||||
#include "modules/audio_coding/test/PCMFile.h"
|
#include "modules/audio_coding/test/PCMFile.h"
|
||||||
@ -39,7 +39,8 @@ class OpusTest {
|
|||||||
|
|
||||||
void OpenOutFile(int test_number);
|
void OpenOutFile(int test_number);
|
||||||
|
|
||||||
std::unique_ptr<acm2::AcmReceiver> acm_receiver_;
|
std::unique_ptr<NetEq> neteq_;
|
||||||
|
acm2::ResamplerHelper resampler_helper_;
|
||||||
TestPackStereo* channel_a2b_;
|
TestPackStereo* channel_a2b_;
|
||||||
PCMFile in_file_stereo_;
|
PCMFile in_file_stereo_;
|
||||||
PCMFile in_file_mono_;
|
PCMFile in_file_mono_;
|
||||||
|
|||||||
@ -15,9 +15,9 @@
|
|||||||
#include "api/environment/environment_factory.h"
|
#include "api/environment/environment_factory.h"
|
||||||
#include "api/rtp_headers.h"
|
#include "api/rtp_headers.h"
|
||||||
#include "api/units/timestamp.h"
|
#include "api/units/timestamp.h"
|
||||||
#include "modules/audio_coding/acm2/acm_receiver.h"
|
|
||||||
#include "modules/audio_coding/codecs/pcm16b/pcm16b.h"
|
#include "modules/audio_coding/codecs/pcm16b/pcm16b.h"
|
||||||
#include "modules/audio_coding/include/audio_coding_module.h"
|
#include "modules/audio_coding/include/audio_coding_module.h"
|
||||||
|
#include "modules/audio_coding/neteq/default_neteq_factory.h"
|
||||||
#include "test/gtest.h"
|
#include "test/gtest.h"
|
||||||
#include "test/testsupport/file_utils.h"
|
#include "test/testsupport/file_utils.h"
|
||||||
|
|
||||||
@ -26,9 +26,10 @@ namespace webrtc {
|
|||||||
class TargetDelayTest : public ::testing::Test {
|
class TargetDelayTest : public ::testing::Test {
|
||||||
protected:
|
protected:
|
||||||
TargetDelayTest()
|
TargetDelayTest()
|
||||||
: receiver_(
|
: neteq_(
|
||||||
CreateEnvironment(),
|
DefaultNetEqFactory().Create(CreateEnvironment(),
|
||||||
acm2::AcmReceiver::Config(CreateBuiltinAudioDecoderFactory())) {}
|
NetEq::Config(),
|
||||||
|
CreateBuiltinAudioDecoderFactory())) {}
|
||||||
|
|
||||||
~TargetDelayTest() {}
|
~TargetDelayTest() {}
|
||||||
|
|
||||||
@ -36,7 +37,7 @@ class TargetDelayTest : public ::testing::Test {
|
|||||||
constexpr int pltype = 108;
|
constexpr int pltype = 108;
|
||||||
std::map<int, SdpAudioFormat> receive_codecs = {
|
std::map<int, SdpAudioFormat> receive_codecs = {
|
||||||
{pltype, {"L16", kSampleRateHz, 1}}};
|
{pltype, {"L16", kSampleRateHz, 1}}};
|
||||||
receiver_.SetCodecs(receive_codecs);
|
neteq_->SetCodecs(receive_codecs);
|
||||||
|
|
||||||
rtp_header_.payloadType = pltype;
|
rtp_header_.payloadType = pltype;
|
||||||
rtp_header_.timestamp = 0;
|
rtp_header_.timestamp = 0;
|
||||||
@ -52,20 +53,20 @@ class TargetDelayTest : public ::testing::Test {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void OutOfRangeInput() {
|
void OutOfRangeInput() {
|
||||||
EXPECT_EQ(-1, SetMinimumDelay(-1));
|
EXPECT_FALSE(SetMinimumDelay(-1));
|
||||||
EXPECT_EQ(-1, SetMinimumDelay(10001));
|
EXPECT_FALSE(SetMinimumDelay(10001));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TargetDelayBufferMinMax() {
|
void TargetDelayBufferMinMax() {
|
||||||
const int kTargetMinDelayMs = kNum10msPerFrame * 10;
|
const int kTargetMinDelayMs = kNum10msPerFrame * 10;
|
||||||
ASSERT_EQ(0, SetMinimumDelay(kTargetMinDelayMs));
|
ASSERT_TRUE(SetMinimumDelay(kTargetMinDelayMs));
|
||||||
for (int m = 0; m < 30; ++m) // Run enough iterations to fill the buffer.
|
for (int m = 0; m < 30; ++m) // Run enough iterations to fill the buffer.
|
||||||
Run(true);
|
Run(true);
|
||||||
int clean_optimal_delay = GetCurrentOptimalDelayMs();
|
int clean_optimal_delay = GetCurrentOptimalDelayMs();
|
||||||
EXPECT_EQ(kTargetMinDelayMs, clean_optimal_delay);
|
EXPECT_EQ(kTargetMinDelayMs, clean_optimal_delay);
|
||||||
|
|
||||||
const int kTargetMaxDelayMs = 2 * (kNum10msPerFrame * 10);
|
const int kTargetMaxDelayMs = 2 * (kNum10msPerFrame * 10);
|
||||||
ASSERT_EQ(0, SetMaximumDelay(kTargetMaxDelayMs));
|
ASSERT_TRUE(SetMaximumDelay(kTargetMaxDelayMs));
|
||||||
for (int n = 0; n < 30; ++n) // Run enough iterations to fill the buffer.
|
for (int n = 0; n < 30; ++n) // Run enough iterations to fill the buffer.
|
||||||
Run(false);
|
Run(false);
|
||||||
|
|
||||||
@ -86,10 +87,10 @@ class TargetDelayTest : public ::testing::Test {
|
|||||||
void Push() {
|
void Push() {
|
||||||
rtp_header_.timestamp += kFrameSizeSamples;
|
rtp_header_.timestamp += kFrameSizeSamples;
|
||||||
rtp_header_.sequenceNumber++;
|
rtp_header_.sequenceNumber++;
|
||||||
ASSERT_EQ(0, receiver_.InsertPacket(rtp_header_,
|
ASSERT_EQ(0, neteq_->InsertPacket(rtp_header_,
|
||||||
rtc::ArrayView<const uint8_t>(
|
rtc::ArrayView<const uint8_t>(
|
||||||
payload_, kFrameSizeSamples * 2),
|
payload_, kFrameSizeSamples * 2),
|
||||||
Timestamp::MinusInfinity()));
|
Timestamp::MinusInfinity()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pull audio equivalent to the amount of audio in one RTP packet.
|
// Pull audio equivalent to the amount of audio in one RTP packet.
|
||||||
@ -97,7 +98,7 @@ class TargetDelayTest : public ::testing::Test {
|
|||||||
AudioFrame frame;
|
AudioFrame frame;
|
||||||
bool muted;
|
bool muted;
|
||||||
for (int k = 0; k < kNum10msPerFrame; ++k) { // Pull one frame.
|
for (int k = 0; k < kNum10msPerFrame; ++k) { // Pull one frame.
|
||||||
ASSERT_EQ(0, receiver_.GetAudio(-1, &frame, &muted));
|
ASSERT_EQ(NetEq::kOK, neteq_->GetAudio(&frame, &muted));
|
||||||
ASSERT_FALSE(muted);
|
ASSERT_FALSE(muted);
|
||||||
// Had to use ASSERT_TRUE, ASSERT_EQ generated error.
|
// Had to use ASSERT_TRUE, ASSERT_EQ generated error.
|
||||||
ASSERT_TRUE(kSampleRateHz == frame.sample_rate_hz_);
|
ASSERT_TRUE(kSampleRateHz == frame.sample_rate_hz_);
|
||||||
@ -124,20 +125,20 @@ class TargetDelayTest : public ::testing::Test {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int SetMinimumDelay(int delay_ms) {
|
int SetMinimumDelay(int delay_ms) {
|
||||||
return receiver_.SetMinimumDelay(delay_ms);
|
return neteq_->SetMinimumDelay(delay_ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
int SetMaximumDelay(int delay_ms) {
|
int SetMaximumDelay(int delay_ms) {
|
||||||
return receiver_.SetMaximumDelay(delay_ms);
|
return neteq_->SetMaximumDelay(delay_ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetCurrentOptimalDelayMs() {
|
int GetCurrentOptimalDelayMs() {
|
||||||
NetworkStatistics stats;
|
NetEqNetworkStatistics neteq_stats;
|
||||||
receiver_.GetNetworkStatistics(&stats);
|
neteq_->NetworkStatistics(&neteq_stats);
|
||||||
return stats.preferredBufferSize;
|
return neteq_stats.preferred_buffer_size_ms;
|
||||||
}
|
}
|
||||||
|
|
||||||
acm2::AcmReceiver receiver_;
|
std::unique_ptr<NetEq> neteq_;
|
||||||
RTPHeader rtp_header_;
|
RTPHeader rtp_header_;
|
||||||
uint8_t payload_[kPayloadLenBytes];
|
uint8_t payload_[kPayloadLenBytes];
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user