OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2010 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2010 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 } | 147 } |
148 bool vad = false; | 148 bool vad = false; |
149 bool codec_fec = false; | 149 bool codec_fec = false; |
150 int max_encoding_bandwidth = 0; | 150 int max_encoding_bandwidth = 0; |
151 bool opus_dtx = false; | 151 bool opus_dtx = false; |
152 int cn8_type = 13; | 152 int cn8_type = 13; |
153 int cn16_type = 105; | 153 int cn16_type = 105; |
154 int associate_send_channel = -1; | 154 int associate_send_channel = -1; |
155 std::vector<webrtc::CodecInst> recv_codecs; | 155 std::vector<webrtc::CodecInst> recv_codecs; |
156 webrtc::CodecInst send_codec; | 156 webrtc::CodecInst send_codec; |
157 int neteq_capacity = -1; | 157 size_t neteq_capacity = 0; |
158 bool neteq_fast_accelerate = false; | 158 bool neteq_fast_accelerate = false; |
159 }; | 159 }; |
160 | 160 |
161 FakeWebRtcVoiceEngine() { | 161 FakeWebRtcVoiceEngine() { |
162 memset(&agc_config_, 0, sizeof(agc_config_)); | 162 memset(&agc_config_, 0, sizeof(agc_config_)); |
163 } | 163 } |
164 ~FakeWebRtcVoiceEngine() override { | 164 ~FakeWebRtcVoiceEngine() override { |
165 RTC_CHECK(channels_.empty()); | 165 RTC_CHECK(channels_.empty()); |
166 } | 166 } |
167 | 167 |
(...skipping 15 matching lines...) Expand all Loading... |
183 return channels_[channel]->max_encoding_bandwidth; | 183 return channels_[channel]->max_encoding_bandwidth; |
184 } | 184 } |
185 int GetSendCNPayloadType(int channel, bool wideband) { | 185 int GetSendCNPayloadType(int channel, bool wideband) { |
186 return (wideband) ? | 186 return (wideband) ? |
187 channels_[channel]->cn16_type : | 187 channels_[channel]->cn16_type : |
188 channels_[channel]->cn8_type; | 188 channels_[channel]->cn8_type; |
189 } | 189 } |
190 void set_fail_create_channel(bool fail_create_channel) { | 190 void set_fail_create_channel(bool fail_create_channel) { |
191 fail_create_channel_ = fail_create_channel; | 191 fail_create_channel_ = fail_create_channel; |
192 } | 192 } |
193 int AddChannel(const webrtc::Config& config) { | |
194 if (fail_create_channel_) { | |
195 return -1; | |
196 } | |
197 Channel* ch = new Channel(); | |
198 auto db = webrtc::acm2::RentACodec::Database(); | |
199 ch->recv_codecs.assign(db.begin(), db.end()); | |
200 if (config.Get<webrtc::NetEqCapacityConfig>().enabled) { | |
201 ch->neteq_capacity = config.Get<webrtc::NetEqCapacityConfig>().capacity; | |
202 } | |
203 ch->neteq_fast_accelerate = | |
204 config.Get<webrtc::NetEqFastAccelerate>().enabled; | |
205 channels_[++last_channel_] = ch; | |
206 return last_channel_; | |
207 } | |
208 | 193 |
209 int GetNumSetSendCodecs() const { return num_set_send_codecs_; } | 194 int GetNumSetSendCodecs() const { return num_set_send_codecs_; } |
210 | 195 |
211 int GetAssociateSendChannel(int channel) { | 196 int GetAssociateSendChannel(int channel) { |
212 return channels_[channel]->associate_send_channel; | 197 return channels_[channel]->associate_send_channel; |
213 } | 198 } |
214 | 199 |
215 WEBRTC_STUB(Release, ()); | 200 WEBRTC_STUB(Release, ()); |
216 | 201 |
217 // webrtc::VoEBase | 202 // webrtc::VoEBase |
(...skipping 12 matching lines...) Expand all Loading... |
230 inited_ = false; | 215 inited_ = false; |
231 return 0; | 216 return 0; |
232 } | 217 } |
233 webrtc::AudioProcessing* audio_processing() override { | 218 webrtc::AudioProcessing* audio_processing() override { |
234 return &audio_processing_; | 219 return &audio_processing_; |
235 } | 220 } |
236 webrtc::AudioDeviceModule* audio_device_module() override { | 221 webrtc::AudioDeviceModule* audio_device_module() override { |
237 return nullptr; | 222 return nullptr; |
238 } | 223 } |
239 WEBRTC_FUNC(CreateChannel, ()) { | 224 WEBRTC_FUNC(CreateChannel, ()) { |
240 webrtc::Config empty_config; | 225 return CreateChannel(webrtc::VoEBase::ChannelConfig()); |
241 return AddChannel(empty_config); | |
242 } | 226 } |
243 WEBRTC_FUNC(CreateChannel, (const webrtc::Config& config)) { | 227 WEBRTC_FUNC(CreateChannel, (const webrtc::VoEBase::ChannelConfig& config)) { |
244 return AddChannel(config); | 228 if (fail_create_channel_) { |
| 229 return -1; |
| 230 } |
| 231 Channel* ch = new Channel(); |
| 232 auto db = webrtc::acm2::RentACodec::Database(); |
| 233 ch->recv_codecs.assign(db.begin(), db.end()); |
| 234 ch->neteq_capacity = config.acm_config.neteq_config.max_packets_in_buffer; |
| 235 ch->neteq_fast_accelerate = |
| 236 config.acm_config.neteq_config.enable_fast_accelerate; |
| 237 channels_[++last_channel_] = ch; |
| 238 return last_channel_; |
245 } | 239 } |
246 WEBRTC_FUNC(DeleteChannel, (int channel)) { | 240 WEBRTC_FUNC(DeleteChannel, (int channel)) { |
247 WEBRTC_CHECK_CHANNEL(channel); | 241 WEBRTC_CHECK_CHANNEL(channel); |
248 for (const auto& ch : channels_) { | 242 for (const auto& ch : channels_) { |
249 if (ch.second->associate_send_channel == channel) { | 243 if (ch.second->associate_send_channel == channel) { |
250 ch.second->associate_send_channel = -1; | 244 ch.second->associate_send_channel = -1; |
251 } | 245 } |
252 } | 246 } |
253 delete channels_[channel]; | 247 delete channels_[channel]; |
254 channels_.erase(channel); | 248 channels_.erase(channel); |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 } | 534 } |
541 bool IsHighPassFilterEnabled() override { | 535 bool IsHighPassFilterEnabled() override { |
542 return highpass_filter_enabled_; | 536 return highpass_filter_enabled_; |
543 } | 537 } |
544 bool IsStereoChannelSwappingEnabled() override { | 538 bool IsStereoChannelSwappingEnabled() override { |
545 return stereo_swapping_enabled_; | 539 return stereo_swapping_enabled_; |
546 } | 540 } |
547 void EnableStereoChannelSwapping(bool enable) override { | 541 void EnableStereoChannelSwapping(bool enable) override { |
548 stereo_swapping_enabled_ = enable; | 542 stereo_swapping_enabled_ = enable; |
549 } | 543 } |
550 int GetNetEqCapacity() const { | 544 size_t GetNetEqCapacity() const { |
551 auto ch = channels_.find(last_channel_); | 545 auto ch = channels_.find(last_channel_); |
552 ASSERT(ch != channels_.end()); | 546 ASSERT(ch != channels_.end()); |
553 return ch->second->neteq_capacity; | 547 return ch->second->neteq_capacity; |
554 } | 548 } |
555 bool GetNetEqFastAccelerate() const { | 549 bool GetNetEqFastAccelerate() const { |
556 auto ch = channels_.find(last_channel_); | 550 auto ch = channels_.find(last_channel_); |
557 ASSERT(ch != channels_.end()); | 551 ASSERT(ch != channels_.end()); |
558 return ch->second->neteq_fast_accelerate; | 552 return ch->second->neteq_fast_accelerate; |
559 } | 553 } |
560 | 554 |
(...skipping 15 matching lines...) Expand all Loading... |
576 webrtc::AecmModes aecm_mode_ = webrtc::kAecmSpeakerphone; | 570 webrtc::AecmModes aecm_mode_ = webrtc::kAecmSpeakerphone; |
577 webrtc::NsModes ns_mode_ = webrtc::kNsDefault; | 571 webrtc::NsModes ns_mode_ = webrtc::kNsDefault; |
578 webrtc::AgcModes agc_mode_ = webrtc::kAgcDefault; | 572 webrtc::AgcModes agc_mode_ = webrtc::kAgcDefault; |
579 webrtc::AgcConfig agc_config_; | 573 webrtc::AgcConfig agc_config_; |
580 FakeAudioProcessing audio_processing_; | 574 FakeAudioProcessing audio_processing_; |
581 }; | 575 }; |
582 | 576 |
583 } // namespace cricket | 577 } // namespace cricket |
584 | 578 |
585 #endif // WEBRTC_MEDIA_ENGINE_FAKEWEBRTCVOICEENGINE_H_ | 579 #endif // WEBRTC_MEDIA_ENGINE_FAKEWEBRTCVOICEENGINE_H_ |
OLD | NEW |