
This changes the following module directories: * webrtc/modules/audio_conference_mixer/interface * webrtc/modules/interface * webrtc/modules/media_file/interface * webrtc/modules/rtp_rtcp/interface * webrtc/modules/utility/interface To avoid breaking downstream, I followed this recipe: 1. Copy the interface dir to a new sibling directory: include 2. Update the header guards in the include directory to match the style guide. 3. Update the header guards in the interface directory to match the ones in include. This is required to avoid getting redefinitions in the not-yet-updated downstream code. 4. Add a pragma warning in the header files in the interface dir. Example: #pragma message("WARNING: webrtc/modules/interface is DEPRECATED; " "use webrtc/modules/include") 5. Search for all source references to webrtc/modules/interface and update them to webrtc/modules/include (*.c*,*.h,*.mm,*.S) 6. Update all GYP+GN files. This required manual inspection since many subdirectories of webrtc/modules referenced the interface dir using ../interface etc(*.gyp*,*.gn*) BUG=5095 TESTED=Passing compile-trybots with --clobber flag: git cl try --clobber --bot=win_compile_rel --bot=linux_compile_rel --bot=android_compile_rel --bot=mac_compile_rel --bot=ios_rel -m tryserver.webrtc R=stefan@webrtc.org, tommi@webrtc.org Review URL: https://codereview.webrtc.org/1417683006 . Cr-Commit-Position: refs/heads/master@{#10500}
89 lines
3.5 KiB
C++
89 lines
3.5 KiB
C++
/*
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license
|
|
* that can be found in the LICENSE file in the root of the source
|
|
* tree. An additional intellectual property rights grant can be found
|
|
* in the file PATENTS. All contributing project authors may
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
|
|
#ifndef WEBRTC_MODULES_AUDIO_CODING_NETEQ_PACKET_H_
|
|
#define WEBRTC_MODULES_AUDIO_CODING_NETEQ_PACKET_H_
|
|
|
|
#include <list>
|
|
|
|
#include "webrtc/modules/include/module_common_types.h"
|
|
#include "webrtc/typedefs.h"
|
|
|
|
namespace webrtc {
|
|
|
|
// Struct for holding RTP packets.
|
|
struct Packet {
|
|
RTPHeader header;
|
|
uint8_t* payload; // Datagram excluding RTP header and header extension.
|
|
size_t 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),
|
|
sync_packet(false) {
|
|
}
|
|
|
|
// Comparison operators. Establish a packet ordering based on (1) timestamp,
|
|
// (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->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. 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
|
|
- this->header.sequenceNumber) < 0xFFFF / 2);
|
|
}
|
|
return (static_cast<uint32_t>(rhs.header.timestamp
|
|
- this->header.timestamp) < 0xFFFFFFFF / 2);
|
|
}
|
|
bool operator>(const Packet& rhs) const { return rhs.operator<(*this); }
|
|
bool operator<=(const Packet& rhs) const { return !operator>(rhs); }
|
|
bool operator>=(const Packet& rhs) const { return !operator<(rhs); }
|
|
};
|
|
|
|
// A list of packets.
|
|
typedef std::list<Packet*> PacketList;
|
|
|
|
} // namespace webrtc
|
|
#endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_PACKET_H_
|