Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(568)

Side by Side Diff: webrtc/modules/audio_coding/neteq/packet_buffer.h

Issue 1917913002: NetEq: Use TickTimer in PacketBuffer (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@add-tick-timer-to-neteq
Patch Set: Remove superfluous comment Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #ifndef WEBRTC_MODULES_AUDIO_CODING_NETEQ_PACKET_BUFFER_H_ 11 #ifndef WEBRTC_MODULES_AUDIO_CODING_NETEQ_PACKET_BUFFER_H_
12 #define WEBRTC_MODULES_AUDIO_CODING_NETEQ_PACKET_BUFFER_H_ 12 #define WEBRTC_MODULES_AUDIO_CODING_NETEQ_PACKET_BUFFER_H_
13 13
14 #include "webrtc/base/constructormagic.h" 14 #include "webrtc/base/constructormagic.h"
15 #include "webrtc/modules/audio_coding/neteq/packet.h" 15 #include "webrtc/modules/audio_coding/neteq/packet.h"
16 #include "webrtc/typedefs.h" 16 #include "webrtc/typedefs.h"
17 17
18 namespace webrtc { 18 namespace webrtc {
19 19
20 // Forward declaration.
21 class DecoderDatabase; 20 class DecoderDatabase;
21 class TickTimer;
22 22
23 // This is the actual buffer holding the packets before decoding. 23 // This is the actual buffer holding the packets before decoding.
24 class PacketBuffer { 24 class PacketBuffer {
25 public: 25 public:
26 enum BufferReturnCodes { 26 enum BufferReturnCodes {
27 kOK = 0, 27 kOK = 0,
28 kFlushed, 28 kFlushed,
29 kNotFound, 29 kNotFound,
30 kBufferEmpty, 30 kBufferEmpty,
31 kInvalidPacket, 31 kInvalidPacket,
32 kInvalidPointer 32 kInvalidPointer
33 }; 33 };
34 34
35 // Constructor creates a buffer which can hold a maximum of 35 // Constructor creates a buffer which can hold a maximum of
36 // |max_number_of_packets| packets. 36 // |max_number_of_packets| packets.
37 PacketBuffer(size_t max_number_of_packets); 37 PacketBuffer(size_t max_number_of_packets, const TickTimer* tick_timer);
38 38
39 // Deletes all packets in the buffer before destroying the buffer. 39 // Deletes all packets in the buffer before destroying the buffer.
40 virtual ~PacketBuffer(); 40 virtual ~PacketBuffer();
41 41
42 // Flushes the buffer and deletes all packets in it. 42 // Flushes the buffer and deletes all packets in it.
43 virtual void Flush(); 43 virtual void Flush();
44 44
45 // Returns true for an empty buffer. 45 // Returns true for an empty buffer.
46 virtual bool Empty() const; 46 virtual bool Empty() const;
47 47
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 109
110 // Returns the number of packets in the buffer, including duplicates and 110 // Returns the number of packets in the buffer, including duplicates and
111 // redundant packets. 111 // redundant packets.
112 virtual size_t NumPacketsInBuffer() const; 112 virtual size_t NumPacketsInBuffer() const;
113 113
114 // Returns the number of samples in the buffer, including samples carried in 114 // Returns the number of samples in the buffer, including samples carried in
115 // duplicate and redundant packets. 115 // duplicate and redundant packets.
116 virtual size_t NumSamplesInBuffer(DecoderDatabase* decoder_database, 116 virtual size_t NumSamplesInBuffer(DecoderDatabase* decoder_database,
117 size_t last_decoded_length) const; 117 size_t last_decoded_length) const;
118 118
119 // Increase the waiting time counter for every packet in the buffer by |inc|.
120 // The default value for |inc| is 1.
121 virtual void IncrementWaitingTimes(int inc = 1);
122
123 virtual void BufferStat(int* num_packets, int* max_num_packets) const; 119 virtual void BufferStat(int* num_packets, int* max_num_packets) const;
124 120
125 // Static method that properly deletes the first packet, and its payload 121 // Static method that properly deletes the first packet, and its payload
126 // array, in |packet_list|. Returns false if |packet_list| already was empty, 122 // array, in |packet_list|. Returns false if |packet_list| already was empty,
127 // otherwise true. 123 // otherwise true.
128 static bool DeleteFirstPacket(PacketList* packet_list); 124 static bool DeleteFirstPacket(PacketList* packet_list);
129 125
130 // Static method that properly deletes all packets, and their payload arrays, 126 // Static method that properly deletes all packets, and their payload arrays,
131 // in |packet_list|. 127 // in |packet_list|.
132 static void DeleteAllPackets(PacketList* packet_list); 128 static void DeleteAllPackets(PacketList* packet_list);
133 129
134 // Static method returning true if |timestamp| is older than |timestamp_limit| 130 // Static method returning true if |timestamp| is older than |timestamp_limit|
135 // but less than |horizon_samples| behind |timestamp_limit|. For instance, 131 // but less than |horizon_samples| behind |timestamp_limit|. For instance,
136 // with timestamp_limit = 100 and horizon_samples = 10, a timestamp in the 132 // with timestamp_limit = 100 and horizon_samples = 10, a timestamp in the
137 // range (90, 100) is considered obsolete, and will yield true. 133 // range (90, 100) is considered obsolete, and will yield true.
138 // Setting |horizon_samples| to 0 is the same as setting it to 2^31, i.e., 134 // Setting |horizon_samples| to 0 is the same as setting it to 2^31, i.e.,
139 // half the 32-bit timestamp range. 135 // half the 32-bit timestamp range.
140 static bool IsObsoleteTimestamp(uint32_t timestamp, 136 static bool IsObsoleteTimestamp(uint32_t timestamp,
141 uint32_t timestamp_limit, 137 uint32_t timestamp_limit,
142 uint32_t horizon_samples) { 138 uint32_t horizon_samples) {
143 return IsNewerTimestamp(timestamp_limit, timestamp) && 139 return IsNewerTimestamp(timestamp_limit, timestamp) &&
144 (horizon_samples == 0 || 140 (horizon_samples == 0 ||
145 IsNewerTimestamp(timestamp, timestamp_limit - horizon_samples)); 141 IsNewerTimestamp(timestamp, timestamp_limit - horizon_samples));
146 } 142 }
147 143
148 private: 144 private:
149 size_t max_number_of_packets_; 145 size_t max_number_of_packets_;
150 PacketList buffer_; 146 PacketList buffer_;
147 const TickTimer* tick_timer_;
151 RTC_DISALLOW_COPY_AND_ASSIGN(PacketBuffer); 148 RTC_DISALLOW_COPY_AND_ASSIGN(PacketBuffer);
152 }; 149 };
153 150
154 } // namespace webrtc 151 } // namespace webrtc
155 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_PACKET_BUFFER_H_ 152 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_PACKET_BUFFER_H_
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/neteq/packet.cc ('k') | webrtc/modules/audio_coding/neteq/packet_buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698