Sync-packet insertion into NetEq4. This is related to r3883 & r4052 for NetEq 3.

BUG=
R=henrik.lundin@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/2099004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@4850 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
turaj@webrtc.org
2013-09-26 00:27:56 +00:00
parent 6b1e21924a
commit 7b75ac6756
7 changed files with 365 additions and 39 deletions

View File

@ -25,32 +25,49 @@ struct Packet {
int payload_length;
bool primary; // Primary, i.e., not redundant payload.
int waiting_time;
bool sync_packet;
// Constructor.
Packet()
: payload(NULL),
payload_length(0),
primary(true),
waiting_time(0) {
waiting_time(0),
sync_packet(false) {
}
// Comparison operators. Establish a packet ordering based on (1) timestamp,
// (2) sequence number, and (3) redundancy. Timestamp and sequence numbers
// are compared taking wrap-around into account. If both timestamp and
// sequence numbers are identical, a primary payload is considered "smaller"
// than a secondary.
// (2) sequence number, (3) regular packet vs sync-packet and (4) redundancy.
// Timestamp and sequence numbers are compared taking wrap-around into
// account. If both timestamp and sequence numbers are identical and one of
// the packets is sync-packet, the regular packet is considered earlier. For
// two regular packets with the same sequence number and timestamp a primary
// payload is considered "smaller" than a secondary.
bool operator==(const Packet& rhs) const {
return (this->header.timestamp == rhs.header.timestamp &&
this->header.sequenceNumber == rhs.header.sequenceNumber &&
this->primary == rhs.primary);
this->primary == rhs.primary &&
this->sync_packet == rhs.sync_packet);
}
bool operator!=(const Packet& rhs) const { return !operator==(rhs); }
bool operator<(const Packet& rhs) const {
if (this->header.timestamp == rhs.header.timestamp) {
if (this->header.sequenceNumber == rhs.header.sequenceNumber) {
// Timestamp and sequence numbers are identical. Deem left hand side
// to be "smaller" (i.e., "earlier") if it is primary, and right hand
// side is not.
// Timestamp and sequence numbers are identical. A sync packet should
// be recognized "larger" (i.e. "later") compared to a "network packet"
// (regular packet from network not sync-packet). If none of the packets
// are sync-packets, then deem the left hand side to be "smaller"
// (i.e., "earlier") if it is primary, and right hand side is not.
//
// The condition on sync packets to be larger than "network packets,"
// given same RTP sequence number and timestamp, guarantees that a
// "network packet" to be inserted in an earlier position into
// |packet_buffer_| compared to a sync packet of same timestamp and
// sequence number.
if (rhs.sync_packet)
return true;
if (this->sync_packet)
return false;
return (this->primary && !rhs.primary);
}
return (static_cast<uint16_t>(rhs.header.sequenceNumber