Optional: Use nullopt and implicit construction in /modules/audio_coding
Changes places where we explicitly construct an Optional to instead use nullopt or the requisite value type only. This CL was uploaded by git cl split. R=kwiberg@webrtc.org Bug: None Change-Id: I055411a3e521964c81100869a197dd92f5608f1b Reviewed-on: https://webrtc-review.googlesource.com/23619 Commit-Queue: Oskar Sundbom <ossu@webrtc.org> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Reviewed-by: Elad Alon <eladalon@webrtc.org> Cr-Commit-Position: refs/heads/master@{#20728}
This commit is contained in:
committed by
Commit Bot
parent
f715c53bca
commit
12ab00b4d8
@ -462,7 +462,7 @@ TEST_F(AudioDecoderPcmUTest, EncodeDecode) {
|
||||
|
||||
namespace {
|
||||
int SetAndGetTargetBitrate(AudioEncoder* audio_encoder, int rate) {
|
||||
audio_encoder->OnReceivedUplinkBandwidth(rate, rtc::Optional<int64_t>());
|
||||
audio_encoder->OnReceivedUplinkBandwidth(rate, rtc::nullopt);
|
||||
return audio_encoder->GetTargetBitrate();
|
||||
}
|
||||
void TestSetAndGetTargetBitratesWithFixedCodec(AudioEncoder* audio_encoder,
|
||||
|
||||
@ -104,10 +104,9 @@ DecoderDatabase::DecoderInfo::CngDecoder::Create(const SdpAudioFormat& format) {
|
||||
const int sample_rate_hz = format.clockrate_hz;
|
||||
RTC_DCHECK(sample_rate_hz == 8000 || sample_rate_hz == 16000 ||
|
||||
sample_rate_hz == 32000 || sample_rate_hz == 48000);
|
||||
return rtc::Optional<DecoderDatabase::DecoderInfo::CngDecoder>(
|
||||
{sample_rate_hz});
|
||||
return DecoderDatabase::DecoderInfo::CngDecoder{sample_rate_hz};
|
||||
} else {
|
||||
return rtc::Optional<CngDecoder>();
|
||||
return rtc::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -18,71 +18,67 @@ namespace webrtc {
|
||||
rtc::Optional<SdpAudioFormat> NetEqDecoderToSdpAudioFormat(NetEqDecoder nd) {
|
||||
switch (nd) {
|
||||
case NetEqDecoder::kDecoderPCMu:
|
||||
return rtc::Optional<SdpAudioFormat>(SdpAudioFormat("pcmu", 8000, 1));
|
||||
return SdpAudioFormat("pcmu", 8000, 1);
|
||||
case NetEqDecoder::kDecoderPCMa:
|
||||
return rtc::Optional<SdpAudioFormat>(SdpAudioFormat("pcma", 8000, 1));
|
||||
return SdpAudioFormat("pcma", 8000, 1);
|
||||
case NetEqDecoder::kDecoderPCMu_2ch:
|
||||
return rtc::Optional<SdpAudioFormat>(SdpAudioFormat("pcmu", 8000, 2));
|
||||
return SdpAudioFormat("pcmu", 8000, 2);
|
||||
case NetEqDecoder::kDecoderPCMa_2ch:
|
||||
return rtc::Optional<SdpAudioFormat>(SdpAudioFormat("pcma", 8000, 2));
|
||||
return SdpAudioFormat("pcma", 8000, 2);
|
||||
case NetEqDecoder::kDecoderILBC:
|
||||
return rtc::Optional<SdpAudioFormat>(SdpAudioFormat("ilbc", 8000, 1));
|
||||
return SdpAudioFormat("ilbc", 8000, 1);
|
||||
case NetEqDecoder::kDecoderISAC:
|
||||
return rtc::Optional<SdpAudioFormat>(SdpAudioFormat("isac", 16000, 1));
|
||||
return SdpAudioFormat("isac", 16000, 1);
|
||||
case NetEqDecoder::kDecoderISACswb:
|
||||
return rtc::Optional<SdpAudioFormat>(SdpAudioFormat("isac", 32000, 1));
|
||||
return SdpAudioFormat("isac", 32000, 1);
|
||||
case NetEqDecoder::kDecoderPCM16B:
|
||||
return rtc::Optional<SdpAudioFormat>(SdpAudioFormat("l16", 8000, 1));
|
||||
return SdpAudioFormat("l16", 8000, 1);
|
||||
case NetEqDecoder::kDecoderPCM16Bwb:
|
||||
return rtc::Optional<SdpAudioFormat>(SdpAudioFormat("l16", 16000, 1));
|
||||
return SdpAudioFormat("l16", 16000, 1);
|
||||
case NetEqDecoder::kDecoderPCM16Bswb32kHz:
|
||||
return rtc::Optional<SdpAudioFormat>(SdpAudioFormat("l16", 32000, 1));
|
||||
return SdpAudioFormat("l16", 32000, 1);
|
||||
case NetEqDecoder::kDecoderPCM16Bswb48kHz:
|
||||
return rtc::Optional<SdpAudioFormat>(SdpAudioFormat("l16", 48000, 1));
|
||||
return SdpAudioFormat("l16", 48000, 1);
|
||||
case NetEqDecoder::kDecoderPCM16B_2ch:
|
||||
return rtc::Optional<SdpAudioFormat>(SdpAudioFormat("l16", 8000, 2));
|
||||
return SdpAudioFormat("l16", 8000, 2);
|
||||
case NetEqDecoder::kDecoderPCM16Bwb_2ch:
|
||||
return rtc::Optional<SdpAudioFormat>(SdpAudioFormat("l16", 16000, 2));
|
||||
return SdpAudioFormat("l16", 16000, 2);
|
||||
case NetEqDecoder::kDecoderPCM16Bswb32kHz_2ch:
|
||||
return rtc::Optional<SdpAudioFormat>(SdpAudioFormat("l16", 32000, 2));
|
||||
return SdpAudioFormat("l16", 32000, 2);
|
||||
case NetEqDecoder::kDecoderPCM16Bswb48kHz_2ch:
|
||||
return rtc::Optional<SdpAudioFormat>(SdpAudioFormat("l16", 48000, 2));
|
||||
return SdpAudioFormat("l16", 48000, 2);
|
||||
case NetEqDecoder::kDecoderPCM16B_5ch:
|
||||
return rtc::Optional<SdpAudioFormat>(SdpAudioFormat("l16", 8000, 5));
|
||||
return SdpAudioFormat("l16", 8000, 5);
|
||||
case NetEqDecoder::kDecoderG722:
|
||||
return rtc::Optional<SdpAudioFormat>(SdpAudioFormat("g722", 8000, 1));
|
||||
return SdpAudioFormat("g722", 8000, 1);
|
||||
case NetEqDecoder::kDecoderG722_2ch:
|
||||
return rtc::Optional<SdpAudioFormat>(SdpAudioFormat("g722", 8000, 2));
|
||||
return SdpAudioFormat("g722", 8000, 2);
|
||||
case NetEqDecoder::kDecoderOpus:
|
||||
return rtc::Optional<SdpAudioFormat>(SdpAudioFormat("opus", 48000, 2));
|
||||
return SdpAudioFormat("opus", 48000, 2);
|
||||
case NetEqDecoder::kDecoderOpus_2ch:
|
||||
return rtc::Optional<SdpAudioFormat>(
|
||||
SdpAudioFormat("opus", 48000, 2,
|
||||
std::map<std::string, std::string>{{"stereo", "1"}}));
|
||||
return SdpAudioFormat(
|
||||
"opus", 48000, 2,
|
||||
std::map<std::string, std::string>{{"stereo", "1"}});
|
||||
case NetEqDecoder::kDecoderRED:
|
||||
return rtc::Optional<SdpAudioFormat>(SdpAudioFormat("red", 8000, 1));
|
||||
return SdpAudioFormat("red", 8000, 1);
|
||||
case NetEqDecoder::kDecoderAVT:
|
||||
return rtc::Optional<SdpAudioFormat>(
|
||||
SdpAudioFormat("telephone-event", 8000, 1));
|
||||
return SdpAudioFormat("telephone-event", 8000, 1);
|
||||
case NetEqDecoder::kDecoderAVT16kHz:
|
||||
return rtc::Optional<SdpAudioFormat>(
|
||||
SdpAudioFormat("telephone-event", 16000, 1));
|
||||
return SdpAudioFormat("telephone-event", 16000, 1);
|
||||
case NetEqDecoder::kDecoderAVT32kHz:
|
||||
return rtc::Optional<SdpAudioFormat>(
|
||||
SdpAudioFormat("telephone-event", 32000, 1));
|
||||
return SdpAudioFormat("telephone-event", 32000, 1);
|
||||
case NetEqDecoder::kDecoderAVT48kHz:
|
||||
return rtc::Optional<SdpAudioFormat>(
|
||||
SdpAudioFormat("telephone-event", 48000, 1));
|
||||
return SdpAudioFormat("telephone-event", 48000, 1);
|
||||
case NetEqDecoder::kDecoderCNGnb:
|
||||
return rtc::Optional<SdpAudioFormat>(SdpAudioFormat("cn", 8000, 1));
|
||||
return SdpAudioFormat("cn", 8000, 1);
|
||||
case NetEqDecoder::kDecoderCNGwb:
|
||||
return rtc::Optional<SdpAudioFormat>(SdpAudioFormat("cn", 16000, 1));
|
||||
return SdpAudioFormat("cn", 16000, 1);
|
||||
case NetEqDecoder::kDecoderCNGswb32kHz:
|
||||
return rtc::Optional<SdpAudioFormat>(SdpAudioFormat("cn", 32000, 1));
|
||||
return SdpAudioFormat("cn", 32000, 1);
|
||||
case NetEqDecoder::kDecoderCNGswb48kHz:
|
||||
return rtc::Optional<SdpAudioFormat>(SdpAudioFormat("cn", 48000, 1));
|
||||
return SdpAudioFormat("cn", 48000, 1);
|
||||
default:
|
||||
return rtc::Optional<SdpAudioFormat>();
|
||||
return rtc::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -423,10 +423,9 @@ rtc::Optional<uint32_t> NetEqImpl::GetPlayoutTimestamp() const {
|
||||
// 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::Optional<uint32_t>();
|
||||
return rtc::nullopt;
|
||||
}
|
||||
return rtc::Optional<uint32_t>(
|
||||
timestamp_scaler_->ToExternal(playout_timestamp_));
|
||||
return timestamp_scaler_->ToExternal(playout_timestamp_);
|
||||
}
|
||||
|
||||
int NetEqImpl::last_output_sample_rate_hz() const {
|
||||
@ -439,7 +438,7 @@ rtc::Optional<CodecInst> NetEqImpl::GetDecoder(int payload_type) const {
|
||||
const DecoderDatabase::DecoderInfo* di =
|
||||
decoder_database_->GetDecoderInfo(payload_type);
|
||||
if (!di) {
|
||||
return rtc::Optional<CodecInst>();
|
||||
return rtc::nullopt;
|
||||
}
|
||||
|
||||
// Create a CodecInst with some fields set. The remaining fields are zeroed,
|
||||
@ -452,7 +451,7 @@ rtc::Optional<CodecInst> NetEqImpl::GetDecoder(int payload_type) const {
|
||||
ci.plfreq = di->IsRed() ? 8000 : di->SampleRateHz();
|
||||
AudioDecoder* const decoder = di->GetDecoder();
|
||||
ci.channels = decoder ? decoder->Channels() : 1;
|
||||
return rtc::Optional<CodecInst>(ci);
|
||||
return ci;
|
||||
}
|
||||
|
||||
rtc::Optional<SdpAudioFormat> NetEqImpl::GetDecoderFormat(
|
||||
@ -461,9 +460,9 @@ rtc::Optional<SdpAudioFormat> NetEqImpl::GetDecoderFormat(
|
||||
const DecoderDatabase::DecoderInfo* const di =
|
||||
decoder_database_->GetDecoderInfo(payload_type);
|
||||
if (!di) {
|
||||
return rtc::Optional<SdpAudioFormat>(); // Payload type not registered.
|
||||
return rtc::nullopt; // Payload type not registered.
|
||||
}
|
||||
return rtc::Optional<SdpAudioFormat>(di->GetFormat());
|
||||
return di->GetFormat();
|
||||
}
|
||||
|
||||
int NetEqImpl::SetTargetNumberOfChannels() {
|
||||
@ -2004,7 +2003,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::Optional<Packet>(); // Ensure it's never used after the move.
|
||||
packet = rtc::nullopt; // Ensure it's never used after the move.
|
||||
|
||||
// Check what packet is available next.
|
||||
next_packet = packet_buffer_->PeekNextPacket();
|
||||
|
||||
@ -348,9 +348,8 @@ TEST_F(NetEqImplTest, InsertPacket) {
|
||||
.Times(1);
|
||||
EXPECT_CALL(*mock_packet_buffer_, InsertPacketList(_, _, _, _, _))
|
||||
.Times(2)
|
||||
.WillRepeatedly(
|
||||
DoAll(SetArgPointee<2>(rtc::Optional<uint8_t>(kPayloadType)),
|
||||
WithArg<0>(Invoke(DeletePacketsAndReturnOk))));
|
||||
.WillRepeatedly(DoAll(SetArgPointee<2>(kPayloadType),
|
||||
WithArg<0>(Invoke(DeletePacketsAndReturnOk))));
|
||||
// SetArgPointee<2>(kPayloadType) means that the third argument (zero-based
|
||||
// index) is a pointer, and the variable pointed to is set to kPayloadType.
|
||||
// Also invoke the function DeletePacketsAndReturnOk to properly delete all
|
||||
|
||||
@ -53,12 +53,11 @@ class MockAudioDecoder final : public AudioDecoder {
|
||||
if (decoded.size() >= output_size) {
|
||||
memset(decoded.data(), 0,
|
||||
sizeof(int16_t) * kPacketDuration * num_channels_);
|
||||
return rtc::Optional<DecodeResult>(
|
||||
{kPacketDuration * num_channels_, kSpeech});
|
||||
return DecodeResult{kPacketDuration * num_channels_, kSpeech};
|
||||
} else {
|
||||
ADD_FAILURE() << "Expected decoded.size() to be >= output_size ("
|
||||
<< decoded.size() << " vs. " << output_size << ")";
|
||||
return rtc::Optional<DecodeResult>();
|
||||
return rtc::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -139,12 +139,11 @@ 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::Optional<uint8_t>();
|
||||
*current_rtp_payload_type = rtc::nullopt;
|
||||
Flush();
|
||||
flushed = true;
|
||||
}
|
||||
*current_cng_rtp_payload_type =
|
||||
rtc::Optional<uint8_t>(packet.payload_type);
|
||||
*current_cng_rtp_payload_type = packet.payload_type;
|
||||
} else if (!decoder_database.IsDtmf(packet.payload_type)) {
|
||||
// This must be speech.
|
||||
if ((*current_rtp_payload_type &&
|
||||
@ -153,11 +152,11 @@ int PacketBuffer::InsertPacketList(
|
||||
!EqualSampleRates(packet.payload_type,
|
||||
**current_cng_rtp_payload_type,
|
||||
decoder_database))) {
|
||||
*current_cng_rtp_payload_type = rtc::Optional<uint8_t>();
|
||||
*current_cng_rtp_payload_type = rtc::nullopt;
|
||||
Flush();
|
||||
flushed = true;
|
||||
}
|
||||
*current_rtp_payload_type = rtc::Optional<uint8_t>(packet.payload_type);
|
||||
*current_rtp_payload_type = packet.payload_type;
|
||||
}
|
||||
int return_val = InsertPacket(std::move(packet), stats);
|
||||
if (return_val == kFlushed) {
|
||||
@ -210,7 +209,7 @@ const Packet* PacketBuffer::PeekNextPacket() const {
|
||||
rtc::Optional<Packet> PacketBuffer::GetNextPacket() {
|
||||
if (Empty()) {
|
||||
// Buffer is empty.
|
||||
return rtc::Optional<Packet>();
|
||||
return rtc::nullopt;
|
||||
}
|
||||
|
||||
rtc::Optional<Packet> packet(std::move(buffer_.front()));
|
||||
|
||||
@ -188,9 +188,8 @@ TEST(PacketBuffer, InsertPacketList) {
|
||||
¤t_cng_pt, &mock_stats));
|
||||
EXPECT_TRUE(list.empty()); // The PacketBuffer should have depleted the list.
|
||||
EXPECT_EQ(10u, buffer.NumPacketsInBuffer());
|
||||
EXPECT_EQ(rtc::Optional<uint8_t>(0),
|
||||
current_pt); // Current payload type changed to 0.
|
||||
EXPECT_FALSE(current_cng_pt); // CNG payload type not changed.
|
||||
EXPECT_EQ(0, current_pt); // Current payload type changed to 0.
|
||||
EXPECT_EQ(rtc::nullopt, current_cng_pt); // CNG payload type not changed.
|
||||
|
||||
buffer.Flush(); // Clean up.
|
||||
|
||||
@ -236,9 +235,8 @@ TEST(PacketBuffer, InsertPacketListChangePayloadType) {
|
||||
¤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(rtc::Optional<uint8_t>(1),
|
||||
current_pt); // Current payload type changed to 1.
|
||||
EXPECT_FALSE(current_cng_pt); // CNG payload type not changed.
|
||||
EXPECT_EQ(1, current_pt); // Current payload type changed to 1.
|
||||
EXPECT_EQ(rtc::nullopt, current_cng_pt); // CNG payload type not changed.
|
||||
|
||||
buffer.Flush(); // Clean up.
|
||||
|
||||
@ -470,9 +468,8 @@ TEST(PacketBuffer, CngFirstThenSpeechWithNewSampleRate) {
|
||||
EXPECT_EQ(1u, buffer.NumPacketsInBuffer());
|
||||
ASSERT_TRUE(buffer.PeekNextPacket());
|
||||
EXPECT_EQ(kCngPt, buffer.PeekNextPacket()->payload_type);
|
||||
EXPECT_FALSE(current_pt); // Current payload type not set.
|
||||
EXPECT_EQ(rtc::Optional<uint8_t>(kCngPt),
|
||||
current_cng_pt); // CNG payload type set.
|
||||
EXPECT_EQ(current_pt, rtc::nullopt); // Current payload type not set.
|
||||
EXPECT_EQ(kCngPt, current_cng_pt); // CNG payload type set.
|
||||
|
||||
// Insert second packet, which is wide-band speech.
|
||||
{
|
||||
@ -490,9 +487,8 @@ TEST(PacketBuffer, CngFirstThenSpeechWithNewSampleRate) {
|
||||
ASSERT_TRUE(buffer.PeekNextPacket());
|
||||
EXPECT_EQ(kSpeechPt, buffer.PeekNextPacket()->payload_type);
|
||||
|
||||
EXPECT_EQ(rtc::Optional<uint8_t>(kSpeechPt),
|
||||
current_pt); // Current payload type set.
|
||||
EXPECT_FALSE(current_cng_pt); // CNG payload type reset.
|
||||
EXPECT_EQ(kSpeechPt, current_pt); // Current payload type set.
|
||||
EXPECT_EQ(rtc::nullopt, current_cng_pt); // CNG payload type reset.
|
||||
|
||||
buffer.Flush(); // Clean up.
|
||||
EXPECT_CALL(decoder_database, Die()); // Called when object is deleted.
|
||||
|
||||
@ -29,11 +29,11 @@ EncodeNetEqInput::EncodeNetEqInput(std::unique_ptr<Generator> generator,
|
||||
|
||||
rtc::Optional<int64_t> EncodeNetEqInput::NextPacketTime() const {
|
||||
RTC_DCHECK(packet_data_);
|
||||
return rtc::Optional<int64_t>(static_cast<int64_t>(packet_data_->time_ms));
|
||||
return static_cast<int64_t>(packet_data_->time_ms);
|
||||
}
|
||||
|
||||
rtc::Optional<int64_t> EncodeNetEqInput::NextOutputEventTime() const {
|
||||
return rtc::Optional<int64_t>(next_output_event_ms_);
|
||||
return next_output_event_ms_;
|
||||
}
|
||||
|
||||
std::unique_ptr<NetEqInput::PacketData> EncodeNetEqInput::PopPacket() {
|
||||
@ -52,7 +52,7 @@ void EncodeNetEqInput::AdvanceOutputEvent() {
|
||||
|
||||
rtc::Optional<RTPHeader> EncodeNetEqInput::NextHeader() const {
|
||||
RTC_DCHECK(packet_data_);
|
||||
return rtc::Optional<RTPHeader>(packet_data_->header);
|
||||
return packet_data_->header;
|
||||
}
|
||||
|
||||
void EncodeNetEqInput::CreatePacket() {
|
||||
|
||||
@ -59,8 +59,7 @@ int FakeDecodeFromFile::DecodeInternal(const uint8_t* encoded,
|
||||
RTC_CHECK(input_->Seek(jump));
|
||||
}
|
||||
|
||||
next_timestamp_from_input_ =
|
||||
rtc::Optional<uint32_t>(timestamp_to_decode + samples_to_decode);
|
||||
next_timestamp_from_input_ = timestamp_to_decode + samples_to_decode;
|
||||
|
||||
uint32_t original_payload_size_bytes =
|
||||
ByteReader<uint32_t>::ReadLittleEndian(&encoded[8]);
|
||||
|
||||
@ -86,12 +86,11 @@ void NetEqDelayAnalyzer::AfterGetAudio(int64_t time_now_ms,
|
||||
auto& it_timing = it->second;
|
||||
RTC_CHECK(!it_timing.decode_get_audio_count)
|
||||
<< "Decode time already written";
|
||||
it_timing.decode_get_audio_count = rtc::Optional<int64_t>(get_audio_count_);
|
||||
it_timing.decode_get_audio_count = get_audio_count_;
|
||||
RTC_CHECK(!it_timing.sync_delay_ms) << "Decode time already written";
|
||||
it_timing.sync_delay_ms = rtc::Optional<int64_t>(last_sync_buffer_ms_);
|
||||
it_timing.target_delay_ms = rtc::Optional<int>(neteq->TargetDelayMs());
|
||||
it_timing.current_delay_ms =
|
||||
rtc::Optional<int>(neteq->FilteredCurrentDelayMs());
|
||||
it_timing.sync_delay_ms = last_sync_buffer_ms_;
|
||||
it_timing.target_delay_ms = neteq->TargetDelayMs();
|
||||
it_timing.current_delay_ms = neteq->FilteredCurrentDelayMs();
|
||||
}
|
||||
last_sample_rate_hz_ = audio_frame.sample_rate_hz_;
|
||||
++get_audio_count_;
|
||||
@ -159,16 +158,16 @@ void NetEqDelayAnalyzer::CreateGraphs(
|
||||
const float playout_ms = *timing.decode_get_audio_count * 10 +
|
||||
get_audio_time_ms_[0] + *timing.sync_delay_ms -
|
||||
offset_send_time_ms;
|
||||
playout_delay_ms->push_back(rtc::Optional<float>(playout_ms));
|
||||
playout_delay_ms->push_back(playout_ms);
|
||||
RTC_DCHECK(timing.target_delay_ms);
|
||||
RTC_DCHECK(timing.current_delay_ms);
|
||||
const float target =
|
||||
playout_ms - *timing.current_delay_ms + *timing.target_delay_ms;
|
||||
target_delay_ms->push_back(rtc::Optional<float>(target));
|
||||
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::Optional<float>());
|
||||
target_delay_ms->push_back(rtc::Optional<float>());
|
||||
playout_delay_ms->push_back(rtc::nullopt);
|
||||
target_delay_ms->push_back(rtc::nullopt);
|
||||
}
|
||||
}
|
||||
RTC_DCHECK(data_it == data_.end());
|
||||
|
||||
@ -52,9 +52,9 @@ class NetEqInput {
|
||||
const auto b = NextOutputEventTime();
|
||||
// Return the minimum of non-empty |a| and |b|, or empty if both are empty.
|
||||
if (a) {
|
||||
return b ? rtc::Optional<int64_t>(std::min(*a, *b)) : a;
|
||||
return b ? std::min(*a, *b) : a;
|
||||
}
|
||||
return b ? b : rtc::Optional<int64_t>();
|
||||
return b ? b : rtc::nullopt;
|
||||
}
|
||||
|
||||
// Returns the next packet to be inserted into NetEq. The packet following the
|
||||
|
||||
@ -25,12 +25,12 @@ NetEqPacketSourceInput::NetEqPacketSourceInput() : next_output_event_ms_(0) {}
|
||||
rtc::Optional<int64_t> NetEqPacketSourceInput::NextPacketTime() const {
|
||||
return packet_
|
||||
? rtc::Optional<int64_t>(static_cast<int64_t>(packet_->time_ms()))
|
||||
: rtc::Optional<int64_t>();
|
||||
: rtc::nullopt;
|
||||
}
|
||||
|
||||
rtc::Optional<RTPHeader> NetEqPacketSourceInput::NextHeader() const {
|
||||
return packet_ ? rtc::Optional<RTPHeader>(packet_->header())
|
||||
: rtc::Optional<RTPHeader>();
|
||||
: rtc::nullopt;
|
||||
}
|
||||
|
||||
void NetEqPacketSourceInput::LoadNextPacket() {
|
||||
@ -78,7 +78,7 @@ void NetEqRtpDumpInput::AdvanceOutputEvent() {
|
||||
*next_output_event_ms_ += kOutputPeriodMs;
|
||||
}
|
||||
if (!NextPacketTime()) {
|
||||
next_output_event_ms_ = rtc::Optional<int64_t>();
|
||||
next_output_event_ms_ = rtc::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
@ -97,14 +97,13 @@ NetEqEventLogInput::NetEqEventLogInput(const std::string& file_name,
|
||||
}
|
||||
|
||||
rtc::Optional<int64_t> NetEqEventLogInput::NextOutputEventTime() const {
|
||||
return rtc::Optional<int64_t>(next_output_event_ms_);
|
||||
return next_output_event_ms_;
|
||||
}
|
||||
|
||||
void NetEqEventLogInput::AdvanceOutputEvent() {
|
||||
next_output_event_ms_ =
|
||||
rtc::Optional<int64_t>(source_->NextAudioOutputEventMs());
|
||||
next_output_event_ms_ = source_->NextAudioOutputEventMs();
|
||||
if (*next_output_event_ms_ == std::numeric_limits<int64_t>::max()) {
|
||||
next_output_event_ms_ = rtc::Optional<int64_t>();
|
||||
next_output_event_ms_ = rtc::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -34,7 +34,7 @@ NetEqReplacementInput::NetEqReplacementInput(
|
||||
rtc::Optional<int64_t> NetEqReplacementInput::NextPacketTime() const {
|
||||
return packet_
|
||||
? rtc::Optional<int64_t>(static_cast<int64_t>(packet_->time_ms))
|
||||
: rtc::Optional<int64_t>();
|
||||
: rtc::nullopt;
|
||||
}
|
||||
|
||||
rtc::Optional<int64_t> NetEqReplacementInput::NextOutputEventTime() const {
|
||||
|
||||
@ -209,20 +209,20 @@ rtc::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)
|
||||
return rtc::Optional<int>(8000);
|
||||
return 8000;
|
||||
if (payload_type == FLAG_isac || payload_type == FLAG_pcm16b_wb ||
|
||||
payload_type == FLAG_g722 || payload_type == FLAG_cn_wb ||
|
||||
payload_type == FLAG_avt_16)
|
||||
return rtc::Optional<int>(16000);
|
||||
return 16000;
|
||||
if (payload_type == FLAG_isac_swb || payload_type == FLAG_pcm16b_swb32 ||
|
||||
payload_type == FLAG_cn_swb32 || payload_type == FLAG_avt_32)
|
||||
return rtc::Optional<int>(32000);
|
||||
return 32000;
|
||||
if (payload_type == FLAG_opus || payload_type == FLAG_pcm16b_swb48 ||
|
||||
payload_type == FLAG_cn_swb48 || payload_type == FLAG_avt_48)
|
||||
return rtc::Optional<int>(48000);
|
||||
return 48000;
|
||||
if (payload_type == FLAG_red)
|
||||
return rtc::Optional<int>(0);
|
||||
return rtc::Optional<int>();
|
||||
return 0;
|
||||
return rtc::nullopt;
|
||||
}
|
||||
|
||||
// Class to let through only the packets with a given SSRC. Should be used as an
|
||||
@ -294,7 +294,7 @@ class SsrcSwitchDetector : public NetEqPostInsertPacket {
|
||||
<< static_cast<int>(packet.header.payloadType) << ")"
|
||||
<< std::endl;
|
||||
}
|
||||
last_ssrc_ = rtc::Optional<uint32_t>(packet.header.ssrc);
|
||||
last_ssrc_ = packet.header.ssrc;
|
||||
if (other_callback_) {
|
||||
other_callback_->AfterInsertPacket(packet, neteq);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user