henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1 | /* |
| 2 | * libjingle |
| 3 | * Copyright 2010 Google Inc. |
| 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that the following conditions are met: |
| 7 | * |
| 8 | * 1. Redistributions of source code must retain the above copyright notice, |
| 9 | * this list of conditions and the following disclaimer. |
| 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
| 11 | * this list of conditions and the following disclaimer in the documentation |
| 12 | * and/or other materials provided with the distribution. |
| 13 | * 3. The name of the author may not be used to endorse or promote products |
| 14 | * derived from this software without specific prior written permission. |
| 15 | * |
| 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
| 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
| 19 | * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 20 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 21 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
| 22 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 23 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
| 24 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
| 25 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 | */ |
| 27 | |
| 28 | #ifndef TALK_SESSION_PHONE_FAKEWEBRTCVOICEENGINE_H_ |
| 29 | #define TALK_SESSION_PHONE_FAKEWEBRTCVOICEENGINE_H_ |
| 30 | |
| 31 | #include <list> |
| 32 | #include <map> |
| 33 | #include <vector> |
| 34 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 35 | #include "talk/media/base/codec.h" |
buildbot@webrtc.org | 7e71b77 | 2014-06-13 01:14:01 +0000 | [diff] [blame] | 36 | #include "talk/media/base/rtputils.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 37 | #include "talk/media/webrtc/fakewebrtccommon.h" |
| 38 | #include "talk/media/webrtc/webrtcvoe.h" |
buildbot@webrtc.org | a09a999 | 2014-08-13 17:26:08 +0000 | [diff] [blame] | 39 | #include "webrtc/base/basictypes.h" |
Fredrik Solenberg | d3ddc1b | 2015-05-07 17:07:34 +0200 | [diff] [blame] | 40 | #include "webrtc/base/checks.h" |
buildbot@webrtc.org | a09a999 | 2014-08-13 17:26:08 +0000 | [diff] [blame] | 41 | #include "webrtc/base/gunit.h" |
| 42 | #include "webrtc/base/stringutils.h" |
Henrik Lundin | 64dad83 | 2015-05-11 12:44:23 +0200 | [diff] [blame] | 43 | #include "webrtc/config.h" |
buildbot@webrtc.org | a8d8ad2 | 2014-07-16 14:23:08 +0000 | [diff] [blame] | 44 | #include "webrtc/modules/audio_processing/include/audio_processing.h" |
buildbot@webrtc.org | f875f15 | 2014-04-14 16:06:21 +0000 | [diff] [blame] | 45 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 46 | namespace cricket { |
| 47 | |
| 48 | // Function returning stats will return these values |
| 49 | // for all values based on type. |
| 50 | const int kIntStatValue = 123; |
| 51 | const float kFractionLostStatValue = 0.5; |
| 52 | |
| 53 | static const char kFakeDefaultDeviceName[] = "Fake Default"; |
| 54 | static const int kFakeDefaultDeviceId = -1; |
| 55 | static const char kFakeDeviceName[] = "Fake Device"; |
| 56 | #ifdef WIN32 |
| 57 | static const int kFakeDeviceId = 0; |
| 58 | #else |
| 59 | static const int kFakeDeviceId = 1; |
| 60 | #endif |
| 61 | |
buildbot@webrtc.org | 5d639b3 | 2014-09-10 07:57:12 +0000 | [diff] [blame] | 62 | static const int kOpusBandwidthNb = 4000; |
| 63 | static const int kOpusBandwidthMb = 6000; |
| 64 | static const int kOpusBandwidthWb = 8000; |
| 65 | static const int kOpusBandwidthSwb = 12000; |
| 66 | static const int kOpusBandwidthFb = 20000; |
| 67 | |
minyue@webrtc.org | c0bd7be | 2015-02-18 15:24:13 +0000 | [diff] [blame] | 68 | static const webrtc::NetworkStatistics kNetStats = { |
| 69 | 1, // uint16_t currentBufferSize; |
| 70 | 2, // uint16_t preferredBufferSize; |
| 71 | true, // bool jitterPeaksFound; |
| 72 | 1234, // uint16_t currentPacketLossRate; |
| 73 | 567, // uint16_t currentDiscardRate; |
| 74 | 8901, // uint16_t currentExpandRate; |
| 75 | 234, // uint16_t currentSpeechExpandRate; |
| 76 | 5678, // uint16_t currentPreemptiveRate; |
| 77 | 9012, // uint16_t currentAccelerateRate; |
| 78 | 3456, // uint16_t currentSecondaryDecodedRate; |
| 79 | 7890, // int32_t clockDriftPPM; |
| 80 | 54, // meanWaitingTimeMs; |
| 81 | 32, // int medianWaitingTimeMs; |
| 82 | 1, // int minWaitingTimeMs; |
| 83 | 98, // int maxWaitingTimeMs; |
| 84 | 7654, // int addedSamples; |
| 85 | }; // These random but non-trivial numbers are used for testing. |
| 86 | |
Fredrik Solenberg | d3ddc1b | 2015-05-07 17:07:34 +0200 | [diff] [blame] | 87 | #define WEBRTC_CHECK_CHANNEL(channel) \ |
| 88 | if (channels_.find(channel) == channels_.end()) return -1; |
| 89 | |
| 90 | #define WEBRTC_ASSERT_CHANNEL(channel) \ |
henrikg | 91d6ede | 2015-09-17 00:24:34 -0700 | [diff] [blame] | 91 | RTC_DCHECK(channels_.find(channel) != channels_.end()); |
Fredrik Solenberg | d3ddc1b | 2015-05-07 17:07:34 +0200 | [diff] [blame] | 92 | |
henrike@webrtc.org | 79047f9 | 2014-03-06 23:46:59 +0000 | [diff] [blame] | 93 | // Verify the header extension ID, if enabled, is within the bounds specified in |
| 94 | // [RFC5285]: 1-14 inclusive. |
| 95 | #define WEBRTC_CHECK_HEADER_EXTENSION_ID(enable, id) \ |
| 96 | do { \ |
| 97 | if (enable && (id < 1 || id > 14)) { \ |
| 98 | return -1; \ |
| 99 | } \ |
| 100 | } while (0); |
| 101 | |
buildbot@webrtc.org | a8d8ad2 | 2014-07-16 14:23:08 +0000 | [diff] [blame] | 102 | class FakeAudioProcessing : public webrtc::AudioProcessing { |
| 103 | public: |
| 104 | FakeAudioProcessing() : experimental_ns_enabled_(false) {} |
| 105 | |
| 106 | WEBRTC_STUB(Initialize, ()) |
| 107 | WEBRTC_STUB(Initialize, ( |
| 108 | int input_sample_rate_hz, |
| 109 | int output_sample_rate_hz, |
| 110 | int reverse_sample_rate_hz, |
| 111 | webrtc::AudioProcessing::ChannelLayout input_layout, |
| 112 | webrtc::AudioProcessing::ChannelLayout output_layout, |
| 113 | webrtc::AudioProcessing::ChannelLayout reverse_layout)); |
Michael Graczyk | 86c6d33 | 2015-07-23 11:41:39 -0700 | [diff] [blame] | 114 | WEBRTC_STUB(Initialize, ( |
| 115 | const webrtc::ProcessingConfig& processing_config)); |
buildbot@webrtc.org | a8d8ad2 | 2014-07-16 14:23:08 +0000 | [diff] [blame] | 116 | |
| 117 | WEBRTC_VOID_FUNC(SetExtraOptions, (const webrtc::Config& config)) { |
| 118 | experimental_ns_enabled_ = config.Get<webrtc::ExperimentalNs>().enabled; |
| 119 | } |
| 120 | |
| 121 | WEBRTC_STUB(set_sample_rate_hz, (int rate)); |
| 122 | WEBRTC_STUB_CONST(input_sample_rate_hz, ()); |
| 123 | WEBRTC_STUB_CONST(sample_rate_hz, ()); |
| 124 | WEBRTC_STUB_CONST(proc_sample_rate_hz, ()); |
| 125 | WEBRTC_STUB_CONST(proc_split_sample_rate_hz, ()); |
| 126 | WEBRTC_STUB_CONST(num_input_channels, ()); |
| 127 | WEBRTC_STUB_CONST(num_output_channels, ()); |
| 128 | WEBRTC_STUB_CONST(num_reverse_channels, ()); |
| 129 | WEBRTC_VOID_STUB(set_output_will_be_muted, (bool muted)); |
| 130 | WEBRTC_BOOL_STUB_CONST(output_will_be_muted, ()); |
| 131 | WEBRTC_STUB(ProcessStream, (webrtc::AudioFrame* frame)); |
| 132 | WEBRTC_STUB(ProcessStream, ( |
| 133 | const float* const* src, |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 134 | size_t samples_per_channel, |
buildbot@webrtc.org | a8d8ad2 | 2014-07-16 14:23:08 +0000 | [diff] [blame] | 135 | int input_sample_rate_hz, |
| 136 | webrtc::AudioProcessing::ChannelLayout input_layout, |
| 137 | int output_sample_rate_hz, |
| 138 | webrtc::AudioProcessing::ChannelLayout output_layout, |
| 139 | float* const* dest)); |
Michael Graczyk | 86c6d33 | 2015-07-23 11:41:39 -0700 | [diff] [blame] | 140 | WEBRTC_STUB(ProcessStream, |
| 141 | (const float* const* src, |
| 142 | const webrtc::StreamConfig& input_config, |
| 143 | const webrtc::StreamConfig& output_config, |
| 144 | float* const* dest)); |
buildbot@webrtc.org | a8d8ad2 | 2014-07-16 14:23:08 +0000 | [diff] [blame] | 145 | WEBRTC_STUB(AnalyzeReverseStream, (webrtc::AudioFrame* frame)); |
ekmeyerson | 60d9b33 | 2015-08-14 10:35:55 -0700 | [diff] [blame] | 146 | WEBRTC_STUB(ProcessReverseStream, (webrtc::AudioFrame * frame)); |
buildbot@webrtc.org | a8d8ad2 | 2014-07-16 14:23:08 +0000 | [diff] [blame] | 147 | WEBRTC_STUB(AnalyzeReverseStream, ( |
| 148 | const float* const* data, |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 149 | size_t samples_per_channel, |
buildbot@webrtc.org | a8d8ad2 | 2014-07-16 14:23:08 +0000 | [diff] [blame] | 150 | int sample_rate_hz, |
| 151 | webrtc::AudioProcessing::ChannelLayout layout)); |
ekmeyerson | 60d9b33 | 2015-08-14 10:35:55 -0700 | [diff] [blame] | 152 | WEBRTC_STUB(ProcessReverseStream, |
| 153 | (const float* const* src, |
| 154 | const webrtc::StreamConfig& reverse_input_config, |
| 155 | const webrtc::StreamConfig& reverse_output_config, |
| 156 | float* const* dest)); |
buildbot@webrtc.org | a8d8ad2 | 2014-07-16 14:23:08 +0000 | [diff] [blame] | 157 | WEBRTC_STUB(set_stream_delay_ms, (int delay)); |
| 158 | WEBRTC_STUB_CONST(stream_delay_ms, ()); |
| 159 | WEBRTC_BOOL_STUB_CONST(was_stream_delay_set, ()); |
| 160 | WEBRTC_VOID_STUB(set_stream_key_pressed, (bool key_pressed)); |
| 161 | WEBRTC_BOOL_STUB_CONST(stream_key_pressed, ()); |
| 162 | WEBRTC_VOID_STUB(set_delay_offset_ms, (int offset)); |
| 163 | WEBRTC_STUB_CONST(delay_offset_ms, ()); |
| 164 | WEBRTC_STUB(StartDebugRecording, (const char filename[kMaxFilenameSize])); |
| 165 | WEBRTC_STUB(StartDebugRecording, (FILE* handle)); |
| 166 | WEBRTC_STUB(StopDebugRecording, ()); |
Bjorn Volcker | 4e7aa43 | 2015-07-07 11:50:05 +0200 | [diff] [blame] | 167 | WEBRTC_VOID_STUB(UpdateHistogramsOnCallEnd, ()); |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 168 | webrtc::EchoCancellation* echo_cancellation() const override { return NULL; } |
| 169 | webrtc::EchoControlMobile* echo_control_mobile() const override { |
buildbot@webrtc.org | a8d8ad2 | 2014-07-16 14:23:08 +0000 | [diff] [blame] | 170 | return NULL; |
| 171 | } |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 172 | webrtc::GainControl* gain_control() const override { return NULL; } |
| 173 | webrtc::HighPassFilter* high_pass_filter() const override { return NULL; } |
| 174 | webrtc::LevelEstimator* level_estimator() const override { return NULL; } |
| 175 | webrtc::NoiseSuppression* noise_suppression() const override { return NULL; } |
| 176 | webrtc::VoiceDetection* voice_detection() const override { return NULL; } |
buildbot@webrtc.org | a8d8ad2 | 2014-07-16 14:23:08 +0000 | [diff] [blame] | 177 | |
| 178 | bool experimental_ns_enabled() { |
| 179 | return experimental_ns_enabled_; |
| 180 | } |
| 181 | |
| 182 | private: |
| 183 | bool experimental_ns_enabled_; |
| 184 | }; |
buildbot@webrtc.org | a8d8ad2 | 2014-07-16 14:23:08 +0000 | [diff] [blame] | 185 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 186 | class FakeWebRtcVoiceEngine |
| 187 | : public webrtc::VoEAudioProcessing, |
| 188 | public webrtc::VoEBase, public webrtc::VoECodec, public webrtc::VoEDtmf, |
Fredrik Solenberg | 7d17336 | 2015-09-23 12:23:21 +0200 | [diff] [blame^] | 189 | public webrtc::VoEHardware, public webrtc::VoENetEqStats, |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 190 | public webrtc::VoENetwork, public webrtc::VoERTP_RTCP, |
| 191 | public webrtc::VoEVideoSync, public webrtc::VoEVolumeControl { |
| 192 | public: |
| 193 | struct DtmfInfo { |
| 194 | DtmfInfo() |
| 195 | : dtmf_event_code(-1), |
| 196 | dtmf_out_of_band(false), |
| 197 | dtmf_length_ms(-1) {} |
| 198 | int dtmf_event_code; |
| 199 | bool dtmf_out_of_band; |
| 200 | int dtmf_length_ms; |
| 201 | }; |
| 202 | struct Channel { |
buildbot@webrtc.org | af6640f | 2014-04-28 21:31:51 +0000 | [diff] [blame] | 203 | explicit Channel() |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 204 | : external_transport(false), |
| 205 | send(false), |
| 206 | playout(false), |
| 207 | volume_scale(1.0), |
| 208 | volume_pan_left(1.0), |
| 209 | volume_pan_right(1.0), |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 210 | vad(false), |
buildbot@webrtc.org | ae740dd | 2014-06-17 10:56:41 +0000 | [diff] [blame] | 211 | codec_fec(false), |
buildbot@webrtc.org | 5d639b3 | 2014-09-10 07:57:12 +0000 | [diff] [blame] | 212 | max_encoding_bandwidth(0), |
minyue@webrtc.org | 9b2e114 | 2015-03-13 09:38:07 +0000 | [diff] [blame] | 213 | opus_dtx(false), |
buildbot@webrtc.org | ae740dd | 2014-06-17 10:56:41 +0000 | [diff] [blame] | 214 | red(false), |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 215 | nack(false), |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 216 | rx_agc_enabled(false), |
| 217 | rx_agc_mode(webrtc::kAgcDefault), |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 218 | cn8_type(13), |
| 219 | cn16_type(105), |
| 220 | dtmf_type(106), |
buildbot@webrtc.org | ae740dd | 2014-06-17 10:56:41 +0000 | [diff] [blame] | 221 | red_type(117), |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 222 | nack_max_packets(0), |
| 223 | send_ssrc(0), |
henrike@webrtc.org | 79047f9 | 2014-03-06 23:46:59 +0000 | [diff] [blame] | 224 | send_audio_level_ext_(-1), |
buildbot@webrtc.org | 150835e | 2014-05-06 15:54:38 +0000 | [diff] [blame] | 225 | receive_audio_level_ext_(-1), |
henrike@webrtc.org | 79047f9 | 2014-03-06 23:46:59 +0000 | [diff] [blame] | 226 | send_absolute_sender_time_ext_(-1), |
Henrik Lundin | 64dad83 | 2015-05-11 12:44:23 +0200 | [diff] [blame] | 227 | receive_absolute_sender_time_ext_(-1), |
Minyue | 2013aec | 2015-05-13 14:14:42 +0200 | [diff] [blame] | 228 | associate_send_channel(-1), |
Henrik Lundin | 5263b3c | 2015-06-01 10:29:41 +0200 | [diff] [blame] | 229 | neteq_capacity(-1), |
| 230 | neteq_fast_accelerate(false) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 231 | memset(&send_codec, 0, sizeof(send_codec)); |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 232 | memset(&rx_agc_config, 0, sizeof(rx_agc_config)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 233 | } |
| 234 | bool external_transport; |
| 235 | bool send; |
| 236 | bool playout; |
| 237 | float volume_scale; |
| 238 | float volume_pan_left; |
| 239 | float volume_pan_right; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 240 | bool vad; |
buildbot@webrtc.org | ae740dd | 2014-06-17 10:56:41 +0000 | [diff] [blame] | 241 | bool codec_fec; |
buildbot@webrtc.org | 5d639b3 | 2014-09-10 07:57:12 +0000 | [diff] [blame] | 242 | int max_encoding_bandwidth; |
minyue@webrtc.org | 9b2e114 | 2015-03-13 09:38:07 +0000 | [diff] [blame] | 243 | bool opus_dtx; |
buildbot@webrtc.org | ae740dd | 2014-06-17 10:56:41 +0000 | [diff] [blame] | 244 | bool red; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 245 | bool nack; |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 246 | bool rx_agc_enabled; |
| 247 | webrtc::AgcModes rx_agc_mode; |
| 248 | webrtc::AgcConfig rx_agc_config; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 249 | int cn8_type; |
| 250 | int cn16_type; |
| 251 | int dtmf_type; |
buildbot@webrtc.org | ae740dd | 2014-06-17 10:56:41 +0000 | [diff] [blame] | 252 | int red_type; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 253 | int nack_max_packets; |
| 254 | uint32 send_ssrc; |
henrike@webrtc.org | 79047f9 | 2014-03-06 23:46:59 +0000 | [diff] [blame] | 255 | int send_audio_level_ext_; |
buildbot@webrtc.org | 150835e | 2014-05-06 15:54:38 +0000 | [diff] [blame] | 256 | int receive_audio_level_ext_; |
henrike@webrtc.org | 79047f9 | 2014-03-06 23:46:59 +0000 | [diff] [blame] | 257 | int send_absolute_sender_time_ext_; |
| 258 | int receive_absolute_sender_time_ext_; |
Minyue | 2013aec | 2015-05-13 14:14:42 +0200 | [diff] [blame] | 259 | int associate_send_channel; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 260 | DtmfInfo dtmf_info; |
| 261 | std::vector<webrtc::CodecInst> recv_codecs; |
| 262 | webrtc::CodecInst send_codec; |
buildbot@webrtc.org | f875f15 | 2014-04-14 16:06:21 +0000 | [diff] [blame] | 263 | webrtc::PacketTime last_rtp_packet_time; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 264 | std::list<std::string> packets; |
Henrik Lundin | 64dad83 | 2015-05-11 12:44:23 +0200 | [diff] [blame] | 265 | int neteq_capacity; |
Henrik Lundin | 5263b3c | 2015-06-01 10:29:41 +0200 | [diff] [blame] | 266 | bool neteq_fast_accelerate; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 267 | }; |
| 268 | |
| 269 | FakeWebRtcVoiceEngine(const cricket::AudioCodec* const* codecs, |
| 270 | int num_codecs) |
| 271 | : inited_(false), |
| 272 | last_channel_(-1), |
| 273 | fail_create_channel_(false), |
| 274 | codecs_(codecs), |
| 275 | num_codecs_(num_codecs), |
wu@webrtc.org | 05e7b44 | 2014-04-01 17:44:24 +0000 | [diff] [blame] | 276 | num_set_send_codecs_(0), |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 277 | ec_enabled_(false), |
| 278 | ec_metrics_enabled_(false), |
| 279 | cng_enabled_(false), |
| 280 | ns_enabled_(false), |
| 281 | agc_enabled_(false), |
| 282 | highpass_filter_enabled_(false), |
| 283 | stereo_swapping_enabled_(false), |
| 284 | typing_detection_enabled_(false), |
| 285 | ec_mode_(webrtc::kEcDefault), |
| 286 | aecm_mode_(webrtc::kAecmSpeakerphone), |
| 287 | ns_mode_(webrtc::kNsDefault), |
| 288 | agc_mode_(webrtc::kAgcDefault), |
| 289 | observer_(NULL), |
| 290 | playout_fail_channel_(-1), |
| 291 | send_fail_channel_(-1), |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 292 | recording_sample_rate_(-1), |
Fredrik Solenberg | 7d17336 | 2015-09-23 12:23:21 +0200 | [diff] [blame^] | 293 | playout_sample_rate_(-1) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 294 | memset(&agc_config_, 0, sizeof(agc_config_)); |
| 295 | } |
| 296 | ~FakeWebRtcVoiceEngine() { |
| 297 | // Ought to have all been deleted by the WebRtcVoiceMediaChannel |
| 298 | // destructors, but just in case ... |
| 299 | for (std::map<int, Channel*>::const_iterator i = channels_.begin(); |
| 300 | i != channels_.end(); ++i) { |
| 301 | delete i->second; |
| 302 | } |
| 303 | } |
| 304 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 305 | bool IsInited() const { return inited_; } |
| 306 | int GetLastChannel() const { return last_channel_; } |
wu@webrtc.org | 9dba525 | 2013-08-05 20:36:57 +0000 | [diff] [blame] | 307 | int GetChannelFromLocalSsrc(uint32 local_ssrc) const { |
| 308 | for (std::map<int, Channel*>::const_iterator iter = channels_.begin(); |
| 309 | iter != channels_.end(); ++iter) { |
| 310 | if (local_ssrc == iter->second->send_ssrc) |
| 311 | return iter->first; |
| 312 | } |
| 313 | return -1; |
| 314 | } |
wu@webrtc.org | 9caf276 | 2013-12-11 18:25:07 +0000 | [diff] [blame] | 315 | int GetNumChannels() const { return static_cast<int>(channels_.size()); } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 316 | bool GetPlayout(int channel) { |
| 317 | return channels_[channel]->playout; |
| 318 | } |
| 319 | bool GetSend(int channel) { |
| 320 | return channels_[channel]->send; |
| 321 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 322 | bool GetVAD(int channel) { |
| 323 | return channels_[channel]->vad; |
| 324 | } |
Minyue Li | 7100dcd | 2015-03-27 05:05:59 +0100 | [diff] [blame] | 325 | bool GetOpusDtx(int channel) { |
| 326 | return channels_[channel]->opus_dtx; |
| 327 | } |
buildbot@webrtc.org | ae740dd | 2014-06-17 10:56:41 +0000 | [diff] [blame] | 328 | bool GetRED(int channel) { |
| 329 | return channels_[channel]->red; |
| 330 | } |
| 331 | bool GetCodecFEC(int channel) { |
| 332 | return channels_[channel]->codec_fec; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 333 | } |
buildbot@webrtc.org | 5d639b3 | 2014-09-10 07:57:12 +0000 | [diff] [blame] | 334 | int GetMaxEncodingBandwidth(int channel) { |
| 335 | return channels_[channel]->max_encoding_bandwidth; |
| 336 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 337 | bool GetNACK(int channel) { |
| 338 | return channels_[channel]->nack; |
| 339 | } |
| 340 | int GetNACKMaxPackets(int channel) { |
| 341 | return channels_[channel]->nack_max_packets; |
| 342 | } |
buildbot@webrtc.org | f875f15 | 2014-04-14 16:06:21 +0000 | [diff] [blame] | 343 | const webrtc::PacketTime& GetLastRtpPacketTime(int channel) { |
| 344 | WEBRTC_ASSERT_CHANNEL(channel); |
| 345 | return channels_[channel]->last_rtp_packet_time; |
| 346 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 347 | int GetSendCNPayloadType(int channel, bool wideband) { |
| 348 | return (wideband) ? |
| 349 | channels_[channel]->cn16_type : |
| 350 | channels_[channel]->cn8_type; |
| 351 | } |
| 352 | int GetSendTelephoneEventPayloadType(int channel) { |
| 353 | return channels_[channel]->dtmf_type; |
| 354 | } |
buildbot@webrtc.org | ae740dd | 2014-06-17 10:56:41 +0000 | [diff] [blame] | 355 | int GetSendREDPayloadType(int channel) { |
| 356 | return channels_[channel]->red_type; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 357 | } |
| 358 | bool CheckPacket(int channel, const void* data, size_t len) { |
| 359 | bool result = !CheckNoPacket(channel); |
| 360 | if (result) { |
| 361 | std::string packet = channels_[channel]->packets.front(); |
| 362 | result = (packet == std::string(static_cast<const char*>(data), len)); |
| 363 | channels_[channel]->packets.pop_front(); |
| 364 | } |
| 365 | return result; |
| 366 | } |
| 367 | bool CheckNoPacket(int channel) { |
| 368 | return channels_[channel]->packets.empty(); |
| 369 | } |
| 370 | void TriggerCallbackOnError(int channel_num, int err_code) { |
henrikg | 91d6ede | 2015-09-17 00:24:34 -0700 | [diff] [blame] | 371 | RTC_DCHECK(observer_ != NULL); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 372 | observer_->CallbackOnError(channel_num, err_code); |
| 373 | } |
| 374 | void set_playout_fail_channel(int channel) { |
| 375 | playout_fail_channel_ = channel; |
| 376 | } |
| 377 | void set_send_fail_channel(int channel) { |
| 378 | send_fail_channel_ = channel; |
| 379 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 380 | void set_fail_create_channel(bool fail_create_channel) { |
| 381 | fail_create_channel_ = fail_create_channel; |
| 382 | } |
Henrik Lundin | 64dad83 | 2015-05-11 12:44:23 +0200 | [diff] [blame] | 383 | int AddChannel(const webrtc::Config& config) { |
wu@webrtc.org | 364f204 | 2013-11-20 21:49:41 +0000 | [diff] [blame] | 384 | if (fail_create_channel_) { |
| 385 | return -1; |
| 386 | } |
buildbot@webrtc.org | af6640f | 2014-04-28 21:31:51 +0000 | [diff] [blame] | 387 | Channel* ch = new Channel(); |
wu@webrtc.org | 364f204 | 2013-11-20 21:49:41 +0000 | [diff] [blame] | 388 | for (int i = 0; i < NumOfCodecs(); ++i) { |
| 389 | webrtc::CodecInst codec; |
| 390 | GetCodec(i, codec); |
| 391 | ch->recv_codecs.push_back(codec); |
| 392 | } |
Henrik Lundin | 64dad83 | 2015-05-11 12:44:23 +0200 | [diff] [blame] | 393 | if (config.Get<webrtc::NetEqCapacityConfig>().enabled) { |
| 394 | ch->neteq_capacity = config.Get<webrtc::NetEqCapacityConfig>().capacity; |
| 395 | } |
Henrik Lundin | 5263b3c | 2015-06-01 10:29:41 +0200 | [diff] [blame] | 396 | ch->neteq_fast_accelerate = |
| 397 | config.Get<webrtc::NetEqFastAccelerate>().enabled; |
wu@webrtc.org | 364f204 | 2013-11-20 21:49:41 +0000 | [diff] [blame] | 398 | channels_[++last_channel_] = ch; |
| 399 | return last_channel_; |
| 400 | } |
buildbot@webrtc.org | 150835e | 2014-05-06 15:54:38 +0000 | [diff] [blame] | 401 | int GetSendRtpExtensionId(int channel, const std::string& extension) { |
| 402 | WEBRTC_ASSERT_CHANNEL(channel); |
| 403 | if (extension == kRtpAudioLevelHeaderExtension) { |
| 404 | return channels_[channel]->send_audio_level_ext_; |
| 405 | } else if (extension == kRtpAbsoluteSenderTimeHeaderExtension) { |
| 406 | return channels_[channel]->send_absolute_sender_time_ext_; |
| 407 | } |
| 408 | return -1; |
henrike@webrtc.org | 79047f9 | 2014-03-06 23:46:59 +0000 | [diff] [blame] | 409 | } |
buildbot@webrtc.org | 150835e | 2014-05-06 15:54:38 +0000 | [diff] [blame] | 410 | int GetReceiveRtpExtensionId(int channel, const std::string& extension) { |
| 411 | WEBRTC_ASSERT_CHANNEL(channel); |
| 412 | if (extension == kRtpAudioLevelHeaderExtension) { |
| 413 | return channels_[channel]->receive_audio_level_ext_; |
| 414 | } else if (extension == kRtpAbsoluteSenderTimeHeaderExtension) { |
| 415 | return channels_[channel]->receive_absolute_sender_time_ext_; |
| 416 | } |
| 417 | return -1; |
henrike@webrtc.org | 79047f9 | 2014-03-06 23:46:59 +0000 | [diff] [blame] | 418 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 419 | |
wu@webrtc.org | 05e7b44 | 2014-04-01 17:44:24 +0000 | [diff] [blame] | 420 | int GetNumSetSendCodecs() const { return num_set_send_codecs_; } |
| 421 | |
Minyue | 2013aec | 2015-05-13 14:14:42 +0200 | [diff] [blame] | 422 | int GetAssociateSendChannel(int channel) { |
| 423 | return channels_[channel]->associate_send_channel; |
| 424 | } |
| 425 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 426 | WEBRTC_STUB(Release, ()); |
| 427 | |
| 428 | // webrtc::VoEBase |
| 429 | WEBRTC_FUNC(RegisterVoiceEngineObserver, ( |
| 430 | webrtc::VoiceEngineObserver& observer)) { |
| 431 | observer_ = &observer; |
| 432 | return 0; |
| 433 | } |
| 434 | WEBRTC_STUB(DeRegisterVoiceEngineObserver, ()); |
| 435 | WEBRTC_FUNC(Init, (webrtc::AudioDeviceModule* adm, |
| 436 | webrtc::AudioProcessing* audioproc)) { |
| 437 | inited_ = true; |
| 438 | return 0; |
| 439 | } |
| 440 | WEBRTC_FUNC(Terminate, ()) { |
| 441 | inited_ = false; |
| 442 | return 0; |
| 443 | } |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 444 | webrtc::AudioProcessing* audio_processing() override { |
buildbot@webrtc.org | a8d8ad2 | 2014-07-16 14:23:08 +0000 | [diff] [blame] | 445 | return &audio_processing_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 446 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 447 | WEBRTC_FUNC(CreateChannel, ()) { |
Henrik Lundin | 64dad83 | 2015-05-11 12:44:23 +0200 | [diff] [blame] | 448 | webrtc::Config empty_config; |
| 449 | return AddChannel(empty_config); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 450 | } |
Henrik Lundin | 64dad83 | 2015-05-11 12:44:23 +0200 | [diff] [blame] | 451 | WEBRTC_FUNC(CreateChannel, (const webrtc::Config& config)) { |
| 452 | return AddChannel(config); |
wu@webrtc.org | 364f204 | 2013-11-20 21:49:41 +0000 | [diff] [blame] | 453 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 454 | WEBRTC_FUNC(DeleteChannel, (int channel)) { |
| 455 | WEBRTC_CHECK_CHANNEL(channel); |
Minyue | 2013aec | 2015-05-13 14:14:42 +0200 | [diff] [blame] | 456 | for (const auto& ch : channels_) { |
| 457 | if (ch.second->associate_send_channel == channel) { |
| 458 | ch.second->associate_send_channel = -1; |
| 459 | } |
| 460 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 461 | delete channels_[channel]; |
| 462 | channels_.erase(channel); |
| 463 | return 0; |
| 464 | } |
| 465 | WEBRTC_STUB(StartReceive, (int channel)); |
| 466 | WEBRTC_FUNC(StartPlayout, (int channel)) { |
| 467 | if (playout_fail_channel_ != channel) { |
| 468 | WEBRTC_CHECK_CHANNEL(channel); |
| 469 | channels_[channel]->playout = true; |
| 470 | return 0; |
| 471 | } else { |
| 472 | // When playout_fail_channel_ == channel, fail the StartPlayout on this |
| 473 | // channel. |
| 474 | return -1; |
| 475 | } |
| 476 | } |
| 477 | WEBRTC_FUNC(StartSend, (int channel)) { |
| 478 | if (send_fail_channel_ != channel) { |
| 479 | WEBRTC_CHECK_CHANNEL(channel); |
| 480 | channels_[channel]->send = true; |
| 481 | return 0; |
| 482 | } else { |
| 483 | // When send_fail_channel_ == channel, fail the StartSend on this |
| 484 | // channel. |
| 485 | return -1; |
| 486 | } |
| 487 | } |
| 488 | WEBRTC_STUB(StopReceive, (int channel)); |
| 489 | WEBRTC_FUNC(StopPlayout, (int channel)) { |
| 490 | WEBRTC_CHECK_CHANNEL(channel); |
| 491 | channels_[channel]->playout = false; |
| 492 | return 0; |
| 493 | } |
| 494 | WEBRTC_FUNC(StopSend, (int channel)) { |
| 495 | WEBRTC_CHECK_CHANNEL(channel); |
| 496 | channels_[channel]->send = false; |
| 497 | return 0; |
| 498 | } |
| 499 | WEBRTC_STUB(GetVersion, (char version[1024])); |
| 500 | WEBRTC_STUB(LastError, ()); |
Minyue | 2013aec | 2015-05-13 14:14:42 +0200 | [diff] [blame] | 501 | WEBRTC_FUNC(AssociateSendChannel, (int channel, |
| 502 | int accociate_send_channel)) { |
| 503 | WEBRTC_CHECK_CHANNEL(channel); |
| 504 | channels_[channel]->associate_send_channel = accociate_send_channel; |
| 505 | return 0; |
| 506 | } |
ivoc | b04965c | 2015-09-09 00:09:43 -0700 | [diff] [blame] | 507 | webrtc::RtcEventLog* GetEventLog() { return nullptr; } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 508 | |
| 509 | // webrtc::VoECodec |
| 510 | WEBRTC_FUNC(NumOfCodecs, ()) { |
| 511 | return num_codecs_; |
| 512 | } |
| 513 | WEBRTC_FUNC(GetCodec, (int index, webrtc::CodecInst& codec)) { |
| 514 | if (index < 0 || index >= NumOfCodecs()) { |
| 515 | return -1; |
| 516 | } |
| 517 | const cricket::AudioCodec& c(*codecs_[index]); |
| 518 | codec.pltype = c.id; |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 519 | rtc::strcpyn(codec.plname, sizeof(codec.plname), c.name.c_str()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 520 | codec.plfreq = c.clockrate; |
| 521 | codec.pacsize = 0; |
| 522 | codec.channels = c.channels; |
| 523 | codec.rate = c.bitrate; |
| 524 | return 0; |
| 525 | } |
| 526 | WEBRTC_FUNC(SetSendCodec, (int channel, const webrtc::CodecInst& codec)) { |
| 527 | WEBRTC_CHECK_CHANNEL(channel); |
henrike@webrtc.org | 704bf9e | 2014-02-27 17:52:04 +0000 | [diff] [blame] | 528 | // To match the behavior of the real implementation. |
| 529 | if (_stricmp(codec.plname, "telephone-event") == 0 || |
| 530 | _stricmp(codec.plname, "audio/telephone-event") == 0 || |
| 531 | _stricmp(codec.plname, "CN") == 0 || |
| 532 | _stricmp(codec.plname, "red") == 0 ) { |
| 533 | return -1; |
| 534 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 535 | channels_[channel]->send_codec = codec; |
wu@webrtc.org | 05e7b44 | 2014-04-01 17:44:24 +0000 | [diff] [blame] | 536 | ++num_set_send_codecs_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 537 | return 0; |
| 538 | } |
| 539 | WEBRTC_FUNC(GetSendCodec, (int channel, webrtc::CodecInst& codec)) { |
| 540 | WEBRTC_CHECK_CHANNEL(channel); |
| 541 | codec = channels_[channel]->send_codec; |
| 542 | return 0; |
| 543 | } |
Ivo Creusen | adf89b7 | 2015-04-29 16:03:33 +0200 | [diff] [blame] | 544 | WEBRTC_STUB(SetBitRate, (int channel, int bitrate_bps)); |
buildbot@webrtc.org | 7e71b77 | 2014-06-13 01:14:01 +0000 | [diff] [blame] | 545 | WEBRTC_FUNC(GetRecCodec, (int channel, webrtc::CodecInst& codec)) { |
| 546 | WEBRTC_CHECK_CHANNEL(channel); |
| 547 | const Channel* c = channels_[channel]; |
| 548 | for (std::list<std::string>::const_iterator it_packet = c->packets.begin(); |
| 549 | it_packet != c->packets.end(); ++it_packet) { |
| 550 | int pltype; |
| 551 | if (!GetRtpPayloadType(it_packet->data(), it_packet->length(), &pltype)) { |
| 552 | continue; |
| 553 | } |
| 554 | for (std::vector<webrtc::CodecInst>::const_iterator it_codec = |
| 555 | c->recv_codecs.begin(); it_codec != c->recv_codecs.end(); |
| 556 | ++it_codec) { |
| 557 | if (it_codec->pltype == pltype) { |
| 558 | codec = *it_codec; |
| 559 | return 0; |
| 560 | } |
| 561 | } |
| 562 | } |
| 563 | return -1; |
| 564 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 565 | WEBRTC_FUNC(SetRecPayloadType, (int channel, |
| 566 | const webrtc::CodecInst& codec)) { |
| 567 | WEBRTC_CHECK_CHANNEL(channel); |
| 568 | Channel* ch = channels_[channel]; |
| 569 | if (ch->playout) |
| 570 | return -1; // Channel is in use. |
| 571 | // Check if something else already has this slot. |
| 572 | if (codec.pltype != -1) { |
| 573 | for (std::vector<webrtc::CodecInst>::iterator it = |
| 574 | ch->recv_codecs.begin(); it != ch->recv_codecs.end(); ++it) { |
| 575 | if (it->pltype == codec.pltype && |
| 576 | _stricmp(it->plname, codec.plname) != 0) { |
| 577 | return -1; |
| 578 | } |
| 579 | } |
| 580 | } |
| 581 | // Otherwise try to find this codec and update its payload type. |
| 582 | for (std::vector<webrtc::CodecInst>::iterator it = ch->recv_codecs.begin(); |
| 583 | it != ch->recv_codecs.end(); ++it) { |
| 584 | if (strcmp(it->plname, codec.plname) == 0 && |
| 585 | it->plfreq == codec.plfreq) { |
| 586 | it->pltype = codec.pltype; |
| 587 | it->channels = codec.channels; |
| 588 | return 0; |
| 589 | } |
| 590 | } |
| 591 | return -1; // not found |
| 592 | } |
| 593 | WEBRTC_FUNC(SetSendCNPayloadType, (int channel, int type, |
| 594 | webrtc::PayloadFrequencies frequency)) { |
| 595 | WEBRTC_CHECK_CHANNEL(channel); |
| 596 | if (frequency == webrtc::kFreq8000Hz) { |
| 597 | channels_[channel]->cn8_type = type; |
| 598 | } else if (frequency == webrtc::kFreq16000Hz) { |
| 599 | channels_[channel]->cn16_type = type; |
| 600 | } |
| 601 | return 0; |
| 602 | } |
| 603 | WEBRTC_FUNC(GetRecPayloadType, (int channel, webrtc::CodecInst& codec)) { |
| 604 | WEBRTC_CHECK_CHANNEL(channel); |
| 605 | Channel* ch = channels_[channel]; |
| 606 | for (std::vector<webrtc::CodecInst>::iterator it = ch->recv_codecs.begin(); |
| 607 | it != ch->recv_codecs.end(); ++it) { |
| 608 | if (strcmp(it->plname, codec.plname) == 0 && |
| 609 | it->plfreq == codec.plfreq && |
| 610 | it->channels == codec.channels && |
| 611 | it->pltype != -1) { |
| 612 | codec.pltype = it->pltype; |
| 613 | return 0; |
| 614 | } |
| 615 | } |
| 616 | return -1; // not found |
| 617 | } |
| 618 | WEBRTC_FUNC(SetVADStatus, (int channel, bool enable, webrtc::VadModes mode, |
| 619 | bool disableDTX)) { |
| 620 | WEBRTC_CHECK_CHANNEL(channel); |
| 621 | if (channels_[channel]->send_codec.channels == 2) { |
| 622 | // Replicating VoE behavior; VAD cannot be enabled for stereo. |
| 623 | return -1; |
| 624 | } |
| 625 | channels_[channel]->vad = enable; |
| 626 | return 0; |
| 627 | } |
| 628 | WEBRTC_STUB(GetVADStatus, (int channel, bool& enabled, |
| 629 | webrtc::VadModes& mode, bool& disabledDTX)); |
buildbot@webrtc.org | 5d639b3 | 2014-09-10 07:57:12 +0000 | [diff] [blame] | 630 | |
buildbot@webrtc.org | ae740dd | 2014-06-17 10:56:41 +0000 | [diff] [blame] | 631 | WEBRTC_FUNC(SetFECStatus, (int channel, bool enable)) { |
| 632 | WEBRTC_CHECK_CHANNEL(channel); |
buildbot@webrtc.org | 5d639b3 | 2014-09-10 07:57:12 +0000 | [diff] [blame] | 633 | if (_stricmp(channels_[channel]->send_codec.plname, "opus") != 0) { |
buildbot@webrtc.org | 3ffa1f9 | 2014-07-02 19:51:26 +0000 | [diff] [blame] | 634 | // Return -1 if current send codec is not Opus. |
| 635 | // TODO(minyue): Excludes other codecs if they support inband FEC. |
| 636 | return -1; |
| 637 | } |
buildbot@webrtc.org | ae740dd | 2014-06-17 10:56:41 +0000 | [diff] [blame] | 638 | channels_[channel]->codec_fec = enable; |
| 639 | return 0; |
| 640 | } |
| 641 | WEBRTC_FUNC(GetFECStatus, (int channel, bool& enable)) { |
| 642 | WEBRTC_CHECK_CHANNEL(channel); |
| 643 | enable = channels_[channel]->codec_fec; |
| 644 | return 0; |
| 645 | } |
buildbot@webrtc.org | 5d639b3 | 2014-09-10 07:57:12 +0000 | [diff] [blame] | 646 | |
| 647 | WEBRTC_FUNC(SetOpusMaxPlaybackRate, (int channel, int frequency_hz)) { |
| 648 | WEBRTC_CHECK_CHANNEL(channel); |
| 649 | if (_stricmp(channels_[channel]->send_codec.plname, "opus") != 0) { |
| 650 | // Return -1 if current send codec is not Opus. |
| 651 | return -1; |
| 652 | } |
| 653 | if (frequency_hz <= 8000) |
| 654 | channels_[channel]->max_encoding_bandwidth = kOpusBandwidthNb; |
| 655 | else if (frequency_hz <= 12000) |
| 656 | channels_[channel]->max_encoding_bandwidth = kOpusBandwidthMb; |
| 657 | else if (frequency_hz <= 16000) |
| 658 | channels_[channel]->max_encoding_bandwidth = kOpusBandwidthWb; |
| 659 | else if (frequency_hz <= 24000) |
| 660 | channels_[channel]->max_encoding_bandwidth = kOpusBandwidthSwb; |
| 661 | else |
| 662 | channels_[channel]->max_encoding_bandwidth = kOpusBandwidthFb; |
| 663 | return 0; |
| 664 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 665 | |
minyue@webrtc.org | 9b2e114 | 2015-03-13 09:38:07 +0000 | [diff] [blame] | 666 | WEBRTC_FUNC(SetOpusDtx, (int channel, bool enable_dtx)) { |
| 667 | WEBRTC_CHECK_CHANNEL(channel); |
| 668 | if (_stricmp(channels_[channel]->send_codec.plname, "opus") != 0) { |
| 669 | // Return -1 if current send codec is not Opus. |
| 670 | return -1; |
| 671 | } |
| 672 | channels_[channel]->opus_dtx = enable_dtx; |
| 673 | return 0; |
| 674 | } |
| 675 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 676 | // webrtc::VoEDtmf |
| 677 | WEBRTC_FUNC(SendTelephoneEvent, (int channel, int event_code, |
| 678 | bool out_of_band = true, int length_ms = 160, int attenuation_db = 10)) { |
| 679 | channels_[channel]->dtmf_info.dtmf_event_code = event_code; |
| 680 | channels_[channel]->dtmf_info.dtmf_out_of_band = out_of_band; |
| 681 | channels_[channel]->dtmf_info.dtmf_length_ms = length_ms; |
| 682 | return 0; |
| 683 | } |
| 684 | |
| 685 | WEBRTC_FUNC(SetSendTelephoneEventPayloadType, |
| 686 | (int channel, unsigned char type)) { |
| 687 | channels_[channel]->dtmf_type = type; |
| 688 | return 0; |
| 689 | }; |
| 690 | WEBRTC_STUB(GetSendTelephoneEventPayloadType, |
| 691 | (int channel, unsigned char& type)); |
| 692 | |
| 693 | WEBRTC_STUB(SetDtmfFeedbackStatus, (bool enable, bool directFeedback)); |
| 694 | WEBRTC_STUB(GetDtmfFeedbackStatus, (bool& enabled, bool& directFeedback)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 695 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 696 | WEBRTC_FUNC(PlayDtmfTone, |
| 697 | (int event_code, int length_ms = 200, int attenuation_db = 10)) { |
| 698 | dtmf_info_.dtmf_event_code = event_code; |
| 699 | dtmf_info_.dtmf_length_ms = length_ms; |
| 700 | return 0; |
| 701 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 702 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 703 | // webrtc::VoEHardware |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 704 | WEBRTC_FUNC(GetNumOfRecordingDevices, (int& num)) { |
| 705 | return GetNumDevices(num); |
| 706 | } |
| 707 | WEBRTC_FUNC(GetNumOfPlayoutDevices, (int& num)) { |
| 708 | return GetNumDevices(num); |
| 709 | } |
| 710 | WEBRTC_FUNC(GetRecordingDeviceName, (int i, char* name, char* guid)) { |
| 711 | return GetDeviceName(i, name, guid); |
| 712 | } |
| 713 | WEBRTC_FUNC(GetPlayoutDeviceName, (int i, char* name, char* guid)) { |
| 714 | return GetDeviceName(i, name, guid); |
| 715 | } |
| 716 | WEBRTC_STUB(SetRecordingDevice, (int, webrtc::StereoChannel)); |
| 717 | WEBRTC_STUB(SetPlayoutDevice, (int)); |
| 718 | WEBRTC_STUB(SetAudioDeviceLayer, (webrtc::AudioLayers)); |
| 719 | WEBRTC_STUB(GetAudioDeviceLayer, (webrtc::AudioLayers&)); |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 720 | WEBRTC_FUNC(SetRecordingSampleRate, (unsigned int samples_per_sec)) { |
| 721 | recording_sample_rate_ = samples_per_sec; |
| 722 | return 0; |
| 723 | } |
| 724 | WEBRTC_FUNC_CONST(RecordingSampleRate, (unsigned int* samples_per_sec)) { |
| 725 | *samples_per_sec = recording_sample_rate_; |
| 726 | return 0; |
| 727 | } |
| 728 | WEBRTC_FUNC(SetPlayoutSampleRate, (unsigned int samples_per_sec)) { |
| 729 | playout_sample_rate_ = samples_per_sec; |
| 730 | return 0; |
| 731 | } |
| 732 | WEBRTC_FUNC_CONST(PlayoutSampleRate, (unsigned int* samples_per_sec)) { |
| 733 | *samples_per_sec = playout_sample_rate_; |
| 734 | return 0; |
| 735 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 736 | WEBRTC_STUB(EnableBuiltInAEC, (bool enable)); |
henrika@webrtc.org | a954c07 | 2014-12-09 16:22:09 +0000 | [diff] [blame] | 737 | virtual bool BuiltInAECIsAvailable() const { return false; } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 738 | |
| 739 | // webrtc::VoENetEqStats |
minyue@webrtc.org | c0bd7be | 2015-02-18 15:24:13 +0000 | [diff] [blame] | 740 | WEBRTC_FUNC(GetNetworkStatistics, (int channel, |
| 741 | webrtc::NetworkStatistics& ns)) { |
| 742 | WEBRTC_CHECK_CHANNEL(channel); |
| 743 | memcpy(&ns, &kNetStats, sizeof(webrtc::NetworkStatistics)); |
| 744 | return 0; |
| 745 | } |
| 746 | |
wu@webrtc.org | 24301a6 | 2013-12-13 19:17:43 +0000 | [diff] [blame] | 747 | WEBRTC_FUNC_CONST(GetDecodingCallStatistics, (int channel, |
| 748 | webrtc::AudioDecodingCallStats*)) { |
| 749 | WEBRTC_CHECK_CHANNEL(channel); |
| 750 | return 0; |
| 751 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 752 | |
| 753 | // webrtc::VoENetwork |
| 754 | WEBRTC_FUNC(RegisterExternalTransport, (int channel, |
| 755 | webrtc::Transport& transport)) { |
| 756 | WEBRTC_CHECK_CHANNEL(channel); |
| 757 | channels_[channel]->external_transport = true; |
| 758 | return 0; |
| 759 | } |
| 760 | WEBRTC_FUNC(DeRegisterExternalTransport, (int channel)) { |
| 761 | WEBRTC_CHECK_CHANNEL(channel); |
| 762 | channels_[channel]->external_transport = false; |
| 763 | return 0; |
| 764 | } |
| 765 | WEBRTC_FUNC(ReceivedRTPPacket, (int channel, const void* data, |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 766 | size_t length)) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 767 | WEBRTC_CHECK_CHANNEL(channel); |
| 768 | if (!channels_[channel]->external_transport) return -1; |
| 769 | channels_[channel]->packets.push_back( |
| 770 | std::string(static_cast<const char*>(data), length)); |
| 771 | return 0; |
| 772 | } |
buildbot@webrtc.org | f875f15 | 2014-04-14 16:06:21 +0000 | [diff] [blame] | 773 | WEBRTC_FUNC(ReceivedRTPPacket, (int channel, const void* data, |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 774 | size_t length, |
buildbot@webrtc.org | f875f15 | 2014-04-14 16:06:21 +0000 | [diff] [blame] | 775 | const webrtc::PacketTime& packet_time)) { |
| 776 | WEBRTC_CHECK_CHANNEL(channel); |
| 777 | if (ReceivedRTPPacket(channel, data, length) == -1) { |
| 778 | return -1; |
| 779 | } |
| 780 | channels_[channel]->last_rtp_packet_time = packet_time; |
| 781 | return 0; |
| 782 | } |
buildbot@webrtc.org | f875f15 | 2014-04-14 16:06:21 +0000 | [diff] [blame] | 783 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 784 | WEBRTC_STUB(ReceivedRTCPPacket, (int channel, const void* data, |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 785 | size_t length)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 786 | |
| 787 | // webrtc::VoERTP_RTCP |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 788 | WEBRTC_FUNC(SetLocalSSRC, (int channel, unsigned int ssrc)) { |
| 789 | WEBRTC_CHECK_CHANNEL(channel); |
| 790 | channels_[channel]->send_ssrc = ssrc; |
| 791 | return 0; |
| 792 | } |
| 793 | WEBRTC_FUNC(GetLocalSSRC, (int channel, unsigned int& ssrc)) { |
| 794 | WEBRTC_CHECK_CHANNEL(channel); |
| 795 | ssrc = channels_[channel]->send_ssrc; |
| 796 | return 0; |
| 797 | } |
| 798 | WEBRTC_STUB(GetRemoteSSRC, (int channel, unsigned int& ssrc)); |
henrike@webrtc.org | 79047f9 | 2014-03-06 23:46:59 +0000 | [diff] [blame] | 799 | WEBRTC_FUNC(SetSendAudioLevelIndicationStatus, (int channel, bool enable, |
| 800 | unsigned char id)) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 801 | WEBRTC_CHECK_CHANNEL(channel); |
henrike@webrtc.org | 79047f9 | 2014-03-06 23:46:59 +0000 | [diff] [blame] | 802 | WEBRTC_CHECK_HEADER_EXTENSION_ID(enable, id); |
| 803 | channels_[channel]->send_audio_level_ext_ = (enable) ? id : -1; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 804 | return 0; |
| 805 | } |
buildbot@webrtc.org | 150835e | 2014-05-06 15:54:38 +0000 | [diff] [blame] | 806 | WEBRTC_FUNC(SetReceiveAudioLevelIndicationStatus, (int channel, bool enable, |
| 807 | unsigned char id)) { |
| 808 | WEBRTC_CHECK_CHANNEL(channel); |
| 809 | WEBRTC_CHECK_HEADER_EXTENSION_ID(enable, id); |
| 810 | channels_[channel]->receive_audio_level_ext_ = (enable) ? id : -1; |
| 811 | return 0; |
| 812 | } |
henrike@webrtc.org | 79047f9 | 2014-03-06 23:46:59 +0000 | [diff] [blame] | 813 | WEBRTC_FUNC(SetSendAbsoluteSenderTimeStatus, (int channel, bool enable, |
| 814 | unsigned char id)) { |
| 815 | WEBRTC_CHECK_CHANNEL(channel); |
| 816 | WEBRTC_CHECK_HEADER_EXTENSION_ID(enable, id); |
| 817 | channels_[channel]->send_absolute_sender_time_ext_ = (enable) ? id : -1; |
| 818 | return 0; |
| 819 | } |
| 820 | WEBRTC_FUNC(SetReceiveAbsoluteSenderTimeStatus, (int channel, bool enable, |
| 821 | unsigned char id)) { |
| 822 | WEBRTC_CHECK_CHANNEL(channel); |
| 823 | WEBRTC_CHECK_HEADER_EXTENSION_ID(enable, id); |
| 824 | channels_[channel]->receive_absolute_sender_time_ext_ = (enable) ? id : -1; |
| 825 | return 0; |
| 826 | } |
henrike@webrtc.org | 79047f9 | 2014-03-06 23:46:59 +0000 | [diff] [blame] | 827 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 828 | WEBRTC_STUB(SetRTCPStatus, (int channel, bool enable)); |
| 829 | WEBRTC_STUB(GetRTCPStatus, (int channel, bool& enabled)); |
| 830 | WEBRTC_STUB(SetRTCP_CNAME, (int channel, const char cname[256])); |
| 831 | WEBRTC_STUB(GetRTCP_CNAME, (int channel, char cname[256])); |
| 832 | WEBRTC_STUB(GetRemoteRTCP_CNAME, (int channel, char* cname)); |
| 833 | WEBRTC_STUB(GetRemoteRTCPData, (int channel, unsigned int& NTPHigh, |
| 834 | unsigned int& NTPLow, |
| 835 | unsigned int& timestamp, |
| 836 | unsigned int& playoutTimestamp, |
| 837 | unsigned int* jitter, |
| 838 | unsigned short* fractionLost)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 839 | WEBRTC_FUNC(GetRemoteRTCPReportBlocks, |
| 840 | (int channel, std::vector<webrtc::ReportBlock>* receive_blocks)) { |
| 841 | WEBRTC_CHECK_CHANNEL(channel); |
| 842 | webrtc::ReportBlock block; |
| 843 | block.source_SSRC = channels_[channel]->send_ssrc; |
| 844 | webrtc::CodecInst send_codec = channels_[channel]->send_codec; |
| 845 | if (send_codec.pltype >= 0) { |
| 846 | block.fraction_lost = (unsigned char)(kFractionLostStatValue * 256); |
| 847 | if (send_codec.plfreq / 1000 > 0) { |
| 848 | block.interarrival_jitter = kIntStatValue * (send_codec.plfreq / 1000); |
| 849 | } |
| 850 | block.cumulative_num_packets_lost = kIntStatValue; |
| 851 | block.extended_highest_sequence_number = kIntStatValue; |
| 852 | receive_blocks->push_back(block); |
| 853 | } |
| 854 | return 0; |
| 855 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 856 | WEBRTC_STUB(GetRTPStatistics, (int channel, unsigned int& averageJitterMs, |
| 857 | unsigned int& maxJitterMs, |
| 858 | unsigned int& discardedPackets)); |
| 859 | WEBRTC_FUNC(GetRTCPStatistics, (int channel, webrtc::CallStatistics& stats)) { |
| 860 | WEBRTC_CHECK_CHANNEL(channel); |
| 861 | stats.fractionLost = static_cast<int16>(kIntStatValue); |
| 862 | stats.cumulativeLost = kIntStatValue; |
| 863 | stats.extendedMax = kIntStatValue; |
| 864 | stats.jitterSamples = kIntStatValue; |
| 865 | stats.rttMs = kIntStatValue; |
| 866 | stats.bytesSent = kIntStatValue; |
| 867 | stats.packetsSent = kIntStatValue; |
| 868 | stats.bytesReceived = kIntStatValue; |
| 869 | stats.packetsReceived = kIntStatValue; |
| 870 | return 0; |
| 871 | } |
buildbot@webrtc.org | ae740dd | 2014-06-17 10:56:41 +0000 | [diff] [blame] | 872 | WEBRTC_FUNC(SetREDStatus, (int channel, bool enable, int redPayloadtype)) { |
buildbot@webrtc.org | bfa758a | 2014-06-27 16:04:43 +0000 | [diff] [blame] | 873 | return SetFECStatus(channel, enable, redPayloadtype); |
| 874 | } |
buildbot@webrtc.org | bfa758a | 2014-06-27 16:04:43 +0000 | [diff] [blame] | 875 | // TODO(minyue): remove the below function when transition to SetREDStatus |
| 876 | // is finished. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 877 | WEBRTC_FUNC(SetFECStatus, (int channel, bool enable, int redPayloadtype)) { |
| 878 | WEBRTC_CHECK_CHANNEL(channel); |
buildbot@webrtc.org | ae740dd | 2014-06-17 10:56:41 +0000 | [diff] [blame] | 879 | channels_[channel]->red = enable; |
| 880 | channels_[channel]->red_type = redPayloadtype; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 881 | return 0; |
| 882 | } |
buildbot@webrtc.org | ae740dd | 2014-06-17 10:56:41 +0000 | [diff] [blame] | 883 | WEBRTC_FUNC(GetREDStatus, (int channel, bool& enable, int& redPayloadtype)) { |
buildbot@webrtc.org | bfa758a | 2014-06-27 16:04:43 +0000 | [diff] [blame] | 884 | return GetFECStatus(channel, enable, redPayloadtype); |
| 885 | } |
buildbot@webrtc.org | bfa758a | 2014-06-27 16:04:43 +0000 | [diff] [blame] | 886 | // TODO(minyue): remove the below function when transition to GetREDStatus |
| 887 | // is finished. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 888 | WEBRTC_FUNC(GetFECStatus, (int channel, bool& enable, int& redPayloadtype)) { |
| 889 | WEBRTC_CHECK_CHANNEL(channel); |
buildbot@webrtc.org | ae740dd | 2014-06-17 10:56:41 +0000 | [diff] [blame] | 890 | enable = channels_[channel]->red; |
| 891 | redPayloadtype = channels_[channel]->red_type; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 892 | return 0; |
| 893 | } |
| 894 | WEBRTC_FUNC(SetNACKStatus, (int channel, bool enable, int maxNoPackets)) { |
| 895 | WEBRTC_CHECK_CHANNEL(channel); |
| 896 | channels_[channel]->nack = enable; |
| 897 | channels_[channel]->nack_max_packets = maxNoPackets; |
| 898 | return 0; |
| 899 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 900 | |
| 901 | // webrtc::VoEVideoSync |
| 902 | WEBRTC_STUB(GetPlayoutBufferSize, (int& bufferMs)); |
| 903 | WEBRTC_STUB(GetPlayoutTimestamp, (int channel, unsigned int& timestamp)); |
wu@webrtc.org | 822fbd8 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 904 | WEBRTC_STUB(GetRtpRtcp, (int, webrtc::RtpRtcp**, webrtc::RtpReceiver**)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 905 | WEBRTC_STUB(SetInitTimestamp, (int channel, unsigned int timestamp)); |
| 906 | WEBRTC_STUB(SetInitSequenceNumber, (int channel, short sequenceNumber)); |
| 907 | WEBRTC_STUB(SetMinimumPlayoutDelay, (int channel, int delayMs)); |
| 908 | WEBRTC_STUB(SetInitialPlayoutDelay, (int channel, int delay_ms)); |
| 909 | WEBRTC_STUB(GetDelayEstimate, (int channel, int* jitter_buffer_delay_ms, |
| 910 | int* playout_buffer_delay_ms)); |
| 911 | WEBRTC_STUB_CONST(GetLeastRequiredDelayMs, (int channel)); |
| 912 | |
| 913 | // webrtc::VoEVolumeControl |
| 914 | WEBRTC_STUB(SetSpeakerVolume, (unsigned int)); |
| 915 | WEBRTC_STUB(GetSpeakerVolume, (unsigned int&)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 916 | WEBRTC_STUB(SetMicVolume, (unsigned int)); |
| 917 | WEBRTC_STUB(GetMicVolume, (unsigned int&)); |
| 918 | WEBRTC_STUB(SetInputMute, (int, bool)); |
| 919 | WEBRTC_STUB(GetInputMute, (int, bool&)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 920 | WEBRTC_STUB(GetSpeechInputLevel, (unsigned int&)); |
| 921 | WEBRTC_STUB(GetSpeechOutputLevel, (int, unsigned int&)); |
| 922 | WEBRTC_STUB(GetSpeechInputLevelFullRange, (unsigned int&)); |
| 923 | WEBRTC_STUB(GetSpeechOutputLevelFullRange, (int, unsigned int&)); |
| 924 | WEBRTC_FUNC(SetChannelOutputVolumeScaling, (int channel, float scale)) { |
| 925 | WEBRTC_CHECK_CHANNEL(channel); |
| 926 | channels_[channel]->volume_scale= scale; |
| 927 | return 0; |
| 928 | } |
| 929 | WEBRTC_FUNC(GetChannelOutputVolumeScaling, (int channel, float& scale)) { |
| 930 | WEBRTC_CHECK_CHANNEL(channel); |
| 931 | scale = channels_[channel]->volume_scale; |
| 932 | return 0; |
| 933 | } |
| 934 | WEBRTC_FUNC(SetOutputVolumePan, (int channel, float left, float right)) { |
| 935 | WEBRTC_CHECK_CHANNEL(channel); |
| 936 | channels_[channel]->volume_pan_left = left; |
| 937 | channels_[channel]->volume_pan_right = right; |
| 938 | return 0; |
| 939 | } |
| 940 | WEBRTC_FUNC(GetOutputVolumePan, (int channel, float& left, float& right)) { |
| 941 | WEBRTC_CHECK_CHANNEL(channel); |
| 942 | left = channels_[channel]->volume_pan_left; |
| 943 | right = channels_[channel]->volume_pan_right; |
| 944 | return 0; |
| 945 | } |
| 946 | |
| 947 | // webrtc::VoEAudioProcessing |
| 948 | WEBRTC_FUNC(SetNsStatus, (bool enable, webrtc::NsModes mode)) { |
| 949 | ns_enabled_ = enable; |
| 950 | ns_mode_ = mode; |
| 951 | return 0; |
| 952 | } |
| 953 | WEBRTC_FUNC(GetNsStatus, (bool& enabled, webrtc::NsModes& mode)) { |
| 954 | enabled = ns_enabled_; |
| 955 | mode = ns_mode_; |
| 956 | return 0; |
| 957 | } |
| 958 | |
| 959 | WEBRTC_FUNC(SetAgcStatus, (bool enable, webrtc::AgcModes mode)) { |
| 960 | agc_enabled_ = enable; |
| 961 | agc_mode_ = mode; |
| 962 | return 0; |
| 963 | } |
| 964 | WEBRTC_FUNC(GetAgcStatus, (bool& enabled, webrtc::AgcModes& mode)) { |
| 965 | enabled = agc_enabled_; |
| 966 | mode = agc_mode_; |
| 967 | return 0; |
| 968 | } |
| 969 | |
| 970 | WEBRTC_FUNC(SetAgcConfig, (webrtc::AgcConfig config)) { |
| 971 | agc_config_ = config; |
| 972 | return 0; |
| 973 | } |
| 974 | WEBRTC_FUNC(GetAgcConfig, (webrtc::AgcConfig& config)) { |
| 975 | config = agc_config_; |
| 976 | return 0; |
| 977 | } |
| 978 | WEBRTC_FUNC(SetEcStatus, (bool enable, webrtc::EcModes mode)) { |
| 979 | ec_enabled_ = enable; |
| 980 | ec_mode_ = mode; |
| 981 | return 0; |
| 982 | } |
| 983 | WEBRTC_FUNC(GetEcStatus, (bool& enabled, webrtc::EcModes& mode)) { |
| 984 | enabled = ec_enabled_; |
| 985 | mode = ec_mode_; |
| 986 | return 0; |
| 987 | } |
| 988 | WEBRTC_STUB(EnableDriftCompensation, (bool enable)) |
| 989 | WEBRTC_BOOL_STUB(DriftCompensationEnabled, ()) |
| 990 | WEBRTC_VOID_STUB(SetDelayOffsetMs, (int offset)) |
| 991 | WEBRTC_STUB(DelayOffsetMs, ()); |
| 992 | WEBRTC_FUNC(SetAecmMode, (webrtc::AecmModes mode, bool enableCNG)) { |
| 993 | aecm_mode_ = mode; |
| 994 | cng_enabled_ = enableCNG; |
| 995 | return 0; |
| 996 | } |
| 997 | WEBRTC_FUNC(GetAecmMode, (webrtc::AecmModes& mode, bool& enabledCNG)) { |
| 998 | mode = aecm_mode_; |
| 999 | enabledCNG = cng_enabled_; |
| 1000 | return 0; |
| 1001 | } |
| 1002 | WEBRTC_STUB(SetRxNsStatus, (int channel, bool enable, webrtc::NsModes mode)); |
| 1003 | WEBRTC_STUB(GetRxNsStatus, (int channel, bool& enabled, |
| 1004 | webrtc::NsModes& mode)); |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 1005 | WEBRTC_FUNC(SetRxAgcStatus, (int channel, bool enable, |
| 1006 | webrtc::AgcModes mode)) { |
| 1007 | channels_[channel]->rx_agc_enabled = enable; |
| 1008 | channels_[channel]->rx_agc_mode = mode; |
| 1009 | return 0; |
| 1010 | } |
| 1011 | WEBRTC_FUNC(GetRxAgcStatus, (int channel, bool& enabled, |
| 1012 | webrtc::AgcModes& mode)) { |
| 1013 | enabled = channels_[channel]->rx_agc_enabled; |
| 1014 | mode = channels_[channel]->rx_agc_mode; |
| 1015 | return 0; |
| 1016 | } |
| 1017 | |
| 1018 | WEBRTC_FUNC(SetRxAgcConfig, (int channel, webrtc::AgcConfig config)) { |
| 1019 | channels_[channel]->rx_agc_config = config; |
| 1020 | return 0; |
| 1021 | } |
| 1022 | WEBRTC_FUNC(GetRxAgcConfig, (int channel, webrtc::AgcConfig& config)) { |
| 1023 | config = channels_[channel]->rx_agc_config; |
| 1024 | return 0; |
| 1025 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1026 | |
| 1027 | WEBRTC_STUB(RegisterRxVadObserver, (int, webrtc::VoERxVadCallback&)); |
| 1028 | WEBRTC_STUB(DeRegisterRxVadObserver, (int channel)); |
| 1029 | WEBRTC_STUB(VoiceActivityIndicator, (int channel)); |
| 1030 | WEBRTC_FUNC(SetEcMetricsStatus, (bool enable)) { |
| 1031 | ec_metrics_enabled_ = enable; |
| 1032 | return 0; |
| 1033 | } |
| 1034 | WEBRTC_FUNC(GetEcMetricsStatus, (bool& enabled)) { |
| 1035 | enabled = ec_metrics_enabled_; |
| 1036 | return 0; |
| 1037 | } |
| 1038 | WEBRTC_STUB(GetEchoMetrics, (int& ERL, int& ERLE, int& RERL, int& A_NLP)); |
bjornv@webrtc.org | cc64a9c | 2015-02-05 12:52:44 +0000 | [diff] [blame] | 1039 | WEBRTC_STUB(GetEcDelayMetrics, (int& delay_median, int& delay_std, |
| 1040 | float& fraction_poor_delays)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1041 | |
| 1042 | WEBRTC_STUB(StartDebugRecording, (const char* fileNameUTF8)); |
wu@webrtc.org | 9caf276 | 2013-12-11 18:25:07 +0000 | [diff] [blame] | 1043 | WEBRTC_STUB(StartDebugRecording, (FILE* handle)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1044 | WEBRTC_STUB(StopDebugRecording, ()); |
| 1045 | |
| 1046 | WEBRTC_FUNC(SetTypingDetectionStatus, (bool enable)) { |
| 1047 | typing_detection_enabled_ = enable; |
| 1048 | return 0; |
| 1049 | } |
| 1050 | WEBRTC_FUNC(GetTypingDetectionStatus, (bool& enabled)) { |
| 1051 | enabled = typing_detection_enabled_; |
| 1052 | return 0; |
| 1053 | } |
| 1054 | |
| 1055 | WEBRTC_STUB(TimeSinceLastTyping, (int& seconds)); |
| 1056 | WEBRTC_STUB(SetTypingDetectionParameters, (int timeWindow, |
| 1057 | int costPerTyping, |
| 1058 | int reportingThreshold, |
| 1059 | int penaltyDecay, |
| 1060 | int typeEventDelay)); |
| 1061 | int EnableHighPassFilter(bool enable) { |
| 1062 | highpass_filter_enabled_ = enable; |
| 1063 | return 0; |
| 1064 | } |
| 1065 | bool IsHighPassFilterEnabled() { |
| 1066 | return highpass_filter_enabled_; |
| 1067 | } |
| 1068 | bool IsStereoChannelSwappingEnabled() { |
| 1069 | return stereo_swapping_enabled_; |
| 1070 | } |
| 1071 | void EnableStereoChannelSwapping(bool enable) { |
| 1072 | stereo_swapping_enabled_ = enable; |
| 1073 | } |
| 1074 | bool WasSendTelephoneEventCalled(int channel, int event_code, int length_ms) { |
| 1075 | return (channels_[channel]->dtmf_info.dtmf_event_code == event_code && |
| 1076 | channels_[channel]->dtmf_info.dtmf_out_of_band == true && |
| 1077 | channels_[channel]->dtmf_info.dtmf_length_ms == length_ms); |
| 1078 | } |
| 1079 | bool WasPlayDtmfToneCalled(int event_code, int length_ms) { |
| 1080 | return (dtmf_info_.dtmf_event_code == event_code && |
| 1081 | dtmf_info_.dtmf_length_ms == length_ms); |
| 1082 | } |
Henrik Lundin | 64dad83 | 2015-05-11 12:44:23 +0200 | [diff] [blame] | 1083 | int GetNetEqCapacity() const { |
| 1084 | auto ch = channels_.find(last_channel_); |
| 1085 | ASSERT(ch != channels_.end()); |
| 1086 | return ch->second->neteq_capacity; |
| 1087 | } |
Henrik Lundin | 5263b3c | 2015-06-01 10:29:41 +0200 | [diff] [blame] | 1088 | bool GetNetEqFastAccelerate() const { |
| 1089 | auto ch = channels_.find(last_channel_); |
| 1090 | ASSERT(ch != channels_.end()); |
| 1091 | return ch->second->neteq_fast_accelerate; |
| 1092 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1093 | |
| 1094 | private: |
| 1095 | int GetNumDevices(int& num) { |
| 1096 | #ifdef WIN32 |
| 1097 | num = 1; |
| 1098 | #else |
| 1099 | // On non-Windows platforms VE adds a special entry for the default device, |
| 1100 | // so if there is one physical device then there are two entries in the |
| 1101 | // list. |
| 1102 | num = 2; |
| 1103 | #endif |
| 1104 | return 0; |
| 1105 | } |
| 1106 | |
| 1107 | int GetDeviceName(int i, char* name, char* guid) { |
| 1108 | const char *s; |
| 1109 | #ifdef WIN32 |
| 1110 | if (0 == i) { |
| 1111 | s = kFakeDeviceName; |
| 1112 | } else { |
| 1113 | return -1; |
| 1114 | } |
| 1115 | #else |
| 1116 | // See comment above. |
| 1117 | if (0 == i) { |
| 1118 | s = kFakeDefaultDeviceName; |
| 1119 | } else if (1 == i) { |
| 1120 | s = kFakeDeviceName; |
| 1121 | } else { |
| 1122 | return -1; |
| 1123 | } |
| 1124 | #endif |
| 1125 | strcpy(name, s); |
| 1126 | guid[0] = '\0'; |
| 1127 | return 0; |
| 1128 | } |
| 1129 | |
| 1130 | bool inited_; |
| 1131 | int last_channel_; |
| 1132 | std::map<int, Channel*> channels_; |
| 1133 | bool fail_create_channel_; |
| 1134 | const cricket::AudioCodec* const* codecs_; |
| 1135 | int num_codecs_; |
wu@webrtc.org | 05e7b44 | 2014-04-01 17:44:24 +0000 | [diff] [blame] | 1136 | int num_set_send_codecs_; // how many times we call SetSendCodec(). |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1137 | bool ec_enabled_; |
| 1138 | bool ec_metrics_enabled_; |
| 1139 | bool cng_enabled_; |
| 1140 | bool ns_enabled_; |
| 1141 | bool agc_enabled_; |
| 1142 | bool highpass_filter_enabled_; |
| 1143 | bool stereo_swapping_enabled_; |
| 1144 | bool typing_detection_enabled_; |
| 1145 | webrtc::EcModes ec_mode_; |
| 1146 | webrtc::AecmModes aecm_mode_; |
| 1147 | webrtc::NsModes ns_mode_; |
| 1148 | webrtc::AgcModes agc_mode_; |
| 1149 | webrtc::AgcConfig agc_config_; |
| 1150 | webrtc::VoiceEngineObserver* observer_; |
| 1151 | int playout_fail_channel_; |
| 1152 | int send_fail_channel_; |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 1153 | int recording_sample_rate_; |
| 1154 | int playout_sample_rate_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1155 | DtmfInfo dtmf_info_; |
buildbot@webrtc.org | a8d8ad2 | 2014-07-16 14:23:08 +0000 | [diff] [blame] | 1156 | FakeAudioProcessing audio_processing_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1157 | }; |
| 1158 | |
henrike@webrtc.org | 79047f9 | 2014-03-06 23:46:59 +0000 | [diff] [blame] | 1159 | #undef WEBRTC_CHECK_HEADER_EXTENSION_ID |
| 1160 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1161 | } // namespace cricket |
| 1162 | |
| 1163 | #endif // TALK_SESSION_PHONE_FAKEWEBRTCVOICEENGINE_H_ |