[ACM] iSAC audio codec removed
Note: this CL has to leave behind one part of iSAC, which is its VAD currently used by AGC1 in APM. The target visibility has been restricted and the VAD will be removed together with AGC1 when the time comes. Tested: see https://chromium-review.googlesource.com/c/chromium/src/+/4013319 Bug: webrtc:14450 Change-Id: I69cc518b16280eae62a1f1977cdbfa24c08cf5f9 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/282421 Reviewed-by: Henrik Lundin <henrik.lundin@webrtc.org> Reviewed-by: Sam Zackrisson <saza@webrtc.org> Reviewed-by: Henrik Boström <hbos@webrtc.org> Commit-Queue: Alessio Bazzica <alessiob@webrtc.org> Cr-Commit-Position: refs/heads/main@{#38652}
This commit is contained in:
committed by
WebRTC LUCI CQ
parent
6aa755c201
commit
b46c4bf27b
@ -62,7 +62,6 @@ rtc_library("builtin_audio_decoder_factory") {
|
||||
"L16:audio_decoder_L16",
|
||||
"g711:audio_decoder_g711",
|
||||
"g722:audio_decoder_g722",
|
||||
"isac:audio_decoder_isac",
|
||||
]
|
||||
defines = []
|
||||
if (rtc_include_ilbc) {
|
||||
@ -95,7 +94,6 @@ rtc_library("builtin_audio_encoder_factory") {
|
||||
"L16:audio_encoder_L16",
|
||||
"g711:audio_encoder_g711",
|
||||
"g722:audio_encoder_g722",
|
||||
"isac:audio_encoder_isac",
|
||||
]
|
||||
defines = []
|
||||
if (rtc_include_ilbc) {
|
||||
|
||||
@ -20,7 +20,6 @@
|
||||
#if WEBRTC_USE_BUILTIN_ILBC
|
||||
#include "api/audio_codecs/ilbc/audio_decoder_ilbc.h" // nogncheck
|
||||
#endif
|
||||
#include "api/audio_codecs/isac/audio_decoder_isac.h"
|
||||
#if WEBRTC_USE_BUILTIN_OPUS
|
||||
#include "api/audio_codecs/opus/audio_decoder_multi_channel_opus.h"
|
||||
#include "api/audio_codecs/opus/audio_decoder_opus.h" // nogncheck
|
||||
@ -57,7 +56,7 @@ rtc::scoped_refptr<AudioDecoderFactory> CreateBuiltinAudioDecoderFactory() {
|
||||
AudioDecoderOpus, NotAdvertised<AudioDecoderMultiChannelOpus>,
|
||||
#endif
|
||||
|
||||
AudioDecoderIsac, AudioDecoderG722,
|
||||
AudioDecoderG722,
|
||||
|
||||
#if WEBRTC_USE_BUILTIN_ILBC
|
||||
AudioDecoderIlbc,
|
||||
|
||||
@ -20,7 +20,6 @@
|
||||
#if WEBRTC_USE_BUILTIN_ILBC
|
||||
#include "api/audio_codecs/ilbc/audio_encoder_ilbc.h" // nogncheck
|
||||
#endif
|
||||
#include "api/audio_codecs/isac/audio_encoder_isac.h"
|
||||
#if WEBRTC_USE_BUILTIN_OPUS
|
||||
#include "api/audio_codecs/opus/audio_encoder_multi_channel_opus.h"
|
||||
#include "api/audio_codecs/opus/audio_encoder_opus.h" // nogncheck
|
||||
@ -63,7 +62,7 @@ rtc::scoped_refptr<AudioEncoderFactory> CreateBuiltinAudioEncoderFactory() {
|
||||
AudioEncoderOpus, NotAdvertised<AudioEncoderMultiChannelOpus>,
|
||||
#endif
|
||||
|
||||
AudioEncoderIsac, AudioEncoderG722,
|
||||
AudioEncoderG722,
|
||||
|
||||
#if WEBRTC_USE_BUILTIN_ILBC
|
||||
AudioEncoderIlbc,
|
||||
|
||||
@ -1,135 +0,0 @@
|
||||
# Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
|
||||
#
|
||||
# Use of this source code is governed by a BSD-style license
|
||||
# that can be found in the LICENSE file in the root of the source
|
||||
# tree. An additional intellectual property rights grant can be found
|
||||
# in the file PATENTS. All contributing project authors may
|
||||
# be found in the AUTHORS file in the root of the source tree.
|
||||
|
||||
import("../../../webrtc.gni")
|
||||
if (is_android) {
|
||||
import("//build/config/android/config.gni")
|
||||
import("//build/config/android/rules.gni")
|
||||
}
|
||||
|
||||
# The targets with _fix and _float suffixes unconditionally use the
|
||||
# fixed-point and floating-point iSAC implementations, respectively.
|
||||
# The targets without suffixes pick one of the implementations based
|
||||
# on cleverly chosen criteria.
|
||||
|
||||
rtc_source_set("audio_encoder_isac") {
|
||||
visibility = [ "*" ]
|
||||
poisonous = [ "audio_codecs" ]
|
||||
public = [ "audio_encoder_isac.h" ]
|
||||
public_configs = [ ":isac_config" ]
|
||||
if (current_cpu == "arm") {
|
||||
deps = [ ":audio_encoder_isac_fix" ]
|
||||
} else {
|
||||
deps = [ ":audio_encoder_isac_float" ]
|
||||
}
|
||||
}
|
||||
|
||||
rtc_source_set("audio_decoder_isac") {
|
||||
visibility = [ "*" ]
|
||||
poisonous = [ "audio_codecs" ]
|
||||
public = [ "audio_decoder_isac.h" ]
|
||||
public_configs = [ ":isac_config" ]
|
||||
if (current_cpu == "arm") {
|
||||
deps = [ ":audio_decoder_isac_fix" ]
|
||||
} else {
|
||||
deps = [ ":audio_decoder_isac_float" ]
|
||||
}
|
||||
}
|
||||
|
||||
config("isac_config") {
|
||||
visibility = [ ":*" ]
|
||||
if (current_cpu == "arm") {
|
||||
defines = [
|
||||
"WEBRTC_USE_BUILTIN_ISAC_FIX=1",
|
||||
"WEBRTC_USE_BUILTIN_ISAC_FLOAT=0",
|
||||
]
|
||||
} else {
|
||||
defines = [
|
||||
"WEBRTC_USE_BUILTIN_ISAC_FIX=0",
|
||||
"WEBRTC_USE_BUILTIN_ISAC_FLOAT=1",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
rtc_library("audio_encoder_isac_fix") {
|
||||
visibility = [ "*" ]
|
||||
poisonous = [ "audio_codecs" ]
|
||||
sources = [
|
||||
"audio_encoder_isac_fix.cc",
|
||||
"audio_encoder_isac_fix.h",
|
||||
]
|
||||
deps = [
|
||||
"..:audio_codecs_api",
|
||||
"../../../api:field_trials_view",
|
||||
"../../../modules/audio_coding:isac_fix",
|
||||
"../../../rtc_base:stringutils",
|
||||
"../../../rtc_base/system:rtc_export",
|
||||
]
|
||||
absl_deps = [
|
||||
"//third_party/abseil-cpp/absl/strings",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
]
|
||||
}
|
||||
|
||||
rtc_library("audio_decoder_isac_fix") {
|
||||
visibility = [ "*" ]
|
||||
poisonous = [ "audio_codecs" ]
|
||||
sources = [
|
||||
"audio_decoder_isac_fix.cc",
|
||||
"audio_decoder_isac_fix.h",
|
||||
]
|
||||
deps = [
|
||||
"..:audio_codecs_api",
|
||||
"../../../api:field_trials_view",
|
||||
"../../../modules/audio_coding:isac_fix",
|
||||
"../../../rtc_base/system:rtc_export",
|
||||
]
|
||||
absl_deps = [
|
||||
"//third_party/abseil-cpp/absl/strings",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
]
|
||||
}
|
||||
|
||||
rtc_library("audio_encoder_isac_float") {
|
||||
visibility = [ "*" ]
|
||||
poisonous = [ "audio_codecs" ]
|
||||
sources = [
|
||||
"audio_encoder_isac_float.cc",
|
||||
"audio_encoder_isac_float.h",
|
||||
]
|
||||
deps = [
|
||||
"..:audio_codecs_api",
|
||||
"../../../api:field_trials_view",
|
||||
"../../../modules/audio_coding:isac",
|
||||
"../../../rtc_base:stringutils",
|
||||
"../../../rtc_base/system:rtc_export",
|
||||
]
|
||||
absl_deps = [
|
||||
"//third_party/abseil-cpp/absl/strings",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
]
|
||||
}
|
||||
|
||||
rtc_library("audio_decoder_isac_float") {
|
||||
visibility = [ "*" ]
|
||||
poisonous = [ "audio_codecs" ]
|
||||
sources = [
|
||||
"audio_decoder_isac_float.cc",
|
||||
"audio_decoder_isac_float.h",
|
||||
]
|
||||
deps = [
|
||||
"..:audio_codecs_api",
|
||||
"../../../api:field_trials_view",
|
||||
"../../../modules/audio_coding:isac",
|
||||
"../../../rtc_base/system:rtc_export",
|
||||
]
|
||||
absl_deps = [
|
||||
"//third_party/abseil-cpp/absl/strings",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
]
|
||||
}
|
||||
@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef API_AUDIO_CODECS_ISAC_AUDIO_DECODER_ISAC_H_
|
||||
#define API_AUDIO_CODECS_ISAC_AUDIO_DECODER_ISAC_H_
|
||||
|
||||
#if WEBRTC_USE_BUILTIN_ISAC_FIX && !WEBRTC_USE_BUILTIN_ISAC_FLOAT
|
||||
#include "api/audio_codecs/isac/audio_decoder_isac_fix.h" // nogncheck
|
||||
#elif WEBRTC_USE_BUILTIN_ISAC_FLOAT && !WEBRTC_USE_BUILTIN_ISAC_FIX
|
||||
#include "api/audio_codecs/isac/audio_decoder_isac_float.h" // nogncheck
|
||||
#else
|
||||
#error "Must choose either fix or float"
|
||||
#endif
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
#if WEBRTC_USE_BUILTIN_ISAC_FIX
|
||||
using AudioDecoderIsac = AudioDecoderIsacFix;
|
||||
#elif WEBRTC_USE_BUILTIN_ISAC_FLOAT
|
||||
using AudioDecoderIsac = AudioDecoderIsacFloat;
|
||||
#endif
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // API_AUDIO_CODECS_ISAC_AUDIO_DECODER_ISAC_H_
|
||||
@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "api/audio_codecs/isac/audio_decoder_isac_fix.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "absl/strings/match.h"
|
||||
#include "modules/audio_coding/codecs/isac/fix/include/audio_decoder_isacfix.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
absl::optional<AudioDecoderIsacFix::Config> AudioDecoderIsacFix::SdpToConfig(
|
||||
const SdpAudioFormat& format) {
|
||||
if (absl::EqualsIgnoreCase(format.name, "ISAC") &&
|
||||
format.clockrate_hz == 16000 && format.num_channels == 1) {
|
||||
return Config();
|
||||
}
|
||||
return absl::nullopt;
|
||||
}
|
||||
|
||||
void AudioDecoderIsacFix::AppendSupportedDecoders(
|
||||
std::vector<AudioCodecSpec>* specs) {
|
||||
specs->push_back({{"ISAC", 16000, 1}, {16000, 1, 32000, 10000, 32000}});
|
||||
}
|
||||
|
||||
std::unique_ptr<AudioDecoder> AudioDecoderIsacFix::MakeAudioDecoder(
|
||||
Config config,
|
||||
absl::optional<AudioCodecPairId> /*codec_pair_id*/,
|
||||
const FieldTrialsView* field_trials) {
|
||||
AudioDecoderIsacFixImpl::Config c;
|
||||
c.sample_rate_hz = 16000;
|
||||
return std::make_unique<AudioDecoderIsacFixImpl>(c);
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef API_AUDIO_CODECS_ISAC_AUDIO_DECODER_ISAC_FIX_H_
|
||||
#define API_AUDIO_CODECS_ISAC_AUDIO_DECODER_ISAC_FIX_H_
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/audio_codecs/audio_codec_pair_id.h"
|
||||
#include "api/audio_codecs/audio_decoder.h"
|
||||
#include "api/audio_codecs/audio_format.h"
|
||||
#include "api/field_trials_view.h"
|
||||
#include "rtc_base/system/rtc_export.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// iSAC decoder API (fixed-point implementation) for use as a template
|
||||
// parameter to CreateAudioDecoderFactory<...>().
|
||||
struct RTC_EXPORT AudioDecoderIsacFix {
|
||||
struct Config {}; // Empty---no config values needed!
|
||||
static absl::optional<Config> SdpToConfig(const SdpAudioFormat& audio_format);
|
||||
static void AppendSupportedDecoders(std::vector<AudioCodecSpec>* specs);
|
||||
static std::unique_ptr<AudioDecoder> MakeAudioDecoder(
|
||||
Config config,
|
||||
absl::optional<AudioCodecPairId> codec_pair_id = absl::nullopt,
|
||||
const FieldTrialsView* field_trials = nullptr);
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // API_AUDIO_CODECS_ISAC_AUDIO_DECODER_ISAC_FIX_H_
|
||||
@ -1,56 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "api/audio_codecs/isac/audio_decoder_isac_float.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "absl/strings/match.h"
|
||||
#include "modules/audio_coding/codecs/isac/main/include/audio_decoder_isac.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
absl::optional<AudioDecoderIsacFloat::Config>
|
||||
AudioDecoderIsacFloat::SdpToConfig(const SdpAudioFormat& format) {
|
||||
if (absl::EqualsIgnoreCase(format.name, "ISAC") &&
|
||||
(format.clockrate_hz == 16000 || format.clockrate_hz == 32000) &&
|
||||
format.num_channels == 1) {
|
||||
Config config;
|
||||
config.sample_rate_hz = format.clockrate_hz;
|
||||
if (!config.IsOk()) {
|
||||
RTC_DCHECK_NOTREACHED();
|
||||
return absl::nullopt;
|
||||
}
|
||||
return config;
|
||||
} else {
|
||||
return absl::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
void AudioDecoderIsacFloat::AppendSupportedDecoders(
|
||||
std::vector<AudioCodecSpec>* specs) {
|
||||
specs->push_back({{"ISAC", 16000, 1}, {16000, 1, 32000, 10000, 32000}});
|
||||
specs->push_back({{"ISAC", 32000, 1}, {32000, 1, 56000, 10000, 56000}});
|
||||
}
|
||||
|
||||
std::unique_ptr<AudioDecoder> AudioDecoderIsacFloat::MakeAudioDecoder(
|
||||
Config config,
|
||||
absl::optional<AudioCodecPairId> /*codec_pair_id*/,
|
||||
const FieldTrialsView* field_trials) {
|
||||
AudioDecoderIsacFloatImpl::Config c;
|
||||
c.sample_rate_hz = config.sample_rate_hz;
|
||||
if (!config.IsOk()) {
|
||||
RTC_DCHECK_NOTREACHED();
|
||||
return nullptr;
|
||||
}
|
||||
return std::make_unique<AudioDecoderIsacFloatImpl>(c);
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef API_AUDIO_CODECS_ISAC_AUDIO_DECODER_ISAC_FLOAT_H_
|
||||
#define API_AUDIO_CODECS_ISAC_AUDIO_DECODER_ISAC_FLOAT_H_
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/audio_codecs/audio_codec_pair_id.h"
|
||||
#include "api/audio_codecs/audio_decoder.h"
|
||||
#include "api/audio_codecs/audio_format.h"
|
||||
#include "api/field_trials_view.h"
|
||||
#include "rtc_base/system/rtc_export.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// iSAC decoder API (floating-point implementation) for use as a template
|
||||
// parameter to CreateAudioDecoderFactory<...>().
|
||||
struct RTC_EXPORT AudioDecoderIsacFloat {
|
||||
struct Config {
|
||||
bool IsOk() const {
|
||||
return sample_rate_hz == 16000 || sample_rate_hz == 32000;
|
||||
}
|
||||
int sample_rate_hz = 16000;
|
||||
};
|
||||
static absl::optional<Config> SdpToConfig(const SdpAudioFormat& audio_format);
|
||||
static void AppendSupportedDecoders(std::vector<AudioCodecSpec>* specs);
|
||||
static std::unique_ptr<AudioDecoder> MakeAudioDecoder(
|
||||
Config config,
|
||||
absl::optional<AudioCodecPairId> codec_pair_id = absl::nullopt,
|
||||
const FieldTrialsView* field_trials = nullptr);
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // API_AUDIO_CODECS_ISAC_AUDIO_DECODER_ISAC_FLOAT_H_
|
||||
@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef API_AUDIO_CODECS_ISAC_AUDIO_ENCODER_ISAC_H_
|
||||
#define API_AUDIO_CODECS_ISAC_AUDIO_ENCODER_ISAC_H_
|
||||
|
||||
#if WEBRTC_USE_BUILTIN_ISAC_FIX && !WEBRTC_USE_BUILTIN_ISAC_FLOAT
|
||||
#include "api/audio_codecs/isac/audio_encoder_isac_fix.h" // nogncheck
|
||||
#elif WEBRTC_USE_BUILTIN_ISAC_FLOAT && !WEBRTC_USE_BUILTIN_ISAC_FIX
|
||||
#include "api/audio_codecs/isac/audio_encoder_isac_float.h" // nogncheck
|
||||
#else
|
||||
#error "Must choose either fix or float"
|
||||
#endif
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
#if WEBRTC_USE_BUILTIN_ISAC_FIX
|
||||
using AudioEncoderIsac = AudioEncoderIsacFix;
|
||||
#elif WEBRTC_USE_BUILTIN_ISAC_FLOAT
|
||||
using AudioEncoderIsac = AudioEncoderIsacFloat;
|
||||
#endif
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // API_AUDIO_CODECS_ISAC_AUDIO_ENCODER_ISAC_H_
|
||||
@ -1,72 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "api/audio_codecs/isac/audio_encoder_isac_fix.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "absl/strings/match.h"
|
||||
#include "modules/audio_coding/codecs/isac/fix/include/audio_encoder_isacfix.h"
|
||||
#include "rtc_base/string_to_number.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
absl::optional<AudioEncoderIsacFix::Config> AudioEncoderIsacFix::SdpToConfig(
|
||||
const SdpAudioFormat& format) {
|
||||
if (absl::EqualsIgnoreCase(format.name, "ISAC") &&
|
||||
format.clockrate_hz == 16000 && format.num_channels == 1) {
|
||||
Config config;
|
||||
const 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 >= 60) {
|
||||
config.frame_size_ms = 60;
|
||||
}
|
||||
}
|
||||
if (!config.IsOk()) {
|
||||
RTC_DCHECK_NOTREACHED();
|
||||
return absl::nullopt;
|
||||
}
|
||||
return config;
|
||||
} else {
|
||||
return absl::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
void AudioEncoderIsacFix::AppendSupportedEncoders(
|
||||
std::vector<AudioCodecSpec>* specs) {
|
||||
const SdpAudioFormat fmt = {"ISAC", 16000, 1};
|
||||
const AudioCodecInfo info = QueryAudioEncoder(*SdpToConfig(fmt));
|
||||
specs->push_back({fmt, info});
|
||||
}
|
||||
|
||||
AudioCodecInfo AudioEncoderIsacFix::QueryAudioEncoder(
|
||||
AudioEncoderIsacFix::Config config) {
|
||||
RTC_DCHECK(config.IsOk());
|
||||
return {16000, 1, 32000, 10000, 32000};
|
||||
}
|
||||
|
||||
std::unique_ptr<AudioEncoder> AudioEncoderIsacFix::MakeAudioEncoder(
|
||||
AudioEncoderIsacFix::Config config,
|
||||
int payload_type,
|
||||
absl::optional<AudioCodecPairId> /*codec_pair_id*/,
|
||||
const FieldTrialsView* field_trials) {
|
||||
AudioEncoderIsacFixImpl::Config c;
|
||||
c.frame_size_ms = config.frame_size_ms;
|
||||
c.bit_rate = config.bit_rate;
|
||||
c.payload_type = payload_type;
|
||||
if (!config.IsOk()) {
|
||||
RTC_DCHECK_NOTREACHED();
|
||||
return nullptr;
|
||||
}
|
||||
return std::make_unique<AudioEncoderIsacFixImpl>(c);
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
@ -1,54 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef API_AUDIO_CODECS_ISAC_AUDIO_ENCODER_ISAC_FIX_H_
|
||||
#define API_AUDIO_CODECS_ISAC_AUDIO_ENCODER_ISAC_FIX_H_
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/audio_codecs/audio_codec_pair_id.h"
|
||||
#include "api/audio_codecs/audio_encoder.h"
|
||||
#include "api/audio_codecs/audio_format.h"
|
||||
#include "api/field_trials_view.h"
|
||||
#include "rtc_base/system/rtc_export.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// iSAC encoder API (fixed-point implementation) for use as a template
|
||||
// parameter to CreateAudioEncoderFactory<...>().
|
||||
struct RTC_EXPORT AudioEncoderIsacFix {
|
||||
struct Config {
|
||||
bool IsOk() const {
|
||||
if (frame_size_ms != 30 && frame_size_ms != 60) {
|
||||
return false;
|
||||
}
|
||||
if (bit_rate < 10000 || bit_rate > 32000) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
int frame_size_ms = 30;
|
||||
int bit_rate = 32000; // Limit on short-term average bit rate, in bits/s.
|
||||
};
|
||||
static absl::optional<Config> SdpToConfig(const SdpAudioFormat& audio_format);
|
||||
static void AppendSupportedEncoders(std::vector<AudioCodecSpec>* specs);
|
||||
static AudioCodecInfo QueryAudioEncoder(Config config);
|
||||
static std::unique_ptr<AudioEncoder> MakeAudioEncoder(
|
||||
Config config,
|
||||
int payload_type,
|
||||
absl::optional<AudioCodecPairId> codec_pair_id = absl::nullopt,
|
||||
const FieldTrialsView* field_trials = nullptr);
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // API_AUDIO_CODECS_ISAC_AUDIO_ENCODER_ISAC_FIX_H_
|
||||
@ -1,85 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "api/audio_codecs/isac/audio_encoder_isac_float.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "absl/strings/match.h"
|
||||
#include "modules/audio_coding/codecs/isac/main/include/audio_encoder_isac.h"
|
||||
#include "rtc_base/string_to_number.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
absl::optional<AudioEncoderIsacFloat::Config>
|
||||
AudioEncoderIsacFloat::SdpToConfig(const SdpAudioFormat& format) {
|
||||
if (absl::EqualsIgnoreCase(format.name, "ISAC") &&
|
||||
(format.clockrate_hz == 16000 || format.clockrate_hz == 32000) &&
|
||||
format.num_channels == 1) {
|
||||
Config config;
|
||||
config.sample_rate_hz = format.clockrate_hz;
|
||||
config.bit_rate = format.clockrate_hz == 16000 ? 32000 : 56000;
|
||||
if (config.sample_rate_hz == 16000) {
|
||||
// For sample rate 16 kHz, optionally use 60 ms frames, instead of the
|
||||
// default 30 ms.
|
||||
const 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 >= 60) {
|
||||
config.frame_size_ms = 60;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!config.IsOk()) {
|
||||
RTC_DCHECK_NOTREACHED();
|
||||
return absl::nullopt;
|
||||
}
|
||||
return config;
|
||||
} else {
|
||||
return absl::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
void AudioEncoderIsacFloat::AppendSupportedEncoders(
|
||||
std::vector<AudioCodecSpec>* specs) {
|
||||
for (int sample_rate_hz : {16000, 32000}) {
|
||||
const SdpAudioFormat fmt = {"ISAC", sample_rate_hz, 1};
|
||||
const AudioCodecInfo info = QueryAudioEncoder(*SdpToConfig(fmt));
|
||||
specs->push_back({fmt, info});
|
||||
}
|
||||
}
|
||||
|
||||
AudioCodecInfo AudioEncoderIsacFloat::QueryAudioEncoder(
|
||||
const AudioEncoderIsacFloat::Config& config) {
|
||||
RTC_DCHECK(config.IsOk());
|
||||
constexpr int min_bitrate = 10000;
|
||||
const int max_bitrate = config.sample_rate_hz == 16000 ? 32000 : 56000;
|
||||
const int default_bitrate = max_bitrate;
|
||||
return {config.sample_rate_hz, 1, default_bitrate, min_bitrate, max_bitrate};
|
||||
}
|
||||
|
||||
std::unique_ptr<AudioEncoder> AudioEncoderIsacFloat::MakeAudioEncoder(
|
||||
const AudioEncoderIsacFloat::Config& config,
|
||||
int payload_type,
|
||||
absl::optional<AudioCodecPairId> /*codec_pair_id*/,
|
||||
const FieldTrialsView* field_trials) {
|
||||
AudioEncoderIsacFloatImpl::Config c;
|
||||
c.payload_type = payload_type;
|
||||
c.sample_rate_hz = config.sample_rate_hz;
|
||||
c.frame_size_ms = config.frame_size_ms;
|
||||
c.bit_rate = config.bit_rate;
|
||||
if (!config.IsOk()) {
|
||||
RTC_DCHECK_NOTREACHED();
|
||||
return nullptr;
|
||||
}
|
||||
return std::make_unique<AudioEncoderIsacFloatImpl>(c);
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
@ -1,68 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef API_AUDIO_CODECS_ISAC_AUDIO_ENCODER_ISAC_FLOAT_H_
|
||||
#define API_AUDIO_CODECS_ISAC_AUDIO_ENCODER_ISAC_FLOAT_H_
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/audio_codecs/audio_codec_pair_id.h"
|
||||
#include "api/audio_codecs/audio_encoder.h"
|
||||
#include "api/audio_codecs/audio_format.h"
|
||||
#include "api/field_trials_view.h"
|
||||
#include "rtc_base/system/rtc_export.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// iSAC encoder API (floating-point implementation) for use as a template
|
||||
// parameter to CreateAudioEncoderFactory<...>().
|
||||
struct RTC_EXPORT AudioEncoderIsacFloat {
|
||||
struct Config {
|
||||
bool IsOk() const {
|
||||
switch (sample_rate_hz) {
|
||||
case 16000:
|
||||
if (frame_size_ms != 30 && frame_size_ms != 60) {
|
||||
return false;
|
||||
}
|
||||
if (bit_rate < 10000 || bit_rate > 32000) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
case 32000:
|
||||
if (frame_size_ms != 30) {
|
||||
return false;
|
||||
}
|
||||
if (bit_rate < 10000 || bit_rate > 56000) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
int sample_rate_hz = 16000;
|
||||
int frame_size_ms = 30;
|
||||
int bit_rate = 32000; // Limit on short-term average bit rate, in bits/s.
|
||||
};
|
||||
static absl::optional<Config> SdpToConfig(const SdpAudioFormat& audio_format);
|
||||
static void AppendSupportedEncoders(std::vector<AudioCodecSpec>* specs);
|
||||
static AudioCodecInfo QueryAudioEncoder(const Config& config);
|
||||
static std::unique_ptr<AudioEncoder> MakeAudioEncoder(
|
||||
const Config& config,
|
||||
int payload_type,
|
||||
absl::optional<AudioCodecPairId> codec_pair_id = absl::nullopt,
|
||||
const FieldTrialsView* field_trials = nullptr);
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // API_AUDIO_CODECS_ISAC_AUDIO_ENCODER_ISAC_FLOAT_H_
|
||||
@ -32,10 +32,6 @@ if (rtc_include_tests) {
|
||||
"../g722:audio_encoder_g722",
|
||||
"../ilbc:audio_decoder_ilbc",
|
||||
"../ilbc:audio_encoder_ilbc",
|
||||
"../isac:audio_decoder_isac_fix",
|
||||
"../isac:audio_decoder_isac_float",
|
||||
"../isac:audio_encoder_isac_fix",
|
||||
"../isac:audio_encoder_isac_float",
|
||||
"../opus:audio_decoder_opus",
|
||||
"../opus:audio_encoder_opus",
|
||||
]
|
||||
|
||||
@ -16,8 +16,6 @@
|
||||
#include "api/audio_codecs/g711/audio_decoder_g711.h"
|
||||
#include "api/audio_codecs/g722/audio_decoder_g722.h"
|
||||
#include "api/audio_codecs/ilbc/audio_decoder_ilbc.h"
|
||||
#include "api/audio_codecs/isac/audio_decoder_isac_fix.h"
|
||||
#include "api/audio_codecs/isac/audio_decoder_isac_float.h"
|
||||
#include "api/audio_codecs/opus/audio_decoder_opus.h"
|
||||
#include "test/gmock.h"
|
||||
#include "test/gtest.h"
|
||||
@ -182,41 +180,6 @@ TEST(AudioDecoderFactoryTemplateTest, Ilbc) {
|
||||
EXPECT_EQ(8000, dec->SampleRateHz());
|
||||
}
|
||||
|
||||
TEST(AudioDecoderFactoryTemplateTest, IsacFix) {
|
||||
auto factory = CreateAudioDecoderFactory<AudioDecoderIsacFix>();
|
||||
EXPECT_THAT(factory->GetSupportedDecoders(),
|
||||
::testing::ElementsAre(AudioCodecSpec{
|
||||
{"ISAC", 16000, 1}, {16000, 1, 32000, 10000, 32000}}));
|
||||
EXPECT_FALSE(factory->IsSupportedDecoder({"isac", 16000, 2}));
|
||||
EXPECT_TRUE(factory->IsSupportedDecoder({"isac", 16000, 1}));
|
||||
EXPECT_FALSE(factory->IsSupportedDecoder({"isac", 32000, 1}));
|
||||
EXPECT_EQ(nullptr,
|
||||
factory->MakeAudioDecoder({"isac", 8000, 1}, absl::nullopt));
|
||||
auto dec = factory->MakeAudioDecoder({"isac", 16000, 1}, absl::nullopt);
|
||||
ASSERT_NE(nullptr, dec);
|
||||
EXPECT_EQ(16000, dec->SampleRateHz());
|
||||
}
|
||||
|
||||
TEST(AudioDecoderFactoryTemplateTest, IsacFloat) {
|
||||
auto factory = CreateAudioDecoderFactory<AudioDecoderIsacFloat>();
|
||||
EXPECT_THAT(
|
||||
factory->GetSupportedDecoders(),
|
||||
::testing::ElementsAre(
|
||||
AudioCodecSpec{{"ISAC", 16000, 1}, {16000, 1, 32000, 10000, 32000}},
|
||||
AudioCodecSpec{{"ISAC", 32000, 1}, {32000, 1, 56000, 10000, 56000}}));
|
||||
EXPECT_FALSE(factory->IsSupportedDecoder({"isac", 16000, 2}));
|
||||
EXPECT_TRUE(factory->IsSupportedDecoder({"isac", 16000, 1}));
|
||||
EXPECT_TRUE(factory->IsSupportedDecoder({"isac", 32000, 1}));
|
||||
EXPECT_EQ(nullptr,
|
||||
factory->MakeAudioDecoder({"isac", 8000, 1}, absl::nullopt));
|
||||
auto dec1 = factory->MakeAudioDecoder({"isac", 16000, 1}, absl::nullopt);
|
||||
ASSERT_NE(nullptr, dec1);
|
||||
EXPECT_EQ(16000, dec1->SampleRateHz());
|
||||
auto dec2 = factory->MakeAudioDecoder({"isac", 32000, 1}, absl::nullopt);
|
||||
ASSERT_NE(nullptr, dec2);
|
||||
EXPECT_EQ(32000, dec2->SampleRateHz());
|
||||
}
|
||||
|
||||
TEST(AudioDecoderFactoryTemplateTest, L16) {
|
||||
auto factory = CreateAudioDecoderFactory<AudioDecoderL16>();
|
||||
EXPECT_THAT(
|
||||
|
||||
@ -16,8 +16,6 @@
|
||||
#include "api/audio_codecs/g711/audio_encoder_g711.h"
|
||||
#include "api/audio_codecs/g722/audio_encoder_g722.h"
|
||||
#include "api/audio_codecs/ilbc/audio_encoder_ilbc.h"
|
||||
#include "api/audio_codecs/isac/audio_encoder_isac_fix.h"
|
||||
#include "api/audio_codecs/isac/audio_encoder_isac_float.h"
|
||||
#include "api/audio_codecs/opus/audio_encoder_opus.h"
|
||||
#include "test/gmock.h"
|
||||
#include "test/gtest.h"
|
||||
@ -180,49 +178,6 @@ TEST(AudioEncoderFactoryTemplateTest, Ilbc) {
|
||||
EXPECT_EQ(8000, enc->SampleRateHz());
|
||||
}
|
||||
|
||||
TEST(AudioEncoderFactoryTemplateTest, IsacFix) {
|
||||
auto factory = CreateAudioEncoderFactory<AudioEncoderIsacFix>();
|
||||
EXPECT_THAT(factory->GetSupportedEncoders(),
|
||||
::testing::ElementsAre(AudioCodecSpec{
|
||||
{"ISAC", 16000, 1}, {16000, 1, 32000, 10000, 32000}}));
|
||||
EXPECT_EQ(absl::nullopt, factory->QueryAudioEncoder({"isac", 16000, 2}));
|
||||
EXPECT_EQ(AudioCodecInfo(16000, 1, 32000, 10000, 32000),
|
||||
factory->QueryAudioEncoder({"isac", 16000, 1}));
|
||||
EXPECT_EQ(absl::nullopt, factory->QueryAudioEncoder({"isac", 32000, 1}));
|
||||
EXPECT_EQ(nullptr,
|
||||
factory->MakeAudioEncoder(17, {"isac", 8000, 1}, absl::nullopt));
|
||||
auto enc1 = factory->MakeAudioEncoder(17, {"isac", 16000, 1}, absl::nullopt);
|
||||
ASSERT_NE(nullptr, enc1);
|
||||
EXPECT_EQ(16000, enc1->SampleRateHz());
|
||||
EXPECT_EQ(3u, enc1->Num10MsFramesInNextPacket());
|
||||
auto enc2 = factory->MakeAudioEncoder(
|
||||
17, {"isac", 16000, 1, {{"ptime", "60"}}}, absl::nullopt);
|
||||
ASSERT_NE(nullptr, enc2);
|
||||
EXPECT_EQ(6u, enc2->Num10MsFramesInNextPacket());
|
||||
}
|
||||
|
||||
TEST(AudioEncoderFactoryTemplateTest, IsacFloat) {
|
||||
auto factory = CreateAudioEncoderFactory<AudioEncoderIsacFloat>();
|
||||
EXPECT_THAT(
|
||||
factory->GetSupportedEncoders(),
|
||||
::testing::ElementsAre(
|
||||
AudioCodecSpec{{"ISAC", 16000, 1}, {16000, 1, 32000, 10000, 32000}},
|
||||
AudioCodecSpec{{"ISAC", 32000, 1}, {32000, 1, 56000, 10000, 56000}}));
|
||||
EXPECT_EQ(absl::nullopt, factory->QueryAudioEncoder({"isac", 16000, 2}));
|
||||
EXPECT_EQ(AudioCodecInfo(16000, 1, 32000, 10000, 32000),
|
||||
factory->QueryAudioEncoder({"isac", 16000, 1}));
|
||||
EXPECT_EQ(AudioCodecInfo(32000, 1, 56000, 10000, 56000),
|
||||
factory->QueryAudioEncoder({"isac", 32000, 1}));
|
||||
EXPECT_EQ(nullptr,
|
||||
factory->MakeAudioEncoder(17, {"isac", 8000, 1}, absl::nullopt));
|
||||
auto enc1 = factory->MakeAudioEncoder(17, {"isac", 16000, 1}, absl::nullopt);
|
||||
ASSERT_NE(nullptr, enc1);
|
||||
EXPECT_EQ(16000, enc1->SampleRateHz());
|
||||
auto enc2 = factory->MakeAudioEncoder(17, {"isac", 32000, 1}, absl::nullopt);
|
||||
ASSERT_NE(nullptr, enc2);
|
||||
EXPECT_EQ(32000, enc2->SampleRateHz());
|
||||
}
|
||||
|
||||
TEST(AudioEncoderFactoryTemplateTest, L16) {
|
||||
auto factory = CreateAudioEncoderFactory<AudioEncoderL16>();
|
||||
EXPECT_THAT(
|
||||
|
||||
Reference in New Issue
Block a user