OLD | NEW |
---|---|
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_DECISION_LOGIC_H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_CODING_NETEQ_DECISION_LOGIC_H_ |
12 #define WEBRTC_MODULES_AUDIO_CODING_NETEQ_DECISION_LOGIC_H_ | 12 #define WEBRTC_MODULES_AUDIO_CODING_NETEQ_DECISION_LOGIC_H_ |
13 | 13 |
14 #include "webrtc/base/constructormagic.h" | 14 #include "webrtc/base/constructormagic.h" |
15 #include "webrtc/modules/audio_coding/neteq/defines.h" | 15 #include "webrtc/modules/audio_coding/neteq/defines.h" |
16 #include "webrtc/modules/audio_coding/neteq/include/neteq.h" | 16 #include "webrtc/modules/audio_coding/neteq/include/neteq.h" |
17 #include "webrtc/modules/audio_coding/neteq/tick_timer.h" | |
17 #include "webrtc/typedefs.h" | 18 #include "webrtc/typedefs.h" |
18 | 19 |
19 namespace webrtc { | 20 namespace webrtc { |
20 | 21 |
21 // Forward declarations. | 22 // Forward declarations. |
22 class BufferLevelFilter; | 23 class BufferLevelFilter; |
23 class DecoderDatabase; | 24 class DecoderDatabase; |
24 class DelayManager; | 25 class DelayManager; |
25 class Expand; | 26 class Expand; |
26 class PacketBuffer; | 27 class PacketBuffer; |
27 class SyncBuffer; | 28 class SyncBuffer; |
28 struct RTPHeader; | 29 struct RTPHeader; |
29 | 30 |
30 // This is the base class for the decision tree implementations. Derived classes | 31 // This is the base class for the decision tree implementations. Derived classes |
31 // must implement the method GetDecisionSpecialized(). | 32 // must implement the method GetDecisionSpecialized(). |
32 class DecisionLogic { | 33 class DecisionLogic { |
33 public: | 34 public: |
34 // Static factory function which creates different types of objects depending | 35 // Static factory function which creates different types of objects depending |
35 // on the |playout_mode|. | 36 // on the |playout_mode|. |
36 static DecisionLogic* Create(int fs_hz, | 37 static DecisionLogic* Create(int fs_hz, |
37 size_t output_size_samples, | 38 size_t output_size_samples, |
38 NetEqPlayoutMode playout_mode, | 39 NetEqPlayoutMode playout_mode, |
39 DecoderDatabase* decoder_database, | 40 DecoderDatabase* decoder_database, |
40 const PacketBuffer& packet_buffer, | 41 const PacketBuffer& packet_buffer, |
41 DelayManager* delay_manager, | 42 DelayManager* delay_manager, |
42 BufferLevelFilter* buffer_level_filter); | 43 BufferLevelFilter* buffer_level_filter, |
44 const TickTimer* tick_timer); | |
43 | 45 |
44 // Constructor. | 46 // Constructor. |
45 DecisionLogic(int fs_hz, | 47 DecisionLogic(int fs_hz, |
46 size_t output_size_samples, | 48 size_t output_size_samples, |
47 NetEqPlayoutMode playout_mode, | 49 NetEqPlayoutMode playout_mode, |
48 DecoderDatabase* decoder_database, | 50 DecoderDatabase* decoder_database, |
49 const PacketBuffer& packet_buffer, | 51 const PacketBuffer& packet_buffer, |
50 DelayManager* delay_manager, | 52 DelayManager* delay_manager, |
51 BufferLevelFilter* buffer_level_filter); | 53 BufferLevelFilter* buffer_level_filter, |
54 const TickTimer* tick_timer); | |
52 | 55 |
53 // Destructor. | 56 virtual ~DecisionLogic(); |
54 virtual ~DecisionLogic() {} | |
55 | 57 |
56 // Resets object to a clean state. | 58 // Resets object to a clean state. |
57 void Reset(); | 59 void Reset(); |
58 | 60 |
59 // Resets parts of the state. Typically done when switching codecs. | 61 // Resets parts of the state. Typically done when switching codecs. |
60 void SoftReset(); | 62 void SoftReset(); |
61 | 63 |
62 // Sets the sample rate and the output block size. | 64 // Sets the sample rate and the output block size. |
63 void SetSampleRate(int fs_hz, size_t output_size_samples); | 65 void SetSampleRate(int fs_hz, size_t output_size_samples); |
64 | 66 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
104 void set_sample_memory(int32_t value) { sample_memory_ = value; } | 106 void set_sample_memory(int32_t value) { sample_memory_ = value; } |
105 size_t noise_fast_forward() const { return noise_fast_forward_; } | 107 size_t noise_fast_forward() const { return noise_fast_forward_; } |
106 size_t packet_length_samples() const { return packet_length_samples_; } | 108 size_t packet_length_samples() const { return packet_length_samples_; } |
107 void set_packet_length_samples(size_t value) { | 109 void set_packet_length_samples(size_t value) { |
108 packet_length_samples_ = value; | 110 packet_length_samples_ = value; |
109 } | 111 } |
110 void set_prev_time_scale(bool value) { prev_time_scale_ = value; } | 112 void set_prev_time_scale(bool value) { prev_time_scale_ = value; } |
111 NetEqPlayoutMode playout_mode() const { return playout_mode_; } | 113 NetEqPlayoutMode playout_mode() const { return playout_mode_; } |
112 | 114 |
113 protected: | 115 protected: |
114 // The value 6 sets maximum time-stretch rate to about 100 ms/s. | 116 // The value 5 sets maximum time-stretch rate to about 100 ms/s. |
115 static const int kMinTimescaleInterval = 6; | 117 static const int kMinTimescaleInterval = 5; |
hlundin-webrtc
2016/05/03 19:09:10
The change from 6 to 5 is motivated by the fact th
| |
116 | 118 |
117 enum CngState { | 119 enum CngState { |
118 kCngOff, | 120 kCngOff, |
119 kCngRfc3389On, | 121 kCngRfc3389On, |
120 kCngInternalOn | 122 kCngInternalOn |
121 }; | 123 }; |
122 | 124 |
123 // Returns the operation that should be done next. |sync_buffer| and |expand| | 125 // Returns the operation that should be done next. |sync_buffer| and |expand| |
124 // are provided for reference. |decoder_frame_length| is the number of samples | 126 // are provided for reference. |decoder_frame_length| is the number of samples |
125 // obtained from the last decoded frame. If there is a packet available, the | 127 // obtained from the last decoded frame. If there is a packet available, the |
(...skipping 14 matching lines...) Expand all Loading... | |
140 size_t generated_noise_samples) = 0; | 142 size_t generated_noise_samples) = 0; |
141 | 143 |
142 // Updates the |buffer_level_filter_| with the current buffer level | 144 // Updates the |buffer_level_filter_| with the current buffer level |
143 // |buffer_size_packets|. | 145 // |buffer_size_packets|. |
144 void FilterBufferLevel(size_t buffer_size_packets, Modes prev_mode); | 146 void FilterBufferLevel(size_t buffer_size_packets, Modes prev_mode); |
145 | 147 |
146 DecoderDatabase* decoder_database_; | 148 DecoderDatabase* decoder_database_; |
147 const PacketBuffer& packet_buffer_; | 149 const PacketBuffer& packet_buffer_; |
148 DelayManager* delay_manager_; | 150 DelayManager* delay_manager_; |
149 BufferLevelFilter* buffer_level_filter_; | 151 BufferLevelFilter* buffer_level_filter_; |
152 const TickTimer* tick_timer_; | |
150 int fs_mult_; | 153 int fs_mult_; |
151 size_t output_size_samples_; | 154 size_t output_size_samples_; |
152 CngState cng_state_; // Remember if comfort noise is interrupted by other | 155 CngState cng_state_; // Remember if comfort noise is interrupted by other |
153 // event (e.g., DTMF). | 156 // event (e.g., DTMF). |
154 size_t noise_fast_forward_ = 0; | 157 size_t noise_fast_forward_ = 0; |
155 size_t packet_length_samples_; | 158 size_t packet_length_samples_; |
156 int sample_memory_; | 159 int sample_memory_; |
157 bool prev_time_scale_; | 160 bool prev_time_scale_; |
158 int timescale_hold_off_; | 161 std::unique_ptr<TickTimer::Countdown> timescale_countdown_; |
159 int num_consecutive_expands_; | 162 int num_consecutive_expands_; |
160 const NetEqPlayoutMode playout_mode_; | 163 const NetEqPlayoutMode playout_mode_; |
161 | 164 |
162 private: | 165 private: |
163 RTC_DISALLOW_COPY_AND_ASSIGN(DecisionLogic); | 166 RTC_DISALLOW_COPY_AND_ASSIGN(DecisionLogic); |
164 }; | 167 }; |
165 | 168 |
166 } // namespace webrtc | 169 } // namespace webrtc |
167 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_DECISION_LOGIC_H_ | 170 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_DECISION_LOGIC_H_ |
OLD | NEW |