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(new PacketBuffer(config.max_packets_in_buffer)), | |
67 payload_splitter(new PayloadSplitter), | |
68 timestamp_scaler(new TimestampScaler(*decoder_database.get())), | |
kwiberg-webrtc
2016/04/26 13:00:04
Just "*decoder_database" should do the same thing.
hlundin-webrtc
2016/04/26 13:20:38
Done.
| |
69 accelerate_factory(new AccelerateFactory), | |
70 expand_factory(new ExpandFactory), | |
71 preemptive_expand_factory(new PreemptiveExpandFactory) {} | |
72 | |
73 NetEqImpl::Dependencies::~Dependencies() = default; | |
74 | |
57 NetEqImpl::NetEqImpl(const NetEq::Config& config, | 75 NetEqImpl::NetEqImpl(const NetEq::Config& config, |
58 std::unique_ptr<TickTimer> tick_timer, | 76 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) | 77 bool create_components) |
72 : tick_timer_(std::move(tick_timer)), | 78 : tick_timer_(std::move(deps.tick_timer)), |
73 buffer_level_filter_(buffer_level_filter), | 79 buffer_level_filter_(std::move(deps.buffer_level_filter)), |
74 decoder_database_(decoder_database), | 80 decoder_database_(std::move(deps.decoder_database)), |
75 delay_manager_(delay_manager), | 81 delay_manager_(std::move(deps.delay_manager)), |
76 delay_peak_detector_(delay_peak_detector), | 82 delay_peak_detector_(std::move(deps.delay_peak_detector)), |
77 dtmf_buffer_(dtmf_buffer), | 83 dtmf_buffer_(std::move(deps.dtmf_buffer)), |
78 dtmf_tone_generator_(dtmf_tone_generator), | 84 dtmf_tone_generator_(std::move(deps.dtmf_tone_generator)), |
79 packet_buffer_(packet_buffer), | 85 packet_buffer_(std::move(deps.packet_buffer)), |
80 payload_splitter_(payload_splitter), | 86 payload_splitter_(std::move(deps.payload_splitter)), |
81 timestamp_scaler_(timestamp_scaler), | 87 timestamp_scaler_(std::move(deps.timestamp_scaler)), |
82 vad_(new PostDecodeVad()), | 88 vad_(new PostDecodeVad()), |
83 expand_factory_(expand_factory), | 89 expand_factory_(std::move(deps.expand_factory)), |
84 accelerate_factory_(accelerate_factory), | 90 accelerate_factory_(std::move(deps.accelerate_factory)), |
85 preemptive_expand_factory_(preemptive_expand_factory), | 91 preemptive_expand_factory_(std::move(deps.preemptive_expand_factory)), |
86 last_mode_(kModeNormal), | 92 last_mode_(kModeNormal), |
87 decoded_buffer_length_(kMaxFrameSize), | 93 decoded_buffer_length_(kMaxFrameSize), |
88 decoded_buffer_(new int16_t[decoded_buffer_length_]), | 94 decoded_buffer_(new int16_t[decoded_buffer_length_]), |
89 playout_timestamp_(0), | 95 playout_timestamp_(0), |
90 new_codec_(false), | 96 new_codec_(false), |
91 timestamp_(0), | 97 timestamp_(0), |
92 reset_decoder_(false), | 98 reset_decoder_(false), |
93 current_rtp_payload_type_(0xFF), // Invalid RTP payload type. | 99 current_rtp_payload_type_(0xFF), // Invalid RTP payload type. |
94 current_cng_rtp_payload_type_(0xFF), // Invalid RTP payload type. | 100 current_cng_rtp_payload_type_(0xFF), // Invalid RTP payload type. |
95 ssrc_(0), | 101 ssrc_(0), |
96 first_packet_(true), | 102 first_packet_(true), |
97 error_code_(0), | 103 error_code_(0), |
98 decoder_error_code_(0), | 104 decoder_error_code_(0), |
99 background_noise_mode_(config.background_noise_mode), | 105 background_noise_mode_(config.background_noise_mode), |
100 playout_mode_(config.playout_mode), | 106 playout_mode_(config.playout_mode), |
101 enable_fast_accelerate_(config.enable_fast_accelerate), | 107 enable_fast_accelerate_(config.enable_fast_accelerate), |
102 nack_enabled_(false) { | 108 nack_enabled_(false) { |
103 LOG(LS_INFO) << "NetEq config: " << config.ToString(); | 109 LOG(LS_INFO) << "NetEq config: " << config.ToString(); |
104 int fs = config.sample_rate_hz; | 110 int fs = config.sample_rate_hz; |
105 if (fs != 8000 && fs != 16000 && fs != 32000 && fs != 48000) { | 111 if (fs != 8000 && fs != 16000 && fs != 32000 && fs != 48000) { |
106 LOG(LS_ERROR) << "Sample rate " << fs << " Hz not supported. " << | 112 LOG(LS_ERROR) << "Sample rate " << fs << " Hz not supported. " << |
107 "Changing to 8000 Hz."; | 113 "Changing to 8000 Hz."; |
108 fs = 8000; | 114 fs = 8000; |
109 } | 115 } |
116 delay_manager_->SetMaximumDelay(config.max_delay_ms); | |
110 fs_hz_ = fs; | 117 fs_hz_ = fs; |
111 fs_mult_ = fs / 8000; | 118 fs_mult_ = fs / 8000; |
112 last_output_sample_rate_hz_ = fs; | 119 last_output_sample_rate_hz_ = fs; |
113 output_size_samples_ = static_cast<size_t>(kOutputSizeMs * 8 * fs_mult_); | 120 output_size_samples_ = static_cast<size_t>(kOutputSizeMs * 8 * fs_mult_); |
114 decoder_frame_length_ = 3 * output_size_samples_; | 121 decoder_frame_length_ = 3 * output_size_samples_; |
115 WebRtcSpl_Init(); | 122 WebRtcSpl_Init(); |
116 if (create_components) { | 123 if (create_components) { |
117 SetSampleRateAndChannels(fs, 1); // Default is 1 channel. | 124 SetSampleRateAndChannels(fs, 1); // Default is 1 channel. |
118 } | 125 } |
119 RTC_DCHECK(!vad_->enabled()); | 126 RTC_DCHECK(!vad_->enabled()); |
(...skipping 1986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2106 | 2113 |
2107 void NetEqImpl::CreateDecisionLogic() { | 2114 void NetEqImpl::CreateDecisionLogic() { |
2108 decision_logic_.reset(DecisionLogic::Create(fs_hz_, output_size_samples_, | 2115 decision_logic_.reset(DecisionLogic::Create(fs_hz_, output_size_samples_, |
2109 playout_mode_, | 2116 playout_mode_, |
2110 decoder_database_.get(), | 2117 decoder_database_.get(), |
2111 *packet_buffer_.get(), | 2118 *packet_buffer_.get(), |
2112 delay_manager_.get(), | 2119 delay_manager_.get(), |
2113 buffer_level_filter_.get())); | 2120 buffer_level_filter_.get())); |
2114 } | 2121 } |
2115 } // namespace webrtc | 2122 } // namespace webrtc |
OLD | NEW |