| 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 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 // true if a reset is required; otherwise it is left unchanged (i.e., it can | 72 // true if a reset is required; otherwise it is left unchanged (i.e., it can |
| 73 // remain true if it was true before the call). | 73 // remain true if it was true before the call). |
| 74 // This method end with calling GetDecisionSpecialized to get the actual | 74 // This method end with calling GetDecisionSpecialized to get the actual |
| 75 // return value. | 75 // return value. |
| 76 Operations GetDecision(const SyncBuffer& sync_buffer, | 76 Operations GetDecision(const SyncBuffer& sync_buffer, |
| 77 const Expand& expand, | 77 const Expand& expand, |
| 78 size_t decoder_frame_length, | 78 size_t decoder_frame_length, |
| 79 const RTPHeader* packet_header, | 79 const RTPHeader* packet_header, |
| 80 Modes prev_mode, | 80 Modes prev_mode, |
| 81 bool play_dtmf, | 81 bool play_dtmf, |
| 82 size_t generated_noise_samples, |
| 82 bool* reset_decoder); | 83 bool* reset_decoder); |
| 83 | 84 |
| 84 // These methods test the |cng_state_| for different conditions. | 85 // These methods test the |cng_state_| for different conditions. |
| 85 bool CngRfc3389On() const { return cng_state_ == kCngRfc3389On; } | 86 bool CngRfc3389On() const { return cng_state_ == kCngRfc3389On; } |
| 86 bool CngOff() const { return cng_state_ == kCngOff; } | 87 bool CngOff() const { return cng_state_ == kCngOff; } |
| 87 | 88 |
| 88 // Resets the |cng_state_| to kCngOff. | 89 // Resets the |cng_state_| to kCngOff. |
| 89 void SetCngOff() { cng_state_ = kCngOff; } | 90 void SetCngOff() { cng_state_ = kCngOff; } |
| 90 | 91 |
| 91 // Reports back to DecisionLogic whether the decision to do expand remains or | 92 // Reports back to DecisionLogic whether the decision to do expand remains or |
| 92 // not. Note that this is necessary, since an expand decision can be changed | 93 // not. Note that this is necessary, since an expand decision can be changed |
| 93 // to kNormal in NetEqImpl::GetDecision if there is still enough data in the | 94 // to kNormal in NetEqImpl::GetDecision if there is still enough data in the |
| 94 // sync buffer. | 95 // sync buffer. |
| 95 virtual void ExpandDecision(Operations operation); | 96 virtual void ExpandDecision(Operations operation); |
| 96 | 97 |
| 97 // Adds |value| to |sample_memory_|. | 98 // Adds |value| to |sample_memory_|. |
| 98 void AddSampleMemory(int32_t value) { | 99 void AddSampleMemory(int32_t value) { |
| 99 sample_memory_ += value; | 100 sample_memory_ += value; |
| 100 } | 101 } |
| 101 | 102 |
| 102 // Accessors and mutators. | 103 // Accessors and mutators. |
| 103 void set_sample_memory(int32_t value) { sample_memory_ = value; } | 104 void set_sample_memory(int32_t value) { sample_memory_ = value; } |
| 104 size_t generated_noise_samples() const { return generated_noise_samples_; } | 105 size_t noise_fast_forward() const { return noise_fast_forward_; } |
| 105 void set_generated_noise_samples(size_t value) { | |
| 106 generated_noise_samples_ = value; | |
| 107 } | |
| 108 size_t packet_length_samples() const { return packet_length_samples_; } | 106 size_t packet_length_samples() const { return packet_length_samples_; } |
| 109 void set_packet_length_samples(size_t value) { | 107 void set_packet_length_samples(size_t value) { |
| 110 packet_length_samples_ = value; | 108 packet_length_samples_ = value; |
| 111 } | 109 } |
| 112 void set_prev_time_scale(bool value) { prev_time_scale_ = value; } | 110 void set_prev_time_scale(bool value) { prev_time_scale_ = value; } |
| 113 NetEqPlayoutMode playout_mode() const { return playout_mode_; } | 111 NetEqPlayoutMode playout_mode() const { return playout_mode_; } |
| 114 | 112 |
| 115 protected: | 113 protected: |
| 116 // The value 6 sets maximum time-stretch rate to about 100 ms/s. | 114 // The value 6 sets maximum time-stretch rate to about 100 ms/s. |
| 117 static const int kMinTimescaleInterval = 6; | 115 static const int kMinTimescaleInterval = 6; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 131 // should be set to true. The output variable |reset_decoder| will be set to | 129 // should be set to true. The output variable |reset_decoder| will be set to |
| 132 // true if a reset is required; otherwise it is left unchanged (i.e., it can | 130 // true if a reset is required; otherwise it is left unchanged (i.e., it can |
| 133 // remain true if it was true before the call). | 131 // remain true if it was true before the call). |
| 134 // Should be implemented by derived classes. | 132 // Should be implemented by derived classes. |
| 135 virtual Operations GetDecisionSpecialized(const SyncBuffer& sync_buffer, | 133 virtual Operations GetDecisionSpecialized(const SyncBuffer& sync_buffer, |
| 136 const Expand& expand, | 134 const Expand& expand, |
| 137 size_t decoder_frame_length, | 135 size_t decoder_frame_length, |
| 138 const RTPHeader* packet_header, | 136 const RTPHeader* packet_header, |
| 139 Modes prev_mode, | 137 Modes prev_mode, |
| 140 bool play_dtmf, | 138 bool play_dtmf, |
| 141 bool* reset_decoder) = 0; | 139 bool* reset_decoder, |
| 140 size_t generated_noise_samples) = 0; |
| 142 | 141 |
| 143 // Updates the |buffer_level_filter_| with the current buffer level | 142 // Updates the |buffer_level_filter_| with the current buffer level |
| 144 // |buffer_size_packets|. | 143 // |buffer_size_packets|. |
| 145 void FilterBufferLevel(size_t buffer_size_packets, Modes prev_mode); | 144 void FilterBufferLevel(size_t buffer_size_packets, Modes prev_mode); |
| 146 | 145 |
| 147 DecoderDatabase* decoder_database_; | 146 DecoderDatabase* decoder_database_; |
| 148 const PacketBuffer& packet_buffer_; | 147 const PacketBuffer& packet_buffer_; |
| 149 DelayManager* delay_manager_; | 148 DelayManager* delay_manager_; |
| 150 BufferLevelFilter* buffer_level_filter_; | 149 BufferLevelFilter* buffer_level_filter_; |
| 151 int fs_mult_; | 150 int fs_mult_; |
| 152 size_t output_size_samples_; | 151 size_t output_size_samples_; |
| 153 CngState cng_state_; // Remember if comfort noise is interrupted by other | 152 CngState cng_state_; // Remember if comfort noise is interrupted by other |
| 154 // event (e.g., DTMF). | 153 // event (e.g., DTMF). |
| 155 size_t generated_noise_samples_; | 154 size_t noise_fast_forward_ = 0; |
| 156 size_t packet_length_samples_; | 155 size_t packet_length_samples_; |
| 157 int sample_memory_; | 156 int sample_memory_; |
| 158 bool prev_time_scale_; | 157 bool prev_time_scale_; |
| 159 int timescale_hold_off_; | 158 int timescale_hold_off_; |
| 160 int num_consecutive_expands_; | 159 int num_consecutive_expands_; |
| 161 const NetEqPlayoutMode playout_mode_; | 160 const NetEqPlayoutMode playout_mode_; |
| 162 | 161 |
| 163 private: | 162 private: |
| 164 RTC_DISALLOW_COPY_AND_ASSIGN(DecisionLogic); | 163 RTC_DISALLOW_COPY_AND_ASSIGN(DecisionLogic); |
| 165 }; | 164 }; |
| 166 | 165 |
| 167 } // namespace webrtc | 166 } // namespace webrtc |
| 168 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_DECISION_LOGIC_H_ | 167 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_DECISION_LOGIC_H_ |
| OLD | NEW |