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

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

Issue 1410073006: ACM: Move NACK functionality inside NetEq (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase Created 5 years, 1 month 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_MAIN_ACM2_NACK_H_ 11 #ifndef WEBRTC_MODULES_AUDIO_CODING_NETEQ_NACK_H_
12 #define WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_NACK_H_ 12 #define WEBRTC_MODULES_AUDIO_CODING_NETEQ_NACK_H_
13 13
14 #include <vector> 14 #include <vector>
15 #include <map> 15 #include <map>
16 16
17 #include "webrtc/base/scoped_ptr.h" 17 #include "webrtc/base/scoped_ptr.h"
18 #include "webrtc/modules/audio_coding/main/include/audio_coding_module_typedefs. h" 18 #include "webrtc/modules/audio_coding/main/include/audio_coding_module_typedefs. h"
19 #include "webrtc/test/testsupport/gtest_prod_util.h" 19 #include "webrtc/test/testsupport/gtest_prod_util.h"
20 20
21 // 21 //
22 // The Nack class keeps track of the lost packets, an estimate of time-to-play 22 // The Nack class keeps track of the lost packets, an estimate of time-to-play
(...skipping 19 matching lines...) Expand all
42 // re-transmission is meaning less for old packet. Therefore, in that case, 42 // re-transmission is meaning less for old packet. Therefore, in that case,
43 // after reset the sampling rate has to be updated. 43 // after reset the sampling rate has to be updated.
44 // 44 //
45 // Thread Safety 45 // Thread Safety
46 // ============= 46 // =============
47 // Please note that this class in not thread safe. The class must be protected 47 // Please note that this class in not thread safe. The class must be protected
48 // if different APIs are called from different threads. 48 // if different APIs are called from different threads.
49 // 49 //
50 namespace webrtc { 50 namespace webrtc {
51 51
52 namespace acm2 {
53
54 class Nack { 52 class Nack {
55 public: 53 public:
56 // A limit for the size of the NACK list. 54 // A limit for the size of the NACK list.
57 static const size_t kNackListSizeLimit = 500; // 10 seconds for 20 ms frame 55 static const size_t kNackListSizeLimit = 500; // 10 seconds for 20 ms frame
58 // packets. 56 // packets.
59 // Factory method. 57 // Factory method.
60 static Nack* Create(int nack_threshold_packets); 58 static Nack* Create(int nack_threshold_packets);
61 59
62 ~Nack(); 60 ~Nack();
63 61
64 // Set a maximum for the size of the NACK list. If the last received packet 62 // Set a maximum for the size of the NACK list. If the last received packet
65 // has sequence number of N, then NACK list will not contain any element 63 // has sequence number of N, then NACK list will not contain any element
66 // with sequence number earlier than N - |max_nack_list_size|. 64 // with sequence number earlier than N - |max_nack_list_size|.
67 // 65 //
68 // The largest maximum size is defined by |kNackListSizeLimit| 66 // The largest maximum size is defined by |kNackListSizeLimit|
69 int SetMaxNackListSize(size_t max_nack_list_size); 67 void SetMaxNackListSize(size_t max_nack_list_size);
70 68
71 // Set the sampling rate. 69 // Set the sampling rate.
72 // 70 //
73 // If associated sampling rate of the received packets is changed, call this 71 // If associated sampling rate of the received packets is changed, call this
74 // function to update sampling rate. Note that if there is any change in 72 // function to update sampling rate. Note that if there is any change in
75 // received codec then NetEq will flush its buffer and NACK has to be reset. 73 // received codec then NetEq will flush its buffer and NACK has to be reset.
76 // After Reset() is called sampling rate has to be set. 74 // After Reset() is called sampling rate has to be set.
77 void UpdateSampleRate(int sample_rate_hz); 75 void UpdateSampleRate(int sample_rate_hz);
78 76
79 // Update the sequence number and the timestamp of the last decoded RTP. This 77 // Update the sequence number and the timestamp of the last decoded RTP. This
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 // packets. This will have a very minor effect on NACK performance. 115 // packets. This will have a very minor effect on NACK performance.
118 uint32_t estimated_timestamp; 116 uint32_t estimated_timestamp;
119 117
120 // True if the packet is considered missing. Otherwise indicates packet is 118 // True if the packet is considered missing. Otherwise indicates packet is
121 // late. 119 // late.
122 bool is_missing; 120 bool is_missing;
123 }; 121 };
124 122
125 class NackListCompare { 123 class NackListCompare {
126 public: 124 public:
127 bool operator() (uint16_t sequence_number_old, 125 bool operator()(uint16_t sequence_number_old,
128 uint16_t sequence_number_new) const { 126 uint16_t sequence_number_new) const {
129 return IsNewerSequenceNumber(sequence_number_new, sequence_number_old); 127 return IsNewerSequenceNumber(sequence_number_new, sequence_number_old);
130 } 128 }
131 }; 129 };
132 130
133 typedef std::map<uint16_t, NackElement, NackListCompare> NackList; 131 typedef std::map<uint16_t, NackElement, NackListCompare> NackList;
134 132
135 // Constructor. 133 // Constructor.
136 explicit Nack(int nack_threshold_packets); 134 explicit Nack(int nack_threshold_packets);
137 135
138 // This API is used only for testing to assess whether time-to-play is 136 // This API is used only for testing to assess whether time-to-play is
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 // A list of missing packets to be retransmitted. Components of the list 197 // A list of missing packets to be retransmitted. Components of the list
200 // contain the sequence number of missing packets and the estimated time that 198 // contain the sequence number of missing packets and the estimated time that
201 // each pack is going to be played out. 199 // each pack is going to be played out.
202 NackList nack_list_; 200 NackList nack_list_;
203 201
204 // NACK list will not keep track of missing packets prior to 202 // NACK list will not keep track of missing packets prior to
205 // |sequence_num_last_received_rtp_| - |max_nack_list_size_|. 203 // |sequence_num_last_received_rtp_| - |max_nack_list_size_|.
206 size_t max_nack_list_size_; 204 size_t max_nack_list_size_;
207 }; 205 };
208 206
209 } // namespace acm2
210
211 } // namespace webrtc 207 } // namespace webrtc
212 208
213 #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_NACK_H_ 209 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_NACK_H_
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/neteq/include/neteq.h ('k') | webrtc/modules/audio_coding/neteq/nack.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698