AudioCodingModuleTest.TestAllCodecs: Create audio encoders the new way
Specifically, don't expect the ACM to be able to create encoders; we have to give it an encoder that we make ourselves. To make it work, I had to add support for the "ptime" parameter to the L16 codec. Bug: webrtc:8396 Change-Id: I3869422882611d2eed65d6c849ea7cd3ad6bd126 Reviewed-on: https://webrtc-review.googlesource.com/87423 Reviewed-by: Oskar Sundbom <ossu@webrtc.org> Commit-Queue: Karl Wiberg <kwiberg@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24217}
This commit is contained in:
@ -24,6 +24,7 @@ rtc_static_library("audio_encoder_L16") {
|
||||
"../../..:webrtc_common",
|
||||
"../../../modules/audio_coding:pcm16b",
|
||||
"../../../rtc_base:rtc_base_approved",
|
||||
"../../../rtc_base:safe_minmax",
|
||||
"//third_party/abseil-cpp/absl/memory",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
]
|
||||
|
||||
@ -15,6 +15,8 @@
|
||||
#include "modules/audio_coding/codecs/pcm16b/audio_encoder_pcm16b.h"
|
||||
#include "modules/audio_coding/codecs/pcm16b/pcm16b_common.h"
|
||||
#include "rtc_base/numerics/safe_conversions.h"
|
||||
#include "rtc_base/numerics/safe_minmax.h"
|
||||
#include "rtc_base/string_to_number.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -26,6 +28,13 @@ absl::optional<AudioEncoderL16::Config> AudioEncoderL16::SdpToConfig(
|
||||
Config config;
|
||||
config.sample_rate_hz = format.clockrate_hz;
|
||||
config.num_channels = rtc::dchecked_cast<int>(format.num_channels);
|
||||
auto ptime_iter = format.parameters.find("ptime");
|
||||
if (ptime_iter != format.parameters.end()) {
|
||||
const auto ptime = rtc::StringToNumber<int>(ptime_iter->second);
|
||||
if (ptime && *ptime > 0) {
|
||||
config.frame_size_ms = rtc::SafeClamp(10 * (*ptime / 10), 10, 60);
|
||||
}
|
||||
}
|
||||
return STR_CASE_CMP(format.name.c_str(), "L16") == 0 && config.IsOk()
|
||||
? absl::optional<Config>(config)
|
||||
: absl::nullopt;
|
||||
|
||||
@ -1327,6 +1327,7 @@ if (rtc_include_tests) {
|
||||
"../..:webrtc_common",
|
||||
"../../api/audio:audio_frame_api",
|
||||
"../../api/audio_codecs:builtin_audio_decoder_factory",
|
||||
"../../api/audio_codecs:builtin_audio_encoder_factory",
|
||||
"../../rtc_base:checks",
|
||||
"../../rtc_base:rtc_base_approved",
|
||||
"../../rtc_base/synchronization:rw_lock_wrapper",
|
||||
|
||||
@ -15,12 +15,14 @@
|
||||
#include <string>
|
||||
|
||||
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
|
||||
#include "api/audio_codecs/builtin_audio_encoder_factory.h"
|
||||
#include "common_types.h" // NOLINT(build/include)
|
||||
#include "modules/audio_coding/codecs/audio_format_conversion.h"
|
||||
#include "modules/audio_coding/include/audio_coding_module.h"
|
||||
#include "modules/audio_coding/include/audio_coding_module_typedefs.h"
|
||||
#include "modules/audio_coding/test/utility.h"
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/stringencode.h"
|
||||
#include "test/gtest.h"
|
||||
#include "test/testsupport/fileutils.h"
|
||||
|
||||
@ -405,7 +407,14 @@ void TestAllCodecs::RegisterSendCodec(char side,
|
||||
sampling_freq_hz, 1));
|
||||
my_codec_param.rate = rate;
|
||||
my_codec_param.pacsize = packet_size;
|
||||
CHECK_ERROR(my_acm->RegisterSendCodec(my_codec_param));
|
||||
|
||||
auto factory = CreateBuiltinAudioEncoderFactory();
|
||||
constexpr int payload_type = 17;
|
||||
SdpAudioFormat format = CodecInstToSdp(my_codec_param);
|
||||
format.parameters["ptime"] = rtc::ToString(rtc::CheckedDivExact(
|
||||
packet_size, rtc::CheckedDivExact(sampling_freq_hz, 1000)));
|
||||
my_acm->SetEncoder(
|
||||
factory->MakeAudioEncoder(payload_type, format, absl::nullopt));
|
||||
}
|
||||
|
||||
void TestAllCodecs::Run(TestPack* channel) {
|
||||
|
||||
Reference in New Issue
Block a user