summaryrefslogtreecommitdiff
path: root/modules/audio_coding/neteq/packet_buffer.h
diff options
context:
space:
mode:
authorTorne (Richard Coles) <torne@google.com>2014-11-06 11:12:39 +0000
committerTorne (Richard Coles) <torne@google.com>2014-11-06 11:12:39 +0000
commit77155b05052120107f7496d7c424ee24e6420550 (patch)
tree5013368c038081fc9d542ad65efe3ec381540eb2 /modules/audio_coding/neteq/packet_buffer.h
parent401138990c86cc095df3bac0acaf3951b393e32e (diff)
parentb44eb8f9b54e77b4ac5c426ea947f72a6ad74aad (diff)
downloadwebrtc-77155b05052120107f7496d7c424ee24e6420550.tar.gz
Merge from Chromium at DEPS revision db3f05efe0f9
This commit was generated by merge_to_master.py. Change-Id: Ibb07e7633f0f96e925c9bd5cdcb91747ad656b6e
Diffstat (limited to 'modules/audio_coding/neteq/packet_buffer.h')
-rw-r--r--modules/audio_coding/neteq/packet_buffer.h28
1 files changed, 26 insertions, 2 deletions
diff --git a/modules/audio_coding/neteq/packet_buffer.h b/modules/audio_coding/neteq/packet_buffer.h
index 76c4ddd1..b9a16189 100644
--- a/modules/audio_coding/neteq/packet_buffer.h
+++ b/modules/audio_coding/neteq/packet_buffer.h
@@ -95,9 +95,19 @@ class PacketBuffer {
// PacketBuffer::kOK otherwise.
virtual int DiscardNextPacket();
- // Discards all packets that are (strictly) older than |timestamp_limit|.
+ // Discards all packets that are (strictly) older than timestamp_limit,
+ // but newer than timestamp_limit - horizon_samples. Setting horizon_samples
+ // to zero implies that the horizon is set to half the timestamp range. That
+ // is, if a packet is more than 2^31 timestamps into the future compared with
+ // timestamp_limit (including wrap-around), it is considered old.
// Returns number of packets discarded.
- virtual int DiscardOldPackets(uint32_t timestamp_limit);
+ virtual int DiscardOldPackets(uint32_t timestamp_limit,
+ uint32_t horizon_samples);
+
+ // Discards all packets that are (strictly) older than timestamp_limit.
+ virtual int DiscardAllOldPackets(uint32_t timestamp_limit) {
+ return DiscardOldPackets(timestamp_limit, 0);
+ }
// Returns the number of packets in the buffer, including duplicates and
// redundant packets.
@@ -125,6 +135,20 @@ class PacketBuffer {
// in |packet_list|.
static void DeleteAllPackets(PacketList* packet_list);
+ // Static method returning true if |timestamp| is older than |timestamp_limit|
+ // but less than |horizon_samples| behind |timestamp_limit|. For instance,
+ // with timestamp_limit = 100 and horizon_samples = 10, a timestamp in the
+ // range (90, 100) is considered obsolete, and will yield true.
+ // Setting |horizon_samples| to 0 is the same as setting it to 2^31, i.e.,
+ // half the 32-bit timestamp range.
+ static bool IsObsoleteTimestamp(uint32_t timestamp,
+ uint32_t timestamp_limit,
+ uint32_t horizon_samples) {
+ return IsNewerTimestamp(timestamp_limit, timestamp) &&
+ (horizon_samples == 0 ||
+ IsNewerTimestamp(timestamp, timestamp_limit - horizon_samples));
+ }
+
private:
size_t max_number_of_packets_;
PacketList buffer_;