Replace rtc::Optional with absl::optional in modules/audio_coding
This is a no-op change because rtc::Optional is an alias to absl::optional
This CL generated by running script with parameter 'modules/audio_coding'
find $@ -type f \( -name \*.h -o -name \*.cc \) \
-exec sed -i 's|rtc::Optional|absl::optional|g' {} \+ \
-exec sed -i 's|rtc::nullopt|absl::nullopt|g' {} \+ \
-exec sed -i 's|#include "api/optional.h"|#include "absl/types/optional.h"|' {} \+
find $@ -type f -name BUILD.gn \
-exec sed -r -i 's|"[\./api]*:optional"|"//third_party/abseil-cpp/absl/types:optional"|' {} \+;
git cl format
Bug: webrtc:9078
Change-Id: Ic980ee605148fdb160666d4aa03cc87175e48fe8
Reviewed-on: https://webrtc-review.googlesource.com/84130
Reviewed-by: Oskar Sundbom <ossu@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23659}
This commit is contained in:
parent
bbfcc703ad
commit
b602123a5a
@ -50,11 +50,11 @@ rtc_static_library("audio_format_conversion") {
|
||||
deps = [
|
||||
"../..:webrtc_common",
|
||||
"../../api:array_view",
|
||||
"../../api:optional",
|
||||
"../../api/audio_codecs:audio_codecs_api",
|
||||
"../../rtc_base:checks",
|
||||
"../../rtc_base:rtc_base_approved",
|
||||
"../../rtc_base:sanitizer",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
]
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ rtc_static_library("rent_a_codec") {
|
||||
"../..:typedefs",
|
||||
"../../rtc_base:checks",
|
||||
"../../api:array_view",
|
||||
"../../api:optional",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
"../../api/audio_codecs:audio_codecs_api",
|
||||
"../..:webrtc_common",
|
||||
"../../rtc_base:protobuf_utils",
|
||||
@ -150,7 +150,7 @@ rtc_static_library("audio_coding") {
|
||||
":rent_a_codec",
|
||||
"../../rtc_base:audio_format_to_string",
|
||||
"../../rtc_base:rtc_base_approved",
|
||||
"../../api:optional",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
"../../logging:rtc_event_log_api",
|
||||
]
|
||||
defines = audio_coding_defines
|
||||
@ -503,10 +503,10 @@ rtc_static_library("isac_common") {
|
||||
":isac_bwinfo",
|
||||
"../..:typedefs",
|
||||
"../..:webrtc_common",
|
||||
"../../api:optional",
|
||||
"../../api/audio_codecs:audio_codecs_api",
|
||||
"../../rtc_base:checks",
|
||||
"../../rtc_base:rtc_base_approved",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
]
|
||||
}
|
||||
|
||||
@ -892,7 +892,6 @@ rtc_static_library("webrtc_opus") {
|
||||
deps = [
|
||||
":audio_network_adaptor",
|
||||
"../..:webrtc_common",
|
||||
"../../api:optional",
|
||||
"../../api/audio_codecs:audio_codecs_api",
|
||||
"../../api/audio_codecs/opus:audio_encoder_opus_config",
|
||||
"../../common_audio",
|
||||
@ -901,6 +900,7 @@ rtc_static_library("webrtc_opus") {
|
||||
"../../rtc_base:rtc_numerics",
|
||||
"../../rtc_base:safe_minmax",
|
||||
"../../system_wrappers:field_trial_api",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
]
|
||||
public_deps = [
|
||||
":webrtc_opus_c",
|
||||
@ -968,7 +968,7 @@ rtc_static_library("audio_network_adaptor_config") {
|
||||
"audio_network_adaptor/include/audio_network_adaptor_config.h",
|
||||
]
|
||||
deps = [
|
||||
"../../api:optional",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
]
|
||||
}
|
||||
|
||||
@ -1007,7 +1007,6 @@ rtc_static_library("audio_network_adaptor") {
|
||||
|
||||
deps = [
|
||||
"../..:webrtc_common",
|
||||
"../../api:optional",
|
||||
"../../api/audio_codecs:audio_codecs_api",
|
||||
"../../common_audio",
|
||||
"../../logging:rtc_event_audio",
|
||||
@ -1018,6 +1017,7 @@ rtc_static_library("audio_network_adaptor") {
|
||||
"../../rtc_base/system:file_wrapper",
|
||||
"../../system_wrappers",
|
||||
"../../system_wrappers:field_trial_api",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
]
|
||||
|
||||
if (rtc_enable_protobuf) {
|
||||
@ -1039,9 +1039,9 @@ rtc_source_set("neteq_decoder_enum") {
|
||||
"neteq/neteq_decoder_enum.h",
|
||||
]
|
||||
deps = [
|
||||
"../../api:optional",
|
||||
"../../api/audio_codecs:audio_codecs_api",
|
||||
"../../rtc_base:rtc_base_approved",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
]
|
||||
}
|
||||
|
||||
@ -1129,7 +1129,6 @@ rtc_static_library("neteq") {
|
||||
"../..:typedefs",
|
||||
"../..:webrtc_common",
|
||||
"../../api:libjingle_peerconnection_api",
|
||||
"../../api:optional",
|
||||
"../../api/audio:audio_frame_api",
|
||||
"../../api/audio_codecs:audio_codecs_api",
|
||||
"../../common_audio",
|
||||
@ -1143,6 +1142,7 @@ rtc_static_library("neteq") {
|
||||
"../../rtc_base/system:fallthrough",
|
||||
"../../system_wrappers:field_trial_api",
|
||||
"../../system_wrappers:metrics_api",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
]
|
||||
}
|
||||
|
||||
@ -1177,13 +1177,13 @@ rtc_source_set("neteq_tools_minimal") {
|
||||
"../..:typedefs",
|
||||
"../..:webrtc_common",
|
||||
"../../api:libjingle_peerconnection_api",
|
||||
"../../api:optional",
|
||||
"../../api/audio:audio_frame_api",
|
||||
"../../api/audio_codecs:audio_codecs_api",
|
||||
"../../api/audio_codecs:builtin_audio_decoder_factory",
|
||||
"../../rtc_base:checks",
|
||||
"../../rtc_base:rtc_base_approved",
|
||||
"../rtp_rtcp",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
]
|
||||
}
|
||||
|
||||
@ -1270,12 +1270,12 @@ rtc_source_set("neteq_tools") {
|
||||
"../..:typedefs",
|
||||
"../..:webrtc_common",
|
||||
"../../api:array_view",
|
||||
"../../api:optional",
|
||||
"../../api/audio_codecs:audio_codecs_api",
|
||||
"../../rtc_base:checks",
|
||||
"../../rtc_base:rtc_base_approved",
|
||||
"../rtp_rtcp",
|
||||
"../rtp_rtcp:rtp_rtcp_format",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
]
|
||||
|
||||
public_deps = [
|
||||
@ -1422,7 +1422,6 @@ if (rtc_include_tests) {
|
||||
"..:module_api",
|
||||
"../..:typedefs",
|
||||
"../..:webrtc_common",
|
||||
"../../api:optional",
|
||||
"../../api/audio:audio_frame_api",
|
||||
"../../api/audio_codecs:builtin_audio_decoder_factory",
|
||||
"../../rtc_base:checks",
|
||||
@ -1431,6 +1430,7 @@ if (rtc_include_tests) {
|
||||
"../../system_wrappers",
|
||||
"../../test:fileutils",
|
||||
"../../test:test_support",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
]
|
||||
defines = audio_coding_defines
|
||||
if (is_win) {
|
||||
@ -1537,7 +1537,6 @@ if (rtc_include_tests) {
|
||||
"..:module_api",
|
||||
"../..:typedefs",
|
||||
"../../:webrtc_common",
|
||||
"../../api:optional",
|
||||
"../../api/audio:audio_frame_api",
|
||||
"../../api/audio_codecs:builtin_audio_decoder_factory",
|
||||
"../../rtc_base:checks",
|
||||
@ -1548,6 +1547,7 @@ if (rtc_include_tests) {
|
||||
"../../test:test_support",
|
||||
"../rtp_rtcp",
|
||||
"//testing/gtest",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
]
|
||||
} # delay_test
|
||||
|
||||
|
||||
@ -64,7 +64,7 @@ int AcmReceiver::LeastRequiredDelayMs() const {
|
||||
return neteq_->LeastRequiredDelayMs();
|
||||
}
|
||||
|
||||
rtc::Optional<int> AcmReceiver::last_packet_sample_rate_hz() const {
|
||||
absl::optional<int> AcmReceiver::last_packet_sample_rate_hz() const {
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
return last_packet_sample_rate_hz_;
|
||||
}
|
||||
@ -86,7 +86,7 @@ int AcmReceiver::InsertPacket(const WebRtcRTPHeader& rtp_header,
|
||||
{
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
|
||||
const rtc::Optional<CodecInst> ci =
|
||||
const absl::optional<CodecInst> ci =
|
||||
RtpHeaderToDecoder(*header, incoming_payload[0]);
|
||||
if (!ci) {
|
||||
RTC_LOG_F(LS_ERROR) << "Payload-type "
|
||||
@ -202,15 +202,15 @@ int32_t AcmReceiver::AddCodec(int acm_codec_id,
|
||||
const auto neteq_decoder = [acm_codec_id, channels]() -> NetEqDecoder {
|
||||
if (acm_codec_id == -1)
|
||||
return NetEqDecoder::kDecoderArbitrary; // External decoder.
|
||||
const rtc::Optional<RentACodec::CodecId> cid =
|
||||
const absl::optional<RentACodec::CodecId> cid =
|
||||
RentACodec::CodecIdFromIndex(acm_codec_id);
|
||||
RTC_DCHECK(cid) << "Invalid codec index: " << acm_codec_id;
|
||||
const rtc::Optional<NetEqDecoder> ned =
|
||||
const absl::optional<NetEqDecoder> ned =
|
||||
RentACodec::NetEqDecoderFromCodecId(*cid, channels);
|
||||
RTC_DCHECK(ned) << "Invalid codec ID: " << static_cast<int>(*cid);
|
||||
return *ned;
|
||||
}();
|
||||
const rtc::Optional<SdpAudioFormat> new_format =
|
||||
const absl::optional<SdpAudioFormat> new_format =
|
||||
NetEqDecoderToSdpAudioFormat(neteq_decoder);
|
||||
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
@ -276,9 +276,9 @@ void AcmReceiver::FlushBuffers() {
|
||||
void AcmReceiver::RemoveAllCodecs() {
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
neteq_->RemoveAllPayloadTypes();
|
||||
last_audio_decoder_ = rtc::nullopt;
|
||||
last_audio_format_ = rtc::nullopt;
|
||||
last_packet_sample_rate_hz_ = rtc::nullopt;
|
||||
last_audio_decoder_ = absl::nullopt;
|
||||
last_audio_format_ = absl::nullopt;
|
||||
last_packet_sample_rate_hz_ = absl::nullopt;
|
||||
}
|
||||
|
||||
int AcmReceiver::RemoveCodec(uint8_t payload_type) {
|
||||
@ -289,14 +289,14 @@ int AcmReceiver::RemoveCodec(uint8_t payload_type) {
|
||||
return -1;
|
||||
}
|
||||
if (last_audio_decoder_ && payload_type == last_audio_decoder_->pltype) {
|
||||
last_audio_decoder_ = rtc::nullopt;
|
||||
last_audio_format_ = rtc::nullopt;
|
||||
last_packet_sample_rate_hz_ = rtc::nullopt;
|
||||
last_audio_decoder_ = absl::nullopt;
|
||||
last_audio_format_ = absl::nullopt;
|
||||
last_packet_sample_rate_hz_ = absl::nullopt;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
rtc::Optional<uint32_t> AcmReceiver::GetPlayoutTimestamp() {
|
||||
absl::optional<uint32_t> AcmReceiver::GetPlayoutTimestamp() {
|
||||
return neteq_->GetPlayoutTimestamp();
|
||||
}
|
||||
|
||||
@ -317,7 +317,7 @@ int AcmReceiver::LastAudioCodec(CodecInst* codec) const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
rtc::Optional<SdpAudioFormat> AcmReceiver::LastAudioFormat() const {
|
||||
absl::optional<SdpAudioFormat> AcmReceiver::LastAudioFormat() const {
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
return last_audio_format_;
|
||||
}
|
||||
@ -354,7 +354,7 @@ void AcmReceiver::GetNetworkStatistics(NetworkStatistics* acm_stat) {
|
||||
int AcmReceiver::DecoderByPayloadType(uint8_t payload_type,
|
||||
CodecInst* codec) const {
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
const rtc::Optional<CodecInst> ci = neteq_->GetDecoder(payload_type);
|
||||
const absl::optional<CodecInst> ci = neteq_->GetDecoder(payload_type);
|
||||
if (ci) {
|
||||
*codec = *ci;
|
||||
return 0;
|
||||
@ -384,10 +384,10 @@ void AcmReceiver::ResetInitialDelay() {
|
||||
// TODO(turajs): Should NetEq Buffer be flushed?
|
||||
}
|
||||
|
||||
const rtc::Optional<CodecInst> AcmReceiver::RtpHeaderToDecoder(
|
||||
const absl::optional<CodecInst> AcmReceiver::RtpHeaderToDecoder(
|
||||
const RTPHeader& rtp_header,
|
||||
uint8_t first_payload_byte) const {
|
||||
const rtc::Optional<CodecInst> ci =
|
||||
const absl::optional<CodecInst> ci =
|
||||
neteq_->GetDecoder(rtp_header.payloadType);
|
||||
if (ci && STR_CASE_CMP(ci->plname, "red") == 0) {
|
||||
// This is a RED packet. Get the payload of the audio codec.
|
||||
|
||||
@ -16,9 +16,9 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "api/audio/audio_frame.h"
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/array_view.h"
|
||||
#include "api/optional.h"
|
||||
#include "api/audio/audio_frame.h"
|
||||
#include "common_audio/vad/include/webrtc_vad.h"
|
||||
#include "modules/audio_coding/acm2/acm_resampler.h"
|
||||
#include "modules/audio_coding/acm2/call_statistics.h"
|
||||
@ -159,7 +159,7 @@ class AcmReceiver {
|
||||
// packet. If no packet of a registered non-CNG codec has been received, the
|
||||
// return value is empty. Also, if the decoder was unregistered since the last
|
||||
// packet was inserted, the return value is empty.
|
||||
rtc::Optional<int> last_packet_sample_rate_hz() const;
|
||||
absl::optional<int> last_packet_sample_rate_hz() const;
|
||||
|
||||
// Returns last_output_sample_rate_hz from the NetEq instance.
|
||||
int last_output_sample_rate_hz() const;
|
||||
@ -195,7 +195,7 @@ class AcmReceiver {
|
||||
|
||||
// Returns the RTP timestamp for the last sample delivered by GetAudio().
|
||||
// The return value will be empty if no valid timestamp is available.
|
||||
rtc::Optional<uint32_t> GetPlayoutTimestamp();
|
||||
absl::optional<uint32_t> GetPlayoutTimestamp();
|
||||
|
||||
// Returns the current total delay from NetEq (packet buffer and sync buffer)
|
||||
// in ms, with smoothing applied to even out short-time fluctuations due to
|
||||
@ -215,7 +215,7 @@ class AcmReceiver {
|
||||
//
|
||||
int LastAudioCodec(CodecInst* codec) const;
|
||||
|
||||
rtc::Optional<SdpAudioFormat> LastAudioFormat() const;
|
||||
absl::optional<SdpAudioFormat> LastAudioFormat() const;
|
||||
|
||||
//
|
||||
// Get a decoder given its registered payload-type.
|
||||
@ -273,22 +273,23 @@ class AcmReceiver {
|
||||
int sample_rate_hz;
|
||||
};
|
||||
|
||||
const rtc::Optional<CodecInst> RtpHeaderToDecoder(const RTPHeader& rtp_header,
|
||||
uint8_t first_payload_byte)
|
||||
const RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
|
||||
const absl::optional<CodecInst> RtpHeaderToDecoder(
|
||||
const RTPHeader& rtp_header,
|
||||
uint8_t first_payload_byte) const
|
||||
RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
|
||||
|
||||
uint32_t NowInTimestamp(int decoder_sampling_rate) const;
|
||||
|
||||
rtc::CriticalSection crit_sect_;
|
||||
rtc::Optional<CodecInst> last_audio_decoder_ RTC_GUARDED_BY(crit_sect_);
|
||||
rtc::Optional<SdpAudioFormat> last_audio_format_ RTC_GUARDED_BY(crit_sect_);
|
||||
absl::optional<CodecInst> last_audio_decoder_ RTC_GUARDED_BY(crit_sect_);
|
||||
absl::optional<SdpAudioFormat> last_audio_format_ RTC_GUARDED_BY(crit_sect_);
|
||||
ACMResampler resampler_ RTC_GUARDED_BY(crit_sect_);
|
||||
std::unique_ptr<int16_t[]> last_audio_buffer_ RTC_GUARDED_BY(crit_sect_);
|
||||
CallStatistics call_stats_ RTC_GUARDED_BY(crit_sect_);
|
||||
const std::unique_ptr<NetEq> neteq_; // NetEq is thread-safe; no lock needed.
|
||||
const Clock* const clock_;
|
||||
bool resampled_last_output_frame_ RTC_GUARDED_BY(crit_sect_);
|
||||
rtc::Optional<int> last_packet_sample_rate_hz_ RTC_GUARDED_BY(crit_sect_);
|
||||
absl::optional<int> last_packet_sample_rate_hz_ RTC_GUARDED_BY(crit_sect_);
|
||||
};
|
||||
|
||||
} // namespace acm2
|
||||
|
||||
@ -54,7 +54,7 @@ class AudioCodingModuleImpl final : public AudioCodingModule {
|
||||
rtc::FunctionView<void(const AudioEncoder*)> query) override;
|
||||
|
||||
// Get current send codec.
|
||||
rtc::Optional<CodecInst> SendCodec() const override;
|
||||
absl::optional<CodecInst> SendCodec() const override;
|
||||
|
||||
// Get current send frequency.
|
||||
int SendFrequency() const override;
|
||||
@ -142,7 +142,7 @@ class AudioCodingModuleImpl final : public AudioCodingModule {
|
||||
// Get current received codec.
|
||||
int ReceiveCodec(CodecInst* current_codec) const override;
|
||||
|
||||
rtc::Optional<SdpAudioFormat> ReceiveFormat() const override;
|
||||
absl::optional<SdpAudioFormat> ReceiveFormat() const override;
|
||||
|
||||
// Incoming packet from network parsed and ready for decode.
|
||||
int IncomingPacket(const uint8_t* incoming_payload,
|
||||
@ -160,7 +160,7 @@ class AudioCodingModuleImpl final : public AudioCodingModule {
|
||||
|
||||
RTC_DEPRECATED int32_t PlayoutTimestamp(uint32_t* timestamp) override;
|
||||
|
||||
rtc::Optional<uint32_t> PlayoutTimestamp() override;
|
||||
absl::optional<uint32_t> PlayoutTimestamp() override;
|
||||
|
||||
int FilteredCurrentDelayMs() const override;
|
||||
|
||||
@ -603,7 +603,7 @@ void AudioCodingModuleImpl::QueryEncoder(
|
||||
}
|
||||
|
||||
// Get current send codec.
|
||||
rtc::Optional<CodecInst> AudioCodingModuleImpl::SendCodec() const {
|
||||
absl::optional<CodecInst> AudioCodingModuleImpl::SendCodec() const {
|
||||
rtc::CritScope lock(&acm_crit_sect_);
|
||||
if (encoder_factory_) {
|
||||
auto* ci = encoder_factory_->codec_manager.GetCodecInst();
|
||||
@ -616,12 +616,12 @@ rtc::Optional<CodecInst> AudioCodingModuleImpl::SendCodec() const {
|
||||
if (enc) {
|
||||
return acm2::CodecManager::ForgeCodecInst(enc.get());
|
||||
}
|
||||
return rtc::nullopt;
|
||||
return absl::nullopt;
|
||||
} else {
|
||||
return encoder_stack_
|
||||
? rtc::Optional<CodecInst>(
|
||||
? absl::optional<CodecInst>(
|
||||
acm2::CodecManager::ForgeCodecInst(encoder_stack_.get()))
|
||||
: rtc::nullopt;
|
||||
: absl::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
@ -640,7 +640,7 @@ int AudioCodingModuleImpl::SendFrequency() const {
|
||||
void AudioCodingModuleImpl::SetBitRate(int bitrate_bps) {
|
||||
rtc::CritScope lock(&acm_crit_sect_);
|
||||
if (encoder_stack_) {
|
||||
encoder_stack_->OnReceivedUplinkBandwidth(bitrate_bps, rtc::nullopt);
|
||||
encoder_stack_->OnReceivedUplinkBandwidth(bitrate_bps, absl::nullopt);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1062,7 +1062,7 @@ int AudioCodingModuleImpl::ReceiveCodec(CodecInst* current_codec) const {
|
||||
return receiver_.LastAudioCodec(current_codec);
|
||||
}
|
||||
|
||||
rtc::Optional<SdpAudioFormat> AudioCodingModuleImpl::ReceiveFormat() const {
|
||||
absl::optional<SdpAudioFormat> AudioCodingModuleImpl::ReceiveFormat() const {
|
||||
rtc::CritScope lock(&acm_crit_sect_);
|
||||
return receiver_.LastAudioFormat();
|
||||
}
|
||||
@ -1180,14 +1180,14 @@ int AudioCodingModuleImpl::DisableOpusDtx() {
|
||||
}
|
||||
|
||||
int32_t AudioCodingModuleImpl::PlayoutTimestamp(uint32_t* timestamp) {
|
||||
rtc::Optional<uint32_t> ts = PlayoutTimestamp();
|
||||
absl::optional<uint32_t> ts = PlayoutTimestamp();
|
||||
if (!ts)
|
||||
return -1;
|
||||
*timestamp = *ts;
|
||||
return 0;
|
||||
}
|
||||
|
||||
rtc::Optional<uint32_t> AudioCodingModuleImpl::PlayoutTimestamp() {
|
||||
absl::optional<uint32_t> AudioCodingModuleImpl::PlayoutTimestamp() {
|
||||
return receiver_.GetPlayoutTimestamp();
|
||||
}
|
||||
|
||||
@ -1279,7 +1279,7 @@ int AudioCodingModule::Codec(const char* payload_name,
|
||||
CodecInst* codec,
|
||||
int sampling_freq_hz,
|
||||
size_t channels) {
|
||||
rtc::Optional<CodecInst> ci = acm2::RentACodec::CodecInstByParams(
|
||||
absl::optional<CodecInst> ci = acm2::RentACodec::CodecInstByParams(
|
||||
payload_name, sampling_freq_hz, channels);
|
||||
if (ci) {
|
||||
*codec = *ci;
|
||||
@ -1299,12 +1299,12 @@ int AudioCodingModule::Codec(const char* payload_name,
|
||||
int AudioCodingModule::Codec(const char* payload_name,
|
||||
int sampling_freq_hz,
|
||||
size_t channels) {
|
||||
rtc::Optional<acm2::RentACodec::CodecId> ci =
|
||||
absl::optional<acm2::RentACodec::CodecId> ci =
|
||||
acm2::RentACodec::CodecIdByParams(payload_name, sampling_freq_hz,
|
||||
channels);
|
||||
if (!ci)
|
||||
return -1;
|
||||
rtc::Optional<int> i = acm2::RentACodec::CodecIndexFromId(*ci);
|
||||
absl::optional<int> i = acm2::RentACodec::CodecIndexFromId(*ci);
|
||||
return i ? *i : -1;
|
||||
}
|
||||
|
||||
|
||||
@ -241,7 +241,7 @@ class AudioCodingModuleTestOldApi : public ::testing::Test {
|
||||
|
||||
// These two have to be kept in sync for now. In the future, we'll be able to
|
||||
// eliminate the CodecInst and keep only the SdpAudioFormat.
|
||||
rtc::Optional<SdpAudioFormat> audio_format_;
|
||||
absl::optional<SdpAudioFormat> audio_format_;
|
||||
CodecInst codec_;
|
||||
|
||||
Clock* clock_;
|
||||
@ -1058,7 +1058,7 @@ TEST_F(AcmReceiverBitExactnessOldApi, 48kHzOutputExternalDecoder) {
|
||||
}
|
||||
std::unique_ptr<AudioDecoder> MakeAudioDecoder(
|
||||
const SdpAudioFormat& format,
|
||||
rtc::Optional<AudioCodecPairId> codec_pair_id) override {
|
||||
absl::optional<AudioCodecPairId> codec_pair_id) override {
|
||||
return format.name == "MockPCMu"
|
||||
? std::move(mock_decoder_)
|
||||
: fact_->MakeAudioDecoder(format, codec_pair_id);
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "api/optional.h"
|
||||
#include "absl/types/optional.h"
|
||||
#include "common_types.h" // NOLINT(build/include)
|
||||
#include "modules/audio_coding/acm2/rent_a_codec.h"
|
||||
#include "modules/audio_coding/include/audio_coding_module.h"
|
||||
@ -43,7 +43,7 @@ class CodecManager final {
|
||||
return send_codec_inst_ ? &*send_codec_inst_ : nullptr;
|
||||
}
|
||||
|
||||
void UnsetCodecInst() { send_codec_inst_ = rtc::nullopt; }
|
||||
void UnsetCodecInst() { send_codec_inst_ = absl::nullopt; }
|
||||
|
||||
const RentACodec::StackParameters* GetStackParams() const {
|
||||
return &codec_stack_params_;
|
||||
@ -63,7 +63,7 @@ class CodecManager final {
|
||||
|
||||
private:
|
||||
rtc::ThreadChecker thread_checker_;
|
||||
rtc::Optional<CodecInst> send_codec_inst_;
|
||||
absl::optional<CodecInst> send_codec_inst_;
|
||||
RentACodec::StackParameters codec_stack_params_;
|
||||
bool recreate_encoder_ = true; // Need to recreate encoder?
|
||||
|
||||
|
||||
@ -44,7 +44,7 @@
|
||||
namespace webrtc {
|
||||
namespace acm2 {
|
||||
|
||||
rtc::Optional<RentACodec::CodecId> RentACodec::CodecIdByParams(
|
||||
absl::optional<RentACodec::CodecId> RentACodec::CodecIdByParams(
|
||||
const char* payload_name,
|
||||
int sampling_freq_hz,
|
||||
size_t channels) {
|
||||
@ -52,25 +52,25 @@ rtc::Optional<RentACodec::CodecId> RentACodec::CodecIdByParams(
|
||||
ACMCodecDB::CodecId(payload_name, sampling_freq_hz, channels));
|
||||
}
|
||||
|
||||
rtc::Optional<CodecInst> RentACodec::CodecInstById(CodecId codec_id) {
|
||||
rtc::Optional<int> mi = CodecIndexFromId(codec_id);
|
||||
return mi ? rtc::Optional<CodecInst>(Database()[*mi])
|
||||
: rtc::nullopt;
|
||||
absl::optional<CodecInst> RentACodec::CodecInstById(CodecId codec_id) {
|
||||
absl::optional<int> mi = CodecIndexFromId(codec_id);
|
||||
return mi ? absl::optional<CodecInst>(Database()[*mi]) : absl::nullopt;
|
||||
}
|
||||
|
||||
rtc::Optional<RentACodec::CodecId> RentACodec::CodecIdByInst(
|
||||
absl::optional<RentACodec::CodecId> RentACodec::CodecIdByInst(
|
||||
const CodecInst& codec_inst) {
|
||||
return CodecIdFromIndex(ACMCodecDB::CodecNumber(codec_inst));
|
||||
}
|
||||
|
||||
rtc::Optional<CodecInst> RentACodec::CodecInstByParams(const char* payload_name,
|
||||
int sampling_freq_hz,
|
||||
size_t channels) {
|
||||
rtc::Optional<CodecId> codec_id =
|
||||
absl::optional<CodecInst> RentACodec::CodecInstByParams(
|
||||
const char* payload_name,
|
||||
int sampling_freq_hz,
|
||||
size_t channels) {
|
||||
absl::optional<CodecId> codec_id =
|
||||
CodecIdByParams(payload_name, sampling_freq_hz, channels);
|
||||
if (!codec_id)
|
||||
return rtc::nullopt;
|
||||
rtc::Optional<CodecInst> ci = CodecInstById(*codec_id);
|
||||
return absl::nullopt;
|
||||
absl::optional<CodecInst> ci = CodecInstById(*codec_id);
|
||||
RTC_DCHECK(ci);
|
||||
|
||||
// Keep the number of channels from the function call. For most codecs it
|
||||
@ -84,13 +84,13 @@ bool RentACodec::IsCodecValid(const CodecInst& codec_inst) {
|
||||
return ACMCodecDB::CodecNumber(codec_inst) >= 0;
|
||||
}
|
||||
|
||||
rtc::Optional<bool> RentACodec::IsSupportedNumChannels(CodecId codec_id,
|
||||
size_t num_channels) {
|
||||
absl::optional<bool> RentACodec::IsSupportedNumChannels(CodecId codec_id,
|
||||
size_t num_channels) {
|
||||
auto i = CodecIndexFromId(codec_id);
|
||||
return i ? rtc::Optional<bool>(
|
||||
return i ? absl::optional<bool>(
|
||||
ACMCodecDB::codec_settings_[*i].channel_support >=
|
||||
num_channels)
|
||||
: rtc::nullopt;
|
||||
: absl::nullopt;
|
||||
}
|
||||
|
||||
rtc::ArrayView<const CodecInst> RentACodec::Database() {
|
||||
@ -98,12 +98,12 @@ rtc::ArrayView<const CodecInst> RentACodec::Database() {
|
||||
NumberOfCodecs());
|
||||
}
|
||||
|
||||
rtc::Optional<NetEqDecoder> RentACodec::NetEqDecoderFromCodecId(
|
||||
absl::optional<NetEqDecoder> RentACodec::NetEqDecoderFromCodecId(
|
||||
CodecId codec_id,
|
||||
size_t num_channels) {
|
||||
rtc::Optional<int> i = CodecIndexFromId(codec_id);
|
||||
absl::optional<int> i = CodecIndexFromId(codec_id);
|
||||
if (!i)
|
||||
return rtc::nullopt;
|
||||
return absl::nullopt;
|
||||
const NetEqDecoder ned = ACMCodecDB::neteq_decoders_[*i];
|
||||
return (ned == NetEqDecoder::kDecoderOpus && num_channels == 2)
|
||||
? NetEqDecoder::kDecoderOpus_2ch
|
||||
@ -276,8 +276,7 @@ std::unique_ptr<AudioEncoder> RentACodec::RentEncoderStack(
|
||||
|
||||
auto pt = [¶m](const std::map<int, int>& m) {
|
||||
auto it = m.find(param->speech_encoder->SampleRateHz());
|
||||
return it == m.end() ? rtc::nullopt
|
||||
: rtc::Optional<int>(it->second);
|
||||
return it == m.end() ? absl::nullopt : absl::optional<int>(it->second);
|
||||
};
|
||||
auto cng_pt = pt(param->cng_payload_types);
|
||||
param->use_cng =
|
||||
|
||||
@ -15,10 +15,10 @@
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/array_view.h"
|
||||
#include "api/audio_codecs/audio_decoder.h"
|
||||
#include "api/audio_codecs/audio_encoder.h"
|
||||
#include "api/optional.h"
|
||||
#include "modules/audio_coding/include/audio_coding_module_typedefs.h"
|
||||
#include "modules/audio_coding/neteq/neteq_decoder_enum.h"
|
||||
#include "rtc_base/constructormagic.h"
|
||||
@ -107,28 +107,28 @@ class RentACodec {
|
||||
return static_cast<size_t>(CodecId::kNumCodecs);
|
||||
}
|
||||
|
||||
static inline rtc::Optional<int> CodecIndexFromId(CodecId codec_id) {
|
||||
static inline absl::optional<int> CodecIndexFromId(CodecId codec_id) {
|
||||
const int i = static_cast<int>(codec_id);
|
||||
return i >= 0 && i < static_cast<int>(NumberOfCodecs())
|
||||
? rtc::Optional<int>(i)
|
||||
: rtc::nullopt;
|
||||
? absl::optional<int>(i)
|
||||
: absl::nullopt;
|
||||
}
|
||||
|
||||
static inline rtc::Optional<CodecId> CodecIdFromIndex(int codec_index) {
|
||||
static inline absl::optional<CodecId> CodecIdFromIndex(int codec_index) {
|
||||
return static_cast<size_t>(codec_index) < NumberOfCodecs()
|
||||
? rtc::Optional<RentACodec::CodecId>(
|
||||
? absl::optional<RentACodec::CodecId>(
|
||||
static_cast<RentACodec::CodecId>(codec_index))
|
||||
: rtc::nullopt;
|
||||
: absl::nullopt;
|
||||
}
|
||||
|
||||
static rtc::Optional<CodecId> CodecIdByParams(const char* payload_name,
|
||||
int sampling_freq_hz,
|
||||
size_t channels);
|
||||
static rtc::Optional<CodecInst> CodecInstById(CodecId codec_id);
|
||||
static rtc::Optional<CodecId> CodecIdByInst(const CodecInst& codec_inst);
|
||||
static rtc::Optional<CodecInst> CodecInstByParams(const char* payload_name,
|
||||
int sampling_freq_hz,
|
||||
size_t channels);
|
||||
static absl::optional<CodecId> CodecIdByParams(const char* payload_name,
|
||||
int sampling_freq_hz,
|
||||
size_t channels);
|
||||
static absl::optional<CodecInst> CodecInstById(CodecId codec_id);
|
||||
static absl::optional<CodecId> CodecIdByInst(const CodecInst& codec_inst);
|
||||
static absl::optional<CodecInst> CodecInstByParams(const char* payload_name,
|
||||
int sampling_freq_hz,
|
||||
size_t channels);
|
||||
static bool IsCodecValid(const CodecInst& codec_inst);
|
||||
|
||||
static inline bool IsPayloadTypeValid(int payload_type) {
|
||||
@ -137,10 +137,10 @@ class RentACodec {
|
||||
|
||||
static rtc::ArrayView<const CodecInst> Database();
|
||||
|
||||
static rtc::Optional<bool> IsSupportedNumChannels(CodecId codec_id,
|
||||
size_t num_channels);
|
||||
static absl::optional<bool> IsSupportedNumChannels(CodecId codec_id,
|
||||
size_t num_channels);
|
||||
|
||||
static rtc::Optional<NetEqDecoder> NetEqDecoderFromCodecId(
|
||||
static absl::optional<NetEqDecoder> NetEqDecoderFromCodecId(
|
||||
CodecId codec_id,
|
||||
size_t num_channels);
|
||||
|
||||
|
||||
@ -123,7 +123,7 @@ AudioEncoderRuntimeConfig AudioNetworkAdaptorImpl::GetEncoderRuntimeConfig() {
|
||||
controller->MakeDecision(&config);
|
||||
|
||||
// Update ANA stats.
|
||||
auto increment_opt = [](rtc::Optional<uint32_t>& a) {
|
||||
auto increment_opt = [](absl::optional<uint32_t>& a) {
|
||||
a = a.value_or(0) + 1;
|
||||
};
|
||||
if (prev_config_) {
|
||||
|
||||
@ -75,7 +75,7 @@ class AudioNetworkAdaptorImpl final : public AudioNetworkAdaptor {
|
||||
|
||||
Controller::NetworkMetrics last_metrics_;
|
||||
|
||||
rtc::Optional<AudioEncoderRuntimeConfig> prev_config_;
|
||||
absl::optional<AudioEncoderRuntimeConfig> prev_config_;
|
||||
|
||||
ANAStats stats_;
|
||||
|
||||
|
||||
@ -43,8 +43,8 @@ class BitrateController final : public Controller {
|
||||
const Config config_;
|
||||
int bitrate_bps_;
|
||||
int frame_length_ms_;
|
||||
rtc::Optional<int> target_audio_bitrate_bps_;
|
||||
rtc::Optional<size_t> overhead_bytes_per_packet_;
|
||||
absl::optional<int> target_audio_bitrate_bps_;
|
||||
absl::optional<size_t> overhead_bytes_per_packet_;
|
||||
RTC_DISALLOW_COPY_AND_ASSIGN(BitrateController);
|
||||
};
|
||||
|
||||
|
||||
@ -20,8 +20,8 @@ namespace {
|
||||
|
||||
void UpdateNetworkMetrics(
|
||||
BitrateController* controller,
|
||||
const rtc::Optional<int>& target_audio_bitrate_bps,
|
||||
const rtc::Optional<size_t>& overhead_bytes_per_packet) {
|
||||
const absl::optional<int>& target_audio_bitrate_bps,
|
||||
const absl::optional<size_t>& overhead_bytes_per_packet) {
|
||||
// UpdateNetworkMetrics can accept multiple network metric updates at once.
|
||||
// However, currently, the most used case is to update one metric at a time.
|
||||
// To reflect this fact, we separate the calls.
|
||||
@ -38,7 +38,7 @@ void UpdateNetworkMetrics(
|
||||
}
|
||||
|
||||
void CheckDecision(BitrateController* controller,
|
||||
const rtc::Optional<int>& frame_length_ms,
|
||||
const absl::optional<int>& frame_length_ms,
|
||||
int expected_bitrate_bps) {
|
||||
AudioEncoderRuntimeConfig config;
|
||||
config.frame_length_ms = frame_length_ms;
|
||||
@ -58,7 +58,7 @@ TEST(AnaBitrateControllerTest, OutputInitValueWhenTargetBitrateUnknown) {
|
||||
constexpr size_t kOverheadBytesPerPacket = 64;
|
||||
BitrateController controller(BitrateController::Config(
|
||||
kInitialBitrateBps, kInitialFrameLengthMs, 0, 0));
|
||||
UpdateNetworkMetrics(&controller, rtc::nullopt, kOverheadBytesPerPacket);
|
||||
UpdateNetworkMetrics(&controller, absl::nullopt, kOverheadBytesPerPacket);
|
||||
CheckDecision(&controller, kInitialFrameLengthMs * 2, kInitialBitrateBps);
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ TEST(AnaBitrateControllerTest, OutputInitValueWhenOverheadUnknown) {
|
||||
constexpr int kTargetBitrateBps = 48000;
|
||||
BitrateController controller(BitrateController::Config(
|
||||
kInitialBitrateBps, kInitialFrameLengthMs, 0, 0));
|
||||
UpdateNetworkMetrics(&controller, kTargetBitrateBps, rtc::nullopt);
|
||||
UpdateNetworkMetrics(&controller, kTargetBitrateBps, absl::nullopt);
|
||||
CheckDecision(&controller, kInitialFrameLengthMs * 2, kInitialBitrateBps);
|
||||
}
|
||||
|
||||
@ -126,7 +126,7 @@ TEST(AnaBitrateControllerTest, TreatUnknownFrameLengthAsFrameLengthUnchanged) {
|
||||
kTargetBitrateBps -
|
||||
kOverheadBytesPerPacket * 8 * 1000 / kInitialFrameLengthMs;
|
||||
UpdateNetworkMetrics(&controller, kTargetBitrateBps, kOverheadBytesPerPacket);
|
||||
CheckDecision(&controller, rtc::nullopt, kBitrateBps);
|
||||
CheckDecision(&controller, absl::nullopt, kBitrateBps);
|
||||
}
|
||||
|
||||
TEST(AnaBitrateControllerTest, IncreaseBitrateOnFrameLengthIncreased) {
|
||||
@ -142,7 +142,7 @@ TEST(AnaBitrateControllerTest, IncreaseBitrateOnFrameLengthIncreased) {
|
||||
kTargetBitrateBps -
|
||||
kOverheadBytesPerPacket * 8 * 1000 / kInitialFrameLengthMs;
|
||||
UpdateNetworkMetrics(&controller, kTargetBitrateBps, kOverheadBytesPerPacket);
|
||||
CheckDecision(&controller, rtc::nullopt, kBitrateBps);
|
||||
CheckDecision(&controller, absl::nullopt, kBitrateBps);
|
||||
|
||||
constexpr int kFrameLengthMs = 60;
|
||||
constexpr size_t kPacketOverheadRateDiff =
|
||||
@ -166,7 +166,7 @@ TEST(AnaBitrateControllerTest, DecreaseBitrateOnFrameLengthDecreased) {
|
||||
kTargetBitrateBps -
|
||||
kOverheadBytesPerPacket * 8 * 1000 / kInitialFrameLengthMs;
|
||||
UpdateNetworkMetrics(&controller, kTargetBitrateBps, kOverheadBytesPerPacket);
|
||||
CheckDecision(&controller, rtc::nullopt, kBitrateBps);
|
||||
CheckDecision(&controller, absl::nullopt, kBitrateBps);
|
||||
|
||||
constexpr int kFrameLengthMs = 20;
|
||||
constexpr size_t kPacketOverheadRateDiff =
|
||||
|
||||
@ -44,7 +44,7 @@ class ChannelController final : public Controller {
|
||||
private:
|
||||
const Config config_;
|
||||
size_t channels_to_encode_;
|
||||
rtc::Optional<int> uplink_bandwidth_bps_;
|
||||
absl::optional<int> uplink_bandwidth_bps_;
|
||||
RTC_DISALLOW_COPY_AND_ASSIGN(ChannelController);
|
||||
};
|
||||
|
||||
|
||||
@ -32,7 +32,7 @@ std::unique_ptr<ChannelController> CreateChannelController(int init_channels) {
|
||||
}
|
||||
|
||||
void CheckDecision(ChannelController* controller,
|
||||
const rtc::Optional<int>& uplink_bandwidth_bps,
|
||||
const absl::optional<int>& uplink_bandwidth_bps,
|
||||
size_t expected_num_channels) {
|
||||
if (uplink_bandwidth_bps) {
|
||||
Controller::NetworkMetrics network_metrics;
|
||||
@ -49,7 +49,7 @@ void CheckDecision(ChannelController* controller,
|
||||
TEST(ChannelControllerTest, OutputInitValueWhenUplinkBandwidthUnknown) {
|
||||
constexpr int kInitChannels = 2;
|
||||
auto controller = CreateChannelController(kInitChannels);
|
||||
CheckDecision(controller.get(), rtc::nullopt, kInitChannels);
|
||||
CheckDecision(controller.get(), absl::nullopt, kInitChannels);
|
||||
}
|
||||
|
||||
TEST(ChannelControllerTest, SwitchTo2ChannelsOnHighUplinkBandwidth) {
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
#ifndef MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_CONTROLLER_H_
|
||||
#define MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_CONTROLLER_H_
|
||||
|
||||
#include "api/optional.h"
|
||||
#include "absl/types/optional.h"
|
||||
#include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -21,12 +21,12 @@ class Controller {
|
||||
struct NetworkMetrics {
|
||||
NetworkMetrics();
|
||||
~NetworkMetrics();
|
||||
rtc::Optional<int> uplink_bandwidth_bps;
|
||||
rtc::Optional<float> uplink_packet_loss_fraction;
|
||||
rtc::Optional<float> uplink_recoverable_packet_loss_fraction;
|
||||
rtc::Optional<int> target_audio_bitrate_bps;
|
||||
rtc::Optional<int> rtt_ms;
|
||||
rtc::Optional<size_t> overhead_bytes_per_packet;
|
||||
absl::optional<int> uplink_bandwidth_bps;
|
||||
absl::optional<float> uplink_packet_loss_fraction;
|
||||
absl::optional<float> uplink_recoverable_packet_loss_fraction;
|
||||
absl::optional<int> target_audio_bitrate_bps;
|
||||
absl::optional<int> rtt_ms;
|
||||
absl::optional<size_t> overhead_bytes_per_packet;
|
||||
};
|
||||
|
||||
virtual ~Controller() = default;
|
||||
|
||||
@ -327,7 +327,7 @@ ControllerManagerImpl::ControllerManagerImpl(
|
||||
const std::map<const Controller*, std::pair<int, float>>& scoring_points)
|
||||
: config_(config),
|
||||
controllers_(std::move(controllers)),
|
||||
last_reordering_time_ms_(rtc::nullopt),
|
||||
last_reordering_time_ms_(absl::nullopt),
|
||||
last_scoring_point_(0, 0.0) {
|
||||
for (auto& controller : controllers_)
|
||||
default_sorted_controllers_.push_back(controller.get());
|
||||
|
||||
@ -104,7 +104,7 @@ class ControllerManagerImpl final : public ControllerManager {
|
||||
|
||||
std::vector<std::unique_ptr<Controller>> controllers_;
|
||||
|
||||
rtc::Optional<int64_t> last_reordering_time_ms_;
|
||||
absl::optional<int64_t> last_reordering_time_ms_;
|
||||
ScoringPoint last_scoring_point_;
|
||||
|
||||
std::vector<Controller*> default_sorted_controllers_;
|
||||
|
||||
@ -87,8 +87,8 @@ ControllerManagerStates CreateControllerManager() {
|
||||
// exists in the vector.
|
||||
void CheckControllersOrder(
|
||||
ControllerManagerStates* states,
|
||||
const rtc::Optional<int>& uplink_bandwidth_bps,
|
||||
const rtc::Optional<float>& uplink_packet_loss_fraction,
|
||||
const absl::optional<int>& uplink_bandwidth_bps,
|
||||
const absl::optional<float>& uplink_packet_loss_fraction,
|
||||
const std::vector<int>& expected_order) {
|
||||
RTC_DCHECK_EQ(kNumControllers, expected_order.size());
|
||||
Controller::NetworkMetrics metrics;
|
||||
@ -124,8 +124,7 @@ TEST(ControllerManagerTest, ControllersInDefaultOrderOnEmptyNetworkMetrics) {
|
||||
auto states = CreateControllerManager();
|
||||
// |network_metrics| are empty, and the controllers are supposed to follow the
|
||||
// default order.
|
||||
CheckControllersOrder(&states, rtc::nullopt, rtc::nullopt,
|
||||
{0, 1, 2, 3});
|
||||
CheckControllersOrder(&states, absl::nullopt, absl::nullopt, {0, 1, 2, 3});
|
||||
}
|
||||
|
||||
TEST(ControllerManagerTest, ControllersWithoutCharPointAtEndAndInDefaultOrder) {
|
||||
|
||||
@ -40,7 +40,7 @@ class DtxController final : public Controller {
|
||||
private:
|
||||
const Config config_;
|
||||
bool dtx_enabled_;
|
||||
rtc::Optional<int> uplink_bandwidth_bps_;
|
||||
absl::optional<int> uplink_bandwidth_bps_;
|
||||
RTC_DISALLOW_COPY_AND_ASSIGN(DtxController);
|
||||
};
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@ std::unique_ptr<DtxController> CreateController(int initial_dtx_enabled) {
|
||||
}
|
||||
|
||||
void CheckDecision(DtxController* controller,
|
||||
const rtc::Optional<int>& uplink_bandwidth_bps,
|
||||
const absl::optional<int>& uplink_bandwidth_bps,
|
||||
bool expected_dtx_enabled) {
|
||||
if (uplink_bandwidth_bps) {
|
||||
Controller::NetworkMetrics network_metrics;
|
||||
@ -47,7 +47,7 @@ void CheckDecision(DtxController* controller,
|
||||
TEST(DtxControllerTest, OutputInitValueWhenUplinkBandwidthUnknown) {
|
||||
constexpr bool kInitialDtxEnabled = true;
|
||||
auto controller = CreateController(kInitialDtxEnabled);
|
||||
CheckDecision(controller.get(), rtc::nullopt, kInitialDtxEnabled);
|
||||
CheckDecision(controller.get(), absl::nullopt, kInitialDtxEnabled);
|
||||
}
|
||||
|
||||
TEST(DtxControllerTest, TurnOnDtxForLowUplinkBandwidth) {
|
||||
|
||||
@ -23,7 +23,7 @@ class NullSmoothingFilter final : public SmoothingFilter {
|
||||
public:
|
||||
void AddSample(float sample) override { last_sample_ = sample; }
|
||||
|
||||
rtc::Optional<float> GetAverage() override { return last_sample_; }
|
||||
absl::optional<float> GetAverage() override { return last_sample_; }
|
||||
|
||||
bool SetTimeConstantMs(int time_constant_ms) override {
|
||||
RTC_NOTREACHED();
|
||||
@ -31,7 +31,7 @@ class NullSmoothingFilter final : public SmoothingFilter {
|
||||
}
|
||||
|
||||
private:
|
||||
rtc::Optional<float> last_sample_;
|
||||
absl::optional<float> last_sample_;
|
||||
};
|
||||
}
|
||||
|
||||
@ -89,7 +89,7 @@ void FecControllerPlrBased::MakeDecision(AudioEncoderRuntimeConfig* config) {
|
||||
}
|
||||
|
||||
bool FecControllerPlrBased::FecEnablingDecision(
|
||||
const rtc::Optional<float>& packet_loss) const {
|
||||
const absl::optional<float>& packet_loss) const {
|
||||
if (!uplink_bandwidth_bps_ || !packet_loss) {
|
||||
return false;
|
||||
} else {
|
||||
@ -100,7 +100,7 @@ bool FecControllerPlrBased::FecEnablingDecision(
|
||||
}
|
||||
|
||||
bool FecControllerPlrBased::FecDisablingDecision(
|
||||
const rtc::Optional<float>& packet_loss) const {
|
||||
const absl::optional<float>& packet_loss) const {
|
||||
if (!uplink_bandwidth_bps_ || !packet_loss) {
|
||||
return false;
|
||||
} else {
|
||||
|
||||
@ -56,12 +56,12 @@ class FecControllerPlrBased final : public Controller {
|
||||
void MakeDecision(AudioEncoderRuntimeConfig* config) override;
|
||||
|
||||
private:
|
||||
bool FecEnablingDecision(const rtc::Optional<float>& packet_loss) const;
|
||||
bool FecDisablingDecision(const rtc::Optional<float>& packet_loss) const;
|
||||
bool FecEnablingDecision(const absl::optional<float>& packet_loss) const;
|
||||
bool FecDisablingDecision(const absl::optional<float>& packet_loss) const;
|
||||
|
||||
const Config config_;
|
||||
bool fec_enabled_;
|
||||
rtc::Optional<int> uplink_bandwidth_bps_;
|
||||
absl::optional<int> uplink_bandwidth_bps_;
|
||||
const std::unique_ptr<SmoothingFilter> packet_loss_smoother_;
|
||||
|
||||
RTC_DISALLOW_COPY_AND_ASSIGN(FecControllerPlrBased);
|
||||
|
||||
@ -78,8 +78,8 @@ FecControllerPlrBasedTestStates CreateFecControllerPlrBased(
|
||||
}
|
||||
|
||||
void UpdateNetworkMetrics(FecControllerPlrBasedTestStates* states,
|
||||
const rtc::Optional<int>& uplink_bandwidth_bps,
|
||||
const rtc::Optional<float>& uplink_packet_loss) {
|
||||
const absl::optional<int>& uplink_bandwidth_bps,
|
||||
const absl::optional<float>& uplink_packet_loss) {
|
||||
// UpdateNetworkMetrics can accept multiple network metric updates at once.
|
||||
// However, currently, the most used case is to update one metric at a time.
|
||||
// To reflect this fact, we separate the calls.
|
||||
@ -131,7 +131,7 @@ TEST(FecControllerPlrBasedTest, OutputInitValueWhenUplinkBandwidthUnknown) {
|
||||
kEnablingPacketLossAtLowBw - kEpsilon, kEnablingPacketLossAtLowBw,
|
||||
kEnablingPacketLossAtLowBw + kEpsilon}) {
|
||||
auto states = CreateFecControllerPlrBased(initial_fec_enabled);
|
||||
UpdateNetworkMetrics(&states, rtc::nullopt, packet_loss);
|
||||
UpdateNetworkMetrics(&states, absl::nullopt, packet_loss);
|
||||
CheckDecision(&states, initial_fec_enabled, packet_loss);
|
||||
}
|
||||
}
|
||||
@ -146,7 +146,7 @@ TEST(FecControllerPlrBasedTest,
|
||||
kDisablingBandwidthLow + 1, kEnablingBandwidthLow - 1,
|
||||
kEnablingBandwidthLow, kEnablingBandwidthLow + 1}) {
|
||||
auto states = CreateFecControllerPlrBased(initial_fec_enabled);
|
||||
UpdateNetworkMetrics(&states, bandwidth, rtc::nullopt);
|
||||
UpdateNetworkMetrics(&states, bandwidth, absl::nullopt);
|
||||
CheckDecision(&states, initial_fec_enabled, 0.0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -55,8 +55,8 @@ class FecControllerRplrBased final : public Controller {
|
||||
|
||||
const Config config_;
|
||||
bool fec_enabled_;
|
||||
rtc::Optional<int> uplink_bandwidth_bps_;
|
||||
rtc::Optional<float> uplink_recoverable_packet_loss_;
|
||||
absl::optional<int> uplink_bandwidth_bps_;
|
||||
absl::optional<float> uplink_recoverable_packet_loss_;
|
||||
|
||||
RTC_DISALLOW_COPY_AND_ASSIGN(FecControllerRplrBased);
|
||||
};
|
||||
|
||||
@ -44,14 +44,14 @@ constexpr float kEnablingRecoverablePacketLossAtHighBw = 0.05f;
|
||||
|
||||
constexpr float kEpsilon = 1e-5f;
|
||||
|
||||
rtc::Optional<float> GetRandomProbabilityOrUnknown() {
|
||||
absl::optional<float> GetRandomProbabilityOrUnknown() {
|
||||
std::random_device rd;
|
||||
std::mt19937 generator(rd());
|
||||
std::uniform_real_distribution<> distribution(0, 1);
|
||||
|
||||
return (distribution(generator) < 0.2)
|
||||
? rtc::nullopt
|
||||
: rtc::Optional<float>(distribution(generator));
|
||||
? absl::nullopt
|
||||
: absl::optional<float>(distribution(generator));
|
||||
}
|
||||
|
||||
std::unique_ptr<FecControllerRplrBased> CreateFecControllerRplrBased(
|
||||
@ -70,9 +70,9 @@ std::unique_ptr<FecControllerRplrBased> CreateFecControllerRplrBased(
|
||||
|
||||
void UpdateNetworkMetrics(
|
||||
FecControllerRplrBased* controller,
|
||||
const rtc::Optional<int>& uplink_bandwidth_bps,
|
||||
const rtc::Optional<float>& uplink_packet_loss,
|
||||
const rtc::Optional<float>& uplink_recoveralbe_packet_loss) {
|
||||
const absl::optional<int>& uplink_bandwidth_bps,
|
||||
const absl::optional<float>& uplink_packet_loss,
|
||||
const absl::optional<float>& uplink_recoveralbe_packet_loss) {
|
||||
// UpdateNetworkMetrics can accept multiple network metric updates at once.
|
||||
// However, currently, the most used case is to update one metric at a time.
|
||||
// To reflect this fact, we separate the calls.
|
||||
@ -96,8 +96,8 @@ void UpdateNetworkMetrics(
|
||||
|
||||
void UpdateNetworkMetrics(
|
||||
FecControllerRplrBased* controller,
|
||||
const rtc::Optional<int>& uplink_bandwidth_bps,
|
||||
const rtc::Optional<float>& uplink_recoveralbe_packet_loss) {
|
||||
const absl::optional<int>& uplink_bandwidth_bps,
|
||||
const absl::optional<float>& uplink_recoveralbe_packet_loss) {
|
||||
// FecControllerRplrBased doesn't currently use the PLR (general packet-loss
|
||||
// rate) at all. (This might be changed in the future.) The unit-tests will
|
||||
// use a random value (including unknown), to show this does not interfere.
|
||||
@ -148,7 +148,7 @@ TEST(FecControllerRplrBasedTest, OutputInitValueWhenUplinkBandwidthUnknown) {
|
||||
kEnablingRecoverablePacketLossAtHighBw,
|
||||
kEnablingRecoverablePacketLossAtHighBw + kEpsilon}) {
|
||||
auto controller = CreateFecControllerRplrBased(initial_fec_enabled);
|
||||
UpdateNetworkMetrics(controller.get(), rtc::nullopt,
|
||||
UpdateNetworkMetrics(controller.get(), absl::nullopt,
|
||||
recoverable_packet_loss);
|
||||
CheckDecision(controller.get(), initial_fec_enabled,
|
||||
recoverable_packet_loss);
|
||||
@ -165,7 +165,7 @@ TEST(FecControllerRplrBasedTest,
|
||||
kDisablingBandwidthLow + 1, kEnablingBandwidthLow - 1,
|
||||
kEnablingBandwidthLow, kEnablingBandwidthLow + 1}) {
|
||||
auto controller = CreateFecControllerRplrBased(initial_fec_enabled);
|
||||
UpdateNetworkMetrics(controller.get(), bandwidth, rtc::nullopt);
|
||||
UpdateNetworkMetrics(controller.get(), bandwidth, absl::nullopt);
|
||||
CheckDecision(controller.get(), initial_fec_enabled, 0.0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,11 +73,11 @@ class FrameLengthController final : public Controller {
|
||||
|
||||
std::vector<int>::const_iterator frame_length_ms_;
|
||||
|
||||
rtc::Optional<int> uplink_bandwidth_bps_;
|
||||
absl::optional<int> uplink_bandwidth_bps_;
|
||||
|
||||
rtc::Optional<float> uplink_packet_loss_fraction_;
|
||||
absl::optional<float> uplink_packet_loss_fraction_;
|
||||
|
||||
rtc::Optional<size_t> overhead_bytes_per_packet_;
|
||||
absl::optional<size_t> overhead_bytes_per_packet_;
|
||||
|
||||
// True if the previous frame length decision was an increase, otherwise
|
||||
// false.
|
||||
|
||||
@ -78,9 +78,9 @@ CreateChangeCriteriaFor20ms60msAnd120ms() {
|
||||
|
||||
void UpdateNetworkMetrics(
|
||||
FrameLengthController* controller,
|
||||
const rtc::Optional<int>& uplink_bandwidth_bps,
|
||||
const rtc::Optional<float>& uplink_packet_loss_fraction,
|
||||
const rtc::Optional<size_t>& overhead_bytes_per_packet) {
|
||||
const absl::optional<int>& uplink_bandwidth_bps,
|
||||
const absl::optional<float>& uplink_packet_loss_fraction,
|
||||
const absl::optional<size_t>& overhead_bytes_per_packet) {
|
||||
// UpdateNetworkMetrics can accept multiple network metric updates at once.
|
||||
// However, currently, the most used case is to update one metric at a time.
|
||||
// To reflect this fact, we separate the calls.
|
||||
@ -114,14 +114,14 @@ TEST(FrameLengthControllerTest, DecreaseTo20MsOnHighUplinkBandwidth) {
|
||||
auto controller =
|
||||
CreateController(CreateChangeCriteriaFor20msAnd60ms(), {20, 60}, 60);
|
||||
UpdateNetworkMetrics(controller.get(), kFl60msTo20msBandwidthBps,
|
||||
rtc::nullopt, kOverheadBytesPerPacket);
|
||||
absl::nullopt, kOverheadBytesPerPacket);
|
||||
CheckDecision(controller.get(), 20);
|
||||
}
|
||||
|
||||
TEST(FrameLengthControllerTest, DecreaseTo20MsOnHighUplinkPacketLossFraction) {
|
||||
auto controller =
|
||||
CreateController(CreateChangeCriteriaFor20msAnd60ms(), {20, 60}, 60);
|
||||
UpdateNetworkMetrics(controller.get(), rtc::nullopt,
|
||||
UpdateNetworkMetrics(controller.get(), absl::nullopt,
|
||||
kFlDecreasingPacketLossFraction,
|
||||
kOverheadBytesPerPacket);
|
||||
CheckDecision(controller.get(), 20);
|
||||
@ -252,16 +252,12 @@ TEST(FrameLengthControllerTest, From120MsTo20MsOnHighUplinkBandwidth) {
|
||||
auto controller = CreateController(CreateChangeCriteriaFor20ms60msAnd120ms(),
|
||||
{20, 60, 120}, 120);
|
||||
// It takes two steps for frame length to go from 120ms to 20ms.
|
||||
UpdateNetworkMetrics(controller.get(),
|
||||
kFl60msTo20msBandwidthBps,
|
||||
rtc::nullopt,
|
||||
kOverheadBytesPerPacket);
|
||||
UpdateNetworkMetrics(controller.get(), kFl60msTo20msBandwidthBps,
|
||||
absl::nullopt, kOverheadBytesPerPacket);
|
||||
CheckDecision(controller.get(), 60);
|
||||
|
||||
UpdateNetworkMetrics(controller.get(),
|
||||
kFl60msTo20msBandwidthBps,
|
||||
rtc::nullopt,
|
||||
kOverheadBytesPerPacket);
|
||||
UpdateNetworkMetrics(controller.get(), kFl60msTo20msBandwidthBps,
|
||||
absl::nullopt, kOverheadBytesPerPacket);
|
||||
CheckDecision(controller.get(), 20);
|
||||
}
|
||||
|
||||
@ -269,12 +265,12 @@ TEST(FrameLengthControllerTest, From120MsTo20MsOnHighUplinkPacketLossFraction) {
|
||||
auto controller = CreateController(CreateChangeCriteriaFor20ms60msAnd120ms(),
|
||||
{20, 60, 120}, 120);
|
||||
// It takes two steps for frame length to go from 120ms to 20ms.
|
||||
UpdateNetworkMetrics(controller.get(), rtc::nullopt,
|
||||
UpdateNetworkMetrics(controller.get(), absl::nullopt,
|
||||
kFlDecreasingPacketLossFraction,
|
||||
kOverheadBytesPerPacket);
|
||||
CheckDecision(controller.get(), 60);
|
||||
|
||||
UpdateNetworkMetrics(controller.get(), rtc::nullopt,
|
||||
UpdateNetworkMetrics(controller.get(), absl::nullopt,
|
||||
kFlDecreasingPacketLossFraction,
|
||||
kOverheadBytesPerPacket);
|
||||
CheckDecision(controller.get(), 20);
|
||||
|
||||
@ -11,8 +11,8 @@
|
||||
#ifndef MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_INCLUDE_AUDIO_NETWORK_ADAPTOR_H_
|
||||
#define MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_INCLUDE_AUDIO_NETWORK_ADAPTOR_H_
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/audio_codecs/audio_encoder.h"
|
||||
#include "api/optional.h"
|
||||
#include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor_config.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
#ifndef MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_INCLUDE_AUDIO_NETWORK_ADAPTOR_CONFIG_H_
|
||||
#define MODULES_AUDIO_CODING_AUDIO_NETWORK_ADAPTOR_INCLUDE_AUDIO_NETWORK_ADAPTOR_CONFIG_H_
|
||||
|
||||
#include "api/optional.h"
|
||||
#include "absl/types/optional.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -21,18 +21,18 @@ struct AudioEncoderRuntimeConfig {
|
||||
~AudioEncoderRuntimeConfig();
|
||||
AudioEncoderRuntimeConfig& operator=(const AudioEncoderRuntimeConfig& other);
|
||||
bool operator==(const AudioEncoderRuntimeConfig& other) const;
|
||||
rtc::Optional<int> bitrate_bps;
|
||||
rtc::Optional<int> frame_length_ms;
|
||||
absl::optional<int> bitrate_bps;
|
||||
absl::optional<int> frame_length_ms;
|
||||
// Note: This is what we tell the encoder. It doesn't have to reflect
|
||||
// the actual NetworkMetrics; it's subject to our decision.
|
||||
rtc::Optional<float> uplink_packet_loss_fraction;
|
||||
rtc::Optional<bool> enable_fec;
|
||||
rtc::Optional<bool> enable_dtx;
|
||||
absl::optional<float> uplink_packet_loss_fraction;
|
||||
absl::optional<bool> enable_fec;
|
||||
absl::optional<bool> enable_dtx;
|
||||
|
||||
// Some encoders can encode fewer channels than the actual input to make
|
||||
// better use of the bandwidth. |num_channels| sets the number of channels
|
||||
// to encode.
|
||||
rtc::Optional<size_t> num_channels;
|
||||
absl::optional<size_t> num_channels;
|
||||
|
||||
// This is true if the last frame length change was an increase, and otherwise
|
||||
// false.
|
||||
|
||||
@ -12,8 +12,8 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/array_view.h"
|
||||
#include "api/optional.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/numerics/safe_conversions.h"
|
||||
#include "rtc_base/sanitizer.h"
|
||||
|
||||
@ -20,7 +20,7 @@ TEST(AudioDecoderFactoryTest, CreateUnknownDecoder) {
|
||||
CreateBuiltinAudioDecoderFactory();
|
||||
ASSERT_TRUE(adf);
|
||||
EXPECT_FALSE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("rey", 8000, 1), rtc::nullopt));
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("rey", 8000, 1), absl::nullopt));
|
||||
}
|
||||
|
||||
TEST(AudioDecoderFactoryTest, CreatePcmu) {
|
||||
@ -29,15 +29,15 @@ TEST(AudioDecoderFactoryTest, CreatePcmu) {
|
||||
ASSERT_TRUE(adf);
|
||||
// PCMu supports 8 kHz, and any number of channels.
|
||||
EXPECT_FALSE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("pcmu", 8000, 0), rtc::nullopt));
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("pcmu", 8000, 0), absl::nullopt));
|
||||
EXPECT_TRUE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("pcmu", 8000, 1), rtc::nullopt));
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("pcmu", 8000, 1), absl::nullopt));
|
||||
EXPECT_TRUE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("pcmu", 8000, 2), rtc::nullopt));
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("pcmu", 8000, 2), absl::nullopt));
|
||||
EXPECT_TRUE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("pcmu", 8000, 3), rtc::nullopt));
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("pcmu", 8000, 3), absl::nullopt));
|
||||
EXPECT_FALSE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("pcmu", 16000, 1), rtc::nullopt));
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("pcmu", 16000, 1), absl::nullopt));
|
||||
}
|
||||
|
||||
TEST(AudioDecoderFactoryTest, CreatePcma) {
|
||||
@ -46,15 +46,15 @@ TEST(AudioDecoderFactoryTest, CreatePcma) {
|
||||
ASSERT_TRUE(adf);
|
||||
// PCMa supports 8 kHz, and any number of channels.
|
||||
EXPECT_FALSE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("pcma", 8000, 0), rtc::nullopt));
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("pcma", 8000, 0), absl::nullopt));
|
||||
EXPECT_TRUE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("pcma", 8000, 1), rtc::nullopt));
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("pcma", 8000, 1), absl::nullopt));
|
||||
EXPECT_TRUE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("pcma", 8000, 2), rtc::nullopt));
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("pcma", 8000, 2), absl::nullopt));
|
||||
EXPECT_TRUE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("pcma", 8000, 3), rtc::nullopt));
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("pcma", 8000, 3), absl::nullopt));
|
||||
EXPECT_FALSE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("pcma", 16000, 1), rtc::nullopt));
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("pcma", 16000, 1), absl::nullopt));
|
||||
}
|
||||
|
||||
TEST(AudioDecoderFactoryTest, CreateIlbc) {
|
||||
@ -63,15 +63,15 @@ TEST(AudioDecoderFactoryTest, CreateIlbc) {
|
||||
ASSERT_TRUE(adf);
|
||||
// iLBC supports 8 kHz, 1 channel.
|
||||
EXPECT_FALSE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("ilbc", 8000, 0), rtc::nullopt));
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("ilbc", 8000, 0), absl::nullopt));
|
||||
#ifdef WEBRTC_CODEC_ILBC
|
||||
EXPECT_TRUE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("ilbc", 8000, 1), rtc::nullopt));
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("ilbc", 8000, 1), absl::nullopt));
|
||||
#endif
|
||||
EXPECT_FALSE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("ilbc", 8000, 2), rtc::nullopt));
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("ilbc", 8000, 2), absl::nullopt));
|
||||
EXPECT_FALSE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("ilbc", 16000, 1), rtc::nullopt));
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("ilbc", 16000, 1), absl::nullopt));
|
||||
}
|
||||
|
||||
TEST(AudioDecoderFactoryTest, CreateIsac) {
|
||||
@ -81,21 +81,21 @@ TEST(AudioDecoderFactoryTest, CreateIsac) {
|
||||
// iSAC supports 16 kHz, 1 channel. The float implementation additionally
|
||||
// supports 32 kHz, 1 channel.
|
||||
EXPECT_FALSE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("isac", 16000, 0), rtc::nullopt));
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("isac", 16000, 0), absl::nullopt));
|
||||
EXPECT_TRUE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("isac", 16000, 1), rtc::nullopt));
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("isac", 16000, 1), absl::nullopt));
|
||||
EXPECT_FALSE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("isac", 16000, 2), rtc::nullopt));
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("isac", 16000, 2), absl::nullopt));
|
||||
EXPECT_FALSE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("isac", 8000, 1), rtc::nullopt));
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("isac", 8000, 1), absl::nullopt));
|
||||
EXPECT_FALSE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("isac", 48000, 1), rtc::nullopt));
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("isac", 48000, 1), absl::nullopt));
|
||||
#ifdef WEBRTC_ARCH_ARM
|
||||
EXPECT_FALSE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("isac", 32000, 1), rtc::nullopt));
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("isac", 32000, 1), absl::nullopt));
|
||||
#else
|
||||
EXPECT_TRUE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("isac", 32000, 1), rtc::nullopt));
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("isac", 32000, 1), absl::nullopt));
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -108,10 +108,10 @@ TEST(AudioDecoderFactoryTest, CreateL16) {
|
||||
const int num_channels[] = {1, 2, 3, 4711};
|
||||
for (int clockrate : clockrates) {
|
||||
EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("l16", clockrate, 0),
|
||||
rtc::nullopt));
|
||||
absl::nullopt));
|
||||
for (int channels : num_channels) {
|
||||
EXPECT_TRUE(adf->MakeAudioDecoder(
|
||||
SdpAudioFormat("l16", clockrate, channels), rtc::nullopt));
|
||||
SdpAudioFormat("l16", clockrate, channels), absl::nullopt));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -122,21 +122,21 @@ TEST(AudioDecoderFactoryTest, CreateG722) {
|
||||
ASSERT_TRUE(adf);
|
||||
// g722 supports 8 kHz, 1-2 channels.
|
||||
EXPECT_FALSE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("g722", 8000, 0), rtc::nullopt));
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("g722", 8000, 0), absl::nullopt));
|
||||
EXPECT_TRUE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("g722", 8000, 1), rtc::nullopt));
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("g722", 8000, 1), absl::nullopt));
|
||||
EXPECT_TRUE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("g722", 8000, 2), rtc::nullopt));
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("g722", 8000, 2), absl::nullopt));
|
||||
EXPECT_FALSE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("g722", 8000, 3), rtc::nullopt));
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("g722", 8000, 3), absl::nullopt));
|
||||
EXPECT_FALSE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("g722", 16000, 1), rtc::nullopt));
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("g722", 16000, 1), absl::nullopt));
|
||||
EXPECT_FALSE(
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("g722", 32000, 1), rtc::nullopt));
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("g722", 32000, 1), absl::nullopt));
|
||||
|
||||
// g722 actually uses a 16 kHz sample rate instead of the nominal 8 kHz.
|
||||
std::unique_ptr<AudioDecoder> dec =
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("g722", 8000, 1), rtc::nullopt);
|
||||
adf->MakeAudioDecoder(SdpAudioFormat("g722", 8000, 1), absl::nullopt);
|
||||
EXPECT_EQ(16000, dec->SampleRateHz());
|
||||
}
|
||||
|
||||
@ -158,7 +158,7 @@ TEST(AudioDecoderFactoryTest, CreateOpus) {
|
||||
EXPECT_EQ(good,
|
||||
static_cast<bool>(adf->MakeAudioDecoder(
|
||||
SdpAudioFormat("opus", hz, channels, std::move(params)),
|
||||
rtc::nullopt)));
|
||||
absl::nullopt)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,7 +43,7 @@ TEST_P(AudioEncoderFactoryTest, CanConstructAllSupportedEncoders) {
|
||||
auto supported_encoders = factory->GetSupportedEncoders();
|
||||
for (const auto& spec : supported_encoders) {
|
||||
auto info = factory->QueryAudioEncoder(spec.format);
|
||||
auto encoder = factory->MakeAudioEncoder(127, spec.format, rtc::nullopt);
|
||||
auto encoder = factory->MakeAudioEncoder(127, spec.format, absl::nullopt);
|
||||
EXPECT_TRUE(encoder);
|
||||
EXPECT_EQ(encoder->SampleRateHz(), info->sample_rate_hz);
|
||||
EXPECT_EQ(encoder->NumChannels(), info->num_channels);
|
||||
@ -57,7 +57,7 @@ TEST_P(AudioEncoderFactoryTest, CanRunAllSupportedEncoders) {
|
||||
auto supported_encoders = factory->GetSupportedEncoders();
|
||||
for (const auto& spec : supported_encoders) {
|
||||
auto encoder =
|
||||
factory->MakeAudioEncoder(kTestPayloadType, spec.format, rtc::nullopt);
|
||||
factory->MakeAudioEncoder(kTestPayloadType, spec.format, absl::nullopt);
|
||||
EXPECT_TRUE(encoder);
|
||||
encoder->Reset();
|
||||
const int num_samples = rtc::checked_cast<int>(
|
||||
|
||||
@ -198,7 +198,7 @@ void AudioEncoderCng::OnReceivedUplinkRecoverablePacketLossFraction(
|
||||
|
||||
void AudioEncoderCng::OnReceivedUplinkBandwidth(
|
||||
int target_audio_bitrate_bps,
|
||||
rtc::Optional<int64_t> bwe_period_ms) {
|
||||
absl::optional<int64_t> bwe_period_ms) {
|
||||
speech_encoder_->OnReceivedUplinkBandwidth(target_audio_bitrate_bps,
|
||||
bwe_period_ms);
|
||||
}
|
||||
|
||||
@ -69,7 +69,7 @@ class AudioEncoderCng final : public AudioEncoder {
|
||||
float uplink_recoverable_packet_loss_fraction) override;
|
||||
void OnReceivedUplinkBandwidth(
|
||||
int target_audio_bitrate_bps,
|
||||
rtc::Optional<int64_t> bwe_period_ms) override;
|
||||
absl::optional<int64_t> bwe_period_ms) override;
|
||||
|
||||
private:
|
||||
EncodedInfo EncodePassive(size_t frames_to_encode,
|
||||
|
||||
@ -220,8 +220,8 @@ TEST_F(AudioEncoderCngTest, CheckFrameSizePropagation) {
|
||||
TEST_F(AudioEncoderCngTest, CheckTargetAudioBitratePropagation) {
|
||||
CreateCng(MakeCngConfig());
|
||||
EXPECT_CALL(*mock_encoder_,
|
||||
OnReceivedUplinkBandwidth(4711, rtc::Optional<int64_t>()));
|
||||
cng_->OnReceivedUplinkBandwidth(4711, rtc::nullopt);
|
||||
OnReceivedUplinkBandwidth(4711, absl::optional<int64_t>()));
|
||||
cng_->OnReceivedUplinkBandwidth(4711, absl::nullopt);
|
||||
}
|
||||
|
||||
TEST_F(AudioEncoderCngTest, CheckPacketLossFractionPropagation) {
|
||||
|
||||
@ -13,8 +13,8 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/audio_codecs/audio_decoder.h"
|
||||
#include "api/optional.h"
|
||||
#include "modules/audio_coding/codecs/isac/locked_bandwidth_info.h"
|
||||
#include "rtc_base/constructormagic.h"
|
||||
#include "rtc_base/scoped_ref_ptr.h"
|
||||
|
||||
@ -27,7 +27,7 @@ size_t LegacyEncodedAudioFrame::Duration() const {
|
||||
return (ret < 0) ? 0 : static_cast<size_t>(ret);
|
||||
}
|
||||
|
||||
rtc::Optional<AudioDecoder::EncodedAudioFrame::DecodeResult>
|
||||
absl::optional<AudioDecoder::EncodedAudioFrame::DecodeResult>
|
||||
LegacyEncodedAudioFrame::Decode(rtc::ArrayView<int16_t> decoded) const {
|
||||
AudioDecoder::SpeechType speech_type = AudioDecoder::kSpeech;
|
||||
const int ret = decoder_->Decode(
|
||||
@ -35,7 +35,7 @@ LegacyEncodedAudioFrame::Decode(rtc::ArrayView<int16_t> decoded) const {
|
||||
decoded.size() * sizeof(int16_t), decoded.data(), &speech_type);
|
||||
|
||||
if (ret < 0)
|
||||
return rtc::nullopt;
|
||||
return absl::nullopt;
|
||||
|
||||
return DecodeResult{static_cast<size_t>(ret), speech_type};
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@ class LegacyEncodedAudioFrame final : public AudioDecoder::EncodedAudioFrame {
|
||||
|
||||
size_t Duration() const override;
|
||||
|
||||
rtc::Optional<DecodeResult> Decode(
|
||||
absl::optional<DecodeResult> Decode(
|
||||
rtc::ArrayView<int16_t> decoded) const override;
|
||||
|
||||
// For testing:
|
||||
|
||||
@ -38,7 +38,7 @@ class OpusFrame : public AudioDecoder::EncodedAudioFrame {
|
||||
|
||||
bool IsDtxPacket() const override { return payload_.size() <= 2; }
|
||||
|
||||
rtc::Optional<DecodeResult> Decode(
|
||||
absl::optional<DecodeResult> Decode(
|
||||
rtc::ArrayView<int16_t> decoded) const override {
|
||||
AudioDecoder::SpeechType speech_type = AudioDecoder::kSpeech;
|
||||
int ret;
|
||||
@ -53,7 +53,7 @@ class OpusFrame : public AudioDecoder::EncodedAudioFrame {
|
||||
}
|
||||
|
||||
if (ret < 0)
|
||||
return rtc::nullopt;
|
||||
return absl::nullopt;
|
||||
|
||||
return DecodeResult{static_cast<size_t>(ret), speech_type};
|
||||
}
|
||||
|
||||
@ -105,18 +105,18 @@ float OptimizePacketLossRate(float new_loss_rate, float old_loss_rate) {
|
||||
}
|
||||
}
|
||||
|
||||
rtc::Optional<std::string> GetFormatParameter(const SdpAudioFormat& format,
|
||||
const std::string& param) {
|
||||
absl::optional<std::string> GetFormatParameter(const SdpAudioFormat& format,
|
||||
const std::string& param) {
|
||||
auto it = format.parameters.find(param);
|
||||
if (it == format.parameters.end())
|
||||
return rtc::nullopt;
|
||||
return absl::nullopt;
|
||||
|
||||
return it->second;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
rtc::Optional<T> GetFormatParameter(const SdpAudioFormat& format,
|
||||
const std::string& param) {
|
||||
absl::optional<T> GetFormatParameter(const SdpAudioFormat& format,
|
||||
const std::string& param) {
|
||||
return rtc::StringToNumber<T>(GetFormatParameter(format, param).value_or(""));
|
||||
}
|
||||
|
||||
@ -139,7 +139,7 @@ int CalculateDefaultBitrate(int max_playback_rate, size_t num_channels) {
|
||||
// out how invalid it is and accurately log invalid values.
|
||||
int CalculateBitrate(int max_playback_rate_hz,
|
||||
size_t num_channels,
|
||||
rtc::Optional<std::string> bitrate_param) {
|
||||
absl::optional<std::string> bitrate_param) {
|
||||
const int default_bitrate =
|
||||
CalculateDefaultBitrate(max_playback_rate_hz, num_channels);
|
||||
|
||||
@ -242,7 +242,7 @@ std::unique_ptr<AudioEncoder> AudioEncoderOpusImpl::MakeAudioEncoder(
|
||||
return rtc::MakeUnique<AudioEncoderOpusImpl>(config, payload_type);
|
||||
}
|
||||
|
||||
rtc::Optional<AudioCodecInfo> AudioEncoderOpusImpl::QueryAudioEncoder(
|
||||
absl::optional<AudioCodecInfo> AudioEncoderOpusImpl::QueryAudioEncoder(
|
||||
const SdpAudioFormat& format) {
|
||||
if (STR_CASE_CMP(format.name.c_str(), GetPayloadName()) == 0 &&
|
||||
format.clockrate_hz == 48000 && format.num_channels == 2) {
|
||||
@ -258,7 +258,7 @@ rtc::Optional<AudioCodecInfo> AudioEncoderOpusImpl::QueryAudioEncoder(
|
||||
|
||||
return info;
|
||||
}
|
||||
return rtc::nullopt;
|
||||
return absl::nullopt;
|
||||
}
|
||||
|
||||
AudioEncoderOpusConfig AudioEncoderOpusImpl::CreateConfig(
|
||||
@ -274,11 +274,11 @@ AudioEncoderOpusConfig AudioEncoderOpusImpl::CreateConfig(
|
||||
return config;
|
||||
}
|
||||
|
||||
rtc::Optional<AudioEncoderOpusConfig> AudioEncoderOpusImpl::SdpToConfig(
|
||||
absl::optional<AudioEncoderOpusConfig> AudioEncoderOpusImpl::SdpToConfig(
|
||||
const SdpAudioFormat& format) {
|
||||
if (STR_CASE_CMP(format.name.c_str(), "opus") != 0 ||
|
||||
format.clockrate_hz != 48000 || format.num_channels != 2) {
|
||||
return rtc::nullopt;
|
||||
return absl::nullopt;
|
||||
}
|
||||
|
||||
AudioEncoderOpusConfig config;
|
||||
@ -313,7 +313,7 @@ rtc::Optional<AudioEncoderOpusConfig> AudioEncoderOpusImpl::SdpToConfig(
|
||||
return config;
|
||||
}
|
||||
|
||||
rtc::Optional<int> AudioEncoderOpusImpl::GetNewComplexity(
|
||||
absl::optional<int> AudioEncoderOpusImpl::GetNewComplexity(
|
||||
const AudioEncoderOpusConfig& config) {
|
||||
RTC_DCHECK(config.IsOk());
|
||||
const int bitrate_bps = GetBitrateBps(config);
|
||||
@ -322,7 +322,7 @@ rtc::Optional<int> AudioEncoderOpusImpl::GetNewComplexity(
|
||||
bitrate_bps <= config.complexity_threshold_bps +
|
||||
config.complexity_threshold_window_bps) {
|
||||
// Within the hysteresis window; make no change.
|
||||
return rtc::nullopt;
|
||||
return absl::nullopt;
|
||||
} else {
|
||||
return bitrate_bps <= config.complexity_threshold_bps
|
||||
? config.low_rate_complexity
|
||||
@ -330,7 +330,7 @@ rtc::Optional<int> AudioEncoderOpusImpl::GetNewComplexity(
|
||||
}
|
||||
}
|
||||
|
||||
rtc::Optional<int> AudioEncoderOpusImpl::GetNewBandwidth(
|
||||
absl::optional<int> AudioEncoderOpusImpl::GetNewBandwidth(
|
||||
const AudioEncoderOpusConfig& config,
|
||||
OpusEncInst* inst) {
|
||||
constexpr int kMinWidebandBitrate = 8000;
|
||||
@ -339,17 +339,17 @@ rtc::Optional<int> AudioEncoderOpusImpl::GetNewBandwidth(
|
||||
RTC_DCHECK(config.IsOk());
|
||||
const int bitrate = GetBitrateBps(config);
|
||||
if (bitrate > kAutomaticThreshold) {
|
||||
return rtc::Optional<int>(OPUS_AUTO);
|
||||
return absl::optional<int>(OPUS_AUTO);
|
||||
}
|
||||
const int bandwidth = WebRtcOpus_GetBandwidth(inst);
|
||||
RTC_DCHECK_GE(bandwidth, 0);
|
||||
if (bitrate > kMaxNarrowbandBitrate && bandwidth < OPUS_BANDWIDTH_WIDEBAND) {
|
||||
return rtc::Optional<int>(OPUS_BANDWIDTH_WIDEBAND);
|
||||
return absl::optional<int>(OPUS_BANDWIDTH_WIDEBAND);
|
||||
} else if (bitrate < kMinWidebandBitrate &&
|
||||
bandwidth > OPUS_BANDWIDTH_NARROWBAND) {
|
||||
return rtc::Optional<int>(OPUS_BANDWIDTH_NARROWBAND);
|
||||
return absl::optional<int>(OPUS_BANDWIDTH_NARROWBAND);
|
||||
}
|
||||
return rtc::Optional<int>();
|
||||
return absl::optional<int>();
|
||||
}
|
||||
|
||||
class AudioEncoderOpusImpl::PacketLossFractionSmoother {
|
||||
@ -529,7 +529,7 @@ void AudioEncoderOpusImpl::OnReceivedUplinkRecoverablePacketLossFraction(
|
||||
|
||||
void AudioEncoderOpusImpl::OnReceivedUplinkBandwidth(
|
||||
int target_audio_bitrate_bps,
|
||||
rtc::Optional<int64_t> bwe_period_ms) {
|
||||
absl::optional<int64_t> bwe_period_ms) {
|
||||
if (audio_network_adaptor_) {
|
||||
audio_network_adaptor_->SetTargetAudioBitrate(target_audio_bitrate_bps);
|
||||
// We give smoothed bitrate allocation to audio network adaptor as
|
||||
@ -801,7 +801,7 @@ void AudioEncoderOpusImpl::MaybeUpdateUplinkBandwidth() {
|
||||
if (!bitrate_smoother_last_update_time_ ||
|
||||
now_ms - *bitrate_smoother_last_update_time_ >=
|
||||
config_.uplink_bandwidth_update_interval_ms) {
|
||||
rtc::Optional<float> smoothed_bitrate = bitrate_smoother_->GetAverage();
|
||||
absl::optional<float> smoothed_bitrate = bitrate_smoother_->GetAverage();
|
||||
if (smoothed_bitrate)
|
||||
audio_network_adaptor_->SetUplinkBandwidth(*smoothed_bitrate);
|
||||
bitrate_smoother_last_update_time_ = now_ms;
|
||||
|
||||
@ -16,10 +16,10 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/audio_codecs/audio_encoder.h"
|
||||
#include "api/audio_codecs/audio_format.h"
|
||||
#include "api/audio_codecs/opus/audio_encoder_opus_config.h"
|
||||
#include "api/optional.h"
|
||||
#include "common_audio/smoothing_filter.h"
|
||||
#include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor.h"
|
||||
#include "modules/audio_coding/codecs/opus/opus_interface.h"
|
||||
@ -40,13 +40,13 @@ class AudioEncoderOpusImpl final : public AudioEncoder {
|
||||
// defined by complexity_threshold_bps +/- complexity_threshold_window_bps.
|
||||
// Otherwise, returns the current complexity depending on whether the
|
||||
// current bitrate is above or below complexity_threshold_bps.
|
||||
static rtc::Optional<int> GetNewComplexity(
|
||||
static absl::optional<int> GetNewComplexity(
|
||||
const AudioEncoderOpusConfig& config);
|
||||
|
||||
// Returns OPUS_AUTO if the the current bitrate is above wideband threshold.
|
||||
// Returns empty if it is below, but bandwidth coincides with the desired one.
|
||||
// Otherwise returns the desired bandwidth.
|
||||
static rtc::Optional<int> GetNewBandwidth(
|
||||
static absl::optional<int> GetNewBandwidth(
|
||||
const AudioEncoderOpusConfig& config,
|
||||
OpusEncInst* inst);
|
||||
|
||||
@ -69,7 +69,7 @@ class AudioEncoderOpusImpl final : public AudioEncoder {
|
||||
|
||||
// Static interface for use by BuiltinAudioEncoderFactory.
|
||||
static constexpr const char* GetPayloadName() { return "opus"; }
|
||||
static rtc::Optional<AudioCodecInfo> QueryAudioEncoder(
|
||||
static absl::optional<AudioCodecInfo> QueryAudioEncoder(
|
||||
const SdpAudioFormat& format);
|
||||
|
||||
int SampleRateHz() const override;
|
||||
@ -98,7 +98,7 @@ class AudioEncoderOpusImpl final : public AudioEncoder {
|
||||
float uplink_recoverable_packet_loss_fraction) override;
|
||||
void OnReceivedUplinkBandwidth(
|
||||
int target_audio_bitrate_bps,
|
||||
rtc::Optional<int64_t> bwe_period_ms) override;
|
||||
absl::optional<int64_t> bwe_period_ms) override;
|
||||
void OnReceivedRtt(int rtt_ms) override;
|
||||
void OnReceivedOverhead(size_t overhead_bytes_per_packet) override;
|
||||
void SetReceiverFrameLengthRange(int min_frame_length_ms,
|
||||
@ -125,7 +125,7 @@ class AudioEncoderOpusImpl final : public AudioEncoder {
|
||||
private:
|
||||
class PacketLossFractionSmoother;
|
||||
|
||||
static rtc::Optional<AudioEncoderOpusConfig> SdpToConfig(
|
||||
static absl::optional<AudioEncoderOpusConfig> SdpToConfig(
|
||||
const SdpAudioFormat& format);
|
||||
static void AppendSupportedEncoders(std::vector<AudioCodecSpec>* specs);
|
||||
static AudioCodecInfo QueryAudioEncoder(const AudioEncoderOpusConfig& config);
|
||||
@ -167,9 +167,9 @@ class AudioEncoderOpusImpl final : public AudioEncoder {
|
||||
std::unique_ptr<PacketLossFractionSmoother> packet_loss_fraction_smoother_;
|
||||
const AudioNetworkAdaptorCreator audio_network_adaptor_creator_;
|
||||
std::unique_ptr<AudioNetworkAdaptor> audio_network_adaptor_;
|
||||
rtc::Optional<size_t> overhead_bytes_per_packet_;
|
||||
absl::optional<size_t> overhead_bytes_per_packet_;
|
||||
const std::unique_ptr<SmoothingFilter> bitrate_smoother_;
|
||||
rtc::Optional<int64_t> bitrate_smoother_last_update_time_;
|
||||
absl::optional<int64_t> bitrate_smoother_last_update_time_;
|
||||
int consecutive_dtx_frames_;
|
||||
|
||||
friend struct AudioEncoderOpus;
|
||||
|
||||
@ -198,20 +198,20 @@ TEST(AudioEncoderOpusTest,
|
||||
const int kMinBitrateBps = 6000;
|
||||
const int kMaxBitrateBps = 510000;
|
||||
// Set a too low bitrate.
|
||||
states->encoder->OnReceivedUplinkBandwidth(kMinBitrateBps - 1, rtc::nullopt);
|
||||
states->encoder->OnReceivedUplinkBandwidth(kMinBitrateBps - 1, absl::nullopt);
|
||||
EXPECT_EQ(kMinBitrateBps, states->encoder->GetTargetBitrate());
|
||||
// Set a too high bitrate.
|
||||
states->encoder->OnReceivedUplinkBandwidth(kMaxBitrateBps + 1, rtc::nullopt);
|
||||
states->encoder->OnReceivedUplinkBandwidth(kMaxBitrateBps + 1, absl::nullopt);
|
||||
EXPECT_EQ(kMaxBitrateBps, states->encoder->GetTargetBitrate());
|
||||
// Set the minimum rate.
|
||||
states->encoder->OnReceivedUplinkBandwidth(kMinBitrateBps, rtc::nullopt);
|
||||
states->encoder->OnReceivedUplinkBandwidth(kMinBitrateBps, absl::nullopt);
|
||||
EXPECT_EQ(kMinBitrateBps, states->encoder->GetTargetBitrate());
|
||||
// Set the maximum rate.
|
||||
states->encoder->OnReceivedUplinkBandwidth(kMaxBitrateBps, rtc::nullopt);
|
||||
states->encoder->OnReceivedUplinkBandwidth(kMaxBitrateBps, absl::nullopt);
|
||||
EXPECT_EQ(kMaxBitrateBps, states->encoder->GetTargetBitrate());
|
||||
// Set rates from kMaxBitrateBps up to 32000 bps.
|
||||
for (int rate = kMinBitrateBps; rate <= 32000; rate += 1000) {
|
||||
states->encoder->OnReceivedUplinkBandwidth(rate, rtc::nullopt);
|
||||
states->encoder->OnReceivedUplinkBandwidth(rate, absl::nullopt);
|
||||
EXPECT_EQ(rate, states->encoder->GetTargetBitrate());
|
||||
}
|
||||
}
|
||||
@ -392,7 +392,7 @@ TEST(AudioEncoderOpusTest, DoNotInvokeSetTargetBitrateIfOverheadUnknown) {
|
||||
auto states = CreateCodec(2);
|
||||
|
||||
states->encoder->OnReceivedUplinkBandwidth(kDefaultOpusSettings.rate * 2,
|
||||
rtc::nullopt);
|
||||
absl::nullopt);
|
||||
|
||||
// Since |OnReceivedOverhead| has not been called, the codec bitrate should
|
||||
// not change.
|
||||
@ -409,7 +409,7 @@ TEST(AudioEncoderOpusTest, OverheadRemovedFromTargetAudioBitrate) {
|
||||
states->encoder->OnReceivedOverhead(kOverheadBytesPerPacket);
|
||||
|
||||
constexpr int kTargetBitrateBps = 40000;
|
||||
states->encoder->OnReceivedUplinkBandwidth(kTargetBitrateBps, rtc::nullopt);
|
||||
states->encoder->OnReceivedUplinkBandwidth(kTargetBitrateBps, absl::nullopt);
|
||||
|
||||
int packet_rate = rtc::CheckedDivExact(48000, kDefaultOpusSettings.pacsize);
|
||||
EXPECT_EQ(kTargetBitrateBps -
|
||||
@ -435,14 +435,14 @@ TEST(AudioEncoderOpusTest, BitrateBounded) {
|
||||
// subtracted. The eventual codec rate should be bounded by |kMinBitrateBps|.
|
||||
int target_bitrate =
|
||||
kOverheadBytesPerPacket * 8 * packet_rate + kMinBitrateBps - 1;
|
||||
states->encoder->OnReceivedUplinkBandwidth(target_bitrate, rtc::nullopt);
|
||||
states->encoder->OnReceivedUplinkBandwidth(target_bitrate, absl::nullopt);
|
||||
EXPECT_EQ(kMinBitrateBps, states->encoder->GetTargetBitrate());
|
||||
|
||||
// Set a target rate that is greater than |kMaxBitrateBps| when overhead is
|
||||
// subtracted. The eventual codec rate should be bounded by |kMaxBitrateBps|.
|
||||
target_bitrate =
|
||||
kOverheadBytesPerPacket * 8 * packet_rate + kMaxBitrateBps + 1;
|
||||
states->encoder->OnReceivedUplinkBandwidth(target_bitrate, rtc::nullopt);
|
||||
states->encoder->OnReceivedUplinkBandwidth(target_bitrate, absl::nullopt);
|
||||
EXPECT_EQ(kMaxBitrateBps, states->encoder->GetTargetBitrate());
|
||||
}
|
||||
|
||||
@ -454,7 +454,7 @@ TEST(AudioEncoderOpusTest, ConfigComplexityAdaptation) {
|
||||
|
||||
// Bitrate within hysteresis window. Expect empty output.
|
||||
config.bitrate_bps = 12500;
|
||||
EXPECT_EQ(rtc::nullopt, AudioEncoderOpusImpl::GetNewComplexity(config));
|
||||
EXPECT_EQ(absl::nullopt, AudioEncoderOpusImpl::GetNewComplexity(config));
|
||||
|
||||
// Bitrate below hysteresis window. Expect higher complexity.
|
||||
config.bitrate_bps = 10999;
|
||||
@ -462,7 +462,7 @@ TEST(AudioEncoderOpusTest, ConfigComplexityAdaptation) {
|
||||
|
||||
// Bitrate within hysteresis window. Expect empty output.
|
||||
config.bitrate_bps = 12500;
|
||||
EXPECT_EQ(rtc::nullopt, AudioEncoderOpusImpl::GetNewComplexity(config));
|
||||
EXPECT_EQ(absl::nullopt, AudioEncoderOpusImpl::GetNewComplexity(config));
|
||||
|
||||
// Bitrate above hysteresis window. Expect lower complexity.
|
||||
config.bitrate_bps = 14001;
|
||||
@ -488,9 +488,9 @@ TEST(AudioEncoderOpusTest, ConfigBandwidthAdaptation) {
|
||||
: 1));
|
||||
|
||||
// Bitrate below minmum wideband. Expect narrowband.
|
||||
config.bitrate_bps = rtc::Optional<int>(7999);
|
||||
config.bitrate_bps = absl::optional<int>(7999);
|
||||
auto bandwidth = AudioEncoderOpusImpl::GetNewBandwidth(config, inst);
|
||||
EXPECT_EQ(rtc::Optional<int>(OPUS_BANDWIDTH_NARROWBAND), bandwidth);
|
||||
EXPECT_EQ(absl::optional<int>(OPUS_BANDWIDTH_NARROWBAND), bandwidth);
|
||||
WebRtcOpus_SetBandwidth(inst, *bandwidth);
|
||||
// It is necessary to encode here because Opus has some logic in the encoder
|
||||
// that goes from the user-set bandwidth to the used and returned one.
|
||||
@ -499,14 +499,14 @@ TEST(AudioEncoderOpusTest, ConfigBandwidthAdaptation) {
|
||||
kMaxBytes, bitstream);
|
||||
|
||||
// Bitrate not yet above maximum narrowband. Expect empty.
|
||||
config.bitrate_bps = rtc::Optional<int>(9000);
|
||||
config.bitrate_bps = absl::optional<int>(9000);
|
||||
bandwidth = AudioEncoderOpusImpl::GetNewBandwidth(config, inst);
|
||||
EXPECT_EQ(rtc::Optional<int>(), bandwidth);
|
||||
EXPECT_EQ(absl::optional<int>(), bandwidth);
|
||||
|
||||
// Bitrate above maximum narrowband. Expect wideband.
|
||||
config.bitrate_bps = rtc::Optional<int>(9001);
|
||||
config.bitrate_bps = absl::optional<int>(9001);
|
||||
bandwidth = AudioEncoderOpusImpl::GetNewBandwidth(config, inst);
|
||||
EXPECT_EQ(rtc::Optional<int>(OPUS_BANDWIDTH_WIDEBAND), bandwidth);
|
||||
EXPECT_EQ(absl::optional<int>(OPUS_BANDWIDTH_WIDEBAND), bandwidth);
|
||||
WebRtcOpus_SetBandwidth(inst, *bandwidth);
|
||||
// It is necessary to encode here because Opus has some logic in the encoder
|
||||
// that goes from the user-set bandwidth to the used and returned one.
|
||||
@ -515,14 +515,14 @@ TEST(AudioEncoderOpusTest, ConfigBandwidthAdaptation) {
|
||||
kMaxBytes, bitstream);
|
||||
|
||||
// Bitrate not yet below minimum wideband. Expect empty.
|
||||
config.bitrate_bps = rtc::Optional<int>(8000);
|
||||
config.bitrate_bps = absl::optional<int>(8000);
|
||||
bandwidth = AudioEncoderOpusImpl::GetNewBandwidth(config, inst);
|
||||
EXPECT_EQ(rtc::Optional<int>(), bandwidth);
|
||||
EXPECT_EQ(absl::optional<int>(), bandwidth);
|
||||
|
||||
// Bitrate above automatic threshold. Expect automatic.
|
||||
config.bitrate_bps = rtc::Optional<int>(12001);
|
||||
config.bitrate_bps = absl::optional<int>(12001);
|
||||
bandwidth = AudioEncoderOpusImpl::GetNewBandwidth(config, inst);
|
||||
EXPECT_EQ(rtc::Optional<int>(OPUS_AUTO), bandwidth);
|
||||
EXPECT_EQ(absl::optional<int>(OPUS_AUTO), bandwidth);
|
||||
|
||||
EXPECT_EQ(0, WebRtcOpus_EncoderFree(inst));
|
||||
}
|
||||
@ -586,7 +586,7 @@ TEST(AudioEncoderOpusTest, EncodeAtMinBitrate) {
|
||||
rtc::Buffer encoded;
|
||||
uint32_t rtp_timestamp = 12345; // Just a number not important to this test.
|
||||
|
||||
states->encoder->OnReceivedUplinkBandwidth(0, rtc::nullopt);
|
||||
states->encoder->OnReceivedUplinkBandwidth(0, absl::nullopt);
|
||||
for (int packet_index = 0; packet_index < kNumPacketsToEncode;
|
||||
packet_index++) {
|
||||
// Make sure we are not encoding before we have enough data for
|
||||
|
||||
@ -110,7 +110,7 @@ TEST(BandwidthAdaptationTest, BandwidthAdaptationTest) {
|
||||
|
||||
// Create encoder.
|
||||
AudioEncoderOpusConfig enc_config;
|
||||
enc_config.bitrate_bps = rtc::Optional<int>(7999);
|
||||
enc_config.bitrate_bps = absl::optional<int>(7999);
|
||||
enc_config.num_channels = kNumChannels;
|
||||
constexpr int payload_type = 17;
|
||||
auto encoder = AudioEncoderOpus::MakeAudioEncoder(enc_config, payload_type);
|
||||
|
||||
@ -134,7 +134,7 @@ void AudioEncoderCopyRed::OnReceivedUplinkRecoverablePacketLossFraction(
|
||||
|
||||
void AudioEncoderCopyRed::OnReceivedUplinkBandwidth(
|
||||
int target_audio_bitrate_bps,
|
||||
rtc::Optional<int64_t> bwe_period_ms) {
|
||||
absl::optional<int64_t> bwe_period_ms) {
|
||||
speech_encoder_->OnReceivedUplinkBandwidth(target_audio_bitrate_bps,
|
||||
bwe_period_ms);
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ class AudioEncoderCopyRed final : public AudioEncoder {
|
||||
float uplink_recoverable_packet_loss_fraction) override;
|
||||
void OnReceivedUplinkBandwidth(
|
||||
int target_audio_bitrate_bps,
|
||||
rtc::Optional<int64_t> bwe_period_ms) override;
|
||||
absl::optional<int64_t> bwe_period_ms) override;
|
||||
|
||||
protected:
|
||||
EncodedInfo EncodeImpl(uint32_t rtp_timestamp,
|
||||
|
||||
@ -99,8 +99,8 @@ TEST_F(AudioEncoderCopyRedTest, CheckMaxFrameSizePropagation) {
|
||||
|
||||
TEST_F(AudioEncoderCopyRedTest, CheckTargetAudioBitratePropagation) {
|
||||
EXPECT_CALL(*mock_encoder_,
|
||||
OnReceivedUplinkBandwidth(4711, rtc::Optional<int64_t>()));
|
||||
red_->OnReceivedUplinkBandwidth(4711, rtc::nullopt);
|
||||
OnReceivedUplinkBandwidth(4711, absl::optional<int64_t>()));
|
||||
red_->OnReceivedUplinkBandwidth(4711, absl::nullopt);
|
||||
}
|
||||
|
||||
TEST_F(AudioEncoderCopyRedTest, CheckPacketLossFractionPropagation) {
|
||||
|
||||
@ -15,9 +15,9 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/audio_codecs/audio_decoder_factory.h"
|
||||
#include "api/audio_codecs/audio_encoder.h"
|
||||
#include "api/optional.h"
|
||||
#include "common_types.h" // NOLINT(build/include)
|
||||
#include "modules/audio_coding/include/audio_coding_module_typedefs.h"
|
||||
#include "modules/audio_coding/neteq/include/neteq.h"
|
||||
@ -228,7 +228,7 @@ class AudioCodingModule {
|
||||
// Return value:
|
||||
// The send codec, or nothing if we don't have one
|
||||
//
|
||||
virtual rtc::Optional<CodecInst> SendCodec() const = 0;
|
||||
virtual absl::optional<CodecInst> SendCodec() const = 0;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// int32_t SendFrequency()
|
||||
@ -546,7 +546,7 @@ class AudioCodingModule {
|
||||
virtual int32_t ReceiveCodec(CodecInst* curr_receive_codec) const = 0;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// rtc::Optional<SdpAudioFormat> ReceiveFormat()
|
||||
// absl::optional<SdpAudioFormat> ReceiveFormat()
|
||||
// Get the format associated with last received payload.
|
||||
//
|
||||
// Return value:
|
||||
@ -554,7 +554,7 @@ class AudioCodingModule {
|
||||
// received payload.
|
||||
// An empty Optional if no payload has yet been received.
|
||||
//
|
||||
virtual rtc::Optional<SdpAudioFormat> ReceiveFormat() const = 0;
|
||||
virtual absl::optional<SdpAudioFormat> ReceiveFormat() const = 0;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// int32_t IncomingPacket()
|
||||
@ -631,7 +631,7 @@ class AudioCodingModule {
|
||||
// the latest audio obtained by calling PlayoutData10ms(), or empty if no
|
||||
// valid timestamp is available.
|
||||
//
|
||||
virtual rtc::Optional<uint32_t> PlayoutTimestamp() = 0;
|
||||
virtual absl::optional<uint32_t> PlayoutTimestamp() = 0;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// int FilteredCurrentDelayMs()
|
||||
|
||||
@ -462,7 +462,7 @@ TEST_F(AudioDecoderPcmUTest, EncodeDecode) {
|
||||
|
||||
namespace {
|
||||
int SetAndGetTargetBitrate(AudioEncoder* audio_encoder, int rate) {
|
||||
audio_encoder->OnReceivedUplinkBandwidth(rate, rtc::nullopt);
|
||||
audio_encoder->OnReceivedUplinkBandwidth(rate, absl::nullopt);
|
||||
return audio_encoder->GetTargetBitrate();
|
||||
}
|
||||
void TestSetAndGetTargetBitratesWithFixedCodec(AudioEncoder* audio_encoder,
|
||||
|
||||
@ -26,7 +26,7 @@ TEST(DecisionLogic, CreateAndDestroy) {
|
||||
int fs_hz = 8000;
|
||||
int output_size_samples = fs_hz / 100; // Samples per 10 ms.
|
||||
DecoderDatabase decoder_database(
|
||||
new rtc::RefCountedObject<MockAudioDecoderFactory>, rtc::nullopt);
|
||||
new rtc::RefCountedObject<MockAudioDecoderFactory>, absl::nullopt);
|
||||
TickTimer tick_timer;
|
||||
PacketBuffer packet_buffer(10, &tick_timer);
|
||||
DelayPeakDetector delay_peak_detector(&tick_timer);
|
||||
|
||||
@ -21,7 +21,7 @@ namespace webrtc {
|
||||
|
||||
DecoderDatabase::DecoderDatabase(
|
||||
const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory,
|
||||
rtc::Optional<AudioCodecPairId> codec_pair_id)
|
||||
absl::optional<AudioCodecPairId> codec_pair_id)
|
||||
: active_decoder_type_(-1),
|
||||
active_cng_decoder_type_(-1),
|
||||
decoder_factory_(decoder_factory),
|
||||
@ -31,7 +31,7 @@ DecoderDatabase::~DecoderDatabase() = default;
|
||||
|
||||
DecoderDatabase::DecoderInfo::DecoderInfo(
|
||||
const SdpAudioFormat& audio_format,
|
||||
rtc::Optional<AudioCodecPairId> codec_pair_id,
|
||||
absl::optional<AudioCodecPairId> codec_pair_id,
|
||||
AudioDecoderFactory* factory,
|
||||
const std::string& codec_name)
|
||||
: name_(codec_name),
|
||||
@ -44,13 +44,13 @@ DecoderDatabase::DecoderInfo::DecoderInfo(
|
||||
|
||||
DecoderDatabase::DecoderInfo::DecoderInfo(
|
||||
const SdpAudioFormat& audio_format,
|
||||
rtc::Optional<AudioCodecPairId> codec_pair_id,
|
||||
absl::optional<AudioCodecPairId> codec_pair_id,
|
||||
AudioDecoderFactory* factory)
|
||||
: DecoderInfo(audio_format, codec_pair_id, factory, audio_format.name) {}
|
||||
|
||||
DecoderDatabase::DecoderInfo::DecoderInfo(
|
||||
NetEqDecoder ct,
|
||||
rtc::Optional<AudioCodecPairId> codec_pair_id,
|
||||
absl::optional<AudioCodecPairId> codec_pair_id,
|
||||
AudioDecoderFactory* factory)
|
||||
: DecoderInfo(*NetEqDecoderToSdpAudioFormat(ct), codec_pair_id, factory) {}
|
||||
|
||||
@ -59,7 +59,7 @@ DecoderDatabase::DecoderInfo::DecoderInfo(const SdpAudioFormat& audio_format,
|
||||
const std::string& codec_name)
|
||||
: name_(codec_name),
|
||||
audio_format_(audio_format),
|
||||
codec_pair_id_(rtc::nullopt),
|
||||
codec_pair_id_(absl::nullopt),
|
||||
factory_(nullptr),
|
||||
external_decoder_(ext_dec),
|
||||
subtype_(Subtype::kNormal) {
|
||||
@ -108,7 +108,7 @@ bool DecoderDatabase::DecoderInfo::IsType(const std::string& name) const {
|
||||
return IsType(name.c_str());
|
||||
}
|
||||
|
||||
rtc::Optional<DecoderDatabase::DecoderInfo::CngDecoder>
|
||||
absl::optional<DecoderDatabase::DecoderInfo::CngDecoder>
|
||||
DecoderDatabase::DecoderInfo::CngDecoder::Create(const SdpAudioFormat& format) {
|
||||
if (STR_CASE_CMP(format.name.c_str(), "CN") == 0) {
|
||||
// CN has a 1:1 RTP clock rate to sample rate ratio.
|
||||
@ -117,7 +117,7 @@ DecoderDatabase::DecoderInfo::CngDecoder::Create(const SdpAudioFormat& format) {
|
||||
sample_rate_hz == 32000 || sample_rate_hz == 48000);
|
||||
return DecoderDatabase::DecoderInfo::CngDecoder{sample_rate_hz};
|
||||
} else {
|
||||
return rtc::nullopt;
|
||||
return absl::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -43,14 +43,14 @@ class DecoderDatabase {
|
||||
class DecoderInfo {
|
||||
public:
|
||||
DecoderInfo(const SdpAudioFormat& audio_format,
|
||||
rtc::Optional<AudioCodecPairId> codec_pair_id,
|
||||
absl::optional<AudioCodecPairId> codec_pair_id,
|
||||
AudioDecoderFactory* factory,
|
||||
const std::string& codec_name);
|
||||
explicit DecoderInfo(const SdpAudioFormat& audio_format,
|
||||
rtc::Optional<AudioCodecPairId> codec_pair_id,
|
||||
absl::optional<AudioCodecPairId> codec_pair_id,
|
||||
AudioDecoderFactory* factory = nullptr);
|
||||
explicit DecoderInfo(NetEqDecoder ct,
|
||||
rtc::Optional<AudioCodecPairId> codec_pair_id,
|
||||
absl::optional<AudioCodecPairId> codec_pair_id,
|
||||
AudioDecoderFactory* factory = nullptr);
|
||||
DecoderInfo(const SdpAudioFormat& audio_format,
|
||||
AudioDecoder* ext_dec,
|
||||
@ -111,7 +111,7 @@ class DecoderDatabase {
|
||||
const std::string name_;
|
||||
|
||||
const SdpAudioFormat audio_format_;
|
||||
const rtc::Optional<AudioCodecPairId> codec_pair_id_;
|
||||
const absl::optional<AudioCodecPairId> codec_pair_id_;
|
||||
AudioDecoderFactory* const factory_;
|
||||
mutable std::unique_ptr<AudioDecoder> decoder_;
|
||||
|
||||
@ -120,10 +120,10 @@ class DecoderDatabase {
|
||||
|
||||
// Set iff this is a comfort noise decoder.
|
||||
struct CngDecoder {
|
||||
static rtc::Optional<CngDecoder> Create(const SdpAudioFormat& format);
|
||||
static absl::optional<CngDecoder> Create(const SdpAudioFormat& format);
|
||||
int sample_rate_hz;
|
||||
};
|
||||
const rtc::Optional<CngDecoder> cng_decoder_;
|
||||
const absl::optional<CngDecoder> cng_decoder_;
|
||||
|
||||
enum class Subtype : int8_t {
|
||||
kNormal,
|
||||
@ -143,7 +143,7 @@ class DecoderDatabase {
|
||||
|
||||
DecoderDatabase(
|
||||
const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory,
|
||||
rtc::Optional<AudioCodecPairId> codec_pair_id);
|
||||
absl::optional<AudioCodecPairId> codec_pair_id);
|
||||
|
||||
virtual ~DecoderDatabase();
|
||||
|
||||
@ -247,7 +247,7 @@ class DecoderDatabase {
|
||||
int active_cng_decoder_type_;
|
||||
mutable std::unique_ptr<ComfortNoiseDecoder> active_cng_decoder_;
|
||||
rtc::scoped_refptr<AudioDecoderFactory> decoder_factory_;
|
||||
const rtc::Optional<AudioCodecPairId> codec_pair_id_;
|
||||
const absl::optional<AudioCodecPairId> codec_pair_id_;
|
||||
|
||||
RTC_DISALLOW_COPY_AND_ASSIGN(DecoderDatabase);
|
||||
};
|
||||
|
||||
@ -29,7 +29,7 @@ namespace webrtc {
|
||||
|
||||
TEST(DecoderDatabase, CreateAndDestroy) {
|
||||
DecoderDatabase db(new rtc::RefCountedObject<MockAudioDecoderFactory>,
|
||||
rtc::nullopt);
|
||||
absl::nullopt);
|
||||
EXPECT_EQ(0, db.Size());
|
||||
EXPECT_TRUE(db.Empty());
|
||||
}
|
||||
@ -42,7 +42,7 @@ TEST(DecoderDatabase, InsertAndRemove) {
|
||||
EXPECT_EQ("pcmu", format.name);
|
||||
return true;
|
||||
}));
|
||||
DecoderDatabase db(factory, rtc::nullopt);
|
||||
DecoderDatabase db(factory, absl::nullopt);
|
||||
const uint8_t kPayloadType = 0;
|
||||
const std::string kCodecName = "Robert\'); DROP TABLE Students;";
|
||||
EXPECT_EQ(
|
||||
@ -67,7 +67,7 @@ TEST(DecoderDatabase, InsertAndRemoveAll) {
|
||||
EXPECT_EQ("pcma", format.name);
|
||||
return true;
|
||||
}));
|
||||
DecoderDatabase db(factory, rtc::nullopt);
|
||||
DecoderDatabase db(factory, absl::nullopt);
|
||||
const std::string kCodecName1 = "Robert\'); DROP TABLE Students;";
|
||||
const std::string kCodecName2 = "https://xkcd.com/327/";
|
||||
EXPECT_EQ(DecoderDatabase::kOK,
|
||||
@ -92,12 +92,12 @@ TEST(DecoderDatabase, GetDecoderInfo) {
|
||||
auto* decoder = new MockAudioDecoder;
|
||||
EXPECT_CALL(*factory, MakeAudioDecoderMock(_, _, _))
|
||||
.WillOnce(Invoke([decoder](const SdpAudioFormat& format,
|
||||
rtc::Optional<AudioCodecPairId> codec_pair_id,
|
||||
absl::optional<AudioCodecPairId> codec_pair_id,
|
||||
std::unique_ptr<AudioDecoder>* dec) {
|
||||
EXPECT_EQ("pcmu", format.name);
|
||||
dec->reset(decoder);
|
||||
}));
|
||||
DecoderDatabase db(factory, rtc::nullopt);
|
||||
DecoderDatabase db(factory, absl::nullopt);
|
||||
const uint8_t kPayloadType = 0;
|
||||
const std::string kCodecName = "Robert\'); DROP TABLE Students;";
|
||||
EXPECT_EQ(
|
||||
@ -114,7 +114,7 @@ TEST(DecoderDatabase, GetDecoderInfo) {
|
||||
}
|
||||
|
||||
TEST(DecoderDatabase, GetDecoder) {
|
||||
DecoderDatabase db(CreateBuiltinAudioDecoderFactory(), rtc::nullopt);
|
||||
DecoderDatabase db(CreateBuiltinAudioDecoderFactory(), absl::nullopt);
|
||||
const uint8_t kPayloadType = 0;
|
||||
const std::string kCodecName = "Robert\'); DROP TABLE Students;";
|
||||
EXPECT_EQ(DecoderDatabase::kOK,
|
||||
@ -132,7 +132,7 @@ TEST(DecoderDatabase, TypeTests) {
|
||||
EXPECT_EQ("pcmu", format.name);
|
||||
return true;
|
||||
}));
|
||||
DecoderDatabase db(factory, rtc::nullopt);
|
||||
DecoderDatabase db(factory, absl::nullopt);
|
||||
const uint8_t kPayloadTypePcmU = 0;
|
||||
const uint8_t kPayloadTypeCng = 13;
|
||||
const uint8_t kPayloadTypeDtmf = 100;
|
||||
@ -168,7 +168,7 @@ TEST(DecoderDatabase, TypeTests) {
|
||||
|
||||
TEST(DecoderDatabase, ExternalDecoder) {
|
||||
DecoderDatabase db(new rtc::RefCountedObject<MockAudioDecoderFactory>,
|
||||
rtc::nullopt);
|
||||
absl::nullopt);
|
||||
const uint8_t kPayloadType = 0;
|
||||
const std::string kCodecName = "Robert\'); DROP TABLE Students;";
|
||||
MockAudioDecoder decoder;
|
||||
@ -205,7 +205,7 @@ TEST(DecoderDatabase, CheckPayloadTypes) {
|
||||
EXPECT_EQ("pcmu", format.name);
|
||||
return true;
|
||||
}));
|
||||
DecoderDatabase db(factory, rtc::nullopt);
|
||||
DecoderDatabase db(factory, absl::nullopt);
|
||||
// Load a number of payloads into the database. Payload types are 0, 1, ...,
|
||||
// while the decoder type is the same for all payload types (this does not
|
||||
// matter for the test).
|
||||
@ -245,7 +245,7 @@ TEST(DecoderDatabase, CheckPayloadTypes) {
|
||||
|
||||
// Test the methods for setting and getting active speech and CNG decoders.
|
||||
TEST(DecoderDatabase, IF_ISAC(ActiveDecoders)) {
|
||||
DecoderDatabase db(CreateBuiltinAudioDecoderFactory(), rtc::nullopt);
|
||||
DecoderDatabase db(CreateBuiltinAudioDecoderFactory(), absl::nullopt);
|
||||
// Load payload types.
|
||||
ASSERT_EQ(DecoderDatabase::kOK,
|
||||
db.RegisterPayload(0, NetEqDecoder::kDecoderPCMu, "pcmu"));
|
||||
|
||||
@ -45,7 +45,7 @@ void ExpandUmaLogger::UpdateSampleCounter(uint64_t samples,
|
||||
last_value_ = samples;
|
||||
sample_rate_hz_ = sample_rate_hz;
|
||||
if (!last_logged_value_) {
|
||||
last_logged_value_ = rtc::Optional<uint64_t>(samples);
|
||||
last_logged_value_ = absl::optional<uint64_t>(samples);
|
||||
}
|
||||
|
||||
if (!timer_->Finished()) {
|
||||
@ -56,7 +56,7 @@ void ExpandUmaLogger::UpdateSampleCounter(uint64_t samples,
|
||||
RTC_DCHECK(last_logged_value_);
|
||||
RTC_DCHECK_GE(last_value_, *last_logged_value_);
|
||||
const uint64_t diff = last_value_ - *last_logged_value_;
|
||||
last_logged_value_ = rtc::Optional<uint64_t>(last_value_);
|
||||
last_logged_value_ = absl::optional<uint64_t>(last_value_);
|
||||
// Calculate rate in percent.
|
||||
RTC_DCHECK_GT(sample_rate_hz, 0);
|
||||
const int rate = (100 * diff) / (sample_rate_hz * logging_period_s_);
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "api/optional.h"
|
||||
#include "absl/types/optional.h"
|
||||
#include "modules/audio_coding/neteq/tick_timer.h"
|
||||
#include "rtc_base/constructormagic.h"
|
||||
|
||||
@ -43,7 +43,7 @@ class ExpandUmaLogger {
|
||||
const int logging_period_s_;
|
||||
const TickTimer& tick_timer_;
|
||||
std::unique_ptr<TickTimer::Countdown> timer_;
|
||||
rtc::Optional<uint64_t> last_logged_value_;
|
||||
absl::optional<uint64_t> last_logged_value_;
|
||||
uint64_t last_value_ = 0;
|
||||
int sample_rate_hz_ = 0;
|
||||
|
||||
|
||||
@ -16,9 +16,9 @@
|
||||
#include <string>
|
||||
#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/optional.h"
|
||||
#include "api/rtp_headers.h"
|
||||
#include "common_types.h" // NOLINT(build/include)
|
||||
#include "modules/audio_coding/neteq/neteq_decoder_enum.h"
|
||||
@ -101,7 +101,7 @@ class NetEq {
|
||||
NetEqPlayoutMode playout_mode = kPlayoutOn;
|
||||
bool enable_fast_accelerate = false;
|
||||
bool enable_muted_state = false;
|
||||
rtc::Optional<AudioCodecPairId> codec_pair_id;
|
||||
absl::optional<AudioCodecPairId> codec_pair_id;
|
||||
};
|
||||
|
||||
enum ReturnCodes {
|
||||
@ -247,7 +247,7 @@ class NetEq {
|
||||
|
||||
// Returns the RTP timestamp for the last sample delivered by GetAudio().
|
||||
// The return value will be empty if no valid timestamp is available.
|
||||
virtual rtc::Optional<uint32_t> GetPlayoutTimestamp() const = 0;
|
||||
virtual absl::optional<uint32_t> GetPlayoutTimestamp() const = 0;
|
||||
|
||||
// Returns the sample rate in Hz of the audio produced in the last GetAudio
|
||||
// call. If GetAudio has not been called yet, the configured sample rate
|
||||
@ -256,11 +256,11 @@ class NetEq {
|
||||
|
||||
// Returns info about the decoder for the given payload type, or an empty
|
||||
// value if we have no decoder for that payload type.
|
||||
virtual rtc::Optional<CodecInst> GetDecoder(int payload_type) const = 0;
|
||||
virtual absl::optional<CodecInst> GetDecoder(int payload_type) const = 0;
|
||||
|
||||
// Returns the decoder format for the given payload type. Returns empty if no
|
||||
// such payload type was registered.
|
||||
virtual rtc::Optional<SdpAudioFormat> GetDecoderFormat(
|
||||
virtual absl::optional<SdpAudioFormat> GetDecoderFormat(
|
||||
int payload_type) const = 0;
|
||||
|
||||
// Not implemented.
|
||||
|
||||
@ -23,7 +23,7 @@ class MockDecoderDatabase : public DecoderDatabase {
|
||||
public:
|
||||
explicit MockDecoderDatabase(
|
||||
rtc::scoped_refptr<AudioDecoderFactory> factory = nullptr)
|
||||
: DecoderDatabase(factory, rtc::nullopt) {}
|
||||
: DecoderDatabase(factory, absl::nullopt) {}
|
||||
virtual ~MockDecoderDatabase() { Die(); }
|
||||
MOCK_METHOD0(Die, void());
|
||||
MOCK_CONST_METHOD0(Empty,
|
||||
|
||||
@ -38,8 +38,8 @@ class MockPacketBuffer : public PacketBuffer {
|
||||
MOCK_METHOD5(InsertPacketList,
|
||||
int(PacketList* packet_list,
|
||||
const DecoderDatabase& decoder_database,
|
||||
rtc::Optional<uint8_t>* current_rtp_payload_type,
|
||||
rtc::Optional<uint8_t>* current_cng_rtp_payload_type,
|
||||
absl::optional<uint8_t>* current_rtp_payload_type,
|
||||
absl::optional<uint8_t>* current_cng_rtp_payload_type,
|
||||
StatisticsCalculator* stats));
|
||||
MOCK_CONST_METHOD1(NextTimestamp,
|
||||
int(uint32_t* next_timestamp));
|
||||
@ -47,8 +47,7 @@ class MockPacketBuffer : public PacketBuffer {
|
||||
int(uint32_t timestamp, uint32_t* next_timestamp));
|
||||
MOCK_CONST_METHOD0(PeekNextPacket,
|
||||
const Packet*());
|
||||
MOCK_METHOD0(GetNextPacket,
|
||||
rtc::Optional<Packet>());
|
||||
MOCK_METHOD0(GetNextPacket, absl::optional<Packet>());
|
||||
MOCK_METHOD1(DiscardNextPacket, int(StatisticsCalculator* stats));
|
||||
MOCK_METHOD3(DiscardOldPackets,
|
||||
void(uint32_t timestamp_limit,
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
rtc::Optional<SdpAudioFormat> NetEqDecoderToSdpAudioFormat(NetEqDecoder nd) {
|
||||
absl::optional<SdpAudioFormat> NetEqDecoderToSdpAudioFormat(NetEqDecoder nd) {
|
||||
switch (nd) {
|
||||
case NetEqDecoder::kDecoderPCMu:
|
||||
return SdpAudioFormat("pcmu", 8000, 1);
|
||||
@ -78,7 +78,7 @@ rtc::Optional<SdpAudioFormat> NetEqDecoderToSdpAudioFormat(NetEqDecoder nd) {
|
||||
case NetEqDecoder::kDecoderCNGswb48kHz:
|
||||
return SdpAudioFormat("cn", 48000, 1);
|
||||
default:
|
||||
return rtc::nullopt;
|
||||
return absl::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -11,8 +11,8 @@
|
||||
#ifndef MODULES_AUDIO_CODING_NETEQ_NETEQ_DECODER_ENUM_H_
|
||||
#define MODULES_AUDIO_CODING_NETEQ_NETEQ_DECODER_ENUM_H_
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/audio_codecs/audio_format.h"
|
||||
#include "api/optional.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -49,7 +49,7 @@ enum class NetEqDecoder {
|
||||
kDecoderOpus_2ch,
|
||||
};
|
||||
|
||||
rtc::Optional<SdpAudioFormat> NetEqDecoderToSdpAudioFormat(NetEqDecoder nd);
|
||||
absl::optional<SdpAudioFormat> NetEqDecoderToSdpAudioFormat(NetEqDecoder nd);
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
|
||||
@ -422,14 +422,14 @@ void NetEqImpl::DisableVad() {
|
||||
vad_->Disable();
|
||||
}
|
||||
|
||||
rtc::Optional<uint32_t> NetEqImpl::GetPlayoutTimestamp() const {
|
||||
absl::optional<uint32_t> NetEqImpl::GetPlayoutTimestamp() const {
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
if (first_packet_ || last_mode_ == kModeRfc3389Cng ||
|
||||
last_mode_ == kModeCodecInternalCng) {
|
||||
// We don't have a valid RTP timestamp until we have decoded our first
|
||||
// RTP packet. Also, the RTP timestamp is not accurate while playing CNG,
|
||||
// which is indicated by returning an empty value.
|
||||
return rtc::nullopt;
|
||||
return absl::nullopt;
|
||||
}
|
||||
return timestamp_scaler_->ToExternal(playout_timestamp_);
|
||||
}
|
||||
@ -439,12 +439,12 @@ int NetEqImpl::last_output_sample_rate_hz() const {
|
||||
return last_output_sample_rate_hz_;
|
||||
}
|
||||
|
||||
rtc::Optional<CodecInst> NetEqImpl::GetDecoder(int payload_type) const {
|
||||
absl::optional<CodecInst> NetEqImpl::GetDecoder(int payload_type) const {
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
const DecoderDatabase::DecoderInfo* di =
|
||||
decoder_database_->GetDecoderInfo(payload_type);
|
||||
if (!di) {
|
||||
return rtc::nullopt;
|
||||
return absl::nullopt;
|
||||
}
|
||||
|
||||
// Create a CodecInst with some fields set. The remaining fields are zeroed,
|
||||
@ -460,13 +460,13 @@ rtc::Optional<CodecInst> NetEqImpl::GetDecoder(int payload_type) const {
|
||||
return ci;
|
||||
}
|
||||
|
||||
rtc::Optional<SdpAudioFormat> NetEqImpl::GetDecoderFormat(
|
||||
absl::optional<SdpAudioFormat> NetEqImpl::GetDecoderFormat(
|
||||
int payload_type) const {
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
const DecoderDatabase::DecoderInfo* const di =
|
||||
decoder_database_->GetDecoderInfo(payload_type);
|
||||
if (!di) {
|
||||
return rtc::nullopt; // Payload type not registered.
|
||||
return absl::nullopt; // Payload type not registered.
|
||||
}
|
||||
return di->GetFormat();
|
||||
}
|
||||
@ -1957,7 +1957,7 @@ int NetEqImpl::ExtractPackets(size_t required_samples,
|
||||
// Packet extraction loop.
|
||||
do {
|
||||
timestamp_ = next_packet->timestamp;
|
||||
rtc::Optional<Packet> packet = packet_buffer_->GetNextPacket();
|
||||
absl::optional<Packet> packet = packet_buffer_->GetNextPacket();
|
||||
// |next_packet| may be invalid after the |packet_buffer_| operation.
|
||||
next_packet = nullptr;
|
||||
if (!packet) {
|
||||
@ -2009,7 +2009,7 @@ int NetEqImpl::ExtractPackets(size_t required_samples,
|
||||
stats_.JitterBufferDelay(extracted_samples, waiting_time_ms);
|
||||
|
||||
packet_list->push_back(std::move(*packet)); // Store packet in list.
|
||||
packet = rtc::nullopt; // Ensure it's never used after the move.
|
||||
packet = absl::nullopt; // Ensure it's never used after the move.
|
||||
|
||||
// Check what packet is available next.
|
||||
next_packet = packet_buffer_->PeekNextPacket();
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "api/optional.h"
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/audio/audio_frame.h"
|
||||
#include "modules/audio_coding/neteq/audio_multi_vector.h"
|
||||
#include "modules/audio_coding/neteq/defines.h"
|
||||
@ -198,13 +198,13 @@ class NetEqImpl : public webrtc::NetEq {
|
||||
// Disables post-decode VAD.
|
||||
void DisableVad() override;
|
||||
|
||||
rtc::Optional<uint32_t> GetPlayoutTimestamp() const override;
|
||||
absl::optional<uint32_t> GetPlayoutTimestamp() const override;
|
||||
|
||||
int last_output_sample_rate_hz() const override;
|
||||
|
||||
rtc::Optional<CodecInst> GetDecoder(int payload_type) const override;
|
||||
absl::optional<CodecInst> GetDecoder(int payload_type) const override;
|
||||
|
||||
rtc::Optional<SdpAudioFormat> GetDecoderFormat(
|
||||
absl::optional<SdpAudioFormat> GetDecoderFormat(
|
||||
int payload_type) const override;
|
||||
|
||||
int SetTargetNumberOfChannels() override;
|
||||
@ -424,8 +424,8 @@ class NetEqImpl : public webrtc::NetEq {
|
||||
bool new_codec_ RTC_GUARDED_BY(crit_sect_);
|
||||
uint32_t timestamp_ RTC_GUARDED_BY(crit_sect_);
|
||||
bool reset_decoder_ RTC_GUARDED_BY(crit_sect_);
|
||||
rtc::Optional<uint8_t> current_rtp_payload_type_ RTC_GUARDED_BY(crit_sect_);
|
||||
rtc::Optional<uint8_t> current_cng_rtp_payload_type_
|
||||
absl::optional<uint8_t> current_rtp_payload_type_ RTC_GUARDED_BY(crit_sect_);
|
||||
absl::optional<uint8_t> current_cng_rtp_payload_type_
|
||||
RTC_GUARDED_BY(crit_sect_);
|
||||
uint32_t ssrc_ RTC_GUARDED_BY(crit_sect_);
|
||||
bool first_packet_ RTC_GUARDED_BY(crit_sect_);
|
||||
|
||||
@ -314,7 +314,7 @@ TEST_F(NetEqImplTest, InsertPacket) {
|
||||
new rtc::RefCountedObject<MockAudioDecoderFactory>);
|
||||
EXPECT_CALL(*mock_decoder_factory, MakeAudioDecoderMock(_, _, _))
|
||||
.WillOnce(Invoke([&](const SdpAudioFormat& format,
|
||||
rtc::Optional<AudioCodecPairId> codec_pair_id,
|
||||
absl::optional<AudioCodecPairId> codec_pair_id,
|
||||
std::unique_ptr<AudioDecoder>* dec) {
|
||||
EXPECT_EQ("pcmu", format.name);
|
||||
|
||||
@ -334,7 +334,7 @@ TEST_F(NetEqImplTest, InsertPacket) {
|
||||
|
||||
*dec = std::move(mock_decoder);
|
||||
}));
|
||||
DecoderDatabase::DecoderInfo info(NetEqDecoder::kDecoderPCMu, rtc::nullopt,
|
||||
DecoderDatabase::DecoderInfo info(NetEqDecoder::kDecoderPCMu, absl::nullopt,
|
||||
mock_decoder_factory);
|
||||
|
||||
// Expectations for decoder database.
|
||||
@ -518,10 +518,10 @@ TEST_F(NetEqImplTest, VerifyTimestampPropagation) {
|
||||
// The value of the last of the output samples is the same as the number of
|
||||
// samples played from the decoded packet. Thus, this number + the RTP
|
||||
// timestamp should match the playout timestamp.
|
||||
// Wrap the expected value in an rtc::Optional to compare them as such.
|
||||
// Wrap the expected value in an absl::optional to compare them as such.
|
||||
EXPECT_EQ(
|
||||
rtc::Optional<uint32_t>(rtp_header.timestamp +
|
||||
output.data()[output.samples_per_channel_ - 1]),
|
||||
absl::optional<uint32_t>(rtp_header.timestamp +
|
||||
output.data()[output.samples_per_channel_ - 1]),
|
||||
neteq_->GetPlayoutTimestamp());
|
||||
|
||||
// Check the timestamp for the last value in the sync buffer. This should
|
||||
@ -783,12 +783,12 @@ TEST_F(NetEqImplTest, CodecInternalCng) {
|
||||
|
||||
bool muted;
|
||||
EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted));
|
||||
rtc::Optional<uint32_t> last_timestamp = neteq_->GetPlayoutTimestamp();
|
||||
absl::optional<uint32_t> last_timestamp = neteq_->GetPlayoutTimestamp();
|
||||
ASSERT_TRUE(last_timestamp);
|
||||
|
||||
// Lambda for verifying the timestamps.
|
||||
auto verify_timestamp = [&last_timestamp, &expected_timestamp_increment](
|
||||
rtc::Optional<uint32_t> ts, size_t i) {
|
||||
absl::optional<uint32_t> ts, size_t i) {
|
||||
if (expected_timestamp_increment[i] == -1) {
|
||||
// Expect to get an empty timestamp value during CNG and PLC.
|
||||
EXPECT_FALSE(ts) << "i = " << i;
|
||||
|
||||
@ -46,7 +46,7 @@ class MockAudioDecoder final : public AudioDecoder {
|
||||
|
||||
size_t Duration() const override { return kPacketDuration; }
|
||||
|
||||
rtc::Optional<DecodeResult> Decode(
|
||||
absl::optional<DecodeResult> Decode(
|
||||
rtc::ArrayView<int16_t> decoded) const override {
|
||||
const size_t output_size =
|
||||
sizeof(int16_t) * kPacketDuration * num_channels_;
|
||||
@ -57,7 +57,7 @@ class MockAudioDecoder final : public AudioDecoder {
|
||||
} else {
|
||||
ADD_FAILURE() << "Expected decoded.size() to be >= output_size ("
|
||||
<< decoded.size() << " vs. " << output_size << ")";
|
||||
return rtc::nullopt;
|
||||
return absl::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -698,7 +698,7 @@ void NetEqDecodingTest::LongCngWithClockDrift(double drift_factor,
|
||||
}
|
||||
|
||||
EXPECT_EQ(AudioFrame::kNormalSpeech, out_frame_.speech_type_);
|
||||
rtc::Optional<uint32_t> playout_timestamp = neteq_->GetPlayoutTimestamp();
|
||||
absl::optional<uint32_t> playout_timestamp = neteq_->GetPlayoutTimestamp();
|
||||
ASSERT_TRUE(playout_timestamp);
|
||||
int32_t delay_before = timestamp - *playout_timestamp;
|
||||
|
||||
@ -1121,7 +1121,7 @@ void NetEqDecodingTest::WrapTest(uint16_t start_seq_no,
|
||||
ASSERT_EQ(1u, output.num_channels_);
|
||||
|
||||
// Expect delay (in samples) to be less than 2 packets.
|
||||
rtc::Optional<uint32_t> playout_timestamp = neteq_->GetPlayoutTimestamp();
|
||||
absl::optional<uint32_t> playout_timestamp = neteq_->GetPlayoutTimestamp();
|
||||
ASSERT_TRUE(playout_timestamp);
|
||||
EXPECT_LE(timestamp - *playout_timestamp,
|
||||
static_cast<uint32_t>(kSamples * 2));
|
||||
@ -1233,7 +1233,7 @@ void NetEqDecodingTest::DuplicateCng() {
|
||||
ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted));
|
||||
ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_);
|
||||
EXPECT_EQ(AudioFrame::kNormalSpeech, out_frame_.speech_type_);
|
||||
rtc::Optional<uint32_t> playout_timestamp = neteq_->GetPlayoutTimestamp();
|
||||
absl::optional<uint32_t> playout_timestamp = neteq_->GetPlayoutTimestamp();
|
||||
ASSERT_TRUE(playout_timestamp);
|
||||
EXPECT_EQ(timestamp + kSamples - algorithmic_delay_samples,
|
||||
*playout_timestamp);
|
||||
|
||||
@ -129,8 +129,8 @@ int PacketBuffer::InsertPacket(Packet&& packet, StatisticsCalculator* stats) {
|
||||
int PacketBuffer::InsertPacketList(
|
||||
PacketList* packet_list,
|
||||
const DecoderDatabase& decoder_database,
|
||||
rtc::Optional<uint8_t>* current_rtp_payload_type,
|
||||
rtc::Optional<uint8_t>* current_cng_rtp_payload_type,
|
||||
absl::optional<uint8_t>* current_rtp_payload_type,
|
||||
absl::optional<uint8_t>* current_cng_rtp_payload_type,
|
||||
StatisticsCalculator* stats) {
|
||||
RTC_DCHECK(stats);
|
||||
bool flushed = false;
|
||||
@ -139,7 +139,7 @@ int PacketBuffer::InsertPacketList(
|
||||
if (*current_cng_rtp_payload_type &&
|
||||
**current_cng_rtp_payload_type != packet.payload_type) {
|
||||
// New CNG payload type implies new codec type.
|
||||
*current_rtp_payload_type = rtc::nullopt;
|
||||
*current_rtp_payload_type = absl::nullopt;
|
||||
Flush();
|
||||
flushed = true;
|
||||
}
|
||||
@ -152,7 +152,7 @@ int PacketBuffer::InsertPacketList(
|
||||
!EqualSampleRates(packet.payload_type,
|
||||
**current_cng_rtp_payload_type,
|
||||
decoder_database))) {
|
||||
*current_cng_rtp_payload_type = rtc::nullopt;
|
||||
*current_cng_rtp_payload_type = absl::nullopt;
|
||||
Flush();
|
||||
flushed = true;
|
||||
}
|
||||
@ -206,13 +206,13 @@ const Packet* PacketBuffer::PeekNextPacket() const {
|
||||
return buffer_.empty() ? nullptr : &buffer_.front();
|
||||
}
|
||||
|
||||
rtc::Optional<Packet> PacketBuffer::GetNextPacket() {
|
||||
absl::optional<Packet> PacketBuffer::GetNextPacket() {
|
||||
if (Empty()) {
|
||||
// Buffer is empty.
|
||||
return rtc::nullopt;
|
||||
return absl::nullopt;
|
||||
}
|
||||
|
||||
rtc::Optional<Packet> packet(std::move(buffer_.front()));
|
||||
absl::optional<Packet> packet(std::move(buffer_.front()));
|
||||
// Assert that the packet sanity checks in InsertPacket method works.
|
||||
RTC_DCHECK(!packet->empty());
|
||||
buffer_.pop_front();
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
#ifndef MODULES_AUDIO_CODING_NETEQ_PACKET_BUFFER_H_
|
||||
#define MODULES_AUDIO_CODING_NETEQ_PACKET_BUFFER_H_
|
||||
|
||||
#include "api/optional.h"
|
||||
#include "absl/types/optional.h"
|
||||
#include "modules/audio_coding/neteq/decoder_database.h"
|
||||
#include "modules/audio_coding/neteq/packet.h"
|
||||
#include "modules/include/module_common_types.h"
|
||||
@ -66,8 +66,8 @@ class PacketBuffer {
|
||||
virtual int InsertPacketList(
|
||||
PacketList* packet_list,
|
||||
const DecoderDatabase& decoder_database,
|
||||
rtc::Optional<uint8_t>* current_rtp_payload_type,
|
||||
rtc::Optional<uint8_t>* current_cng_rtp_payload_type,
|
||||
absl::optional<uint8_t>* current_rtp_payload_type,
|
||||
absl::optional<uint8_t>* current_cng_rtp_payload_type,
|
||||
StatisticsCalculator* stats);
|
||||
|
||||
// Gets the timestamp for the first packet in the buffer and writes it to the
|
||||
@ -90,7 +90,7 @@ class PacketBuffer {
|
||||
|
||||
// Extracts the first packet in the buffer and returns it.
|
||||
// Returns an empty optional if the buffer is empty.
|
||||
virtual rtc::Optional<Packet> GetNextPacket();
|
||||
virtual absl::optional<Packet> GetNextPacket();
|
||||
|
||||
// Discards the first packet in the buffer. The packet is deleted.
|
||||
// Returns PacketBuffer::kBufferEmpty if the buffer is empty,
|
||||
|
||||
@ -176,21 +176,21 @@ TEST(PacketBuffer, InsertPacketList) {
|
||||
MockDecoderDatabase decoder_database;
|
||||
auto factory = CreateBuiltinAudioDecoderFactory();
|
||||
const DecoderDatabase::DecoderInfo info(NetEqDecoder::kDecoderPCMu,
|
||||
rtc::nullopt, factory);
|
||||
absl::nullopt, factory);
|
||||
EXPECT_CALL(decoder_database, GetDecoderInfo(0))
|
||||
.WillRepeatedly(Return(&info));
|
||||
|
||||
StrictMock<MockStatisticsCalculator> mock_stats;
|
||||
|
||||
rtc::Optional<uint8_t> current_pt;
|
||||
rtc::Optional<uint8_t> current_cng_pt;
|
||||
absl::optional<uint8_t> current_pt;
|
||||
absl::optional<uint8_t> current_cng_pt;
|
||||
EXPECT_EQ(PacketBuffer::kOK,
|
||||
buffer.InsertPacketList(&list, decoder_database, ¤t_pt,
|
||||
¤t_cng_pt, &mock_stats));
|
||||
EXPECT_TRUE(list.empty()); // The PacketBuffer should have depleted the list.
|
||||
EXPECT_EQ(10u, buffer.NumPacketsInBuffer());
|
||||
EXPECT_EQ(0, current_pt); // Current payload type changed to 0.
|
||||
EXPECT_EQ(rtc::nullopt, current_cng_pt); // CNG payload type not changed.
|
||||
EXPECT_EQ(absl::nullopt, current_cng_pt); // CNG payload type not changed.
|
||||
|
||||
buffer.Flush(); // Clean up.
|
||||
|
||||
@ -221,25 +221,25 @@ TEST(PacketBuffer, InsertPacketListChangePayloadType) {
|
||||
MockDecoderDatabase decoder_database;
|
||||
auto factory = CreateBuiltinAudioDecoderFactory();
|
||||
const DecoderDatabase::DecoderInfo info0(NetEqDecoder::kDecoderPCMu,
|
||||
rtc::nullopt, factory);
|
||||
absl::nullopt, factory);
|
||||
EXPECT_CALL(decoder_database, GetDecoderInfo(0))
|
||||
.WillRepeatedly(Return(&info0));
|
||||
const DecoderDatabase::DecoderInfo info1(NetEqDecoder::kDecoderPCMa,
|
||||
rtc::nullopt, factory);
|
||||
absl::nullopt, factory);
|
||||
EXPECT_CALL(decoder_database, GetDecoderInfo(1))
|
||||
.WillRepeatedly(Return(&info1));
|
||||
|
||||
StrictMock<MockStatisticsCalculator> mock_stats;
|
||||
|
||||
rtc::Optional<uint8_t> current_pt;
|
||||
rtc::Optional<uint8_t> current_cng_pt;
|
||||
absl::optional<uint8_t> current_pt;
|
||||
absl::optional<uint8_t> current_cng_pt;
|
||||
EXPECT_EQ(PacketBuffer::kFlushed,
|
||||
buffer.InsertPacketList(&list, decoder_database, ¤t_pt,
|
||||
¤t_cng_pt, &mock_stats));
|
||||
EXPECT_TRUE(list.empty()); // The PacketBuffer should have depleted the list.
|
||||
EXPECT_EQ(1u, buffer.NumPacketsInBuffer()); // Only the last packet.
|
||||
EXPECT_EQ(1, current_pt); // Current payload type changed to 1.
|
||||
EXPECT_EQ(rtc::nullopt, current_cng_pt); // CNG payload type not changed.
|
||||
EXPECT_EQ(absl::nullopt, current_cng_pt); // CNG payload type not changed.
|
||||
|
||||
buffer.Flush(); // Clean up.
|
||||
|
||||
@ -313,7 +313,7 @@ TEST(PacketBuffer, ExtractOrderRedundancy) {
|
||||
EXPECT_EQ(kExpectPacketsInBuffer, buffer.NumPacketsInBuffer());
|
||||
|
||||
for (size_t i = 0; i < kExpectPacketsInBuffer; ++i) {
|
||||
const rtc::Optional<Packet> packet = buffer.GetNextPacket();
|
||||
const absl::optional<Packet> packet = buffer.GetNextPacket();
|
||||
EXPECT_EQ(packet, expect_order[i]); // Compare contents.
|
||||
}
|
||||
EXPECT_TRUE(buffer.Empty());
|
||||
@ -408,11 +408,11 @@ TEST(PacketBuffer, Reordering) {
|
||||
MockDecoderDatabase decoder_database;
|
||||
auto factory = CreateBuiltinAudioDecoderFactory();
|
||||
const DecoderDatabase::DecoderInfo info(NetEqDecoder::kDecoderPCMu,
|
||||
rtc::nullopt, factory);
|
||||
absl::nullopt, factory);
|
||||
EXPECT_CALL(decoder_database, GetDecoderInfo(0))
|
||||
.WillRepeatedly(Return(&info));
|
||||
rtc::Optional<uint8_t> current_pt;
|
||||
rtc::Optional<uint8_t> current_cng_pt;
|
||||
absl::optional<uint8_t> current_pt;
|
||||
absl::optional<uint8_t> current_cng_pt;
|
||||
|
||||
StrictMock<MockStatisticsCalculator> mock_stats;
|
||||
|
||||
@ -424,7 +424,7 @@ TEST(PacketBuffer, Reordering) {
|
||||
// Extract them and make sure that come out in the right order.
|
||||
uint32_t current_ts = start_ts;
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
const rtc::Optional<Packet> packet = buffer.GetNextPacket();
|
||||
const absl::optional<Packet> packet = buffer.GetNextPacket();
|
||||
ASSERT_TRUE(packet);
|
||||
EXPECT_EQ(current_ts, packet->timestamp);
|
||||
current_ts += ts_increment;
|
||||
@ -448,11 +448,11 @@ TEST(PacketBuffer, CngFirstThenSpeechWithNewSampleRate) {
|
||||
MockDecoderDatabase decoder_database;
|
||||
auto factory = CreateBuiltinAudioDecoderFactory();
|
||||
const DecoderDatabase::DecoderInfo info_cng(NetEqDecoder::kDecoderCNGnb,
|
||||
rtc::nullopt, factory);
|
||||
absl::nullopt, factory);
|
||||
EXPECT_CALL(decoder_database, GetDecoderInfo(kCngPt))
|
||||
.WillRepeatedly(Return(&info_cng));
|
||||
const DecoderDatabase::DecoderInfo info_speech(NetEqDecoder::kDecoderPCM16Bwb,
|
||||
rtc::nullopt, factory);
|
||||
absl::nullopt, factory);
|
||||
EXPECT_CALL(decoder_database, GetDecoderInfo(kSpeechPt))
|
||||
.WillRepeatedly(Return(&info_speech));
|
||||
|
||||
@ -460,8 +460,8 @@ TEST(PacketBuffer, CngFirstThenSpeechWithNewSampleRate) {
|
||||
PacketGenerator gen(0, 0, kCngPt, 10);
|
||||
PacketList list;
|
||||
list.push_back(gen.NextPacket(kPayloadLen));
|
||||
rtc::Optional<uint8_t> current_pt;
|
||||
rtc::Optional<uint8_t> current_cng_pt;
|
||||
absl::optional<uint8_t> current_pt;
|
||||
absl::optional<uint8_t> current_cng_pt;
|
||||
|
||||
StrictMock<MockStatisticsCalculator> mock_stats;
|
||||
|
||||
@ -472,7 +472,7 @@ TEST(PacketBuffer, CngFirstThenSpeechWithNewSampleRate) {
|
||||
EXPECT_EQ(1u, buffer.NumPacketsInBuffer());
|
||||
ASSERT_TRUE(buffer.PeekNextPacket());
|
||||
EXPECT_EQ(kCngPt, buffer.PeekNextPacket()->payload_type);
|
||||
EXPECT_EQ(current_pt, rtc::nullopt); // Current payload type not set.
|
||||
EXPECT_EQ(current_pt, absl::nullopt); // Current payload type not set.
|
||||
EXPECT_EQ(kCngPt, current_cng_pt); // CNG payload type set.
|
||||
|
||||
// Insert second packet, which is wide-band speech.
|
||||
@ -492,7 +492,7 @@ TEST(PacketBuffer, CngFirstThenSpeechWithNewSampleRate) {
|
||||
EXPECT_EQ(kSpeechPt, buffer.PeekNextPacket()->payload_type);
|
||||
|
||||
EXPECT_EQ(kSpeechPt, current_pt); // Current payload type set.
|
||||
EXPECT_EQ(rtc::nullopt, current_cng_pt); // CNG payload type reset.
|
||||
EXPECT_EQ(absl::nullopt, current_cng_pt); // CNG payload type reset.
|
||||
|
||||
buffer.Flush(); // Clean up.
|
||||
EXPECT_CALL(decoder_database, Die()); // Called when object is deleted.
|
||||
@ -550,11 +550,11 @@ TEST(PacketBuffer, Failures) {
|
||||
MockDecoderDatabase decoder_database;
|
||||
auto factory = CreateBuiltinAudioDecoderFactory();
|
||||
const DecoderDatabase::DecoderInfo info(NetEqDecoder::kDecoderPCMu,
|
||||
rtc::nullopt, factory);
|
||||
absl::nullopt, factory);
|
||||
EXPECT_CALL(decoder_database, GetDecoderInfo(0))
|
||||
.WillRepeatedly(Return(&info));
|
||||
rtc::Optional<uint8_t> current_pt;
|
||||
rtc::Optional<uint8_t> current_cng_pt;
|
||||
absl::optional<uint8_t> current_pt;
|
||||
absl::optional<uint8_t> current_cng_pt;
|
||||
EXPECT_EQ(PacketBuffer::kInvalidPacket,
|
||||
buffer->InsertPacketList(&list, decoder_database, ¤t_pt,
|
||||
¤t_cng_pt, &mock_stats));
|
||||
|
||||
@ -299,7 +299,7 @@ TEST(RedPayloadSplitter, CheckRedPayloads) {
|
||||
// easier to just register the payload types and let the actual implementation
|
||||
// do its job.
|
||||
DecoderDatabase decoder_database(
|
||||
new rtc::RefCountedObject<MockAudioDecoderFactory>, rtc::nullopt);
|
||||
new rtc::RefCountedObject<MockAudioDecoderFactory>, absl::nullopt);
|
||||
decoder_database.RegisterPayload(0, NetEqDecoder::kDecoderCNGnb, "cng-nb");
|
||||
decoder_database.RegisterPayload(1, NetEqDecoder::kDecoderPCMu, "pcmu");
|
||||
decoder_database.RegisterPayload(2, NetEqDecoder::kDecoderAVT, "avt");
|
||||
|
||||
@ -26,7 +26,7 @@ TEST(TimestampScaler, TestNoScaling) {
|
||||
auto factory = CreateBuiltinAudioDecoderFactory();
|
||||
// Use PCMu, because it doesn't use scaled timestamps.
|
||||
const DecoderDatabase::DecoderInfo info(NetEqDecoder::kDecoderPCMu,
|
||||
rtc::nullopt, factory);
|
||||
absl::nullopt, factory);
|
||||
static const uint8_t kRtpPayloadType = 0;
|
||||
EXPECT_CALL(db, GetDecoderInfo(kRtpPayloadType))
|
||||
.WillRepeatedly(Return(&info));
|
||||
@ -48,7 +48,7 @@ TEST(TimestampScaler, TestNoScalingLargeStep) {
|
||||
auto factory = CreateBuiltinAudioDecoderFactory();
|
||||
// Use PCMu, because it doesn't use scaled timestamps.
|
||||
const DecoderDatabase::DecoderInfo info(NetEqDecoder::kDecoderPCMu,
|
||||
rtc::nullopt, factory);
|
||||
absl::nullopt, factory);
|
||||
static const uint8_t kRtpPayloadType = 0;
|
||||
EXPECT_CALL(db, GetDecoderInfo(kRtpPayloadType))
|
||||
.WillRepeatedly(Return(&info));
|
||||
@ -75,7 +75,7 @@ TEST(TimestampScaler, TestG722) {
|
||||
auto factory = CreateBuiltinAudioDecoderFactory();
|
||||
// Use G722, which has a factor 2 scaling.
|
||||
const DecoderDatabase::DecoderInfo info(NetEqDecoder::kDecoderG722,
|
||||
rtc::nullopt, factory);
|
||||
absl::nullopt, factory);
|
||||
static const uint8_t kRtpPayloadType = 17;
|
||||
EXPECT_CALL(db, GetDecoderInfo(kRtpPayloadType))
|
||||
.WillRepeatedly(Return(&info));
|
||||
@ -101,7 +101,7 @@ TEST(TimestampScaler, TestG722LargeStep) {
|
||||
auto factory = CreateBuiltinAudioDecoderFactory();
|
||||
// Use G722, which has a factor 2 scaling.
|
||||
const DecoderDatabase::DecoderInfo info(NetEqDecoder::kDecoderG722,
|
||||
rtc::nullopt, factory);
|
||||
absl::nullopt, factory);
|
||||
static const uint8_t kRtpPayloadType = 17;
|
||||
EXPECT_CALL(db, GetDecoderInfo(kRtpPayloadType))
|
||||
.WillRepeatedly(Return(&info));
|
||||
@ -131,9 +131,9 @@ TEST(TimestampScaler, TestG722WithCng) {
|
||||
auto factory = CreateBuiltinAudioDecoderFactory();
|
||||
// Use G722, which has a factor 2 scaling.
|
||||
const DecoderDatabase::DecoderInfo info_g722(NetEqDecoder::kDecoderG722,
|
||||
rtc::nullopt, factory);
|
||||
absl::nullopt, factory);
|
||||
const DecoderDatabase::DecoderInfo info_cng(NetEqDecoder::kDecoderCNGwb,
|
||||
rtc::nullopt, factory);
|
||||
absl::nullopt, factory);
|
||||
static const uint8_t kRtpPayloadTypeG722 = 17;
|
||||
static const uint8_t kRtpPayloadTypeCng = 13;
|
||||
EXPECT_CALL(db, GetDecoderInfo(kRtpPayloadTypeG722))
|
||||
@ -175,7 +175,7 @@ TEST(TimestampScaler, TestG722Packet) {
|
||||
auto factory = CreateBuiltinAudioDecoderFactory();
|
||||
// Use G722, which has a factor 2 scaling.
|
||||
const DecoderDatabase::DecoderInfo info(NetEqDecoder::kDecoderG722,
|
||||
rtc::nullopt, factory);
|
||||
absl::nullopt, factory);
|
||||
static const uint8_t kRtpPayloadType = 17;
|
||||
EXPECT_CALL(db, GetDecoderInfo(kRtpPayloadType))
|
||||
.WillRepeatedly(Return(&info));
|
||||
@ -205,7 +205,7 @@ TEST(TimestampScaler, TestG722PacketList) {
|
||||
auto factory = CreateBuiltinAudioDecoderFactory();
|
||||
// Use G722, which has a factor 2 scaling.
|
||||
const DecoderDatabase::DecoderInfo info(NetEqDecoder::kDecoderG722,
|
||||
rtc::nullopt, factory);
|
||||
absl::nullopt, factory);
|
||||
static const uint8_t kRtpPayloadType = 17;
|
||||
EXPECT_CALL(db, GetDecoderInfo(kRtpPayloadType))
|
||||
.WillRepeatedly(Return(&info));
|
||||
@ -239,7 +239,7 @@ TEST(TimestampScaler, TestG722Reset) {
|
||||
auto factory = CreateBuiltinAudioDecoderFactory();
|
||||
// Use G722, which has a factor 2 scaling.
|
||||
const DecoderDatabase::DecoderInfo info(NetEqDecoder::kDecoderG722,
|
||||
rtc::nullopt, factory);
|
||||
absl::nullopt, factory);
|
||||
static const uint8_t kRtpPayloadType = 17;
|
||||
EXPECT_CALL(db, GetDecoderInfo(kRtpPayloadType))
|
||||
.WillRepeatedly(Return(&info));
|
||||
@ -280,7 +280,7 @@ TEST(TimestampScaler, TestOpusLargeStep) {
|
||||
MockDecoderDatabase db;
|
||||
auto factory = CreateBuiltinAudioDecoderFactory();
|
||||
const DecoderDatabase::DecoderInfo info(NetEqDecoder::kDecoderOpus,
|
||||
rtc::nullopt, factory);
|
||||
absl::nullopt, factory);
|
||||
static const uint8_t kRtpPayloadType = 17;
|
||||
EXPECT_CALL(db, GetDecoderInfo(kRtpPayloadType))
|
||||
.WillRepeatedly(Return(&info));
|
||||
|
||||
@ -27,12 +27,12 @@ EncodeNetEqInput::EncodeNetEqInput(std::unique_ptr<Generator> generator,
|
||||
CreatePacket();
|
||||
}
|
||||
|
||||
rtc::Optional<int64_t> EncodeNetEqInput::NextPacketTime() const {
|
||||
absl::optional<int64_t> EncodeNetEqInput::NextPacketTime() const {
|
||||
RTC_DCHECK(packet_data_);
|
||||
return static_cast<int64_t>(packet_data_->time_ms);
|
||||
}
|
||||
|
||||
rtc::Optional<int64_t> EncodeNetEqInput::NextOutputEventTime() const {
|
||||
absl::optional<int64_t> EncodeNetEqInput::NextOutputEventTime() const {
|
||||
return next_output_event_ms_;
|
||||
}
|
||||
|
||||
@ -50,7 +50,7 @@ void EncodeNetEqInput::AdvanceOutputEvent() {
|
||||
next_output_event_ms_ += kOutputPeriodMs;
|
||||
}
|
||||
|
||||
rtc::Optional<RTPHeader> EncodeNetEqInput::NextHeader() const {
|
||||
absl::optional<RTPHeader> EncodeNetEqInput::NextHeader() const {
|
||||
RTC_DCHECK(packet_data_);
|
||||
return packet_data_->header;
|
||||
}
|
||||
|
||||
@ -36,9 +36,9 @@ class EncodeNetEqInput : public NetEqInput {
|
||||
std::unique_ptr<AudioEncoder> encoder,
|
||||
int64_t input_duration_ms);
|
||||
|
||||
rtc::Optional<int64_t> NextPacketTime() const override;
|
||||
absl::optional<int64_t> NextPacketTime() const override;
|
||||
|
||||
rtc::Optional<int64_t> NextOutputEventTime() const override;
|
||||
absl::optional<int64_t> NextOutputEventTime() const override;
|
||||
|
||||
std::unique_ptr<PacketData> PopPacket() override;
|
||||
|
||||
@ -48,7 +48,7 @@ class EncodeNetEqInput : public NetEqInput {
|
||||
return next_output_event_ms_ <= input_duration_ms_;
|
||||
}
|
||||
|
||||
rtc::Optional<RTPHeader> NextHeader() const override;
|
||||
absl::optional<RTPHeader> NextHeader() const override;
|
||||
|
||||
private:
|
||||
static constexpr int64_t kOutputPeriodMs = 10;
|
||||
|
||||
@ -13,9 +13,9 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/array_view.h"
|
||||
#include "api/audio_codecs/audio_decoder.h"
|
||||
#include "api/optional.h"
|
||||
#include "modules/audio_coding/neteq/tools/input_audio_file.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -61,7 +61,7 @@ class FakeDecodeFromFile : public AudioDecoder {
|
||||
|
||||
private:
|
||||
std::unique_ptr<InputAudioFile> input_;
|
||||
rtc::Optional<uint32_t> next_timestamp_from_input_;
|
||||
absl::optional<uint32_t> next_timestamp_from_input_;
|
||||
const int sample_rate_hz_;
|
||||
const bool stereo_;
|
||||
size_t last_decoded_length_ = 0;
|
||||
|
||||
@ -101,8 +101,8 @@ void NetEqDelayAnalyzer::CreateGraphs(
|
||||
std::vector<float>* send_time_s,
|
||||
std::vector<float>* arrival_delay_ms,
|
||||
std::vector<float>* corrected_arrival_delay_ms,
|
||||
std::vector<rtc::Optional<float>>* playout_delay_ms,
|
||||
std::vector<rtc::Optional<float>>* target_delay_ms) const {
|
||||
std::vector<absl::optional<float>>* playout_delay_ms,
|
||||
std::vector<absl::optional<float>>* target_delay_ms) const {
|
||||
if (get_audio_time_ms_.empty()) {
|
||||
return;
|
||||
}
|
||||
@ -167,8 +167,8 @@ void NetEqDelayAnalyzer::CreateGraphs(
|
||||
target_delay_ms->push_back(target);
|
||||
} else {
|
||||
// This packet was never decoded. Mark target and playout delays as empty.
|
||||
playout_delay_ms->push_back(rtc::nullopt);
|
||||
target_delay_ms->push_back(rtc::nullopt);
|
||||
playout_delay_ms->push_back(absl::nullopt);
|
||||
target_delay_ms->push_back(absl::nullopt);
|
||||
}
|
||||
}
|
||||
RTC_DCHECK(data_it == data_.end());
|
||||
@ -182,8 +182,8 @@ void NetEqDelayAnalyzer::CreateMatlabScript(
|
||||
std::vector<float> send_time_s;
|
||||
std::vector<float> arrival_delay_ms;
|
||||
std::vector<float> corrected_arrival_delay_ms;
|
||||
std::vector<rtc::Optional<float>> playout_delay_ms;
|
||||
std::vector<rtc::Optional<float>> target_delay_ms;
|
||||
std::vector<absl::optional<float>> playout_delay_ms;
|
||||
std::vector<absl::optional<float>> target_delay_ms;
|
||||
CreateGraphs(&send_time_s, &arrival_delay_ms, &corrected_arrival_delay_ms,
|
||||
&playout_delay_ms, &target_delay_ms);
|
||||
|
||||
@ -258,8 +258,8 @@ void NetEqDelayAnalyzer::CreatePythonScript(
|
||||
std::vector<float> send_time_s;
|
||||
std::vector<float> arrival_delay_ms;
|
||||
std::vector<float> corrected_arrival_delay_ms;
|
||||
std::vector<rtc::Optional<float>> playout_delay_ms;
|
||||
std::vector<rtc::Optional<float>> target_delay_ms;
|
||||
std::vector<absl::optional<float>> playout_delay_ms;
|
||||
std::vector<absl::optional<float>> target_delay_ms;
|
||||
CreateGraphs(&send_time_s, &arrival_delay_ms, &corrected_arrival_delay_ms,
|
||||
&playout_delay_ms, &target_delay_ms);
|
||||
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "api/optional.h"
|
||||
#include "absl/types/optional.h"
|
||||
#include "modules/audio_coding/neteq/tools/neteq_input.h"
|
||||
#include "modules/audio_coding/neteq/tools/neteq_test.h"
|
||||
#include "typedefs.h" // NOLINT(build/include)
|
||||
@ -40,8 +40,8 @@ class NetEqDelayAnalyzer : public test::NetEqPostInsertPacket,
|
||||
void CreateGraphs(std::vector<float>* send_times_s,
|
||||
std::vector<float>* arrival_delay_ms,
|
||||
std::vector<float>* corrected_arrival_delay_ms,
|
||||
std::vector<rtc::Optional<float>>* playout_delay_ms,
|
||||
std::vector<rtc::Optional<float>>* target_delay_ms) const;
|
||||
std::vector<absl::optional<float>>* playout_delay_ms,
|
||||
std::vector<absl::optional<float>>* target_delay_ms) const;
|
||||
|
||||
// Creates a matlab script with file name script_name. When executed in
|
||||
// Matlab, the script will generate graphs with the same timing information
|
||||
@ -57,10 +57,10 @@ class NetEqDelayAnalyzer : public test::NetEqPostInsertPacket,
|
||||
struct TimingData {
|
||||
explicit TimingData(double at) : arrival_time_ms(at) {}
|
||||
double arrival_time_ms;
|
||||
rtc::Optional<int64_t> decode_get_audio_count;
|
||||
rtc::Optional<int64_t> sync_delay_ms;
|
||||
rtc::Optional<int> target_delay_ms;
|
||||
rtc::Optional<int> current_delay_ms;
|
||||
absl::optional<int64_t> decode_get_audio_count;
|
||||
absl::optional<int64_t> sync_delay_ms;
|
||||
absl::optional<int> target_delay_ms;
|
||||
absl::optional<int> current_delay_ms;
|
||||
};
|
||||
std::map<uint32_t, TimingData> data_;
|
||||
std::vector<int64_t> get_audio_time_ms_;
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "api/optional.h"
|
||||
#include "absl/types/optional.h"
|
||||
#include "common_types.h" // NOLINT(build/include)
|
||||
#include "modules/audio_coding/neteq/tools/packet.h"
|
||||
#include "modules/audio_coding/neteq/tools/packet_source.h"
|
||||
@ -39,22 +39,22 @@ class NetEqInput {
|
||||
|
||||
// Returns at what time (in ms) NetEq::InsertPacket should be called next, or
|
||||
// empty if the source is out of packets.
|
||||
virtual rtc::Optional<int64_t> NextPacketTime() const = 0;
|
||||
virtual absl::optional<int64_t> NextPacketTime() const = 0;
|
||||
|
||||
// Returns at what time (in ms) NetEq::GetAudio should be called next, or
|
||||
// empty if no more output events are available.
|
||||
virtual rtc::Optional<int64_t> NextOutputEventTime() const = 0;
|
||||
virtual absl::optional<int64_t> NextOutputEventTime() const = 0;
|
||||
|
||||
// Returns the time (in ms) for the next event from either NextPacketTime()
|
||||
// or NextOutputEventTime(), or empty if both are out of events.
|
||||
rtc::Optional<int64_t> NextEventTime() const {
|
||||
absl::optional<int64_t> NextEventTime() const {
|
||||
const auto a = NextPacketTime();
|
||||
const auto b = NextOutputEventTime();
|
||||
// Return the minimum of non-empty |a| and |b|, or empty if both are empty.
|
||||
if (a) {
|
||||
return b ? std::min(*a, *b) : a;
|
||||
}
|
||||
return b ? b : rtc::nullopt;
|
||||
return b ? b : absl::nullopt;
|
||||
}
|
||||
|
||||
// Returns the next packet to be inserted into NetEq. The packet following the
|
||||
@ -75,7 +75,7 @@ class NetEqInput {
|
||||
|
||||
// Returns the RTP header for the next packet, i.e., the packet that will be
|
||||
// delivered next by PopPacket().
|
||||
virtual rtc::Optional<RTPHeader> NextHeader() const = 0;
|
||||
virtual absl::optional<RTPHeader> NextHeader() const = 0;
|
||||
};
|
||||
|
||||
} // namespace test
|
||||
|
||||
@ -22,15 +22,14 @@ namespace test {
|
||||
|
||||
NetEqPacketSourceInput::NetEqPacketSourceInput() : next_output_event_ms_(0) {}
|
||||
|
||||
rtc::Optional<int64_t> NetEqPacketSourceInput::NextPacketTime() const {
|
||||
absl::optional<int64_t> NetEqPacketSourceInput::NextPacketTime() const {
|
||||
return packet_
|
||||
? rtc::Optional<int64_t>(static_cast<int64_t>(packet_->time_ms()))
|
||||
: rtc::nullopt;
|
||||
? absl::optional<int64_t>(static_cast<int64_t>(packet_->time_ms()))
|
||||
: absl::nullopt;
|
||||
}
|
||||
|
||||
rtc::Optional<RTPHeader> NetEqPacketSourceInput::NextHeader() const {
|
||||
return packet_ ? rtc::Optional<RTPHeader>(packet_->header())
|
||||
: rtc::nullopt;
|
||||
absl::optional<RTPHeader> NetEqPacketSourceInput::NextHeader() const {
|
||||
return packet_ ? absl::optional<RTPHeader>(packet_->header()) : absl::nullopt;
|
||||
}
|
||||
|
||||
void NetEqPacketSourceInput::LoadNextPacket() {
|
||||
@ -75,7 +74,7 @@ NetEqRtpDumpInput::NetEqRtpDumpInput(const std::string& file_name,
|
||||
LoadNextPacket();
|
||||
}
|
||||
|
||||
rtc::Optional<int64_t> NetEqRtpDumpInput::NextOutputEventTime() const {
|
||||
absl::optional<int64_t> NetEqRtpDumpInput::NextOutputEventTime() const {
|
||||
return next_output_event_ms_;
|
||||
}
|
||||
|
||||
@ -84,7 +83,7 @@ void NetEqRtpDumpInput::AdvanceOutputEvent() {
|
||||
*next_output_event_ms_ += kOutputPeriodMs;
|
||||
}
|
||||
if (!NextPacketTime()) {
|
||||
next_output_event_ms_ = rtc::nullopt;
|
||||
next_output_event_ms_ = absl::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
@ -102,14 +101,14 @@ NetEqEventLogInput::NetEqEventLogInput(const std::string& file_name,
|
||||
AdvanceOutputEvent();
|
||||
}
|
||||
|
||||
rtc::Optional<int64_t> NetEqEventLogInput::NextOutputEventTime() const {
|
||||
absl::optional<int64_t> NetEqEventLogInput::NextOutputEventTime() const {
|
||||
return next_output_event_ms_;
|
||||
}
|
||||
|
||||
void NetEqEventLogInput::AdvanceOutputEvent() {
|
||||
next_output_event_ms_ = source_->NextAudioOutputEventMs();
|
||||
if (*next_output_event_ms_ == std::numeric_limits<int64_t>::max()) {
|
||||
next_output_event_ms_ = rtc::nullopt;
|
||||
next_output_event_ms_ = absl::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -29,9 +29,9 @@ class NetEqPacketSourceInput : public NetEqInput {
|
||||
using RtpHeaderExtensionMap = std::map<int, webrtc::RTPExtensionType>;
|
||||
|
||||
NetEqPacketSourceInput();
|
||||
rtc::Optional<int64_t> NextPacketTime() const override;
|
||||
absl::optional<int64_t> NextPacketTime() const override;
|
||||
std::unique_ptr<PacketData> PopPacket() override;
|
||||
rtc::Optional<RTPHeader> NextHeader() const override;
|
||||
absl::optional<RTPHeader> NextHeader() const override;
|
||||
bool ended() const override { return !next_output_event_ms_; }
|
||||
void SelectSsrc(uint32_t);
|
||||
|
||||
@ -39,7 +39,7 @@ class NetEqPacketSourceInput : public NetEqInput {
|
||||
virtual PacketSource* source() = 0;
|
||||
void LoadNextPacket();
|
||||
|
||||
rtc::Optional<int64_t> next_output_event_ms_;
|
||||
absl::optional<int64_t> next_output_event_ms_;
|
||||
|
||||
private:
|
||||
std::unique_ptr<Packet> packet_;
|
||||
@ -51,7 +51,7 @@ class NetEqRtpDumpInput final : public NetEqPacketSourceInput {
|
||||
NetEqRtpDumpInput(const std::string& file_name,
|
||||
const RtpHeaderExtensionMap& hdr_ext_map);
|
||||
|
||||
rtc::Optional<int64_t> NextOutputEventTime() const override;
|
||||
absl::optional<int64_t> NextOutputEventTime() const override;
|
||||
void AdvanceOutputEvent() override;
|
||||
|
||||
protected:
|
||||
@ -70,7 +70,7 @@ class NetEqEventLogInput final : public NetEqPacketSourceInput {
|
||||
NetEqEventLogInput(const std::string& file_name,
|
||||
const RtpHeaderExtensionMap& hdr_ext_map);
|
||||
|
||||
rtc::Optional<int64_t> NextOutputEventTime() const override;
|
||||
absl::optional<int64_t> NextOutputEventTime() const override;
|
||||
void AdvanceOutputEvent() override;
|
||||
|
||||
protected:
|
||||
|
||||
@ -31,13 +31,13 @@ NetEqReplacementInput::NetEqReplacementInput(
|
||||
RTC_CHECK(packet_);
|
||||
}
|
||||
|
||||
rtc::Optional<int64_t> NetEqReplacementInput::NextPacketTime() const {
|
||||
absl::optional<int64_t> NetEqReplacementInput::NextPacketTime() const {
|
||||
return packet_
|
||||
? rtc::Optional<int64_t>(static_cast<int64_t>(packet_->time_ms))
|
||||
: rtc::nullopt;
|
||||
? absl::optional<int64_t>(static_cast<int64_t>(packet_->time_ms))
|
||||
: absl::nullopt;
|
||||
}
|
||||
|
||||
rtc::Optional<int64_t> NetEqReplacementInput::NextOutputEventTime() const {
|
||||
absl::optional<int64_t> NetEqReplacementInput::NextOutputEventTime() const {
|
||||
return source_->NextOutputEventTime();
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ bool NetEqReplacementInput::ended() const {
|
||||
return source_->ended();
|
||||
}
|
||||
|
||||
rtc::Optional<RTPHeader> NetEqReplacementInput::NextHeader() const {
|
||||
absl::optional<RTPHeader> NetEqReplacementInput::NextHeader() const {
|
||||
return source_->NextHeader();
|
||||
}
|
||||
|
||||
@ -82,7 +82,7 @@ void NetEqReplacementInput::ReplacePacket() {
|
||||
return;
|
||||
}
|
||||
|
||||
rtc::Optional<RTPHeader> next_hdr = source_->NextHeader();
|
||||
absl::optional<RTPHeader> next_hdr = source_->NextHeader();
|
||||
RTC_DCHECK(next_hdr);
|
||||
uint8_t payload[12];
|
||||
RTC_DCHECK_LE(last_frame_size_timestamps_, 120 * 48);
|
||||
|
||||
@ -28,12 +28,12 @@ class NetEqReplacementInput : public NetEqInput {
|
||||
const std::set<uint8_t>& comfort_noise_types,
|
||||
const std::set<uint8_t>& forbidden_types);
|
||||
|
||||
rtc::Optional<int64_t> NextPacketTime() const override;
|
||||
rtc::Optional<int64_t> NextOutputEventTime() const override;
|
||||
absl::optional<int64_t> NextPacketTime() const override;
|
||||
absl::optional<int64_t> NextOutputEventTime() const override;
|
||||
std::unique_ptr<PacketData> PopPacket() override;
|
||||
void AdvanceOutputEvent() override;
|
||||
bool ended() const override;
|
||||
rtc::Optional<RTPHeader> NextHeader() const override;
|
||||
absl::optional<RTPHeader> NextHeader() const override;
|
||||
|
||||
private:
|
||||
void ReplacePacket();
|
||||
|
||||
@ -206,7 +206,7 @@ void PrintCodecMapping() {
|
||||
PrintCodecMappingEntry(NetEqDecoder::kDecoderCNGswb48kHz, FLAG_cn_swb48);
|
||||
}
|
||||
|
||||
rtc::Optional<int> CodecSampleRate(uint8_t payload_type) {
|
||||
absl::optional<int> CodecSampleRate(uint8_t payload_type) {
|
||||
if (payload_type == FLAG_pcmu || payload_type == FLAG_pcma ||
|
||||
payload_type == FLAG_ilbc || payload_type == FLAG_pcm16b ||
|
||||
payload_type == FLAG_cn_nb || payload_type == FLAG_avt)
|
||||
@ -223,7 +223,7 @@ rtc::Optional<int> CodecSampleRate(uint8_t payload_type) {
|
||||
return 48000;
|
||||
if (payload_type == FLAG_red)
|
||||
return 0;
|
||||
return rtc::nullopt;
|
||||
return absl::nullopt;
|
||||
}
|
||||
|
||||
// A callback class which prints whenver the inserted packet stream changes
|
||||
@ -253,7 +253,7 @@ class SsrcSwitchDetector : public NetEqPostInsertPacket {
|
||||
|
||||
private:
|
||||
NetEqPostInsertPacket* other_callback_;
|
||||
rtc::Optional<uint32_t> last_ssrc_;
|
||||
absl::optional<uint32_t> last_ssrc_;
|
||||
};
|
||||
|
||||
int RunTest(int argc, char* argv[]) {
|
||||
@ -340,9 +340,9 @@ int RunTest(int argc, char* argv[]) {
|
||||
}
|
||||
|
||||
// Check the sample rate.
|
||||
rtc::Optional<int> sample_rate_hz;
|
||||
absl::optional<int> sample_rate_hz;
|
||||
std::set<std::pair<int, uint32_t>> discarded_pt_and_ssrc;
|
||||
while (rtc::Optional<RTPHeader> first_rtp_header = input->NextHeader()) {
|
||||
while (absl::optional<RTPHeader> first_rtp_header = input->NextHeader()) {
|
||||
RTC_DCHECK(first_rtp_header);
|
||||
sample_rate_hz = CodecSampleRate(first_rtp_header->payloadType);
|
||||
if (sample_rate_hz) {
|
||||
|
||||
@ -16,8 +16,8 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/audio/audio_frame.h"
|
||||
#include "api/optional.h"
|
||||
#include "typedefs.h" // NOLINT(build/include)
|
||||
|
||||
namespace webrtc {
|
||||
@ -67,7 +67,7 @@ class PCMFile {
|
||||
uint32_t timestamp_;
|
||||
bool read_stereo_;
|
||||
bool save_stereo_;
|
||||
rtc::Optional<int> num_10ms_blocks_to_read_;
|
||||
absl::optional<int> num_10ms_blocks_to_read_;
|
||||
int blocks_read_ = 0;
|
||||
};
|
||||
|
||||
|
||||
@ -217,7 +217,7 @@ class DelayTest {
|
||||
audio_frame.data(),
|
||||
audio_frame.samples_per_channel_ * audio_frame.num_channels_);
|
||||
received_ts = channel_a2b_->LastInTimestamp();
|
||||
rtc::Optional<uint32_t> playout_timestamp = acm_b_->PlayoutTimestamp();
|
||||
absl::optional<uint32_t> playout_timestamp = acm_b_->PlayoutTimestamp();
|
||||
ASSERT_TRUE(playout_timestamp);
|
||||
inst_delay_sec = static_cast<uint32_t>(received_ts - *playout_timestamp) /
|
||||
static_cast<double>(encoding_sample_rate_hz_);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user