| 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 class FakeWebRtcVoiceEngine | 121 class FakeWebRtcVoiceEngine |
| 122 : public webrtc::VoEAudioProcessing, | 122 : public webrtc::VoEAudioProcessing, |
| 123 public webrtc::VoEBase, public webrtc::VoECodec, | 123 public webrtc::VoEBase, public webrtc::VoECodec, |
| 124 public webrtc::VoEHardware, | 124 public webrtc::VoEHardware, |
| 125 public webrtc::VoEVolumeControl { | 125 public webrtc::VoEVolumeControl { |
| 126 public: | 126 public: |
| 127 struct Channel { | 127 struct Channel { |
| 128 Channel() { | 128 Channel() { |
| 129 memset(&send_codec, 0, sizeof(send_codec)); | 129 memset(&send_codec, 0, sizeof(send_codec)); |
| 130 } | 130 } |
| 131 bool playout = false; | |
| 132 bool vad = false; | 131 bool vad = false; |
| 133 bool codec_fec = false; | 132 bool codec_fec = false; |
| 134 int max_encoding_bandwidth = 0; | 133 int max_encoding_bandwidth = 0; |
| 135 bool opus_dtx = false; | 134 bool opus_dtx = false; |
| 136 int cn8_type = 13; | 135 int cn8_type = 13; |
| 137 int cn16_type = 105; | 136 int cn16_type = 105; |
| 138 int associate_send_channel = -1; | 137 int associate_send_channel = -1; |
| 139 std::vector<webrtc::CodecInst> recv_codecs; | 138 std::vector<webrtc::CodecInst> recv_codecs; |
| 140 webrtc::CodecInst send_codec; | 139 webrtc::CodecInst send_codec; |
| 141 int neteq_capacity = -1; | 140 int neteq_capacity = -1; |
| 142 bool neteq_fast_accelerate = false; | 141 bool neteq_fast_accelerate = false; |
| 143 }; | 142 }; |
| 144 | 143 |
| 145 FakeWebRtcVoiceEngine() { | 144 FakeWebRtcVoiceEngine() { |
| 146 memset(&agc_config_, 0, sizeof(agc_config_)); | 145 memset(&agc_config_, 0, sizeof(agc_config_)); |
| 147 } | 146 } |
| 148 ~FakeWebRtcVoiceEngine() override { | 147 ~FakeWebRtcVoiceEngine() override { |
| 149 RTC_CHECK(channels_.empty()); | 148 RTC_CHECK(channels_.empty()); |
| 150 } | 149 } |
| 151 | 150 |
| 152 bool ec_metrics_enabled() const { return ec_metrics_enabled_; } | 151 bool ec_metrics_enabled() const { return ec_metrics_enabled_; } |
| 153 | 152 |
| 154 bool IsInited() const { return inited_; } | 153 bool IsInited() const { return inited_; } |
| 155 int GetLastChannel() const { return last_channel_; } | 154 int GetLastChannel() const { return last_channel_; } |
| 156 int GetNumChannels() const { return static_cast<int>(channels_.size()); } | 155 int GetNumChannels() const { return static_cast<int>(channels_.size()); } |
| 157 bool GetPlayout(int channel) { | |
| 158 return channels_[channel]->playout; | |
| 159 } | |
| 160 bool GetVAD(int channel) { | 156 bool GetVAD(int channel) { |
| 161 return channels_[channel]->vad; | 157 return channels_[channel]->vad; |
| 162 } | 158 } |
| 163 bool GetOpusDtx(int channel) { | 159 bool GetOpusDtx(int channel) { |
| 164 return channels_[channel]->opus_dtx; | 160 return channels_[channel]->opus_dtx; |
| 165 } | 161 } |
| 166 bool GetCodecFEC(int channel) { | 162 bool GetCodecFEC(int channel) { |
| 167 return channels_[channel]->codec_fec; | 163 return channels_[channel]->codec_fec; |
| 168 } | 164 } |
| 169 int GetMaxEncodingBandwidth(int channel) { | 165 int GetMaxEncodingBandwidth(int channel) { |
| 170 return channels_[channel]->max_encoding_bandwidth; | 166 return channels_[channel]->max_encoding_bandwidth; |
| 171 } | 167 } |
| 172 int GetSendCNPayloadType(int channel, bool wideband) { | 168 int GetSendCNPayloadType(int channel, bool wideband) { |
| 173 return (wideband) ? | 169 return (wideband) ? |
| 174 channels_[channel]->cn16_type : | 170 channels_[channel]->cn16_type : |
| 175 channels_[channel]->cn8_type; | 171 channels_[channel]->cn8_type; |
| 176 } | 172 } |
| 177 void set_playout_fail_channel(int channel) { | |
| 178 playout_fail_channel_ = channel; | |
| 179 } | |
| 180 void set_fail_create_channel(bool fail_create_channel) { | 173 void set_fail_create_channel(bool fail_create_channel) { |
| 181 fail_create_channel_ = fail_create_channel; | 174 fail_create_channel_ = fail_create_channel; |
| 182 } | 175 } |
| 183 int AddChannel(const webrtc::Config& config) { | 176 int AddChannel(const webrtc::Config& config) { |
| 184 if (fail_create_channel_) { | 177 if (fail_create_channel_) { |
| 185 return -1; | 178 return -1; |
| 186 } | 179 } |
| 187 Channel* ch = new Channel(); | 180 Channel* ch = new Channel(); |
| 188 auto db = webrtc::acm2::RentACodec::Database(); | 181 auto db = webrtc::acm2::RentACodec::Database(); |
| 189 ch->recv_codecs.assign(db.begin(), db.end()); | 182 ch->recv_codecs.assign(db.begin(), db.end()); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 for (const auto& ch : channels_) { | 231 for (const auto& ch : channels_) { |
| 239 if (ch.second->associate_send_channel == channel) { | 232 if (ch.second->associate_send_channel == channel) { |
| 240 ch.second->associate_send_channel = -1; | 233 ch.second->associate_send_channel = -1; |
| 241 } | 234 } |
| 242 } | 235 } |
| 243 delete channels_[channel]; | 236 delete channels_[channel]; |
| 244 channels_.erase(channel); | 237 channels_.erase(channel); |
| 245 return 0; | 238 return 0; |
| 246 } | 239 } |
| 247 WEBRTC_STUB(StartReceive, (int channel)); | 240 WEBRTC_STUB(StartReceive, (int channel)); |
| 248 WEBRTC_FUNC(StartPlayout, (int channel)) { | 241 WEBRTC_STUB(StartPlayout, (int channel)); |
| 249 if (playout_fail_channel_ != channel) { | |
| 250 WEBRTC_CHECK_CHANNEL(channel); | |
| 251 channels_[channel]->playout = true; | |
| 252 return 0; | |
| 253 } else { | |
| 254 // When playout_fail_channel_ == channel, fail the StartPlayout on this | |
| 255 // channel. | |
| 256 return -1; | |
| 257 } | |
| 258 } | |
| 259 WEBRTC_STUB(StartSend, (int channel)); | 242 WEBRTC_STUB(StartSend, (int channel)); |
| 260 WEBRTC_STUB(StopReceive, (int channel)); | 243 WEBRTC_STUB(StopReceive, (int channel)); |
| 261 WEBRTC_FUNC(StopPlayout, (int channel)) { | 244 WEBRTC_STUB(StopPlayout, (int channel)); |
| 262 WEBRTC_CHECK_CHANNEL(channel); | |
| 263 channels_[channel]->playout = false; | |
| 264 return 0; | |
| 265 } | |
| 266 WEBRTC_STUB(StopSend, (int channel)); | 245 WEBRTC_STUB(StopSend, (int channel)); |
| 267 WEBRTC_STUB(GetVersion, (char version[1024])); | 246 WEBRTC_STUB(GetVersion, (char version[1024])); |
| 268 WEBRTC_STUB(LastError, ()); | 247 WEBRTC_STUB(LastError, ()); |
| 269 WEBRTC_FUNC(AssociateSendChannel, (int channel, | 248 WEBRTC_FUNC(AssociateSendChannel, (int channel, |
| 270 int accociate_send_channel)) { | 249 int accociate_send_channel)) { |
| 271 WEBRTC_CHECK_CHANNEL(channel); | 250 WEBRTC_CHECK_CHANNEL(channel); |
| 272 channels_[channel]->associate_send_channel = accociate_send_channel; | 251 channels_[channel]->associate_send_channel = accociate_send_channel; |
| 273 return 0; | 252 return 0; |
| 274 } | 253 } |
| 275 | 254 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 293 WEBRTC_CHECK_CHANNEL(channel); | 272 WEBRTC_CHECK_CHANNEL(channel); |
| 294 codec = channels_[channel]->send_codec; | 273 codec = channels_[channel]->send_codec; |
| 295 return 0; | 274 return 0; |
| 296 } | 275 } |
| 297 WEBRTC_STUB(SetBitRate, (int channel, int bitrate_bps)); | 276 WEBRTC_STUB(SetBitRate, (int channel, int bitrate_bps)); |
| 298 WEBRTC_STUB(GetRecCodec, (int channel, webrtc::CodecInst& codec)); | 277 WEBRTC_STUB(GetRecCodec, (int channel, webrtc::CodecInst& codec)); |
| 299 WEBRTC_FUNC(SetRecPayloadType, (int channel, | 278 WEBRTC_FUNC(SetRecPayloadType, (int channel, |
| 300 const webrtc::CodecInst& codec)) { | 279 const webrtc::CodecInst& codec)) { |
| 301 WEBRTC_CHECK_CHANNEL(channel); | 280 WEBRTC_CHECK_CHANNEL(channel); |
| 302 Channel* ch = channels_[channel]; | 281 Channel* ch = channels_[channel]; |
| 303 if (ch->playout) | |
| 304 return -1; // Channel is in use. | |
| 305 // Check if something else already has this slot. | 282 // Check if something else already has this slot. |
| 306 if (codec.pltype != -1) { | 283 if (codec.pltype != -1) { |
| 307 for (std::vector<webrtc::CodecInst>::iterator it = | 284 for (std::vector<webrtc::CodecInst>::iterator it = |
| 308 ch->recv_codecs.begin(); it != ch->recv_codecs.end(); ++it) { | 285 ch->recv_codecs.begin(); it != ch->recv_codecs.end(); ++it) { |
| 309 if (it->pltype == codec.pltype && | 286 if (it->pltype == codec.pltype && |
| 310 _stricmp(it->plname, codec.plname) != 0) { | 287 _stricmp(it->plname, codec.plname) != 0) { |
| 311 return -1; | 288 return -1; |
| 312 } | 289 } |
| 313 } | 290 } |
| 314 } | 291 } |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 bool ns_enabled_ = false; | 553 bool ns_enabled_ = false; |
| 577 bool agc_enabled_ = false; | 554 bool agc_enabled_ = false; |
| 578 bool highpass_filter_enabled_ = false; | 555 bool highpass_filter_enabled_ = false; |
| 579 bool stereo_swapping_enabled_ = false; | 556 bool stereo_swapping_enabled_ = false; |
| 580 bool typing_detection_enabled_ = false; | 557 bool typing_detection_enabled_ = false; |
| 581 webrtc::EcModes ec_mode_ = webrtc::kEcDefault; | 558 webrtc::EcModes ec_mode_ = webrtc::kEcDefault; |
| 582 webrtc::AecmModes aecm_mode_ = webrtc::kAecmSpeakerphone; | 559 webrtc::AecmModes aecm_mode_ = webrtc::kAecmSpeakerphone; |
| 583 webrtc::NsModes ns_mode_ = webrtc::kNsDefault; | 560 webrtc::NsModes ns_mode_ = webrtc::kNsDefault; |
| 584 webrtc::AgcModes agc_mode_ = webrtc::kAgcDefault; | 561 webrtc::AgcModes agc_mode_ = webrtc::kAgcDefault; |
| 585 webrtc::AgcConfig agc_config_; | 562 webrtc::AgcConfig agc_config_; |
| 586 int playout_fail_channel_ = -1; | |
| 587 FakeAudioProcessing audio_processing_; | 563 FakeAudioProcessing audio_processing_; |
| 588 }; | 564 }; |
| 589 | 565 |
| 590 } // namespace cricket | 566 } // namespace cricket |
| 591 | 567 |
| 592 #endif // WEBRTC_MEDIA_ENGINE_FAKEWEBRTCVOICEENGINE_H_ | 568 #endif // WEBRTC_MEDIA_ENGINE_FAKEWEBRTCVOICEENGINE_H_ |
| OLD | NEW |