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

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

Issue 2045243002: NetEq: Rename Nack to NackTracker to avoid name collisions in GN (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 6 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) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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_NACK_H_ 11 #ifndef WEBRTC_MODULES_AUDIO_CODING_NETEQ_NACK_TRACKER_H_
12 #define WEBRTC_MODULES_AUDIO_CODING_NETEQ_NACK_H_ 12 #define WEBRTC_MODULES_AUDIO_CODING_NETEQ_NACK_TRACKER_H_
13 13
14 #include <vector> 14 #include <vector>
15 #include <map> 15 #include <map>
16 16
17 #include "webrtc/base/gtest_prod_util.h" 17 #include "webrtc/base/gtest_prod_util.h"
18 #include "webrtc/modules/audio_coding/include/audio_coding_module_typedefs.h" 18 #include "webrtc/modules/audio_coding/include/audio_coding_module_typedefs.h"
19 19
20 // 20 //
21 // The Nack class keeps track of the lost packets, an estimate of time-to-play 21 // The NackTracker class keeps track of the lost packets, an estimate of
22 // for each packet is also given. 22 // time-to-play for each packet is also given.
23 // 23 //
24 // Every time a packet is pushed into NetEq, LastReceivedPacket() has to be 24 // Every time a packet is pushed into NetEq, LastReceivedPacket() has to be
25 // called to update the NACK list. 25 // called to update the NACK list.
26 // 26 //
27 // Every time 10ms audio is pulled from NetEq LastDecodedPacket() should be 27 // Every time 10ms audio is pulled from NetEq LastDecodedPacket() should be
28 // called, and time-to-play is updated at that moment. 28 // called, and time-to-play is updated at that moment.
29 // 29 //
30 // If packet N is received, any packet prior to |N - NackThreshold| which is not 30 // If packet N is received, any packet prior to |N - NackThreshold| which is not
31 // arrived is considered lost, and should be labeled as "missing" (the size of 31 // arrived is considered lost, and should be labeled as "missing" (the size of
32 // the list might be limited and older packet eliminated from the list). Packets 32 // the list might be limited and older packet eliminated from the list). Packets
33 // |N - NackThreshold|, |N - NackThreshold + 1|, ..., |N - 1| are considered 33 // |N - NackThreshold|, |N - NackThreshold + 1|, ..., |N - 1| are considered
34 // "late." A "late" packet with sequence number K is changed to "missing" any 34 // "late." A "late" packet with sequence number K is changed to "missing" any
35 // time a packet with sequence number newer than |K + NackList| is arrived. 35 // time a packet with sequence number newer than |K + NackList| is arrived.
36 // 36 //
37 // The Nack class has to know about the sample rate of the packets to compute 37 // The NackTracker class has to know about the sample rate of the packets to
38 // time-to-play. So sample rate should be set as soon as the first packet is 38 // compute time-to-play. So sample rate should be set as soon as the first
39 // received. If there is a change in the receive codec (sender changes codec) 39 // packet is received. If there is a change in the receive codec (sender changes
40 // then Nack should be reset. This is because NetEQ would flush its buffer and 40 // codec) then NackTracker should be reset. This is because NetEQ would flush
41 // re-transmission is meaning less for old packet. Therefore, in that case, 41 // its buffer and re-transmission is meaning less for old packet. Therefore, in
42 // after reset the sampling rate has to be updated. 42 // that case, after reset the sampling rate has to be updated.
43 // 43 //
44 // Thread Safety 44 // Thread Safety
45 // ============= 45 // =============
46 // Please note that this class in not thread safe. The class must be protected 46 // Please note that this class in not thread safe. The class must be protected
47 // if different APIs are called from different threads. 47 // if different APIs are called from different threads.
48 // 48 //
49 namespace webrtc { 49 namespace webrtc {
50 50
51 class Nack { 51 class NackTracker {
52 public: 52 public:
53 // A limit for the size of the NACK list. 53 // A limit for the size of the NACK list.
54 static const size_t kNackListSizeLimit = 500; // 10 seconds for 20 ms frame 54 static const size_t kNackListSizeLimit = 500; // 10 seconds for 20 ms frame
55 // packets. 55 // packets.
56 // Factory method. 56 // Factory method.
57 static Nack* Create(int nack_threshold_packets); 57 static NackTracker* Create(int nack_threshold_packets);
58 58
59 ~Nack(); 59 ~NackTracker();
60 60
61 // Set a maximum for the size of the NACK list. If the last received packet 61 // Set a maximum for the size of the NACK list. If the last received packet
62 // has sequence number of N, then NACK list will not contain any element 62 // has sequence number of N, then NACK list will not contain any element
63 // with sequence number earlier than N - |max_nack_list_size|. 63 // with sequence number earlier than N - |max_nack_list_size|.
64 // 64 //
65 // The largest maximum size is defined by |kNackListSizeLimit| 65 // The largest maximum size is defined by |kNackListSizeLimit|
66 void SetMaxNackListSize(size_t max_nack_list_size); 66 void SetMaxNackListSize(size_t max_nack_list_size);
67 67
68 // Set the sampling rate. 68 // Set the sampling rate.
69 // 69 //
(...skipping 15 matching lines...) Expand all
85 // than the given round-trip-time (in milliseconds). 85 // than the given round-trip-time (in milliseconds).
86 // Note: Late packets are not included. 86 // Note: Late packets are not included.
87 std::vector<uint16_t> GetNackList(int64_t round_trip_time_ms) const; 87 std::vector<uint16_t> GetNackList(int64_t round_trip_time_ms) const;
88 88
89 // Reset to default values. The NACK list is cleared. 89 // Reset to default values. The NACK list is cleared.
90 // |nack_threshold_packets_| & |max_nack_list_size_| preserve their values. 90 // |nack_threshold_packets_| & |max_nack_list_size_| preserve their values.
91 void Reset(); 91 void Reset();
92 92
93 private: 93 private:
94 // This test need to access the private method GetNackList(). 94 // This test need to access the private method GetNackList().
95 FRIEND_TEST_ALL_PREFIXES(NackTest, EstimateTimestampAndTimeToPlay); 95 FRIEND_TEST_ALL_PREFIXES(NackTrackerTest, EstimateTimestampAndTimeToPlay);
96 96
97 struct NackElement { 97 struct NackElement {
98 NackElement(int64_t initial_time_to_play_ms, 98 NackElement(int64_t initial_time_to_play_ms,
99 uint32_t initial_timestamp, 99 uint32_t initial_timestamp,
100 bool missing) 100 bool missing)
101 : time_to_play_ms(initial_time_to_play_ms), 101 : time_to_play_ms(initial_time_to_play_ms),
102 estimated_timestamp(initial_timestamp), 102 estimated_timestamp(initial_timestamp),
103 is_missing(missing) {} 103 is_missing(missing) {}
104 104
105 // Estimated time (ms) left for this packet to be decoded. This estimate is 105 // Estimated time (ms) left for this packet to be decoded. This estimate is
(...skipping 17 matching lines...) Expand all
123 public: 123 public:
124 bool operator()(uint16_t sequence_number_old, 124 bool operator()(uint16_t sequence_number_old,
125 uint16_t sequence_number_new) const { 125 uint16_t sequence_number_new) const {
126 return IsNewerSequenceNumber(sequence_number_new, sequence_number_old); 126 return IsNewerSequenceNumber(sequence_number_new, sequence_number_old);
127 } 127 }
128 }; 128 };
129 129
130 typedef std::map<uint16_t, NackElement, NackListCompare> NackList; 130 typedef std::map<uint16_t, NackElement, NackListCompare> NackList;
131 131
132 // Constructor. 132 // Constructor.
133 explicit Nack(int nack_threshold_packets); 133 explicit NackTracker(int nack_threshold_packets);
134 134
135 // This API is used only for testing to assess whether time-to-play is 135 // This API is used only for testing to assess whether time-to-play is
136 // computed correctly. 136 // computed correctly.
137 NackList GetNackList() const; 137 NackList GetNackList() const;
138 138
139 // Given the |sequence_number_current_received_rtp| of currently received RTP, 139 // Given the |sequence_number_current_received_rtp| of currently received RTP,
140 // recognize packets which are not arrive and add to the list. 140 // recognize packets which are not arrive and add to the list.
141 void AddToList(uint16_t sequence_number_current_received_rtp); 141 void AddToList(uint16_t sequence_number_current_received_rtp);
142 142
143 // This function subtracts 10 ms of time-to-play for all packets in NACK list. 143 // This function subtracts 10 ms of time-to-play for all packets in NACK list.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 // each pack is going to be played out. 198 // each pack is going to be played out.
199 NackList nack_list_; 199 NackList nack_list_;
200 200
201 // NACK list will not keep track of missing packets prior to 201 // NACK list will not keep track of missing packets prior to
202 // |sequence_num_last_received_rtp_| - |max_nack_list_size_|. 202 // |sequence_num_last_received_rtp_| - |max_nack_list_size_|.
203 size_t max_nack_list_size_; 203 size_t max_nack_list_size_;
204 }; 204 };
205 205
206 } // namespace webrtc 206 } // namespace webrtc
207 207
208 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_NACK_H_ 208 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_NACK_TRACKER_H_
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/neteq/nack.cc ('k') | webrtc/modules/audio_coding/neteq/nack_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698