NetEq: Change member variables for current RTP types to rtc::Optionals
With this change, the value 0xFF is no longer used to flag that the RTP
type is unknown. Instead, an empty value for the rtc::Optional is used.
Review-Url: https://codereview.webrtc.org/2290153002
Cr-Commit-Position: refs/heads/master@{#13989}
diff --git a/webrtc/modules/audio_coding/neteq/neteq_impl.cc b/webrtc/modules/audio_coding/neteq/neteq_impl.cc
index 78e3112..8c36dd9 100644
--- a/webrtc/modules/audio_coding/neteq/neteq_impl.cc
+++ b/webrtc/modules/audio_coding/neteq/neteq_impl.cc
@@ -95,8 +95,6 @@
new_codec_(false),
timestamp_(0),
reset_decoder_(false),
- current_rtp_payload_type_(0xFF), // Invalid RTP payload type.
- current_cng_rtp_payload_type_(0xFF), // Invalid RTP payload type.
ssrc_(0),
first_packet_(true),
error_code_(0),
@@ -537,10 +535,10 @@
<< static_cast<int>(rtp_header.header.payloadType);
return kSyncPacketNotAccepted;
}
- if (first_packet_ ||
- rtp_header.header.payloadType != current_rtp_payload_type_ ||
+ if (first_packet_ || !current_rtp_payload_type_ ||
+ rtp_header.header.payloadType != *current_rtp_payload_type_ ||
rtp_header.header.ssrc != ssrc_) {
- // Even if |current_rtp_payload_type_| is 0xFF, sync-packet isn't
+ // Even if |current_rtp_payload_type_| is empty, sync-packet isn't
// accepted.
LOG_F(LS_ERROR)
<< "Changing codec, SSRC or first packet with sync-packet.";
@@ -743,10 +741,11 @@
new_codec_ = true;
}
- RTC_DCHECK(current_rtp_payload_type_ == 0xFF ||
- decoder_database_->GetDecoderInfo(current_rtp_payload_type_))
- << "Payload type " << static_cast<int>(current_rtp_payload_type_)
- << " is unknown where it shouldn't be";
+ if (current_rtp_payload_type_) {
+ RTC_DCHECK(decoder_database_->GetDecoderInfo(*current_rtp_payload_type_))
+ << "Payload type " << static_cast<int>(*current_rtp_payload_type_)
+ << " is unknown where it shouldn't be";
+ }
if (update_sample_rate_and_channels && !packet_buffer_->Empty()) {
// We do not use |current_rtp_payload_type_| to |set payload_type|, but