| OLD | NEW |
| 1 /* | 1 /* |
| 2 * libjingle | 2 * libjingle |
| 3 * Copyright 2010 Google Inc. | 3 * Copyright 2010 Google Inc. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
| 9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 | 27 |
| 28 #ifndef TALK_SESSION_PHONE_FAKEWEBRTCVOICEENGINE_H_ | 28 #ifndef TALK_SESSION_PHONE_FAKEWEBRTCVOICEENGINE_H_ |
| 29 #define TALK_SESSION_PHONE_FAKEWEBRTCVOICEENGINE_H_ | 29 #define TALK_SESSION_PHONE_FAKEWEBRTCVOICEENGINE_H_ |
| 30 | 30 |
| 31 #include <list> | 31 #include <list> |
| 32 #include <map> | 32 #include <map> |
| 33 #include <vector> | 33 #include <vector> |
| 34 | 34 |
| 35 #include "talk/media/base/codec.h" | 35 #include "talk/media/base/codec.h" |
| 36 #include "talk/media/base/rtputils.h" | 36 #include "talk/media/base/rtputils.h" |
| 37 #include "talk/media/base/voiceprocessor.h" | |
| 38 #include "talk/media/webrtc/fakewebrtccommon.h" | 37 #include "talk/media/webrtc/fakewebrtccommon.h" |
| 39 #include "talk/media/webrtc/webrtcvoe.h" | 38 #include "talk/media/webrtc/webrtcvoe.h" |
| 40 #include "webrtc/base/basictypes.h" | 39 #include "webrtc/base/basictypes.h" |
| 41 #include "webrtc/base/checks.h" | 40 #include "webrtc/base/checks.h" |
| 42 #include "webrtc/base/gunit.h" | 41 #include "webrtc/base/gunit.h" |
| 43 #include "webrtc/base/stringutils.h" | 42 #include "webrtc/base/stringutils.h" |
| 44 #include "webrtc/config.h" | 43 #include "webrtc/config.h" |
| 45 #include "webrtc/modules/audio_processing/include/audio_processing.h" | 44 #include "webrtc/modules/audio_processing/include/audio_processing.h" |
| 46 | 45 |
| 47 namespace cricket { | 46 namespace cricket { |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 return experimental_ns_enabled_; | 179 return experimental_ns_enabled_; |
| 181 } | 180 } |
| 182 | 181 |
| 183 private: | 182 private: |
| 184 bool experimental_ns_enabled_; | 183 bool experimental_ns_enabled_; |
| 185 }; | 184 }; |
| 186 | 185 |
| 187 class FakeWebRtcVoiceEngine | 186 class FakeWebRtcVoiceEngine |
| 188 : public webrtc::VoEAudioProcessing, | 187 : public webrtc::VoEAudioProcessing, |
| 189 public webrtc::VoEBase, public webrtc::VoECodec, public webrtc::VoEDtmf, | 188 public webrtc::VoEBase, public webrtc::VoECodec, public webrtc::VoEDtmf, |
| 190 public webrtc::VoEHardware, | 189 public webrtc::VoEHardware, public webrtc::VoENetEqStats, |
| 191 public webrtc::VoEExternalMedia, public webrtc::VoENetEqStats, | |
| 192 public webrtc::VoENetwork, public webrtc::VoERTP_RTCP, | 190 public webrtc::VoENetwork, public webrtc::VoERTP_RTCP, |
| 193 public webrtc::VoEVideoSync, public webrtc::VoEVolumeControl { | 191 public webrtc::VoEVideoSync, public webrtc::VoEVolumeControl { |
| 194 public: | 192 public: |
| 195 struct DtmfInfo { | 193 struct DtmfInfo { |
| 196 DtmfInfo() | 194 DtmfInfo() |
| 197 : dtmf_event_code(-1), | 195 : dtmf_event_code(-1), |
| 198 dtmf_out_of_band(false), | 196 dtmf_out_of_band(false), |
| 199 dtmf_length_ms(-1) {} | 197 dtmf_length_ms(-1) {} |
| 200 int dtmf_event_code; | 198 int dtmf_event_code; |
| 201 bool dtmf_out_of_band; | 199 bool dtmf_out_of_band; |
| 202 int dtmf_length_ms; | 200 int dtmf_length_ms; |
| 203 }; | 201 }; |
| 204 struct Channel { | 202 struct Channel { |
| 205 explicit Channel() | 203 explicit Channel() |
| 206 : external_transport(false), | 204 : external_transport(false), |
| 207 send(false), | 205 send(false), |
| 208 playout(false), | 206 playout(false), |
| 209 volume_scale(1.0), | 207 volume_scale(1.0), |
| 210 volume_pan_left(1.0), | 208 volume_pan_left(1.0), |
| 211 volume_pan_right(1.0), | 209 volume_pan_right(1.0), |
| 212 vad(false), | 210 vad(false), |
| 213 codec_fec(false), | 211 codec_fec(false), |
| 214 max_encoding_bandwidth(0), | 212 max_encoding_bandwidth(0), |
| 215 opus_dtx(false), | 213 opus_dtx(false), |
| 216 red(false), | 214 red(false), |
| 217 nack(false), | 215 nack(false), |
| 218 media_processor_registered(false), | |
| 219 rx_agc_enabled(false), | 216 rx_agc_enabled(false), |
| 220 rx_agc_mode(webrtc::kAgcDefault), | 217 rx_agc_mode(webrtc::kAgcDefault), |
| 221 cn8_type(13), | 218 cn8_type(13), |
| 222 cn16_type(105), | 219 cn16_type(105), |
| 223 dtmf_type(106), | 220 dtmf_type(106), |
| 224 red_type(117), | 221 red_type(117), |
| 225 nack_max_packets(0), | 222 nack_max_packets(0), |
| 226 send_ssrc(0), | 223 send_ssrc(0), |
| 227 send_audio_level_ext_(-1), | 224 send_audio_level_ext_(-1), |
| 228 receive_audio_level_ext_(-1), | 225 receive_audio_level_ext_(-1), |
| (...skipping 10 matching lines...) Expand all Loading... |
| 239 bool playout; | 236 bool playout; |
| 240 float volume_scale; | 237 float volume_scale; |
| 241 float volume_pan_left; | 238 float volume_pan_left; |
| 242 float volume_pan_right; | 239 float volume_pan_right; |
| 243 bool vad; | 240 bool vad; |
| 244 bool codec_fec; | 241 bool codec_fec; |
| 245 int max_encoding_bandwidth; | 242 int max_encoding_bandwidth; |
| 246 bool opus_dtx; | 243 bool opus_dtx; |
| 247 bool red; | 244 bool red; |
| 248 bool nack; | 245 bool nack; |
| 249 bool media_processor_registered; | |
| 250 bool rx_agc_enabled; | 246 bool rx_agc_enabled; |
| 251 webrtc::AgcModes rx_agc_mode; | 247 webrtc::AgcModes rx_agc_mode; |
| 252 webrtc::AgcConfig rx_agc_config; | 248 webrtc::AgcConfig rx_agc_config; |
| 253 int cn8_type; | 249 int cn8_type; |
| 254 int cn16_type; | 250 int cn16_type; |
| 255 int dtmf_type; | 251 int dtmf_type; |
| 256 int red_type; | 252 int red_type; |
| 257 int nack_max_packets; | 253 int nack_max_packets; |
| 258 uint32 send_ssrc; | 254 uint32 send_ssrc; |
| 259 int send_audio_level_ext_; | 255 int send_audio_level_ext_; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 287 stereo_swapping_enabled_(false), | 283 stereo_swapping_enabled_(false), |
| 288 typing_detection_enabled_(false), | 284 typing_detection_enabled_(false), |
| 289 ec_mode_(webrtc::kEcDefault), | 285 ec_mode_(webrtc::kEcDefault), |
| 290 aecm_mode_(webrtc::kAecmSpeakerphone), | 286 aecm_mode_(webrtc::kAecmSpeakerphone), |
| 291 ns_mode_(webrtc::kNsDefault), | 287 ns_mode_(webrtc::kNsDefault), |
| 292 agc_mode_(webrtc::kAgcDefault), | 288 agc_mode_(webrtc::kAgcDefault), |
| 293 observer_(NULL), | 289 observer_(NULL), |
| 294 playout_fail_channel_(-1), | 290 playout_fail_channel_(-1), |
| 295 send_fail_channel_(-1), | 291 send_fail_channel_(-1), |
| 296 recording_sample_rate_(-1), | 292 recording_sample_rate_(-1), |
| 297 playout_sample_rate_(-1), | 293 playout_sample_rate_(-1) { |
| 298 media_processor_(NULL) { | |
| 299 memset(&agc_config_, 0, sizeof(agc_config_)); | 294 memset(&agc_config_, 0, sizeof(agc_config_)); |
| 300 } | 295 } |
| 301 ~FakeWebRtcVoiceEngine() { | 296 ~FakeWebRtcVoiceEngine() { |
| 302 // Ought to have all been deleted by the WebRtcVoiceMediaChannel | 297 // Ought to have all been deleted by the WebRtcVoiceMediaChannel |
| 303 // destructors, but just in case ... | 298 // destructors, but just in case ... |
| 304 for (std::map<int, Channel*>::const_iterator i = channels_.begin(); | 299 for (std::map<int, Channel*>::const_iterator i = channels_.begin(); |
| 305 i != channels_.end(); ++i) { | 300 i != channels_.end(); ++i) { |
| 306 delete i->second; | 301 delete i->second; |
| 307 } | 302 } |
| 308 } | 303 } |
| 309 | 304 |
| 310 bool IsExternalMediaProcessorRegistered() const { | |
| 311 return media_processor_ != NULL; | |
| 312 } | |
| 313 bool IsInited() const { return inited_; } | 305 bool IsInited() const { return inited_; } |
| 314 int GetLastChannel() const { return last_channel_; } | 306 int GetLastChannel() const { return last_channel_; } |
| 315 int GetChannelFromLocalSsrc(uint32 local_ssrc) const { | 307 int GetChannelFromLocalSsrc(uint32 local_ssrc) const { |
| 316 for (std::map<int, Channel*>::const_iterator iter = channels_.begin(); | 308 for (std::map<int, Channel*>::const_iterator iter = channels_.begin(); |
| 317 iter != channels_.end(); ++iter) { | 309 iter != channels_.end(); ++iter) { |
| 318 if (local_ssrc == iter->second->send_ssrc) | 310 if (local_ssrc == iter->second->send_ssrc) |
| 319 return iter->first; | 311 return iter->first; |
| 320 } | 312 } |
| 321 return -1; | 313 return -1; |
| 322 } | 314 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 } | 373 } |
| 382 void set_playout_fail_channel(int channel) { | 374 void set_playout_fail_channel(int channel) { |
| 383 playout_fail_channel_ = channel; | 375 playout_fail_channel_ = channel; |
| 384 } | 376 } |
| 385 void set_send_fail_channel(int channel) { | 377 void set_send_fail_channel(int channel) { |
| 386 send_fail_channel_ = channel; | 378 send_fail_channel_ = channel; |
| 387 } | 379 } |
| 388 void set_fail_create_channel(bool fail_create_channel) { | 380 void set_fail_create_channel(bool fail_create_channel) { |
| 389 fail_create_channel_ = fail_create_channel; | 381 fail_create_channel_ = fail_create_channel; |
| 390 } | 382 } |
| 391 void TriggerProcessPacket(MediaProcessorDirection direction) { | |
| 392 webrtc::ProcessingTypes pt = | |
| 393 (direction == cricket::MPD_TX) ? | |
| 394 webrtc::kRecordingPerChannel : webrtc::kPlaybackAllChannelsMixed; | |
| 395 if (media_processor_ != NULL) { | |
| 396 media_processor_->Process(0, | |
| 397 pt, | |
| 398 NULL, | |
| 399 0, | |
| 400 0, | |
| 401 true); | |
| 402 } | |
| 403 } | |
| 404 int AddChannel(const webrtc::Config& config) { | 383 int AddChannel(const webrtc::Config& config) { |
| 405 if (fail_create_channel_) { | 384 if (fail_create_channel_) { |
| 406 return -1; | 385 return -1; |
| 407 } | 386 } |
| 408 Channel* ch = new Channel(); | 387 Channel* ch = new Channel(); |
| 409 for (int i = 0; i < NumOfCodecs(); ++i) { | 388 for (int i = 0; i < NumOfCodecs(); ++i) { |
| 410 webrtc::CodecInst codec; | 389 webrtc::CodecInst codec; |
| 411 GetCodec(i, codec); | 390 GetCodec(i, codec); |
| 412 ch->recv_codecs.push_back(codec); | 391 ch->recv_codecs.push_back(codec); |
| 413 } | 392 } |
| (...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1094 } | 1073 } |
| 1095 bool WasSendTelephoneEventCalled(int channel, int event_code, int length_ms) { | 1074 bool WasSendTelephoneEventCalled(int channel, int event_code, int length_ms) { |
| 1096 return (channels_[channel]->dtmf_info.dtmf_event_code == event_code && | 1075 return (channels_[channel]->dtmf_info.dtmf_event_code == event_code && |
| 1097 channels_[channel]->dtmf_info.dtmf_out_of_band == true && | 1076 channels_[channel]->dtmf_info.dtmf_out_of_band == true && |
| 1098 channels_[channel]->dtmf_info.dtmf_length_ms == length_ms); | 1077 channels_[channel]->dtmf_info.dtmf_length_ms == length_ms); |
| 1099 } | 1078 } |
| 1100 bool WasPlayDtmfToneCalled(int event_code, int length_ms) { | 1079 bool WasPlayDtmfToneCalled(int event_code, int length_ms) { |
| 1101 return (dtmf_info_.dtmf_event_code == event_code && | 1080 return (dtmf_info_.dtmf_event_code == event_code && |
| 1102 dtmf_info_.dtmf_length_ms == length_ms); | 1081 dtmf_info_.dtmf_length_ms == length_ms); |
| 1103 } | 1082 } |
| 1104 // webrtc::VoEExternalMedia | |
| 1105 WEBRTC_FUNC(RegisterExternalMediaProcessing, | |
| 1106 (int channel, webrtc::ProcessingTypes type, | |
| 1107 webrtc::VoEMediaProcess& processObject)) { | |
| 1108 WEBRTC_CHECK_CHANNEL(channel); | |
| 1109 if (channels_[channel]->media_processor_registered) { | |
| 1110 return -1; | |
| 1111 } | |
| 1112 channels_[channel]->media_processor_registered = true; | |
| 1113 media_processor_ = &processObject; | |
| 1114 return 0; | |
| 1115 } | |
| 1116 WEBRTC_FUNC(DeRegisterExternalMediaProcessing, | |
| 1117 (int channel, webrtc::ProcessingTypes type)) { | |
| 1118 WEBRTC_CHECK_CHANNEL(channel); | |
| 1119 if (!channels_[channel]->media_processor_registered) { | |
| 1120 return -1; | |
| 1121 } | |
| 1122 channels_[channel]->media_processor_registered = false; | |
| 1123 media_processor_ = NULL; | |
| 1124 return 0; | |
| 1125 } | |
| 1126 WEBRTC_STUB(GetAudioFrame, (int channel, int desired_sample_rate_hz, | |
| 1127 webrtc::AudioFrame* frame)); | |
| 1128 WEBRTC_STUB(SetExternalMixing, (int channel, bool enable)); | |
| 1129 int GetNetEqCapacity() const { | 1083 int GetNetEqCapacity() const { |
| 1130 auto ch = channels_.find(last_channel_); | 1084 auto ch = channels_.find(last_channel_); |
| 1131 ASSERT(ch != channels_.end()); | 1085 ASSERT(ch != channels_.end()); |
| 1132 return ch->second->neteq_capacity; | 1086 return ch->second->neteq_capacity; |
| 1133 } | 1087 } |
| 1134 bool GetNetEqFastAccelerate() const { | 1088 bool GetNetEqFastAccelerate() const { |
| 1135 auto ch = channels_.find(last_channel_); | 1089 auto ch = channels_.find(last_channel_); |
| 1136 ASSERT(ch != channels_.end()); | 1090 ASSERT(ch != channels_.end()); |
| 1137 return ch->second->neteq_fast_accelerate; | 1091 return ch->second->neteq_fast_accelerate; |
| 1138 } | 1092 } |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1192 webrtc::AecmModes aecm_mode_; | 1146 webrtc::AecmModes aecm_mode_; |
| 1193 webrtc::NsModes ns_mode_; | 1147 webrtc::NsModes ns_mode_; |
| 1194 webrtc::AgcModes agc_mode_; | 1148 webrtc::AgcModes agc_mode_; |
| 1195 webrtc::AgcConfig agc_config_; | 1149 webrtc::AgcConfig agc_config_; |
| 1196 webrtc::VoiceEngineObserver* observer_; | 1150 webrtc::VoiceEngineObserver* observer_; |
| 1197 int playout_fail_channel_; | 1151 int playout_fail_channel_; |
| 1198 int send_fail_channel_; | 1152 int send_fail_channel_; |
| 1199 int recording_sample_rate_; | 1153 int recording_sample_rate_; |
| 1200 int playout_sample_rate_; | 1154 int playout_sample_rate_; |
| 1201 DtmfInfo dtmf_info_; | 1155 DtmfInfo dtmf_info_; |
| 1202 webrtc::VoEMediaProcess* media_processor_; | |
| 1203 FakeAudioProcessing audio_processing_; | 1156 FakeAudioProcessing audio_processing_; |
| 1204 }; | 1157 }; |
| 1205 | 1158 |
| 1206 #undef WEBRTC_CHECK_HEADER_EXTENSION_ID | 1159 #undef WEBRTC_CHECK_HEADER_EXTENSION_ID |
| 1207 | 1160 |
| 1208 } // namespace cricket | 1161 } // namespace cricket |
| 1209 | 1162 |
| 1210 #endif // TALK_SESSION_PHONE_FAKEWEBRTCVOICEENGINE_H_ | 1163 #endif // TALK_SESSION_PHONE_FAKEWEBRTCVOICEENGINE_H_ |
| OLD | NEW |