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:
Danil Chapovalov
2018-06-19 13:26:36 +02:00
committed by Commit Bot
parent bbfcc703ad
commit b602123a5a
82 changed files with 452 additions and 459 deletions

View File

@ -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,

View File

@ -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);

View File

@ -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;
}
}

View File

@ -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);
};

View File

@ -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"));

View File

@ -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_);

View File

@ -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;

View File

@ -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.

View File

@ -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,

View File

@ -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,

View File

@ -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;
}
}

View File

@ -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

View File

@ -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();

View File

@ -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_);

View File

@ -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;

View File

@ -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;
}
}

View File

@ -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);

View File

@ -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();

View File

@ -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,

View File

@ -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, &current_pt,
&current_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, &current_pt,
&current_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, &current_pt,
&current_cng_pt, &mock_stats));

View File

@ -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");

View File

@ -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));

View File

@ -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;
}

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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_;

View File

@ -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

View File

@ -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;
}
}

View File

@ -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:

View File

@ -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);

View File

@ -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();

View File

@ -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) {