OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 #include "webrtc/modules/audio_coding/neteq/timestamp_scaler.h" | 47 #include "webrtc/modules/audio_coding/neteq/timestamp_scaler.h" |
48 #include "webrtc/modules/include/module_common_types.h" | 48 #include "webrtc/modules/include/module_common_types.h" |
49 | 49 |
50 // Modify the code to obtain backwards bit-exactness. Once bit-exactness is no | 50 // Modify the code to obtain backwards bit-exactness. Once bit-exactness is no |
51 // longer required, this #define should be removed (and the code that it | 51 // longer required, this #define should be removed (and the code that it |
52 // enables). | 52 // enables). |
53 #define LEGACY_BITEXACT | 53 #define LEGACY_BITEXACT |
54 | 54 |
55 namespace webrtc { | 55 namespace webrtc { |
56 | 56 |
| 57 NetEqImpl::Dependencies::Dependencies(const NetEq::Config& config) |
| 58 : tick_timer(new TickTimer), |
| 59 buffer_level_filter(new BufferLevelFilter), |
| 60 decoder_database(new DecoderDatabase), |
| 61 delay_peak_detector(new DelayPeakDetector), |
| 62 delay_manager(new DelayManager(config.max_packets_in_buffer, |
| 63 delay_peak_detector.get())), |
| 64 dtmf_buffer(new DtmfBuffer(config.sample_rate_hz)), |
| 65 dtmf_tone_generator(new DtmfToneGenerator), |
| 66 packet_buffer( |
| 67 new PacketBuffer(config.max_packets_in_buffer, tick_timer.get())), |
| 68 payload_splitter(new PayloadSplitter), |
| 69 timestamp_scaler(new TimestampScaler(*decoder_database)), |
| 70 accelerate_factory(new AccelerateFactory), |
| 71 expand_factory(new ExpandFactory), |
| 72 preemptive_expand_factory(new PreemptiveExpandFactory) {} |
| 73 |
| 74 NetEqImpl::Dependencies::~Dependencies() = default; |
| 75 |
57 NetEqImpl::NetEqImpl(const NetEq::Config& config, | 76 NetEqImpl::NetEqImpl(const NetEq::Config& config, |
58 std::unique_ptr<TickTimer> tick_timer, | 77 Dependencies&& deps, |
59 BufferLevelFilter* buffer_level_filter, | |
60 DecoderDatabase* decoder_database, | |
61 DelayManager* delay_manager, | |
62 DelayPeakDetector* delay_peak_detector, | |
63 DtmfBuffer* dtmf_buffer, | |
64 DtmfToneGenerator* dtmf_tone_generator, | |
65 PacketBuffer* packet_buffer, | |
66 PayloadSplitter* payload_splitter, | |
67 TimestampScaler* timestamp_scaler, | |
68 AccelerateFactory* accelerate_factory, | |
69 ExpandFactory* expand_factory, | |
70 PreemptiveExpandFactory* preemptive_expand_factory, | |
71 bool create_components) | 78 bool create_components) |
72 : tick_timer_(std::move(tick_timer)), | 79 : tick_timer_(std::move(deps.tick_timer)), |
73 buffer_level_filter_(buffer_level_filter), | 80 buffer_level_filter_(std::move(deps.buffer_level_filter)), |
74 decoder_database_(decoder_database), | 81 decoder_database_(std::move(deps.decoder_database)), |
75 delay_manager_(delay_manager), | 82 delay_manager_(std::move(deps.delay_manager)), |
76 delay_peak_detector_(delay_peak_detector), | 83 delay_peak_detector_(std::move(deps.delay_peak_detector)), |
77 dtmf_buffer_(dtmf_buffer), | 84 dtmf_buffer_(std::move(deps.dtmf_buffer)), |
78 dtmf_tone_generator_(dtmf_tone_generator), | 85 dtmf_tone_generator_(std::move(deps.dtmf_tone_generator)), |
79 packet_buffer_(packet_buffer), | 86 packet_buffer_(std::move(deps.packet_buffer)), |
80 payload_splitter_(payload_splitter), | 87 payload_splitter_(std::move(deps.payload_splitter)), |
81 timestamp_scaler_(timestamp_scaler), | 88 timestamp_scaler_(std::move(deps.timestamp_scaler)), |
82 vad_(new PostDecodeVad()), | 89 vad_(new PostDecodeVad()), |
83 expand_factory_(expand_factory), | 90 expand_factory_(std::move(deps.expand_factory)), |
84 accelerate_factory_(accelerate_factory), | 91 accelerate_factory_(std::move(deps.accelerate_factory)), |
85 preemptive_expand_factory_(preemptive_expand_factory), | 92 preemptive_expand_factory_(std::move(deps.preemptive_expand_factory)), |
86 last_mode_(kModeNormal), | 93 last_mode_(kModeNormal), |
87 decoded_buffer_length_(kMaxFrameSize), | 94 decoded_buffer_length_(kMaxFrameSize), |
88 decoded_buffer_(new int16_t[decoded_buffer_length_]), | 95 decoded_buffer_(new int16_t[decoded_buffer_length_]), |
89 playout_timestamp_(0), | 96 playout_timestamp_(0), |
90 new_codec_(false), | 97 new_codec_(false), |
91 timestamp_(0), | 98 timestamp_(0), |
92 reset_decoder_(false), | 99 reset_decoder_(false), |
93 current_rtp_payload_type_(0xFF), // Invalid RTP payload type. | 100 current_rtp_payload_type_(0xFF), // Invalid RTP payload type. |
94 current_cng_rtp_payload_type_(0xFF), // Invalid RTP payload type. | 101 current_cng_rtp_payload_type_(0xFF), // Invalid RTP payload type. |
95 ssrc_(0), | 102 ssrc_(0), |
96 first_packet_(true), | 103 first_packet_(true), |
97 error_code_(0), | 104 error_code_(0), |
98 decoder_error_code_(0), | 105 decoder_error_code_(0), |
99 background_noise_mode_(config.background_noise_mode), | 106 background_noise_mode_(config.background_noise_mode), |
100 playout_mode_(config.playout_mode), | 107 playout_mode_(config.playout_mode), |
101 enable_fast_accelerate_(config.enable_fast_accelerate), | 108 enable_fast_accelerate_(config.enable_fast_accelerate), |
102 nack_enabled_(false) { | 109 nack_enabled_(false) { |
103 LOG(LS_INFO) << "NetEq config: " << config.ToString(); | 110 LOG(LS_INFO) << "NetEq config: " << config.ToString(); |
104 int fs = config.sample_rate_hz; | 111 int fs = config.sample_rate_hz; |
105 if (fs != 8000 && fs != 16000 && fs != 32000 && fs != 48000) { | 112 if (fs != 8000 && fs != 16000 && fs != 32000 && fs != 48000) { |
106 LOG(LS_ERROR) << "Sample rate " << fs << " Hz not supported. " << | 113 LOG(LS_ERROR) << "Sample rate " << fs << " Hz not supported. " << |
107 "Changing to 8000 Hz."; | 114 "Changing to 8000 Hz."; |
108 fs = 8000; | 115 fs = 8000; |
109 } | 116 } |
| 117 delay_manager_->SetMaximumDelay(config.max_delay_ms); |
110 fs_hz_ = fs; | 118 fs_hz_ = fs; |
111 fs_mult_ = fs / 8000; | 119 fs_mult_ = fs / 8000; |
112 last_output_sample_rate_hz_ = fs; | 120 last_output_sample_rate_hz_ = fs; |
113 output_size_samples_ = static_cast<size_t>(kOutputSizeMs * 8 * fs_mult_); | 121 output_size_samples_ = static_cast<size_t>(kOutputSizeMs * 8 * fs_mult_); |
114 decoder_frame_length_ = 3 * output_size_samples_; | 122 decoder_frame_length_ = 3 * output_size_samples_; |
115 WebRtcSpl_Init(); | 123 WebRtcSpl_Init(); |
116 if (create_components) { | 124 if (create_components) { |
117 SetSampleRateAndChannels(fs, 1); // Default is 1 channel. | 125 SetSampleRateAndChannels(fs, 1); // Default is 1 channel. |
118 } | 126 } |
119 RTC_DCHECK(!vad_->enabled()); | 127 RTC_DCHECK(!vad_->enabled()); |
(...skipping 1985 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2105 | 2113 |
2106 void NetEqImpl::CreateDecisionLogic() { | 2114 void NetEqImpl::CreateDecisionLogic() { |
2107 decision_logic_.reset(DecisionLogic::Create(fs_hz_, output_size_samples_, | 2115 decision_logic_.reset(DecisionLogic::Create(fs_hz_, output_size_samples_, |
2108 playout_mode_, | 2116 playout_mode_, |
2109 decoder_database_.get(), | 2117 decoder_database_.get(), |
2110 *packet_buffer_.get(), | 2118 *packet_buffer_.get(), |
2111 delay_manager_.get(), | 2119 delay_manager_.get(), |
2112 buffer_level_filter_.get())); | 2120 buffer_level_filter_.get())); |
2113 } | 2121 } |
2114 } // namespace webrtc | 2122 } // namespace webrtc |
OLD | NEW |