Moved Opus-specific payload splitting into AudioDecoderOpus.
The biggest change to NetEq is the move from a primary flag, to a
Priority with two separate levels: one set by RED splitting and one
set by the codec itself. This allows us to unambigously prioritize
"fallback" packets from these two sources. I've chosen what I believe
is the sensible ordering: packets that the codec prioritizes are
chosen first, regardless of if they are secondary RED packets or
not. So if we were to use Opus w/ FEC in RED, we'd only do Opus FEC
decoding if there was no RED packet that could cover the time slot.
With this change, PayloadSplitter now only deals with RED
packets. Maybe it should be renamed RedPayloadSplitter?
BUG=webrtc:5805
Review-Url: https://codereview.webrtc.org/2342443005
Cr-Commit-Position: refs/heads/master@{#14347}
diff --git a/webrtc/modules/audio_coding/neteq/packet_buffer.cc b/webrtc/modules/audio_coding/neteq/packet_buffer.cc
index c5b23dc..eeb1d27 100644
--- a/webrtc/modules/audio_coding/neteq/packet_buffer.cc
+++ b/webrtc/modules/audio_coding/neteq/packet_buffer.cc
@@ -76,6 +76,9 @@
return kInvalidPacket;
}
+ RTC_DCHECK_GE(packet->priority.codec_level, 0);
+ RTC_DCHECK_GE(packet->priority.red_level, 0);
+
int return_val = kOK;
packet->waiting_time = tick_timer_->GetNewStopwatch();
@@ -262,7 +265,7 @@
void PacketBuffer::DiscardPacketsWithPayloadType(uint8_t payload_type) {
for (auto it = buffer_.begin(); it != buffer_.end(); /* */) {
- Packet *packet = *it;
+ Packet* packet = *it;
if (packet->header.payloadType == payload_type) {
delete packet;
it = buffer_.erase(it);
@@ -281,7 +284,9 @@
size_t last_duration = last_decoded_length;
for (Packet* packet : buffer_) {
if (packet->frame) {
- if (!packet->primary) {
+ // TODO(hlundin): Verify that it's fine to count all packets and remove
+ // this check.
+ if (packet->priority != Packet::Priority(0, 0)) {
continue;
}
size_t duration = packet->frame->Duration();