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}
diff --git a/modules/audio_coding/neteq/neteq_impl.cc b/modules/audio_coding/neteq/neteq_impl.cc
index 089f6ca..14f2fc7 100644
--- a/modules/audio_coding/neteq/neteq_impl.cc
+++ b/modules/audio_coding/neteq/neteq_impl.cc
@@ -423,10 +423,9 @@
// 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 @@
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 @@
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 @@
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 @@
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();