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

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

Issue 1296633002: NetEq/ACM: Refactor how packet waiting times are calculated (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 4 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_STATISTICS_CALCULATOR_H_ 11 #ifndef WEBRTC_MODULES_AUDIO_CODING_NETEQ_STATISTICS_CALCULATOR_H_
12 #define WEBRTC_MODULES_AUDIO_CODING_NETEQ_STATISTICS_CALCULATOR_H_ 12 #define WEBRTC_MODULES_AUDIO_CODING_NETEQ_STATISTICS_CALCULATOR_H_
13 13
14 #include <vector> 14 #include <list>
15 15
16 #include "webrtc/base/constructormagic.h" 16 #include "webrtc/base/constructormagic.h"
17 #include "webrtc/modules/audio_coding/neteq/interface/neteq.h" 17 #include "webrtc/modules/audio_coding/neteq/interface/neteq.h"
18 #include "webrtc/typedefs.h" 18 #include "webrtc/typedefs.h"
19 19
20 namespace webrtc { 20 namespace webrtc {
21 21
22 // Forward declarations. 22 // Forward declarations.
23 class DecisionLogic; 23 class DecisionLogic;
24 class DelayManager; 24 class DelayManager;
25 25
26 // This class handles various network statistics in NetEq. 26 // This class handles various network statistics in NetEq.
27 class StatisticsCalculator { 27 class StatisticsCalculator {
28 public: 28 public:
29 StatisticsCalculator(); 29 StatisticsCalculator();
30 30
31 virtual ~StatisticsCalculator() {} 31 virtual ~StatisticsCalculator();
32 32
33 // Resets most of the counters. 33 // Resets most of the counters.
34 void Reset(); 34 void Reset();
35 35
36 // Resets the counters that are not handled by Reset(). 36 // Resets the counters that are not handled by Reset().
37 void ResetMcu(); 37 void ResetMcu();
38 38
39 // Resets the waiting time statistics.
40 void ResetWaitingTimeStatistics();
41
42 // Reports that |num_samples| samples were produced through expansion, and 39 // Reports that |num_samples| samples were produced through expansion, and
43 // that the expansion produced other than just noise samples. 40 // that the expansion produced other than just noise samples.
44 void ExpandedVoiceSamples(int num_samples); 41 void ExpandedVoiceSamples(int num_samples);
45 42
46 // Reports that |num_samples| samples were produced through expansion, and 43 // Reports that |num_samples| samples were produced through expansion, and
47 // that the expansion produced only noise samples. 44 // that the expansion produced only noise samples.
48 void ExpandedNoiseSamples(int num_samples); 45 void ExpandedNoiseSamples(int num_samples);
49 46
50 // Reports that |num_samples| samples were produced through preemptive 47 // Reports that |num_samples| samples were produced through preemptive
51 // expansion. 48 // expansion.
(...skipping 25 matching lines...) Expand all
77 // is |fs_hz|, the total number of samples in packet buffer and sync buffer 74 // is |fs_hz|, the total number of samples in packet buffer and sync buffer
78 // yet to play out is |num_samples_in_buffers|, and the number of samples per 75 // yet to play out is |num_samples_in_buffers|, and the number of samples per
79 // packet is |samples_per_packet|. 76 // packet is |samples_per_packet|.
80 void GetNetworkStatistics(int fs_hz, 77 void GetNetworkStatistics(int fs_hz,
81 int num_samples_in_buffers, 78 int num_samples_in_buffers,
82 int samples_per_packet, 79 int samples_per_packet,
83 const DelayManager& delay_manager, 80 const DelayManager& delay_manager,
84 const DecisionLogic& decision_logic, 81 const DecisionLogic& decision_logic,
85 NetEqNetworkStatistics *stats); 82 NetEqNetworkStatistics *stats);
86 83
87 void WaitingTimes(std::vector<int>* waiting_times);
88
89 private: 84 private:
90 static const int kMaxReportPeriod = 60; // Seconds before auto-reset. 85 static const int kMaxReportPeriod = 60; // Seconds before auto-reset.
91 static const int kLenWaitingTimes = 100; 86 static const size_t kLenWaitingTimes = 100;
92 87
93 // Calculates numerator / denominator, and returns the value in Q14. 88 // Calculates numerator / denominator, and returns the value in Q14.
94 static uint16_t CalculateQ14Ratio(uint32_t numerator, uint32_t denominator); 89 static uint16_t CalculateQ14Ratio(uint32_t numerator, uint32_t denominator);
95 90
96 uint32_t preemptive_samples_; 91 uint32_t preemptive_samples_;
97 uint32_t accelerate_samples_; 92 uint32_t accelerate_samples_;
98 int added_zero_samples_; 93 int added_zero_samples_;
99 uint32_t expanded_speech_samples_; 94 uint32_t expanded_speech_samples_;
100 uint32_t expanded_noise_samples_; 95 uint32_t expanded_noise_samples_;
101 int discarded_packets_; 96 int discarded_packets_;
102 uint32_t lost_timestamps_; 97 uint32_t lost_timestamps_;
103 uint32_t timestamps_since_last_report_; 98 uint32_t timestamps_since_last_report_;
104 int waiting_times_[kLenWaitingTimes]; // Used as a circular buffer. 99 std::list<int> waiting_times_;
minyue-webrtc 2015/08/18 12:55:34 why to change from vector to list?
hlundin-webrtc 2015/08/19 08:28:39 The reasoning behind my choice is that waiting_tim
minyue-webrtc 2015/08/19 11:21:52 maybe use std::deque
hlundin-webrtc 2015/08/19 14:34:49 Yes, much better. Thanks!
105 int len_waiting_times_;
106 int next_waiting_time_index_;
107 uint32_t secondary_decoded_samples_; 100 uint32_t secondary_decoded_samples_;
108 101
109 DISALLOW_COPY_AND_ASSIGN(StatisticsCalculator); 102 DISALLOW_COPY_AND_ASSIGN(StatisticsCalculator);
110 }; 103 };
111 104
112 } // namespace webrtc 105 } // namespace webrtc
113 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_STATISTICS_CALCULATOR_H_ 106 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_STATISTICS_CALCULATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698