henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1 | /* |
kjellander | 1afca73 | 2016-02-07 20:46:45 -0800 | [diff] [blame] | 2 | * Copyright (c) 2010 The WebRTC project authors. All Rights Reserved. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3 | * |
kjellander | 1afca73 | 2016-02-07 20:46:45 -0800 | [diff] [blame] | 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 9 | */ |
| 10 | |
kjellander@webrtc.org | 5ad1297 | 2016-02-12 06:39:40 +0100 | [diff] [blame] | 11 | #ifndef WEBRTC_MEDIA_ENGINE_FAKEWEBRTCVOICEENGINE_H_ |
| 12 | #define WEBRTC_MEDIA_ENGINE_FAKEWEBRTCVOICEENGINE_H_ |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 13 | |
| 14 | #include <list> |
| 15 | #include <map> |
| 16 | #include <vector> |
| 17 | |
buildbot@webrtc.org | a09a999 | 2014-08-13 17:26:08 +0000 | [diff] [blame] | 18 | #include "webrtc/base/basictypes.h" |
Fredrik Solenberg | d3ddc1b | 2015-05-07 17:07:34 +0200 | [diff] [blame] | 19 | #include "webrtc/base/checks.h" |
buildbot@webrtc.org | a09a999 | 2014-08-13 17:26:08 +0000 | [diff] [blame] | 20 | #include "webrtc/base/gunit.h" |
| 21 | #include "webrtc/base/stringutils.h" |
Henrik Lundin | 64dad83 | 2015-05-11 12:44:23 +0200 | [diff] [blame] | 22 | #include "webrtc/config.h" |
kjellander | a96e2d7 | 2016-02-04 23:52:28 -0800 | [diff] [blame] | 23 | #include "webrtc/media/base/codec.h" |
| 24 | #include "webrtc/media/base/rtputils.h" |
kjellander@webrtc.org | 5ad1297 | 2016-02-12 06:39:40 +0100 | [diff] [blame] | 25 | #include "webrtc/media/engine/fakewebrtccommon.h" |
| 26 | #include "webrtc/media/engine/webrtcvoe.h" |
solenberg | 26c8c91 | 2015-11-27 04:00:25 -0800 | [diff] [blame] | 27 | #include "webrtc/modules/audio_coding/acm2/rent_a_codec.h" |
buildbot@webrtc.org | a8d8ad2 | 2014-07-16 14:23:08 +0000 | [diff] [blame] | 28 | #include "webrtc/modules/audio_processing/include/audio_processing.h" |
buildbot@webrtc.org | f875f15 | 2014-04-14 16:06:21 +0000 | [diff] [blame] | 29 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 30 | namespace cricket { |
| 31 | |
buildbot@webrtc.org | 5d639b3 | 2014-09-10 07:57:12 +0000 | [diff] [blame] | 32 | static const int kOpusBandwidthNb = 4000; |
| 33 | static const int kOpusBandwidthMb = 6000; |
| 34 | static const int kOpusBandwidthWb = 8000; |
| 35 | static const int kOpusBandwidthSwb = 12000; |
| 36 | static const int kOpusBandwidthFb = 20000; |
| 37 | |
Fredrik Solenberg | d3ddc1b | 2015-05-07 17:07:34 +0200 | [diff] [blame] | 38 | #define WEBRTC_CHECK_CHANNEL(channel) \ |
| 39 | if (channels_.find(channel) == channels_.end()) return -1; |
| 40 | |
buildbot@webrtc.org | a8d8ad2 | 2014-07-16 14:23:08 +0000 | [diff] [blame] | 41 | class FakeAudioProcessing : public webrtc::AudioProcessing { |
| 42 | public: |
| 43 | FakeAudioProcessing() : experimental_ns_enabled_(false) {} |
| 44 | |
| 45 | WEBRTC_STUB(Initialize, ()) |
| 46 | WEBRTC_STUB(Initialize, ( |
| 47 | int input_sample_rate_hz, |
| 48 | int output_sample_rate_hz, |
| 49 | int reverse_sample_rate_hz, |
| 50 | webrtc::AudioProcessing::ChannelLayout input_layout, |
| 51 | webrtc::AudioProcessing::ChannelLayout output_layout, |
| 52 | webrtc::AudioProcessing::ChannelLayout reverse_layout)); |
Michael Graczyk | 86c6d33 | 2015-07-23 11:41:39 -0700 | [diff] [blame] | 53 | WEBRTC_STUB(Initialize, ( |
| 54 | const webrtc::ProcessingConfig& processing_config)); |
buildbot@webrtc.org | a8d8ad2 | 2014-07-16 14:23:08 +0000 | [diff] [blame] | 55 | |
| 56 | WEBRTC_VOID_FUNC(SetExtraOptions, (const webrtc::Config& config)) { |
| 57 | experimental_ns_enabled_ = config.Get<webrtc::ExperimentalNs>().enabled; |
| 58 | } |
| 59 | |
buildbot@webrtc.org | a8d8ad2 | 2014-07-16 14:23:08 +0000 | [diff] [blame] | 60 | WEBRTC_STUB_CONST(proc_sample_rate_hz, ()); |
| 61 | WEBRTC_STUB_CONST(proc_split_sample_rate_hz, ()); |
Peter Kasting | 6955870 | 2016-01-12 16:26:35 -0800 | [diff] [blame] | 62 | size_t num_input_channels() const override { return 0; } |
| 63 | size_t num_proc_channels() const override { return 0; } |
| 64 | size_t num_output_channels() const override { return 0; } |
| 65 | size_t num_reverse_channels() const override { return 0; } |
buildbot@webrtc.org | a8d8ad2 | 2014-07-16 14:23:08 +0000 | [diff] [blame] | 66 | WEBRTC_VOID_STUB(set_output_will_be_muted, (bool muted)); |
buildbot@webrtc.org | a8d8ad2 | 2014-07-16 14:23:08 +0000 | [diff] [blame] | 67 | WEBRTC_STUB(ProcessStream, (webrtc::AudioFrame* frame)); |
| 68 | WEBRTC_STUB(ProcessStream, ( |
| 69 | const float* const* src, |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 70 | size_t samples_per_channel, |
buildbot@webrtc.org | a8d8ad2 | 2014-07-16 14:23:08 +0000 | [diff] [blame] | 71 | int input_sample_rate_hz, |
| 72 | webrtc::AudioProcessing::ChannelLayout input_layout, |
| 73 | int output_sample_rate_hz, |
| 74 | webrtc::AudioProcessing::ChannelLayout output_layout, |
| 75 | float* const* dest)); |
Michael Graczyk | 86c6d33 | 2015-07-23 11:41:39 -0700 | [diff] [blame] | 76 | WEBRTC_STUB(ProcessStream, |
| 77 | (const float* const* src, |
| 78 | const webrtc::StreamConfig& input_config, |
| 79 | const webrtc::StreamConfig& output_config, |
| 80 | float* const* dest)); |
ekmeyerson | 60d9b33 | 2015-08-14 10:35:55 -0700 | [diff] [blame] | 81 | WEBRTC_STUB(ProcessReverseStream, (webrtc::AudioFrame * frame)); |
buildbot@webrtc.org | a8d8ad2 | 2014-07-16 14:23:08 +0000 | [diff] [blame] | 82 | WEBRTC_STUB(AnalyzeReverseStream, ( |
| 83 | const float* const* data, |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 84 | size_t samples_per_channel, |
buildbot@webrtc.org | a8d8ad2 | 2014-07-16 14:23:08 +0000 | [diff] [blame] | 85 | int sample_rate_hz, |
| 86 | webrtc::AudioProcessing::ChannelLayout layout)); |
ekmeyerson | 60d9b33 | 2015-08-14 10:35:55 -0700 | [diff] [blame] | 87 | WEBRTC_STUB(ProcessReverseStream, |
| 88 | (const float* const* src, |
| 89 | const webrtc::StreamConfig& reverse_input_config, |
| 90 | const webrtc::StreamConfig& reverse_output_config, |
| 91 | float* const* dest)); |
buildbot@webrtc.org | a8d8ad2 | 2014-07-16 14:23:08 +0000 | [diff] [blame] | 92 | WEBRTC_STUB(set_stream_delay_ms, (int delay)); |
| 93 | WEBRTC_STUB_CONST(stream_delay_ms, ()); |
| 94 | WEBRTC_BOOL_STUB_CONST(was_stream_delay_set, ()); |
| 95 | WEBRTC_VOID_STUB(set_stream_key_pressed, (bool key_pressed)); |
buildbot@webrtc.org | a8d8ad2 | 2014-07-16 14:23:08 +0000 | [diff] [blame] | 96 | WEBRTC_VOID_STUB(set_delay_offset_ms, (int offset)); |
| 97 | WEBRTC_STUB_CONST(delay_offset_ms, ()); |
ivoc | d66b44d | 2016-01-15 03:06:36 -0800 | [diff] [blame] | 98 | WEBRTC_STUB(StartDebugRecording, |
| 99 | (const char filename[kMaxFilenameSize], int64_t max_size_bytes)); |
| 100 | WEBRTC_STUB(StartDebugRecording, (FILE * handle, int64_t max_size_bytes)); |
buildbot@webrtc.org | a8d8ad2 | 2014-07-16 14:23:08 +0000 | [diff] [blame] | 101 | WEBRTC_STUB(StopDebugRecording, ()); |
Bjorn Volcker | 4e7aa43 | 2015-07-07 11:50:05 +0200 | [diff] [blame] | 102 | WEBRTC_VOID_STUB(UpdateHistogramsOnCallEnd, ()); |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 103 | webrtc::EchoCancellation* echo_cancellation() const override { return NULL; } |
| 104 | webrtc::EchoControlMobile* echo_control_mobile() const override { |
buildbot@webrtc.org | a8d8ad2 | 2014-07-16 14:23:08 +0000 | [diff] [blame] | 105 | return NULL; |
| 106 | } |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 107 | webrtc::GainControl* gain_control() const override { return NULL; } |
| 108 | webrtc::HighPassFilter* high_pass_filter() const override { return NULL; } |
| 109 | webrtc::LevelEstimator* level_estimator() const override { return NULL; } |
| 110 | webrtc::NoiseSuppression* noise_suppression() const override { return NULL; } |
| 111 | webrtc::VoiceDetection* voice_detection() const override { return NULL; } |
buildbot@webrtc.org | a8d8ad2 | 2014-07-16 14:23:08 +0000 | [diff] [blame] | 112 | |
| 113 | bool experimental_ns_enabled() { |
| 114 | return experimental_ns_enabled_; |
| 115 | } |
| 116 | |
| 117 | private: |
| 118 | bool experimental_ns_enabled_; |
| 119 | }; |
buildbot@webrtc.org | a8d8ad2 | 2014-07-16 14:23:08 +0000 | [diff] [blame] | 120 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 121 | class FakeWebRtcVoiceEngine |
| 122 | : public webrtc::VoEAudioProcessing, |
Fredrik Solenberg | b572768 | 2015-12-04 15:22:19 +0100 | [diff] [blame] | 123 | public webrtc::VoEBase, public webrtc::VoECodec, |
Fredrik Solenberg | 4f4ec0a | 2015-10-22 10:49:27 +0200 | [diff] [blame] | 124 | public webrtc::VoEHardware, |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 125 | public webrtc::VoENetwork, public webrtc::VoERTP_RTCP, |
Fredrik Solenberg | 4f4ec0a | 2015-10-22 10:49:27 +0200 | [diff] [blame] | 126 | public webrtc::VoEVolumeControl { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 127 | public: |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 128 | struct Channel { |
solenberg | bc37fc8 | 2016-04-04 09:54:44 -0700 | [diff] [blame^] | 129 | Channel() { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 130 | memset(&send_codec, 0, sizeof(send_codec)); |
| 131 | } |
solenberg | bc37fc8 | 2016-04-04 09:54:44 -0700 | [diff] [blame^] | 132 | bool external_transport = false; |
| 133 | bool playout = false; |
| 134 | float volume_scale = 1.0f; |
| 135 | bool vad = false; |
| 136 | bool codec_fec = false; |
| 137 | int max_encoding_bandwidth = 0; |
| 138 | bool opus_dtx = false; |
| 139 | bool red = false; |
| 140 | bool nack = false; |
| 141 | int cn8_type = 13; |
| 142 | int cn16_type = 105; |
| 143 | int red_type = 117; |
| 144 | int nack_max_packets = 0; |
| 145 | uint32_t send_ssrc = 0; |
| 146 | int associate_send_channel = -1; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 147 | std::vector<webrtc::CodecInst> recv_codecs; |
| 148 | webrtc::CodecInst send_codec; |
buildbot@webrtc.org | f875f15 | 2014-04-14 16:06:21 +0000 | [diff] [blame] | 149 | webrtc::PacketTime last_rtp_packet_time; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 150 | std::list<std::string> packets; |
solenberg | bc37fc8 | 2016-04-04 09:54:44 -0700 | [diff] [blame^] | 151 | int neteq_capacity = -1; |
| 152 | bool neteq_fast_accelerate = false; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 153 | }; |
| 154 | |
solenberg | bc37fc8 | 2016-04-04 09:54:44 -0700 | [diff] [blame^] | 155 | FakeWebRtcVoiceEngine() { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 156 | memset(&agc_config_, 0, sizeof(agc_config_)); |
| 157 | } |
solenberg | ff97631 | 2016-03-30 23:28:51 -0700 | [diff] [blame] | 158 | ~FakeWebRtcVoiceEngine() override { |
solenberg | 26c8c91 | 2015-11-27 04:00:25 -0800 | [diff] [blame] | 159 | RTC_CHECK(channels_.empty()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 160 | } |
| 161 | |
solenberg | 85a0496 | 2015-10-27 03:35:21 -0700 | [diff] [blame] | 162 | bool ec_metrics_enabled() const { return ec_metrics_enabled_; } |
| 163 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 164 | bool IsInited() const { return inited_; } |
| 165 | int GetLastChannel() const { return last_channel_; } |
wu@webrtc.org | 9caf276 | 2013-12-11 18:25:07 +0000 | [diff] [blame] | 166 | int GetNumChannels() const { return static_cast<int>(channels_.size()); } |
solenberg | 85a0496 | 2015-10-27 03:35:21 -0700 | [diff] [blame] | 167 | uint32_t GetLocalSSRC(int channel) { |
| 168 | return channels_[channel]->send_ssrc; |
| 169 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 170 | bool GetPlayout(int channel) { |
| 171 | return channels_[channel]->playout; |
| 172 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 173 | bool GetVAD(int channel) { |
| 174 | return channels_[channel]->vad; |
| 175 | } |
Minyue Li | 7100dcd | 2015-03-27 05:05:59 +0100 | [diff] [blame] | 176 | bool GetOpusDtx(int channel) { |
| 177 | return channels_[channel]->opus_dtx; |
| 178 | } |
buildbot@webrtc.org | ae740dd | 2014-06-17 10:56:41 +0000 | [diff] [blame] | 179 | bool GetRED(int channel) { |
| 180 | return channels_[channel]->red; |
| 181 | } |
| 182 | bool GetCodecFEC(int channel) { |
| 183 | return channels_[channel]->codec_fec; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 184 | } |
buildbot@webrtc.org | 5d639b3 | 2014-09-10 07:57:12 +0000 | [diff] [blame] | 185 | int GetMaxEncodingBandwidth(int channel) { |
| 186 | return channels_[channel]->max_encoding_bandwidth; |
| 187 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 188 | bool GetNACK(int channel) { |
| 189 | return channels_[channel]->nack; |
| 190 | } |
| 191 | int GetNACKMaxPackets(int channel) { |
| 192 | return channels_[channel]->nack_max_packets; |
| 193 | } |
buildbot@webrtc.org | f875f15 | 2014-04-14 16:06:21 +0000 | [diff] [blame] | 194 | const webrtc::PacketTime& GetLastRtpPacketTime(int channel) { |
solenberg | 26c8c91 | 2015-11-27 04:00:25 -0800 | [diff] [blame] | 195 | RTC_DCHECK(channels_.find(channel) != channels_.end()); |
buildbot@webrtc.org | f875f15 | 2014-04-14 16:06:21 +0000 | [diff] [blame] | 196 | return channels_[channel]->last_rtp_packet_time; |
| 197 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 198 | int GetSendCNPayloadType(int channel, bool wideband) { |
| 199 | return (wideband) ? |
| 200 | channels_[channel]->cn16_type : |
| 201 | channels_[channel]->cn8_type; |
| 202 | } |
buildbot@webrtc.org | ae740dd | 2014-06-17 10:56:41 +0000 | [diff] [blame] | 203 | int GetSendREDPayloadType(int channel) { |
| 204 | return channels_[channel]->red_type; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 205 | } |
| 206 | bool CheckPacket(int channel, const void* data, size_t len) { |
| 207 | bool result = !CheckNoPacket(channel); |
| 208 | if (result) { |
| 209 | std::string packet = channels_[channel]->packets.front(); |
| 210 | result = (packet == std::string(static_cast<const char*>(data), len)); |
| 211 | channels_[channel]->packets.pop_front(); |
| 212 | } |
| 213 | return result; |
| 214 | } |
| 215 | bool CheckNoPacket(int channel) { |
| 216 | return channels_[channel]->packets.empty(); |
| 217 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 218 | void set_playout_fail_channel(int channel) { |
| 219 | playout_fail_channel_ = channel; |
| 220 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 221 | void set_fail_create_channel(bool fail_create_channel) { |
| 222 | fail_create_channel_ = fail_create_channel; |
| 223 | } |
Henrik Lundin | 64dad83 | 2015-05-11 12:44:23 +0200 | [diff] [blame] | 224 | int AddChannel(const webrtc::Config& config) { |
wu@webrtc.org | 364f204 | 2013-11-20 21:49:41 +0000 | [diff] [blame] | 225 | if (fail_create_channel_) { |
| 226 | return -1; |
| 227 | } |
buildbot@webrtc.org | af6640f | 2014-04-28 21:31:51 +0000 | [diff] [blame] | 228 | Channel* ch = new Channel(); |
solenberg | 26c8c91 | 2015-11-27 04:00:25 -0800 | [diff] [blame] | 229 | auto db = webrtc::acm2::RentACodec::Database(); |
| 230 | ch->recv_codecs.assign(db.begin(), db.end()); |
Henrik Lundin | 64dad83 | 2015-05-11 12:44:23 +0200 | [diff] [blame] | 231 | if (config.Get<webrtc::NetEqCapacityConfig>().enabled) { |
| 232 | ch->neteq_capacity = config.Get<webrtc::NetEqCapacityConfig>().capacity; |
| 233 | } |
Henrik Lundin | 5263b3c | 2015-06-01 10:29:41 +0200 | [diff] [blame] | 234 | ch->neteq_fast_accelerate = |
| 235 | config.Get<webrtc::NetEqFastAccelerate>().enabled; |
wu@webrtc.org | 364f204 | 2013-11-20 21:49:41 +0000 | [diff] [blame] | 236 | channels_[++last_channel_] = ch; |
| 237 | return last_channel_; |
| 238 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 239 | |
wu@webrtc.org | 05e7b44 | 2014-04-01 17:44:24 +0000 | [diff] [blame] | 240 | int GetNumSetSendCodecs() const { return num_set_send_codecs_; } |
| 241 | |
Minyue | 2013aec | 2015-05-13 14:14:42 +0200 | [diff] [blame] | 242 | int GetAssociateSendChannel(int channel) { |
| 243 | return channels_[channel]->associate_send_channel; |
| 244 | } |
| 245 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 246 | WEBRTC_STUB(Release, ()); |
| 247 | |
| 248 | // webrtc::VoEBase |
solenberg | bc37fc8 | 2016-04-04 09:54:44 -0700 | [diff] [blame^] | 249 | WEBRTC_STUB(RegisterVoiceEngineObserver, ( |
| 250 | webrtc::VoiceEngineObserver& observer)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 251 | WEBRTC_STUB(DeRegisterVoiceEngineObserver, ()); |
| 252 | WEBRTC_FUNC(Init, (webrtc::AudioDeviceModule* adm, |
| 253 | webrtc::AudioProcessing* audioproc)) { |
| 254 | inited_ = true; |
| 255 | return 0; |
| 256 | } |
| 257 | WEBRTC_FUNC(Terminate, ()) { |
| 258 | inited_ = false; |
| 259 | return 0; |
| 260 | } |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 261 | webrtc::AudioProcessing* audio_processing() override { |
buildbot@webrtc.org | a8d8ad2 | 2014-07-16 14:23:08 +0000 | [diff] [blame] | 262 | return &audio_processing_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 263 | } |
solenberg | ff97631 | 2016-03-30 23:28:51 -0700 | [diff] [blame] | 264 | webrtc::AudioDeviceModule* audio_device_module() override { |
solenberg | bc37fc8 | 2016-04-04 09:54:44 -0700 | [diff] [blame^] | 265 | return nullptr; |
solenberg | ff97631 | 2016-03-30 23:28:51 -0700 | [diff] [blame] | 266 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 267 | WEBRTC_FUNC(CreateChannel, ()) { |
Henrik Lundin | 64dad83 | 2015-05-11 12:44:23 +0200 | [diff] [blame] | 268 | webrtc::Config empty_config; |
| 269 | return AddChannel(empty_config); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 270 | } |
Henrik Lundin | 64dad83 | 2015-05-11 12:44:23 +0200 | [diff] [blame] | 271 | WEBRTC_FUNC(CreateChannel, (const webrtc::Config& config)) { |
| 272 | return AddChannel(config); |
wu@webrtc.org | 364f204 | 2013-11-20 21:49:41 +0000 | [diff] [blame] | 273 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 274 | WEBRTC_FUNC(DeleteChannel, (int channel)) { |
| 275 | WEBRTC_CHECK_CHANNEL(channel); |
Minyue | 2013aec | 2015-05-13 14:14:42 +0200 | [diff] [blame] | 276 | for (const auto& ch : channels_) { |
| 277 | if (ch.second->associate_send_channel == channel) { |
| 278 | ch.second->associate_send_channel = -1; |
| 279 | } |
| 280 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 281 | delete channels_[channel]; |
| 282 | channels_.erase(channel); |
| 283 | return 0; |
| 284 | } |
| 285 | WEBRTC_STUB(StartReceive, (int channel)); |
| 286 | WEBRTC_FUNC(StartPlayout, (int channel)) { |
| 287 | if (playout_fail_channel_ != channel) { |
| 288 | WEBRTC_CHECK_CHANNEL(channel); |
| 289 | channels_[channel]->playout = true; |
| 290 | return 0; |
| 291 | } else { |
| 292 | // When playout_fail_channel_ == channel, fail the StartPlayout on this |
| 293 | // channel. |
| 294 | return -1; |
| 295 | } |
| 296 | } |
Taylor Brandstetter | 1a018dc | 2016-03-08 12:37:39 -0800 | [diff] [blame] | 297 | WEBRTC_STUB(StartSend, (int channel)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 298 | WEBRTC_STUB(StopReceive, (int channel)); |
| 299 | WEBRTC_FUNC(StopPlayout, (int channel)) { |
| 300 | WEBRTC_CHECK_CHANNEL(channel); |
| 301 | channels_[channel]->playout = false; |
| 302 | return 0; |
| 303 | } |
Taylor Brandstetter | 1a018dc | 2016-03-08 12:37:39 -0800 | [diff] [blame] | 304 | WEBRTC_STUB(StopSend, (int channel)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 305 | WEBRTC_STUB(GetVersion, (char version[1024])); |
| 306 | WEBRTC_STUB(LastError, ()); |
Minyue | 2013aec | 2015-05-13 14:14:42 +0200 | [diff] [blame] | 307 | WEBRTC_FUNC(AssociateSendChannel, (int channel, |
| 308 | int accociate_send_channel)) { |
| 309 | WEBRTC_CHECK_CHANNEL(channel); |
| 310 | channels_[channel]->associate_send_channel = accociate_send_channel; |
| 311 | return 0; |
| 312 | } |
ivoc | b04965c | 2015-09-09 00:09:43 -0700 | [diff] [blame] | 313 | webrtc::RtcEventLog* GetEventLog() { return nullptr; } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 314 | |
| 315 | // webrtc::VoECodec |
solenberg | 26c8c91 | 2015-11-27 04:00:25 -0800 | [diff] [blame] | 316 | WEBRTC_STUB(NumOfCodecs, ()); |
| 317 | WEBRTC_STUB(GetCodec, (int index, webrtc::CodecInst& codec)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 318 | WEBRTC_FUNC(SetSendCodec, (int channel, const webrtc::CodecInst& codec)) { |
| 319 | WEBRTC_CHECK_CHANNEL(channel); |
henrike@webrtc.org | 704bf9e | 2014-02-27 17:52:04 +0000 | [diff] [blame] | 320 | // To match the behavior of the real implementation. |
| 321 | if (_stricmp(codec.plname, "telephone-event") == 0 || |
| 322 | _stricmp(codec.plname, "audio/telephone-event") == 0 || |
| 323 | _stricmp(codec.plname, "CN") == 0 || |
| 324 | _stricmp(codec.plname, "red") == 0 ) { |
| 325 | return -1; |
| 326 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 327 | channels_[channel]->send_codec = codec; |
wu@webrtc.org | 05e7b44 | 2014-04-01 17:44:24 +0000 | [diff] [blame] | 328 | ++num_set_send_codecs_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 329 | return 0; |
| 330 | } |
| 331 | WEBRTC_FUNC(GetSendCodec, (int channel, webrtc::CodecInst& codec)) { |
| 332 | WEBRTC_CHECK_CHANNEL(channel); |
| 333 | codec = channels_[channel]->send_codec; |
| 334 | return 0; |
| 335 | } |
Ivo Creusen | adf89b7 | 2015-04-29 16:03:33 +0200 | [diff] [blame] | 336 | WEBRTC_STUB(SetBitRate, (int channel, int bitrate_bps)); |
Fredrik Solenberg | 4f4ec0a | 2015-10-22 10:49:27 +0200 | [diff] [blame] | 337 | WEBRTC_STUB(GetRecCodec, (int channel, webrtc::CodecInst& codec)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 338 | WEBRTC_FUNC(SetRecPayloadType, (int channel, |
| 339 | const webrtc::CodecInst& codec)) { |
| 340 | WEBRTC_CHECK_CHANNEL(channel); |
| 341 | Channel* ch = channels_[channel]; |
| 342 | if (ch->playout) |
| 343 | return -1; // Channel is in use. |
| 344 | // Check if something else already has this slot. |
| 345 | if (codec.pltype != -1) { |
| 346 | for (std::vector<webrtc::CodecInst>::iterator it = |
| 347 | ch->recv_codecs.begin(); it != ch->recv_codecs.end(); ++it) { |
| 348 | if (it->pltype == codec.pltype && |
| 349 | _stricmp(it->plname, codec.plname) != 0) { |
| 350 | return -1; |
| 351 | } |
| 352 | } |
| 353 | } |
| 354 | // Otherwise try to find this codec and update its payload type. |
solenberg | 26c8c91 | 2015-11-27 04:00:25 -0800 | [diff] [blame] | 355 | int result = -1; // not found |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 356 | for (std::vector<webrtc::CodecInst>::iterator it = ch->recv_codecs.begin(); |
| 357 | it != ch->recv_codecs.end(); ++it) { |
| 358 | if (strcmp(it->plname, codec.plname) == 0 && |
solenberg | 26c8c91 | 2015-11-27 04:00:25 -0800 | [diff] [blame] | 359 | it->plfreq == codec.plfreq && |
| 360 | it->channels == codec.channels) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 361 | it->pltype = codec.pltype; |
solenberg | 26c8c91 | 2015-11-27 04:00:25 -0800 | [diff] [blame] | 362 | result = 0; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 363 | } |
| 364 | } |
solenberg | 26c8c91 | 2015-11-27 04:00:25 -0800 | [diff] [blame] | 365 | return result; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 366 | } |
| 367 | WEBRTC_FUNC(SetSendCNPayloadType, (int channel, int type, |
| 368 | webrtc::PayloadFrequencies frequency)) { |
| 369 | WEBRTC_CHECK_CHANNEL(channel); |
| 370 | if (frequency == webrtc::kFreq8000Hz) { |
| 371 | channels_[channel]->cn8_type = type; |
| 372 | } else if (frequency == webrtc::kFreq16000Hz) { |
| 373 | channels_[channel]->cn16_type = type; |
| 374 | } |
| 375 | return 0; |
| 376 | } |
| 377 | WEBRTC_FUNC(GetRecPayloadType, (int channel, webrtc::CodecInst& codec)) { |
| 378 | WEBRTC_CHECK_CHANNEL(channel); |
| 379 | Channel* ch = channels_[channel]; |
| 380 | for (std::vector<webrtc::CodecInst>::iterator it = ch->recv_codecs.begin(); |
| 381 | it != ch->recv_codecs.end(); ++it) { |
| 382 | if (strcmp(it->plname, codec.plname) == 0 && |
| 383 | it->plfreq == codec.plfreq && |
| 384 | it->channels == codec.channels && |
| 385 | it->pltype != -1) { |
| 386 | codec.pltype = it->pltype; |
| 387 | return 0; |
| 388 | } |
| 389 | } |
| 390 | return -1; // not found |
| 391 | } |
| 392 | WEBRTC_FUNC(SetVADStatus, (int channel, bool enable, webrtc::VadModes mode, |
| 393 | bool disableDTX)) { |
| 394 | WEBRTC_CHECK_CHANNEL(channel); |
| 395 | if (channels_[channel]->send_codec.channels == 2) { |
| 396 | // Replicating VoE behavior; VAD cannot be enabled for stereo. |
| 397 | return -1; |
| 398 | } |
| 399 | channels_[channel]->vad = enable; |
| 400 | return 0; |
| 401 | } |
| 402 | WEBRTC_STUB(GetVADStatus, (int channel, bool& enabled, |
| 403 | webrtc::VadModes& mode, bool& disabledDTX)); |
buildbot@webrtc.org | 5d639b3 | 2014-09-10 07:57:12 +0000 | [diff] [blame] | 404 | |
buildbot@webrtc.org | ae740dd | 2014-06-17 10:56:41 +0000 | [diff] [blame] | 405 | WEBRTC_FUNC(SetFECStatus, (int channel, bool enable)) { |
| 406 | WEBRTC_CHECK_CHANNEL(channel); |
buildbot@webrtc.org | 5d639b3 | 2014-09-10 07:57:12 +0000 | [diff] [blame] | 407 | if (_stricmp(channels_[channel]->send_codec.plname, "opus") != 0) { |
buildbot@webrtc.org | 3ffa1f9 | 2014-07-02 19:51:26 +0000 | [diff] [blame] | 408 | // Return -1 if current send codec is not Opus. |
| 409 | // TODO(minyue): Excludes other codecs if they support inband FEC. |
| 410 | return -1; |
| 411 | } |
buildbot@webrtc.org | ae740dd | 2014-06-17 10:56:41 +0000 | [diff] [blame] | 412 | channels_[channel]->codec_fec = enable; |
| 413 | return 0; |
| 414 | } |
| 415 | WEBRTC_FUNC(GetFECStatus, (int channel, bool& enable)) { |
| 416 | WEBRTC_CHECK_CHANNEL(channel); |
| 417 | enable = channels_[channel]->codec_fec; |
| 418 | return 0; |
| 419 | } |
buildbot@webrtc.org | 5d639b3 | 2014-09-10 07:57:12 +0000 | [diff] [blame] | 420 | |
| 421 | WEBRTC_FUNC(SetOpusMaxPlaybackRate, (int channel, int frequency_hz)) { |
| 422 | WEBRTC_CHECK_CHANNEL(channel); |
| 423 | if (_stricmp(channels_[channel]->send_codec.plname, "opus") != 0) { |
| 424 | // Return -1 if current send codec is not Opus. |
| 425 | return -1; |
| 426 | } |
| 427 | if (frequency_hz <= 8000) |
| 428 | channels_[channel]->max_encoding_bandwidth = kOpusBandwidthNb; |
| 429 | else if (frequency_hz <= 12000) |
| 430 | channels_[channel]->max_encoding_bandwidth = kOpusBandwidthMb; |
| 431 | else if (frequency_hz <= 16000) |
| 432 | channels_[channel]->max_encoding_bandwidth = kOpusBandwidthWb; |
| 433 | else if (frequency_hz <= 24000) |
| 434 | channels_[channel]->max_encoding_bandwidth = kOpusBandwidthSwb; |
| 435 | else |
| 436 | channels_[channel]->max_encoding_bandwidth = kOpusBandwidthFb; |
| 437 | return 0; |
| 438 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 439 | |
minyue@webrtc.org | 9b2e114 | 2015-03-13 09:38:07 +0000 | [diff] [blame] | 440 | WEBRTC_FUNC(SetOpusDtx, (int channel, bool enable_dtx)) { |
| 441 | WEBRTC_CHECK_CHANNEL(channel); |
| 442 | if (_stricmp(channels_[channel]->send_codec.plname, "opus") != 0) { |
| 443 | // Return -1 if current send codec is not Opus. |
| 444 | return -1; |
| 445 | } |
| 446 | channels_[channel]->opus_dtx = enable_dtx; |
| 447 | return 0; |
| 448 | } |
| 449 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 450 | // webrtc::VoEHardware |
solenberg | 246b817 | 2015-12-08 09:50:23 -0800 | [diff] [blame] | 451 | WEBRTC_STUB(GetNumOfRecordingDevices, (int& num)); |
| 452 | WEBRTC_STUB(GetNumOfPlayoutDevices, (int& num)); |
| 453 | WEBRTC_STUB(GetRecordingDeviceName, (int i, char* name, char* guid)); |
| 454 | WEBRTC_STUB(GetPlayoutDeviceName, (int i, char* name, char* guid)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 455 | WEBRTC_STUB(SetRecordingDevice, (int, webrtc::StereoChannel)); |
| 456 | WEBRTC_STUB(SetPlayoutDevice, (int)); |
| 457 | WEBRTC_STUB(SetAudioDeviceLayer, (webrtc::AudioLayers)); |
| 458 | WEBRTC_STUB(GetAudioDeviceLayer, (webrtc::AudioLayers&)); |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 459 | WEBRTC_FUNC(SetRecordingSampleRate, (unsigned int samples_per_sec)) { |
| 460 | recording_sample_rate_ = samples_per_sec; |
| 461 | return 0; |
| 462 | } |
| 463 | WEBRTC_FUNC_CONST(RecordingSampleRate, (unsigned int* samples_per_sec)) { |
| 464 | *samples_per_sec = recording_sample_rate_; |
| 465 | return 0; |
| 466 | } |
| 467 | WEBRTC_FUNC(SetPlayoutSampleRate, (unsigned int samples_per_sec)) { |
| 468 | playout_sample_rate_ = samples_per_sec; |
| 469 | return 0; |
| 470 | } |
| 471 | WEBRTC_FUNC_CONST(PlayoutSampleRate, (unsigned int* samples_per_sec)) { |
| 472 | *samples_per_sec = playout_sample_rate_; |
| 473 | return 0; |
| 474 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 475 | WEBRTC_STUB(EnableBuiltInAEC, (bool enable)); |
henrika@webrtc.org | a954c07 | 2014-12-09 16:22:09 +0000 | [diff] [blame] | 476 | virtual bool BuiltInAECIsAvailable() const { return false; } |
henrika | c14f5ff | 2015-09-23 14:08:33 +0200 | [diff] [blame] | 477 | WEBRTC_STUB(EnableBuiltInAGC, (bool enable)); |
| 478 | virtual bool BuiltInAGCIsAvailable() const { return false; } |
| 479 | WEBRTC_STUB(EnableBuiltInNS, (bool enable)); |
| 480 | virtual bool BuiltInNSIsAvailable() const { return false; } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 481 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 482 | // webrtc::VoENetwork |
| 483 | WEBRTC_FUNC(RegisterExternalTransport, (int channel, |
| 484 | webrtc::Transport& transport)) { |
| 485 | WEBRTC_CHECK_CHANNEL(channel); |
| 486 | channels_[channel]->external_transport = true; |
| 487 | return 0; |
| 488 | } |
| 489 | WEBRTC_FUNC(DeRegisterExternalTransport, (int channel)) { |
| 490 | WEBRTC_CHECK_CHANNEL(channel); |
| 491 | channels_[channel]->external_transport = false; |
| 492 | return 0; |
| 493 | } |
| 494 | WEBRTC_FUNC(ReceivedRTPPacket, (int channel, const void* data, |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 495 | size_t length)) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 496 | WEBRTC_CHECK_CHANNEL(channel); |
| 497 | if (!channels_[channel]->external_transport) return -1; |
| 498 | channels_[channel]->packets.push_back( |
| 499 | std::string(static_cast<const char*>(data), length)); |
| 500 | return 0; |
| 501 | } |
buildbot@webrtc.org | f875f15 | 2014-04-14 16:06:21 +0000 | [diff] [blame] | 502 | WEBRTC_FUNC(ReceivedRTPPacket, (int channel, const void* data, |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 503 | size_t length, |
buildbot@webrtc.org | f875f15 | 2014-04-14 16:06:21 +0000 | [diff] [blame] | 504 | const webrtc::PacketTime& packet_time)) { |
| 505 | WEBRTC_CHECK_CHANNEL(channel); |
| 506 | if (ReceivedRTPPacket(channel, data, length) == -1) { |
| 507 | return -1; |
| 508 | } |
| 509 | channels_[channel]->last_rtp_packet_time = packet_time; |
| 510 | return 0; |
| 511 | } |
buildbot@webrtc.org | f875f15 | 2014-04-14 16:06:21 +0000 | [diff] [blame] | 512 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 513 | WEBRTC_STUB(ReceivedRTCPPacket, (int channel, const void* data, |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 514 | size_t length)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 515 | |
| 516 | // webrtc::VoERTP_RTCP |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 517 | WEBRTC_FUNC(SetLocalSSRC, (int channel, unsigned int ssrc)) { |
| 518 | WEBRTC_CHECK_CHANNEL(channel); |
| 519 | channels_[channel]->send_ssrc = ssrc; |
| 520 | return 0; |
| 521 | } |
solenberg | 85a0496 | 2015-10-27 03:35:21 -0700 | [diff] [blame] | 522 | WEBRTC_STUB(GetLocalSSRC, (int channel, unsigned int& ssrc)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 523 | WEBRTC_STUB(GetRemoteSSRC, (int channel, unsigned int& ssrc)); |
solenberg | 3a94154 | 2015-11-16 07:34:50 -0800 | [diff] [blame] | 524 | WEBRTC_STUB(SetSendAudioLevelIndicationStatus, (int channel, bool enable, |
| 525 | unsigned char id)); |
solenberg | 7add058 | 2015-11-20 09:59:34 -0800 | [diff] [blame] | 526 | WEBRTC_STUB(SetReceiveAudioLevelIndicationStatus, (int channel, bool enable, |
| 527 | unsigned char id)); |
solenberg | 3a94154 | 2015-11-16 07:34:50 -0800 | [diff] [blame] | 528 | WEBRTC_STUB(SetSendAbsoluteSenderTimeStatus, (int channel, bool enable, |
| 529 | unsigned char id)); |
solenberg | 7add058 | 2015-11-20 09:59:34 -0800 | [diff] [blame] | 530 | WEBRTC_STUB(SetReceiveAbsoluteSenderTimeStatus, (int channel, bool enable, |
| 531 | unsigned char id)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 532 | WEBRTC_STUB(SetRTCPStatus, (int channel, bool enable)); |
| 533 | WEBRTC_STUB(GetRTCPStatus, (int channel, bool& enabled)); |
| 534 | WEBRTC_STUB(SetRTCP_CNAME, (int channel, const char cname[256])); |
| 535 | WEBRTC_STUB(GetRTCP_CNAME, (int channel, char cname[256])); |
| 536 | WEBRTC_STUB(GetRemoteRTCP_CNAME, (int channel, char* cname)); |
| 537 | WEBRTC_STUB(GetRemoteRTCPData, (int channel, unsigned int& NTPHigh, |
| 538 | unsigned int& NTPLow, |
| 539 | unsigned int& timestamp, |
| 540 | unsigned int& playoutTimestamp, |
| 541 | unsigned int* jitter, |
| 542 | unsigned short* fractionLost)); |
solenberg | 85a0496 | 2015-10-27 03:35:21 -0700 | [diff] [blame] | 543 | WEBRTC_STUB(GetRemoteRTCPReportBlocks, |
| 544 | (int channel, std::vector<webrtc::ReportBlock>* receive_blocks)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 545 | WEBRTC_STUB(GetRTPStatistics, (int channel, unsigned int& averageJitterMs, |
| 546 | unsigned int& maxJitterMs, |
| 547 | unsigned int& discardedPackets)); |
solenberg | 85a0496 | 2015-10-27 03:35:21 -0700 | [diff] [blame] | 548 | WEBRTC_STUB(GetRTCPStatistics, (int channel, webrtc::CallStatistics& stats)); |
buildbot@webrtc.org | ae740dd | 2014-06-17 10:56:41 +0000 | [diff] [blame] | 549 | WEBRTC_FUNC(SetREDStatus, (int channel, bool enable, int redPayloadtype)) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 550 | WEBRTC_CHECK_CHANNEL(channel); |
buildbot@webrtc.org | ae740dd | 2014-06-17 10:56:41 +0000 | [diff] [blame] | 551 | channels_[channel]->red = enable; |
| 552 | channels_[channel]->red_type = redPayloadtype; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 553 | return 0; |
| 554 | } |
buildbot@webrtc.org | ae740dd | 2014-06-17 10:56:41 +0000 | [diff] [blame] | 555 | WEBRTC_FUNC(GetREDStatus, (int channel, bool& enable, int& redPayloadtype)) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 556 | WEBRTC_CHECK_CHANNEL(channel); |
buildbot@webrtc.org | ae740dd | 2014-06-17 10:56:41 +0000 | [diff] [blame] | 557 | enable = channels_[channel]->red; |
| 558 | redPayloadtype = channels_[channel]->red_type; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 559 | return 0; |
| 560 | } |
| 561 | WEBRTC_FUNC(SetNACKStatus, (int channel, bool enable, int maxNoPackets)) { |
| 562 | WEBRTC_CHECK_CHANNEL(channel); |
| 563 | channels_[channel]->nack = enable; |
| 564 | channels_[channel]->nack_max_packets = maxNoPackets; |
| 565 | return 0; |
| 566 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 567 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 568 | // webrtc::VoEVolumeControl |
| 569 | WEBRTC_STUB(SetSpeakerVolume, (unsigned int)); |
| 570 | WEBRTC_STUB(GetSpeakerVolume, (unsigned int&)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 571 | WEBRTC_STUB(SetMicVolume, (unsigned int)); |
| 572 | WEBRTC_STUB(GetMicVolume, (unsigned int&)); |
| 573 | WEBRTC_STUB(SetInputMute, (int, bool)); |
| 574 | WEBRTC_STUB(GetInputMute, (int, bool&)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 575 | WEBRTC_STUB(GetSpeechInputLevel, (unsigned int&)); |
| 576 | WEBRTC_STUB(GetSpeechOutputLevel, (int, unsigned int&)); |
| 577 | WEBRTC_STUB(GetSpeechInputLevelFullRange, (unsigned int&)); |
| 578 | WEBRTC_STUB(GetSpeechOutputLevelFullRange, (int, unsigned int&)); |
| 579 | WEBRTC_FUNC(SetChannelOutputVolumeScaling, (int channel, float scale)) { |
| 580 | WEBRTC_CHECK_CHANNEL(channel); |
| 581 | channels_[channel]->volume_scale= scale; |
| 582 | return 0; |
| 583 | } |
| 584 | WEBRTC_FUNC(GetChannelOutputVolumeScaling, (int channel, float& scale)) { |
| 585 | WEBRTC_CHECK_CHANNEL(channel); |
| 586 | scale = channels_[channel]->volume_scale; |
| 587 | return 0; |
| 588 | } |
solenberg | 4bac9c5 | 2015-10-09 02:32:53 -0700 | [diff] [blame] | 589 | WEBRTC_STUB(SetOutputVolumePan, (int channel, float left, float right)); |
| 590 | WEBRTC_STUB(GetOutputVolumePan, (int channel, float& left, float& right)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 591 | |
| 592 | // webrtc::VoEAudioProcessing |
| 593 | WEBRTC_FUNC(SetNsStatus, (bool enable, webrtc::NsModes mode)) { |
| 594 | ns_enabled_ = enable; |
| 595 | ns_mode_ = mode; |
| 596 | return 0; |
| 597 | } |
| 598 | WEBRTC_FUNC(GetNsStatus, (bool& enabled, webrtc::NsModes& mode)) { |
| 599 | enabled = ns_enabled_; |
| 600 | mode = ns_mode_; |
| 601 | return 0; |
| 602 | } |
| 603 | |
| 604 | WEBRTC_FUNC(SetAgcStatus, (bool enable, webrtc::AgcModes mode)) { |
| 605 | agc_enabled_ = enable; |
| 606 | agc_mode_ = mode; |
| 607 | return 0; |
| 608 | } |
| 609 | WEBRTC_FUNC(GetAgcStatus, (bool& enabled, webrtc::AgcModes& mode)) { |
| 610 | enabled = agc_enabled_; |
| 611 | mode = agc_mode_; |
| 612 | return 0; |
| 613 | } |
| 614 | |
| 615 | WEBRTC_FUNC(SetAgcConfig, (webrtc::AgcConfig config)) { |
| 616 | agc_config_ = config; |
| 617 | return 0; |
| 618 | } |
| 619 | WEBRTC_FUNC(GetAgcConfig, (webrtc::AgcConfig& config)) { |
| 620 | config = agc_config_; |
| 621 | return 0; |
| 622 | } |
| 623 | WEBRTC_FUNC(SetEcStatus, (bool enable, webrtc::EcModes mode)) { |
| 624 | ec_enabled_ = enable; |
| 625 | ec_mode_ = mode; |
| 626 | return 0; |
| 627 | } |
| 628 | WEBRTC_FUNC(GetEcStatus, (bool& enabled, webrtc::EcModes& mode)) { |
| 629 | enabled = ec_enabled_; |
| 630 | mode = ec_mode_; |
| 631 | return 0; |
| 632 | } |
| 633 | WEBRTC_STUB(EnableDriftCompensation, (bool enable)) |
| 634 | WEBRTC_BOOL_STUB(DriftCompensationEnabled, ()) |
| 635 | WEBRTC_VOID_STUB(SetDelayOffsetMs, (int offset)) |
| 636 | WEBRTC_STUB(DelayOffsetMs, ()); |
| 637 | WEBRTC_FUNC(SetAecmMode, (webrtc::AecmModes mode, bool enableCNG)) { |
| 638 | aecm_mode_ = mode; |
| 639 | cng_enabled_ = enableCNG; |
| 640 | return 0; |
| 641 | } |
| 642 | WEBRTC_FUNC(GetAecmMode, (webrtc::AecmModes& mode, bool& enabledCNG)) { |
| 643 | mode = aecm_mode_; |
| 644 | enabledCNG = cng_enabled_; |
| 645 | return 0; |
| 646 | } |
| 647 | WEBRTC_STUB(SetRxNsStatus, (int channel, bool enable, webrtc::NsModes mode)); |
| 648 | WEBRTC_STUB(GetRxNsStatus, (int channel, bool& enabled, |
| 649 | webrtc::NsModes& mode)); |
solenberg | 0b67546 | 2015-10-09 01:37:09 -0700 | [diff] [blame] | 650 | WEBRTC_STUB(SetRxAgcStatus, (int channel, bool enable, |
| 651 | webrtc::AgcModes mode)); |
| 652 | WEBRTC_STUB(GetRxAgcStatus, (int channel, bool& enabled, |
| 653 | webrtc::AgcModes& mode)); |
| 654 | WEBRTC_STUB(SetRxAgcConfig, (int channel, webrtc::AgcConfig config)); |
| 655 | WEBRTC_STUB(GetRxAgcConfig, (int channel, webrtc::AgcConfig& config)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 656 | |
| 657 | WEBRTC_STUB(RegisterRxVadObserver, (int, webrtc::VoERxVadCallback&)); |
| 658 | WEBRTC_STUB(DeRegisterRxVadObserver, (int channel)); |
| 659 | WEBRTC_STUB(VoiceActivityIndicator, (int channel)); |
| 660 | WEBRTC_FUNC(SetEcMetricsStatus, (bool enable)) { |
| 661 | ec_metrics_enabled_ = enable; |
| 662 | return 0; |
| 663 | } |
solenberg | 85a0496 | 2015-10-27 03:35:21 -0700 | [diff] [blame] | 664 | WEBRTC_STUB(GetEcMetricsStatus, (bool& enabled)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 665 | 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] | 666 | WEBRTC_STUB(GetEcDelayMetrics, (int& delay_median, int& delay_std, |
| 667 | float& fraction_poor_delays)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 668 | |
| 669 | WEBRTC_STUB(StartDebugRecording, (const char* fileNameUTF8)); |
wu@webrtc.org | 9caf276 | 2013-12-11 18:25:07 +0000 | [diff] [blame] | 670 | WEBRTC_STUB(StartDebugRecording, (FILE* handle)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 671 | WEBRTC_STUB(StopDebugRecording, ()); |
| 672 | |
| 673 | WEBRTC_FUNC(SetTypingDetectionStatus, (bool enable)) { |
| 674 | typing_detection_enabled_ = enable; |
| 675 | return 0; |
| 676 | } |
| 677 | WEBRTC_FUNC(GetTypingDetectionStatus, (bool& enabled)) { |
| 678 | enabled = typing_detection_enabled_; |
| 679 | return 0; |
| 680 | } |
| 681 | |
| 682 | WEBRTC_STUB(TimeSinceLastTyping, (int& seconds)); |
| 683 | WEBRTC_STUB(SetTypingDetectionParameters, (int timeWindow, |
| 684 | int costPerTyping, |
| 685 | int reportingThreshold, |
| 686 | int penaltyDecay, |
| 687 | int typeEventDelay)); |
| 688 | int EnableHighPassFilter(bool enable) { |
| 689 | highpass_filter_enabled_ = enable; |
| 690 | return 0; |
| 691 | } |
| 692 | bool IsHighPassFilterEnabled() { |
| 693 | return highpass_filter_enabled_; |
| 694 | } |
| 695 | bool IsStereoChannelSwappingEnabled() { |
| 696 | return stereo_swapping_enabled_; |
| 697 | } |
| 698 | void EnableStereoChannelSwapping(bool enable) { |
| 699 | stereo_swapping_enabled_ = enable; |
| 700 | } |
Henrik Lundin | 64dad83 | 2015-05-11 12:44:23 +0200 | [diff] [blame] | 701 | int GetNetEqCapacity() const { |
| 702 | auto ch = channels_.find(last_channel_); |
| 703 | ASSERT(ch != channels_.end()); |
| 704 | return ch->second->neteq_capacity; |
| 705 | } |
Henrik Lundin | 5263b3c | 2015-06-01 10:29:41 +0200 | [diff] [blame] | 706 | bool GetNetEqFastAccelerate() const { |
| 707 | auto ch = channels_.find(last_channel_); |
| 708 | ASSERT(ch != channels_.end()); |
| 709 | return ch->second->neteq_fast_accelerate; |
| 710 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 711 | |
| 712 | private: |
solenberg | bc37fc8 | 2016-04-04 09:54:44 -0700 | [diff] [blame^] | 713 | bool inited_ = false; |
| 714 | int last_channel_ = -1; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 715 | std::map<int, Channel*> channels_; |
solenberg | bc37fc8 | 2016-04-04 09:54:44 -0700 | [diff] [blame^] | 716 | bool fail_create_channel_ = false; |
| 717 | int num_set_send_codecs_ = 0; // how many times we call SetSendCodec(). |
| 718 | bool ec_enabled_ = false; |
| 719 | bool ec_metrics_enabled_ = false; |
| 720 | bool cng_enabled_ = false; |
| 721 | bool ns_enabled_ = false; |
| 722 | bool agc_enabled_ = false; |
| 723 | bool highpass_filter_enabled_ = false; |
| 724 | bool stereo_swapping_enabled_ = false; |
| 725 | bool typing_detection_enabled_ = false; |
| 726 | webrtc::EcModes ec_mode_ = webrtc::kEcDefault; |
| 727 | webrtc::AecmModes aecm_mode_ = webrtc::kAecmSpeakerphone; |
| 728 | webrtc::NsModes ns_mode_ = webrtc::kNsDefault; |
| 729 | webrtc::AgcModes agc_mode_ = webrtc::kAgcDefault; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 730 | webrtc::AgcConfig agc_config_; |
solenberg | bc37fc8 | 2016-04-04 09:54:44 -0700 | [diff] [blame^] | 731 | int playout_fail_channel_ = -1; |
| 732 | int recording_sample_rate_ = -1; |
| 733 | int playout_sample_rate_ = -1; |
buildbot@webrtc.org | a8d8ad2 | 2014-07-16 14:23:08 +0000 | [diff] [blame] | 734 | FakeAudioProcessing audio_processing_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 735 | }; |
| 736 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 737 | } // namespace cricket |
| 738 | |
kjellander@webrtc.org | 5ad1297 | 2016-02-12 06:39:40 +0100 | [diff] [blame] | 739 | #endif // WEBRTC_MEDIA_ENGINE_FAKEWEBRTCVOICEENGINE_H_ |