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/base/basictypes.h" |
wu@webrtc.org | 9caf276 | 2013-12-11 18:25:07 +0000 | [diff] [blame] | 36 | #include "talk/base/gunit.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 37 | #include "talk/base/stringutils.h" |
| 38 | #include "talk/media/base/codec.h" |
buildbot@webrtc.org | 7e71b77 | 2014-06-13 01:14:01 +0000 | [diff] [blame] | 39 | #include "talk/media/base/rtputils.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 40 | #include "talk/media/base/voiceprocessor.h" |
| 41 | #include "talk/media/webrtc/fakewebrtccommon.h" |
| 42 | #include "talk/media/webrtc/webrtcvoe.h" |
| 43 | |
buildbot@webrtc.org | f875f15 | 2014-04-14 16:06:21 +0000 | [diff] [blame] | 44 | namespace webrtc { |
| 45 | class ViENetwork; |
| 46 | } |
| 47 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 48 | namespace cricket { |
| 49 | |
| 50 | // Function returning stats will return these values |
| 51 | // for all values based on type. |
| 52 | const int kIntStatValue = 123; |
| 53 | const float kFractionLostStatValue = 0.5; |
| 54 | |
| 55 | static const char kFakeDefaultDeviceName[] = "Fake Default"; |
| 56 | static const int kFakeDefaultDeviceId = -1; |
| 57 | static const char kFakeDeviceName[] = "Fake Device"; |
| 58 | #ifdef WIN32 |
| 59 | static const int kFakeDeviceId = 0; |
| 60 | #else |
| 61 | static const int kFakeDeviceId = 1; |
| 62 | #endif |
| 63 | |
henrike@webrtc.org | 79047f9 | 2014-03-06 23:46:59 +0000 | [diff] [blame] | 64 | // Verify the header extension ID, if enabled, is within the bounds specified in |
| 65 | // [RFC5285]: 1-14 inclusive. |
| 66 | #define WEBRTC_CHECK_HEADER_EXTENSION_ID(enable, id) \ |
| 67 | do { \ |
| 68 | if (enable && (id < 1 || id > 14)) { \ |
| 69 | return -1; \ |
| 70 | } \ |
| 71 | } while (0); |
| 72 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 73 | class FakeWebRtcVoiceEngine |
| 74 | : public webrtc::VoEAudioProcessing, |
| 75 | public webrtc::VoEBase, public webrtc::VoECodec, public webrtc::VoEDtmf, |
| 76 | public webrtc::VoEFile, public webrtc::VoEHardware, |
| 77 | public webrtc::VoEExternalMedia, public webrtc::VoENetEqStats, |
| 78 | public webrtc::VoENetwork, public webrtc::VoERTP_RTCP, |
| 79 | public webrtc::VoEVideoSync, public webrtc::VoEVolumeControl { |
| 80 | public: |
| 81 | struct DtmfInfo { |
| 82 | DtmfInfo() |
| 83 | : dtmf_event_code(-1), |
| 84 | dtmf_out_of_band(false), |
| 85 | dtmf_length_ms(-1) {} |
| 86 | int dtmf_event_code; |
| 87 | bool dtmf_out_of_band; |
| 88 | int dtmf_length_ms; |
| 89 | }; |
| 90 | struct Channel { |
buildbot@webrtc.org | af6640f | 2014-04-28 21:31:51 +0000 | [diff] [blame] | 91 | explicit Channel() |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 92 | : external_transport(false), |
| 93 | send(false), |
| 94 | playout(false), |
| 95 | volume_scale(1.0), |
| 96 | volume_pan_left(1.0), |
| 97 | volume_pan_right(1.0), |
| 98 | file(false), |
| 99 | vad(false), |
buildbot@webrtc.org | ae740dd | 2014-06-17 10:56:41 +0000 | [diff] [blame] | 100 | codec_fec(false), |
| 101 | red(false), |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 102 | nack(false), |
| 103 | media_processor_registered(false), |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 104 | rx_agc_enabled(false), |
| 105 | rx_agc_mode(webrtc::kAgcDefault), |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 106 | cn8_type(13), |
| 107 | cn16_type(105), |
| 108 | dtmf_type(106), |
buildbot@webrtc.org | ae740dd | 2014-06-17 10:56:41 +0000 | [diff] [blame] | 109 | red_type(117), |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 110 | nack_max_packets(0), |
buildbot@webrtc.org | f875f15 | 2014-04-14 16:06:21 +0000 | [diff] [blame] | 111 | vie_network(NULL), |
| 112 | video_channel(-1), |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 113 | send_ssrc(0), |
henrike@webrtc.org | 79047f9 | 2014-03-06 23:46:59 +0000 | [diff] [blame] | 114 | send_audio_level_ext_(-1), |
buildbot@webrtc.org | 150835e | 2014-05-06 15:54:38 +0000 | [diff] [blame] | 115 | receive_audio_level_ext_(-1), |
henrike@webrtc.org | 79047f9 | 2014-03-06 23:46:59 +0000 | [diff] [blame] | 116 | send_absolute_sender_time_ext_(-1), |
buildbot@webrtc.org | af6640f | 2014-04-28 21:31:51 +0000 | [diff] [blame] | 117 | receive_absolute_sender_time_ext_(-1) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 118 | memset(&send_codec, 0, sizeof(send_codec)); |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 119 | memset(&rx_agc_config, 0, sizeof(rx_agc_config)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 120 | } |
| 121 | bool external_transport; |
| 122 | bool send; |
| 123 | bool playout; |
| 124 | float volume_scale; |
| 125 | float volume_pan_left; |
| 126 | float volume_pan_right; |
| 127 | bool file; |
| 128 | bool vad; |
buildbot@webrtc.org | ae740dd | 2014-06-17 10:56:41 +0000 | [diff] [blame] | 129 | bool codec_fec; |
| 130 | bool red; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 131 | bool nack; |
| 132 | bool media_processor_registered; |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 133 | bool rx_agc_enabled; |
| 134 | webrtc::AgcModes rx_agc_mode; |
| 135 | webrtc::AgcConfig rx_agc_config; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 136 | int cn8_type; |
| 137 | int cn16_type; |
| 138 | int dtmf_type; |
buildbot@webrtc.org | ae740dd | 2014-06-17 10:56:41 +0000 | [diff] [blame] | 139 | int red_type; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 140 | int nack_max_packets; |
buildbot@webrtc.org | f875f15 | 2014-04-14 16:06:21 +0000 | [diff] [blame] | 141 | webrtc::ViENetwork* vie_network; |
| 142 | int video_channel; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 143 | uint32 send_ssrc; |
henrike@webrtc.org | 79047f9 | 2014-03-06 23:46:59 +0000 | [diff] [blame] | 144 | int send_audio_level_ext_; |
buildbot@webrtc.org | 150835e | 2014-05-06 15:54:38 +0000 | [diff] [blame] | 145 | int receive_audio_level_ext_; |
henrike@webrtc.org | 79047f9 | 2014-03-06 23:46:59 +0000 | [diff] [blame] | 146 | int send_absolute_sender_time_ext_; |
| 147 | int receive_absolute_sender_time_ext_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 148 | DtmfInfo dtmf_info; |
| 149 | std::vector<webrtc::CodecInst> recv_codecs; |
| 150 | webrtc::CodecInst send_codec; |
buildbot@webrtc.org | f875f15 | 2014-04-14 16:06:21 +0000 | [diff] [blame] | 151 | webrtc::PacketTime last_rtp_packet_time; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 152 | std::list<std::string> packets; |
| 153 | }; |
| 154 | |
| 155 | FakeWebRtcVoiceEngine(const cricket::AudioCodec* const* codecs, |
| 156 | int num_codecs) |
| 157 | : inited_(false), |
| 158 | last_channel_(-1), |
| 159 | fail_create_channel_(false), |
| 160 | codecs_(codecs), |
| 161 | num_codecs_(num_codecs), |
wu@webrtc.org | 05e7b44 | 2014-04-01 17:44:24 +0000 | [diff] [blame] | 162 | num_set_send_codecs_(0), |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 163 | ec_enabled_(false), |
| 164 | ec_metrics_enabled_(false), |
| 165 | cng_enabled_(false), |
| 166 | ns_enabled_(false), |
| 167 | agc_enabled_(false), |
| 168 | highpass_filter_enabled_(false), |
| 169 | stereo_swapping_enabled_(false), |
| 170 | typing_detection_enabled_(false), |
| 171 | ec_mode_(webrtc::kEcDefault), |
| 172 | aecm_mode_(webrtc::kAecmSpeakerphone), |
| 173 | ns_mode_(webrtc::kNsDefault), |
| 174 | agc_mode_(webrtc::kAgcDefault), |
| 175 | observer_(NULL), |
| 176 | playout_fail_channel_(-1), |
| 177 | send_fail_channel_(-1), |
| 178 | fail_start_recording_microphone_(false), |
| 179 | recording_microphone_(false), |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 180 | recording_sample_rate_(-1), |
| 181 | playout_sample_rate_(-1), |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 182 | media_processor_(NULL) { |
| 183 | memset(&agc_config_, 0, sizeof(agc_config_)); |
| 184 | } |
| 185 | ~FakeWebRtcVoiceEngine() { |
| 186 | // Ought to have all been deleted by the WebRtcVoiceMediaChannel |
| 187 | // destructors, but just in case ... |
| 188 | for (std::map<int, Channel*>::const_iterator i = channels_.begin(); |
| 189 | i != channels_.end(); ++i) { |
| 190 | delete i->second; |
| 191 | } |
| 192 | } |
| 193 | |
| 194 | bool IsExternalMediaProcessorRegistered() const { |
| 195 | return media_processor_ != NULL; |
| 196 | } |
| 197 | bool IsInited() const { return inited_; } |
| 198 | int GetLastChannel() const { return last_channel_; } |
wu@webrtc.org | 9dba525 | 2013-08-05 20:36:57 +0000 | [diff] [blame] | 199 | int GetChannelFromLocalSsrc(uint32 local_ssrc) const { |
| 200 | for (std::map<int, Channel*>::const_iterator iter = channels_.begin(); |
| 201 | iter != channels_.end(); ++iter) { |
| 202 | if (local_ssrc == iter->second->send_ssrc) |
| 203 | return iter->first; |
| 204 | } |
| 205 | return -1; |
| 206 | } |
wu@webrtc.org | 9caf276 | 2013-12-11 18:25:07 +0000 | [diff] [blame] | 207 | int GetNumChannels() const { return static_cast<int>(channels_.size()); } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 208 | bool GetPlayout(int channel) { |
| 209 | return channels_[channel]->playout; |
| 210 | } |
| 211 | bool GetSend(int channel) { |
| 212 | return channels_[channel]->send; |
| 213 | } |
| 214 | bool GetRecordingMicrophone() { |
| 215 | return recording_microphone_; |
| 216 | } |
| 217 | bool GetVAD(int channel) { |
| 218 | return channels_[channel]->vad; |
| 219 | } |
buildbot@webrtc.org | ae740dd | 2014-06-17 10:56:41 +0000 | [diff] [blame] | 220 | bool GetRED(int channel) { |
| 221 | return channels_[channel]->red; |
| 222 | } |
| 223 | bool GetCodecFEC(int channel) { |
| 224 | return channels_[channel]->codec_fec; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 225 | } |
| 226 | bool GetNACK(int channel) { |
| 227 | return channels_[channel]->nack; |
| 228 | } |
| 229 | int GetNACKMaxPackets(int channel) { |
| 230 | return channels_[channel]->nack_max_packets; |
| 231 | } |
buildbot@webrtc.org | f875f15 | 2014-04-14 16:06:21 +0000 | [diff] [blame] | 232 | webrtc::ViENetwork* GetViENetwork(int channel) { |
| 233 | WEBRTC_ASSERT_CHANNEL(channel); |
| 234 | return channels_[channel]->vie_network; |
| 235 | } |
| 236 | int GetVideoChannel(int channel) { |
| 237 | WEBRTC_ASSERT_CHANNEL(channel); |
| 238 | return channels_[channel]->video_channel; |
| 239 | } |
| 240 | const webrtc::PacketTime& GetLastRtpPacketTime(int channel) { |
| 241 | WEBRTC_ASSERT_CHANNEL(channel); |
| 242 | return channels_[channel]->last_rtp_packet_time; |
| 243 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 244 | int GetSendCNPayloadType(int channel, bool wideband) { |
| 245 | return (wideband) ? |
| 246 | channels_[channel]->cn16_type : |
| 247 | channels_[channel]->cn8_type; |
| 248 | } |
| 249 | int GetSendTelephoneEventPayloadType(int channel) { |
| 250 | return channels_[channel]->dtmf_type; |
| 251 | } |
buildbot@webrtc.org | ae740dd | 2014-06-17 10:56:41 +0000 | [diff] [blame] | 252 | int GetSendREDPayloadType(int channel) { |
| 253 | return channels_[channel]->red_type; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 254 | } |
| 255 | bool CheckPacket(int channel, const void* data, size_t len) { |
| 256 | bool result = !CheckNoPacket(channel); |
| 257 | if (result) { |
| 258 | std::string packet = channels_[channel]->packets.front(); |
| 259 | result = (packet == std::string(static_cast<const char*>(data), len)); |
| 260 | channels_[channel]->packets.pop_front(); |
| 261 | } |
| 262 | return result; |
| 263 | } |
| 264 | bool CheckNoPacket(int channel) { |
| 265 | return channels_[channel]->packets.empty(); |
| 266 | } |
| 267 | void TriggerCallbackOnError(int channel_num, int err_code) { |
| 268 | ASSERT(observer_ != NULL); |
| 269 | observer_->CallbackOnError(channel_num, err_code); |
| 270 | } |
| 271 | void set_playout_fail_channel(int channel) { |
| 272 | playout_fail_channel_ = channel; |
| 273 | } |
| 274 | void set_send_fail_channel(int channel) { |
| 275 | send_fail_channel_ = channel; |
| 276 | } |
| 277 | void set_fail_start_recording_microphone( |
| 278 | bool fail_start_recording_microphone) { |
| 279 | fail_start_recording_microphone_ = fail_start_recording_microphone; |
| 280 | } |
| 281 | void set_fail_create_channel(bool fail_create_channel) { |
| 282 | fail_create_channel_ = fail_create_channel; |
| 283 | } |
| 284 | void TriggerProcessPacket(MediaProcessorDirection direction) { |
| 285 | webrtc::ProcessingTypes pt = |
| 286 | (direction == cricket::MPD_TX) ? |
| 287 | webrtc::kRecordingPerChannel : webrtc::kPlaybackAllChannelsMixed; |
| 288 | if (media_processor_ != NULL) { |
| 289 | media_processor_->Process(0, |
| 290 | pt, |
| 291 | NULL, |
| 292 | 0, |
| 293 | 0, |
| 294 | true); |
| 295 | } |
| 296 | } |
buildbot@webrtc.org | af6640f | 2014-04-28 21:31:51 +0000 | [diff] [blame] | 297 | int AddChannel() { |
wu@webrtc.org | 364f204 | 2013-11-20 21:49:41 +0000 | [diff] [blame] | 298 | if (fail_create_channel_) { |
| 299 | return -1; |
| 300 | } |
buildbot@webrtc.org | af6640f | 2014-04-28 21:31:51 +0000 | [diff] [blame] | 301 | Channel* ch = new Channel(); |
wu@webrtc.org | 364f204 | 2013-11-20 21:49:41 +0000 | [diff] [blame] | 302 | for (int i = 0; i < NumOfCodecs(); ++i) { |
| 303 | webrtc::CodecInst codec; |
| 304 | GetCodec(i, codec); |
| 305 | ch->recv_codecs.push_back(codec); |
| 306 | } |
| 307 | channels_[++last_channel_] = ch; |
| 308 | return last_channel_; |
| 309 | } |
buildbot@webrtc.org | 150835e | 2014-05-06 15:54:38 +0000 | [diff] [blame] | 310 | int GetSendRtpExtensionId(int channel, const std::string& extension) { |
| 311 | WEBRTC_ASSERT_CHANNEL(channel); |
| 312 | if (extension == kRtpAudioLevelHeaderExtension) { |
| 313 | return channels_[channel]->send_audio_level_ext_; |
| 314 | } else if (extension == kRtpAbsoluteSenderTimeHeaderExtension) { |
| 315 | return channels_[channel]->send_absolute_sender_time_ext_; |
| 316 | } |
| 317 | return -1; |
henrike@webrtc.org | 79047f9 | 2014-03-06 23:46:59 +0000 | [diff] [blame] | 318 | } |
buildbot@webrtc.org | 150835e | 2014-05-06 15:54:38 +0000 | [diff] [blame] | 319 | int GetReceiveRtpExtensionId(int channel, const std::string& extension) { |
| 320 | WEBRTC_ASSERT_CHANNEL(channel); |
| 321 | if (extension == kRtpAudioLevelHeaderExtension) { |
| 322 | return channels_[channel]->receive_audio_level_ext_; |
| 323 | } else if (extension == kRtpAbsoluteSenderTimeHeaderExtension) { |
| 324 | return channels_[channel]->receive_absolute_sender_time_ext_; |
| 325 | } |
| 326 | return -1; |
henrike@webrtc.org | 79047f9 | 2014-03-06 23:46:59 +0000 | [diff] [blame] | 327 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 328 | |
wu@webrtc.org | 05e7b44 | 2014-04-01 17:44:24 +0000 | [diff] [blame] | 329 | int GetNumSetSendCodecs() const { return num_set_send_codecs_; } |
| 330 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 331 | WEBRTC_STUB(Release, ()); |
| 332 | |
| 333 | // webrtc::VoEBase |
| 334 | WEBRTC_FUNC(RegisterVoiceEngineObserver, ( |
| 335 | webrtc::VoiceEngineObserver& observer)) { |
| 336 | observer_ = &observer; |
| 337 | return 0; |
| 338 | } |
| 339 | WEBRTC_STUB(DeRegisterVoiceEngineObserver, ()); |
| 340 | WEBRTC_FUNC(Init, (webrtc::AudioDeviceModule* adm, |
| 341 | webrtc::AudioProcessing* audioproc)) { |
| 342 | inited_ = true; |
| 343 | return 0; |
| 344 | } |
| 345 | WEBRTC_FUNC(Terminate, ()) { |
| 346 | inited_ = false; |
| 347 | return 0; |
| 348 | } |
| 349 | virtual webrtc::AudioProcessing* audio_processing() OVERRIDE { |
| 350 | return NULL; |
| 351 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 352 | WEBRTC_FUNC(CreateChannel, ()) { |
buildbot@webrtc.org | af6640f | 2014-04-28 21:31:51 +0000 | [diff] [blame] | 353 | return AddChannel(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 354 | } |
buildbot@webrtc.org | af6640f | 2014-04-28 21:31:51 +0000 | [diff] [blame] | 355 | WEBRTC_FUNC(CreateChannel, (const webrtc::Config& /*config*/)) { |
| 356 | return AddChannel(); |
wu@webrtc.org | 364f204 | 2013-11-20 21:49:41 +0000 | [diff] [blame] | 357 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 358 | WEBRTC_FUNC(DeleteChannel, (int channel)) { |
| 359 | WEBRTC_CHECK_CHANNEL(channel); |
| 360 | delete channels_[channel]; |
| 361 | channels_.erase(channel); |
| 362 | return 0; |
| 363 | } |
| 364 | WEBRTC_STUB(StartReceive, (int channel)); |
| 365 | WEBRTC_FUNC(StartPlayout, (int channel)) { |
| 366 | if (playout_fail_channel_ != channel) { |
| 367 | WEBRTC_CHECK_CHANNEL(channel); |
| 368 | channels_[channel]->playout = true; |
| 369 | return 0; |
| 370 | } else { |
| 371 | // When playout_fail_channel_ == channel, fail the StartPlayout on this |
| 372 | // channel. |
| 373 | return -1; |
| 374 | } |
| 375 | } |
| 376 | WEBRTC_FUNC(StartSend, (int channel)) { |
| 377 | if (send_fail_channel_ != channel) { |
| 378 | WEBRTC_CHECK_CHANNEL(channel); |
| 379 | channels_[channel]->send = true; |
| 380 | return 0; |
| 381 | } else { |
| 382 | // When send_fail_channel_ == channel, fail the StartSend on this |
| 383 | // channel. |
| 384 | return -1; |
| 385 | } |
| 386 | } |
| 387 | WEBRTC_STUB(StopReceive, (int channel)); |
| 388 | WEBRTC_FUNC(StopPlayout, (int channel)) { |
| 389 | WEBRTC_CHECK_CHANNEL(channel); |
| 390 | channels_[channel]->playout = false; |
| 391 | return 0; |
| 392 | } |
| 393 | WEBRTC_FUNC(StopSend, (int channel)) { |
| 394 | WEBRTC_CHECK_CHANNEL(channel); |
| 395 | channels_[channel]->send = false; |
| 396 | return 0; |
| 397 | } |
| 398 | WEBRTC_STUB(GetVersion, (char version[1024])); |
| 399 | WEBRTC_STUB(LastError, ()); |
| 400 | WEBRTC_STUB(SetOnHoldStatus, (int, bool, webrtc::OnHoldModes)); |
| 401 | WEBRTC_STUB(GetOnHoldStatus, (int, bool&, webrtc::OnHoldModes&)); |
| 402 | WEBRTC_STUB(SetNetEQPlayoutMode, (int, webrtc::NetEqModes)); |
| 403 | WEBRTC_STUB(GetNetEQPlayoutMode, (int, webrtc::NetEqModes&)); |
| 404 | |
| 405 | // webrtc::VoECodec |
| 406 | WEBRTC_FUNC(NumOfCodecs, ()) { |
| 407 | return num_codecs_; |
| 408 | } |
| 409 | WEBRTC_FUNC(GetCodec, (int index, webrtc::CodecInst& codec)) { |
| 410 | if (index < 0 || index >= NumOfCodecs()) { |
| 411 | return -1; |
| 412 | } |
| 413 | const cricket::AudioCodec& c(*codecs_[index]); |
| 414 | codec.pltype = c.id; |
| 415 | talk_base::strcpyn(codec.plname, sizeof(codec.plname), c.name.c_str()); |
| 416 | codec.plfreq = c.clockrate; |
| 417 | codec.pacsize = 0; |
| 418 | codec.channels = c.channels; |
| 419 | codec.rate = c.bitrate; |
| 420 | return 0; |
| 421 | } |
| 422 | WEBRTC_FUNC(SetSendCodec, (int channel, const webrtc::CodecInst& codec)) { |
| 423 | WEBRTC_CHECK_CHANNEL(channel); |
henrike@webrtc.org | 704bf9e | 2014-02-27 17:52:04 +0000 | [diff] [blame] | 424 | // To match the behavior of the real implementation. |
| 425 | if (_stricmp(codec.plname, "telephone-event") == 0 || |
| 426 | _stricmp(codec.plname, "audio/telephone-event") == 0 || |
| 427 | _stricmp(codec.plname, "CN") == 0 || |
| 428 | _stricmp(codec.plname, "red") == 0 ) { |
| 429 | return -1; |
| 430 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 431 | channels_[channel]->send_codec = codec; |
wu@webrtc.org | 05e7b44 | 2014-04-01 17:44:24 +0000 | [diff] [blame] | 432 | ++num_set_send_codecs_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 433 | return 0; |
| 434 | } |
| 435 | WEBRTC_FUNC(GetSendCodec, (int channel, webrtc::CodecInst& codec)) { |
| 436 | WEBRTC_CHECK_CHANNEL(channel); |
| 437 | codec = channels_[channel]->send_codec; |
| 438 | return 0; |
| 439 | } |
| 440 | WEBRTC_STUB(SetSecondarySendCodec, (int channel, |
| 441 | const webrtc::CodecInst& codec, |
| 442 | int red_payload_type)); |
| 443 | WEBRTC_STUB(RemoveSecondarySendCodec, (int channel)); |
| 444 | WEBRTC_STUB(GetSecondarySendCodec, (int channel, |
| 445 | webrtc::CodecInst& codec)); |
buildbot@webrtc.org | 7e71b77 | 2014-06-13 01:14:01 +0000 | [diff] [blame] | 446 | WEBRTC_FUNC(GetRecCodec, (int channel, webrtc::CodecInst& codec)) { |
| 447 | WEBRTC_CHECK_CHANNEL(channel); |
| 448 | const Channel* c = channels_[channel]; |
| 449 | for (std::list<std::string>::const_iterator it_packet = c->packets.begin(); |
| 450 | it_packet != c->packets.end(); ++it_packet) { |
| 451 | int pltype; |
| 452 | if (!GetRtpPayloadType(it_packet->data(), it_packet->length(), &pltype)) { |
| 453 | continue; |
| 454 | } |
| 455 | for (std::vector<webrtc::CodecInst>::const_iterator it_codec = |
| 456 | c->recv_codecs.begin(); it_codec != c->recv_codecs.end(); |
| 457 | ++it_codec) { |
| 458 | if (it_codec->pltype == pltype) { |
| 459 | codec = *it_codec; |
| 460 | return 0; |
| 461 | } |
| 462 | } |
| 463 | } |
| 464 | return -1; |
| 465 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 466 | WEBRTC_STUB(SetAMREncFormat, (int channel, webrtc::AmrMode mode)); |
| 467 | WEBRTC_STUB(SetAMRDecFormat, (int channel, webrtc::AmrMode mode)); |
| 468 | WEBRTC_STUB(SetAMRWbEncFormat, (int channel, webrtc::AmrMode mode)); |
| 469 | WEBRTC_STUB(SetAMRWbDecFormat, (int channel, webrtc::AmrMode mode)); |
| 470 | WEBRTC_STUB(SetISACInitTargetRate, (int channel, int rateBps, |
| 471 | bool useFixedFrameSize)); |
| 472 | WEBRTC_STUB(SetISACMaxRate, (int channel, int rateBps)); |
| 473 | WEBRTC_STUB(SetISACMaxPayloadSize, (int channel, int sizeBytes)); |
| 474 | WEBRTC_FUNC(SetRecPayloadType, (int channel, |
| 475 | const webrtc::CodecInst& codec)) { |
| 476 | WEBRTC_CHECK_CHANNEL(channel); |
| 477 | Channel* ch = channels_[channel]; |
| 478 | if (ch->playout) |
| 479 | return -1; // Channel is in use. |
| 480 | // Check if something else already has this slot. |
| 481 | if (codec.pltype != -1) { |
| 482 | for (std::vector<webrtc::CodecInst>::iterator it = |
| 483 | ch->recv_codecs.begin(); it != ch->recv_codecs.end(); ++it) { |
| 484 | if (it->pltype == codec.pltype && |
| 485 | _stricmp(it->plname, codec.plname) != 0) { |
| 486 | return -1; |
| 487 | } |
| 488 | } |
| 489 | } |
| 490 | // Otherwise try to find this codec and update its payload type. |
| 491 | for (std::vector<webrtc::CodecInst>::iterator it = ch->recv_codecs.begin(); |
| 492 | it != ch->recv_codecs.end(); ++it) { |
| 493 | if (strcmp(it->plname, codec.plname) == 0 && |
| 494 | it->plfreq == codec.plfreq) { |
| 495 | it->pltype = codec.pltype; |
| 496 | it->channels = codec.channels; |
| 497 | return 0; |
| 498 | } |
| 499 | } |
| 500 | return -1; // not found |
| 501 | } |
| 502 | WEBRTC_FUNC(SetSendCNPayloadType, (int channel, int type, |
| 503 | webrtc::PayloadFrequencies frequency)) { |
| 504 | WEBRTC_CHECK_CHANNEL(channel); |
| 505 | if (frequency == webrtc::kFreq8000Hz) { |
| 506 | channels_[channel]->cn8_type = type; |
| 507 | } else if (frequency == webrtc::kFreq16000Hz) { |
| 508 | channels_[channel]->cn16_type = type; |
| 509 | } |
| 510 | return 0; |
| 511 | } |
| 512 | WEBRTC_FUNC(GetRecPayloadType, (int channel, webrtc::CodecInst& codec)) { |
| 513 | WEBRTC_CHECK_CHANNEL(channel); |
| 514 | Channel* ch = channels_[channel]; |
| 515 | for (std::vector<webrtc::CodecInst>::iterator it = ch->recv_codecs.begin(); |
| 516 | it != ch->recv_codecs.end(); ++it) { |
| 517 | if (strcmp(it->plname, codec.plname) == 0 && |
| 518 | it->plfreq == codec.plfreq && |
| 519 | it->channels == codec.channels && |
| 520 | it->pltype != -1) { |
| 521 | codec.pltype = it->pltype; |
| 522 | return 0; |
| 523 | } |
| 524 | } |
| 525 | return -1; // not found |
| 526 | } |
| 527 | WEBRTC_FUNC(SetVADStatus, (int channel, bool enable, webrtc::VadModes mode, |
| 528 | bool disableDTX)) { |
| 529 | WEBRTC_CHECK_CHANNEL(channel); |
| 530 | if (channels_[channel]->send_codec.channels == 2) { |
| 531 | // Replicating VoE behavior; VAD cannot be enabled for stereo. |
| 532 | return -1; |
| 533 | } |
| 534 | channels_[channel]->vad = enable; |
| 535 | return 0; |
| 536 | } |
| 537 | WEBRTC_STUB(GetVADStatus, (int channel, bool& enabled, |
| 538 | webrtc::VadModes& mode, bool& disabledDTX)); |
buildbot@webrtc.org | ae740dd | 2014-06-17 10:56:41 +0000 | [diff] [blame] | 539 | #ifdef USE_WEBRTC_DEV_BRANCH |
| 540 | WEBRTC_FUNC(SetFECStatus, (int channel, bool enable)) { |
| 541 | WEBRTC_CHECK_CHANNEL(channel); |
buildbot@webrtc.org | 3ffa1f9 | 2014-07-02 19:51:26 +0000 | [diff] [blame^] | 542 | if (strcmp(channels_[channel]->send_codec.plname, "opus")) { |
| 543 | // Return -1 if current send codec is not Opus. |
| 544 | // TODO(minyue): Excludes other codecs if they support inband FEC. |
| 545 | return -1; |
| 546 | } |
buildbot@webrtc.org | ae740dd | 2014-06-17 10:56:41 +0000 | [diff] [blame] | 547 | channels_[channel]->codec_fec = enable; |
| 548 | return 0; |
| 549 | } |
| 550 | WEBRTC_FUNC(GetFECStatus, (int channel, bool& enable)) { |
| 551 | WEBRTC_CHECK_CHANNEL(channel); |
| 552 | enable = channels_[channel]->codec_fec; |
| 553 | return 0; |
| 554 | } |
| 555 | #endif // USE_WEBRTC_DEV_BRANCH |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 556 | |
| 557 | // webrtc::VoEDtmf |
| 558 | WEBRTC_FUNC(SendTelephoneEvent, (int channel, int event_code, |
| 559 | bool out_of_band = true, int length_ms = 160, int attenuation_db = 10)) { |
| 560 | channels_[channel]->dtmf_info.dtmf_event_code = event_code; |
| 561 | channels_[channel]->dtmf_info.dtmf_out_of_band = out_of_band; |
| 562 | channels_[channel]->dtmf_info.dtmf_length_ms = length_ms; |
| 563 | return 0; |
| 564 | } |
| 565 | |
| 566 | WEBRTC_FUNC(SetSendTelephoneEventPayloadType, |
| 567 | (int channel, unsigned char type)) { |
| 568 | channels_[channel]->dtmf_type = type; |
| 569 | return 0; |
| 570 | }; |
| 571 | WEBRTC_STUB(GetSendTelephoneEventPayloadType, |
| 572 | (int channel, unsigned char& type)); |
| 573 | |
| 574 | WEBRTC_STUB(SetDtmfFeedbackStatus, (bool enable, bool directFeedback)); |
| 575 | WEBRTC_STUB(GetDtmfFeedbackStatus, (bool& enabled, bool& directFeedback)); |
| 576 | WEBRTC_STUB(SetDtmfPlayoutStatus, (int channel, bool enable)); |
| 577 | WEBRTC_STUB(GetDtmfPlayoutStatus, (int channel, bool& enabled)); |
| 578 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 579 | WEBRTC_FUNC(PlayDtmfTone, |
| 580 | (int event_code, int length_ms = 200, int attenuation_db = 10)) { |
| 581 | dtmf_info_.dtmf_event_code = event_code; |
| 582 | dtmf_info_.dtmf_length_ms = length_ms; |
| 583 | return 0; |
| 584 | } |
| 585 | WEBRTC_STUB(StartPlayingDtmfTone, |
| 586 | (int eventCode, int attenuationDb = 10)); |
| 587 | WEBRTC_STUB(StopPlayingDtmfTone, ()); |
| 588 | |
| 589 | // webrtc::VoEFile |
| 590 | WEBRTC_FUNC(StartPlayingFileLocally, (int channel, const char* fileNameUTF8, |
| 591 | bool loop, webrtc::FileFormats format, |
| 592 | float volumeScaling, int startPointMs, |
| 593 | int stopPointMs)) { |
| 594 | WEBRTC_CHECK_CHANNEL(channel); |
| 595 | channels_[channel]->file = true; |
| 596 | return 0; |
| 597 | } |
| 598 | WEBRTC_FUNC(StartPlayingFileLocally, (int channel, webrtc::InStream* stream, |
| 599 | webrtc::FileFormats format, |
| 600 | float volumeScaling, int startPointMs, |
| 601 | int stopPointMs)) { |
| 602 | WEBRTC_CHECK_CHANNEL(channel); |
| 603 | channels_[channel]->file = true; |
| 604 | return 0; |
| 605 | } |
| 606 | WEBRTC_FUNC(StopPlayingFileLocally, (int channel)) { |
| 607 | WEBRTC_CHECK_CHANNEL(channel); |
| 608 | channels_[channel]->file = false; |
| 609 | return 0; |
| 610 | } |
| 611 | WEBRTC_FUNC(IsPlayingFileLocally, (int channel)) { |
| 612 | WEBRTC_CHECK_CHANNEL(channel); |
| 613 | return (channels_[channel]->file) ? 1 : 0; |
| 614 | } |
| 615 | WEBRTC_STUB(ScaleLocalFilePlayout, (int channel, float scale)); |
| 616 | WEBRTC_STUB(StartPlayingFileAsMicrophone, (int channel, |
| 617 | const char* fileNameUTF8, |
| 618 | bool loop, |
| 619 | bool mixWithMicrophone, |
| 620 | webrtc::FileFormats format, |
| 621 | float volumeScaling)); |
| 622 | WEBRTC_STUB(StartPlayingFileAsMicrophone, (int channel, |
| 623 | webrtc::InStream* stream, |
| 624 | bool mixWithMicrophone, |
| 625 | webrtc::FileFormats format, |
| 626 | float volumeScaling)); |
| 627 | WEBRTC_STUB(StopPlayingFileAsMicrophone, (int channel)); |
| 628 | WEBRTC_STUB(IsPlayingFileAsMicrophone, (int channel)); |
| 629 | WEBRTC_STUB(ScaleFileAsMicrophonePlayout, (int channel, float scale)); |
| 630 | WEBRTC_STUB(StartRecordingPlayout, (int channel, const char* fileNameUTF8, |
| 631 | webrtc::CodecInst* compression, |
| 632 | int maxSizeBytes)); |
| 633 | WEBRTC_STUB(StartRecordingPlayout, (int channel, webrtc::OutStream* stream, |
| 634 | webrtc::CodecInst* compression)); |
| 635 | WEBRTC_STUB(StopRecordingPlayout, (int channel)); |
| 636 | WEBRTC_FUNC(StartRecordingMicrophone, (const char* fileNameUTF8, |
| 637 | webrtc::CodecInst* compression, |
| 638 | int maxSizeBytes)) { |
| 639 | if (fail_start_recording_microphone_) { |
| 640 | return -1; |
| 641 | } |
| 642 | recording_microphone_ = true; |
| 643 | return 0; |
| 644 | } |
| 645 | WEBRTC_FUNC(StartRecordingMicrophone, (webrtc::OutStream* stream, |
| 646 | webrtc::CodecInst* compression)) { |
| 647 | if (fail_start_recording_microphone_) { |
| 648 | return -1; |
| 649 | } |
| 650 | recording_microphone_ = true; |
| 651 | return 0; |
| 652 | } |
| 653 | WEBRTC_FUNC(StopRecordingMicrophone, ()) { |
| 654 | if (!recording_microphone_) { |
| 655 | return -1; |
| 656 | } |
| 657 | recording_microphone_ = false; |
| 658 | return 0; |
| 659 | } |
| 660 | WEBRTC_STUB(ConvertPCMToWAV, (const char* fileNameInUTF8, |
| 661 | const char* fileNameOutUTF8)); |
| 662 | WEBRTC_STUB(ConvertPCMToWAV, (webrtc::InStream* streamIn, |
| 663 | webrtc::OutStream* streamOut)); |
| 664 | WEBRTC_STUB(ConvertWAVToPCM, (const char* fileNameInUTF8, |
| 665 | const char* fileNameOutUTF8)); |
| 666 | WEBRTC_STUB(ConvertWAVToPCM, (webrtc::InStream* streamIn, |
| 667 | webrtc::OutStream* streamOut)); |
| 668 | WEBRTC_STUB(ConvertPCMToCompressed, (const char* fileNameInUTF8, |
| 669 | const char* fileNameOutUTF8, |
| 670 | webrtc::CodecInst* compression)); |
| 671 | WEBRTC_STUB(ConvertPCMToCompressed, (webrtc::InStream* streamIn, |
| 672 | webrtc::OutStream* streamOut, |
| 673 | webrtc::CodecInst* compression)); |
| 674 | WEBRTC_STUB(ConvertCompressedToPCM, (const char* fileNameInUTF8, |
| 675 | const char* fileNameOutUTF8)); |
| 676 | WEBRTC_STUB(ConvertCompressedToPCM, (webrtc::InStream* streamIn, |
| 677 | webrtc::OutStream* streamOut)); |
| 678 | WEBRTC_STUB(GetFileDuration, (const char* fileNameUTF8, int& durationMs, |
| 679 | webrtc::FileFormats format)); |
| 680 | WEBRTC_STUB(GetPlaybackPosition, (int channel, int& positionMs)); |
| 681 | |
| 682 | // webrtc::VoEHardware |
| 683 | WEBRTC_STUB(GetCPULoad, (int&)); |
| 684 | WEBRTC_FUNC(GetNumOfRecordingDevices, (int& num)) { |
| 685 | return GetNumDevices(num); |
| 686 | } |
| 687 | WEBRTC_FUNC(GetNumOfPlayoutDevices, (int& num)) { |
| 688 | return GetNumDevices(num); |
| 689 | } |
| 690 | WEBRTC_FUNC(GetRecordingDeviceName, (int i, char* name, char* guid)) { |
| 691 | return GetDeviceName(i, name, guid); |
| 692 | } |
| 693 | WEBRTC_FUNC(GetPlayoutDeviceName, (int i, char* name, char* guid)) { |
| 694 | return GetDeviceName(i, name, guid); |
| 695 | } |
| 696 | WEBRTC_STUB(SetRecordingDevice, (int, webrtc::StereoChannel)); |
| 697 | WEBRTC_STUB(SetPlayoutDevice, (int)); |
| 698 | WEBRTC_STUB(SetAudioDeviceLayer, (webrtc::AudioLayers)); |
| 699 | WEBRTC_STUB(GetAudioDeviceLayer, (webrtc::AudioLayers&)); |
| 700 | WEBRTC_STUB(GetPlayoutDeviceStatus, (bool&)); |
| 701 | WEBRTC_STUB(GetRecordingDeviceStatus, (bool&)); |
| 702 | WEBRTC_STUB(ResetAudioDevice, ()); |
| 703 | WEBRTC_STUB(AudioDeviceControl, (unsigned int, unsigned int, unsigned int)); |
| 704 | WEBRTC_STUB(SetLoudspeakerStatus, (bool enable)); |
| 705 | WEBRTC_STUB(GetLoudspeakerStatus, (bool& enabled)); |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 706 | WEBRTC_FUNC(SetRecordingSampleRate, (unsigned int samples_per_sec)) { |
| 707 | recording_sample_rate_ = samples_per_sec; |
| 708 | return 0; |
| 709 | } |
| 710 | WEBRTC_FUNC_CONST(RecordingSampleRate, (unsigned int* samples_per_sec)) { |
| 711 | *samples_per_sec = recording_sample_rate_; |
| 712 | return 0; |
| 713 | } |
| 714 | WEBRTC_FUNC(SetPlayoutSampleRate, (unsigned int samples_per_sec)) { |
| 715 | playout_sample_rate_ = samples_per_sec; |
| 716 | return 0; |
| 717 | } |
| 718 | WEBRTC_FUNC_CONST(PlayoutSampleRate, (unsigned int* samples_per_sec)) { |
| 719 | *samples_per_sec = playout_sample_rate_; |
| 720 | return 0; |
| 721 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 722 | WEBRTC_STUB(EnableBuiltInAEC, (bool enable)); |
| 723 | virtual bool BuiltInAECIsEnabled() const { return true; } |
| 724 | |
| 725 | // webrtc::VoENetEqStats |
| 726 | WEBRTC_STUB(GetNetworkStatistics, (int, webrtc::NetworkStatistics&)); |
wu@webrtc.org | 24301a6 | 2013-12-13 19:17:43 +0000 | [diff] [blame] | 727 | WEBRTC_FUNC_CONST(GetDecodingCallStatistics, (int channel, |
| 728 | webrtc::AudioDecodingCallStats*)) { |
| 729 | WEBRTC_CHECK_CHANNEL(channel); |
| 730 | return 0; |
| 731 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 732 | |
| 733 | // webrtc::VoENetwork |
| 734 | WEBRTC_FUNC(RegisterExternalTransport, (int channel, |
| 735 | webrtc::Transport& transport)) { |
| 736 | WEBRTC_CHECK_CHANNEL(channel); |
| 737 | channels_[channel]->external_transport = true; |
| 738 | return 0; |
| 739 | } |
| 740 | WEBRTC_FUNC(DeRegisterExternalTransport, (int channel)) { |
| 741 | WEBRTC_CHECK_CHANNEL(channel); |
| 742 | channels_[channel]->external_transport = false; |
| 743 | return 0; |
| 744 | } |
| 745 | WEBRTC_FUNC(ReceivedRTPPacket, (int channel, const void* data, |
| 746 | unsigned int length)) { |
| 747 | WEBRTC_CHECK_CHANNEL(channel); |
| 748 | if (!channels_[channel]->external_transport) return -1; |
| 749 | channels_[channel]->packets.push_back( |
| 750 | std::string(static_cast<const char*>(data), length)); |
| 751 | return 0; |
| 752 | } |
buildbot@webrtc.org | f875f15 | 2014-04-14 16:06:21 +0000 | [diff] [blame] | 753 | WEBRTC_FUNC(ReceivedRTPPacket, (int channel, const void* data, |
| 754 | unsigned int length, |
| 755 | const webrtc::PacketTime& packet_time)) { |
| 756 | WEBRTC_CHECK_CHANNEL(channel); |
| 757 | if (ReceivedRTPPacket(channel, data, length) == -1) { |
| 758 | return -1; |
| 759 | } |
| 760 | channels_[channel]->last_rtp_packet_time = packet_time; |
| 761 | return 0; |
| 762 | } |
buildbot@webrtc.org | f875f15 | 2014-04-14 16:06:21 +0000 | [diff] [blame] | 763 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 764 | WEBRTC_STUB(ReceivedRTCPPacket, (int channel, const void* data, |
| 765 | unsigned int length)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 766 | |
| 767 | // webrtc::VoERTP_RTCP |
| 768 | WEBRTC_STUB(RegisterRTPObserver, (int channel, |
| 769 | webrtc::VoERTPObserver& observer)); |
| 770 | WEBRTC_STUB(DeRegisterRTPObserver, (int channel)); |
| 771 | WEBRTC_STUB(RegisterRTCPObserver, (int channel, |
| 772 | webrtc::VoERTCPObserver& observer)); |
| 773 | WEBRTC_STUB(DeRegisterRTCPObserver, (int channel)); |
| 774 | WEBRTC_FUNC(SetLocalSSRC, (int channel, unsigned int ssrc)) { |
| 775 | WEBRTC_CHECK_CHANNEL(channel); |
| 776 | channels_[channel]->send_ssrc = ssrc; |
| 777 | return 0; |
| 778 | } |
| 779 | WEBRTC_FUNC(GetLocalSSRC, (int channel, unsigned int& ssrc)) { |
| 780 | WEBRTC_CHECK_CHANNEL(channel); |
| 781 | ssrc = channels_[channel]->send_ssrc; |
| 782 | return 0; |
| 783 | } |
| 784 | WEBRTC_STUB(GetRemoteSSRC, (int channel, unsigned int& ssrc)); |
henrike@webrtc.org | 79047f9 | 2014-03-06 23:46:59 +0000 | [diff] [blame] | 785 | WEBRTC_FUNC(SetSendAudioLevelIndicationStatus, (int channel, bool enable, |
| 786 | unsigned char id)) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 787 | WEBRTC_CHECK_CHANNEL(channel); |
henrike@webrtc.org | 79047f9 | 2014-03-06 23:46:59 +0000 | [diff] [blame] | 788 | WEBRTC_CHECK_HEADER_EXTENSION_ID(enable, id); |
| 789 | channels_[channel]->send_audio_level_ext_ = (enable) ? id : -1; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 790 | return 0; |
| 791 | } |
buildbot@webrtc.org | 150835e | 2014-05-06 15:54:38 +0000 | [diff] [blame] | 792 | #ifdef USE_WEBRTC_DEV_BRANCH |
| 793 | WEBRTC_FUNC(SetReceiveAudioLevelIndicationStatus, (int channel, bool enable, |
| 794 | unsigned char id)) { |
| 795 | WEBRTC_CHECK_CHANNEL(channel); |
| 796 | WEBRTC_CHECK_HEADER_EXTENSION_ID(enable, id); |
| 797 | channels_[channel]->receive_audio_level_ext_ = (enable) ? id : -1; |
| 798 | return 0; |
| 799 | } |
| 800 | #endif // USE_WEBRTC_DEV_BRANCH |
henrike@webrtc.org | 79047f9 | 2014-03-06 23:46:59 +0000 | [diff] [blame] | 801 | WEBRTC_FUNC(SetSendAbsoluteSenderTimeStatus, (int channel, bool enable, |
| 802 | unsigned char id)) { |
| 803 | WEBRTC_CHECK_CHANNEL(channel); |
| 804 | WEBRTC_CHECK_HEADER_EXTENSION_ID(enable, id); |
| 805 | channels_[channel]->send_absolute_sender_time_ext_ = (enable) ? id : -1; |
| 806 | return 0; |
| 807 | } |
| 808 | WEBRTC_FUNC(SetReceiveAbsoluteSenderTimeStatus, (int channel, bool enable, |
| 809 | unsigned char id)) { |
| 810 | WEBRTC_CHECK_CHANNEL(channel); |
| 811 | WEBRTC_CHECK_HEADER_EXTENSION_ID(enable, id); |
| 812 | channels_[channel]->receive_absolute_sender_time_ext_ = (enable) ? id : -1; |
| 813 | return 0; |
| 814 | } |
henrike@webrtc.org | 79047f9 | 2014-03-06 23:46:59 +0000 | [diff] [blame] | 815 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 816 | WEBRTC_STUB(GetRemoteCSRCs, (int channel, unsigned int arrCSRC[15])); |
| 817 | WEBRTC_STUB(SetRTCPStatus, (int channel, bool enable)); |
| 818 | WEBRTC_STUB(GetRTCPStatus, (int channel, bool& enabled)); |
| 819 | WEBRTC_STUB(SetRTCP_CNAME, (int channel, const char cname[256])); |
| 820 | WEBRTC_STUB(GetRTCP_CNAME, (int channel, char cname[256])); |
| 821 | WEBRTC_STUB(GetRemoteRTCP_CNAME, (int channel, char* cname)); |
| 822 | WEBRTC_STUB(GetRemoteRTCPData, (int channel, unsigned int& NTPHigh, |
| 823 | unsigned int& NTPLow, |
| 824 | unsigned int& timestamp, |
| 825 | unsigned int& playoutTimestamp, |
| 826 | unsigned int* jitter, |
| 827 | unsigned short* fractionLost)); |
| 828 | WEBRTC_STUB(GetRemoteRTCPSenderInfo, (int channel, |
| 829 | webrtc::SenderInfo* sender_info)); |
| 830 | WEBRTC_FUNC(GetRemoteRTCPReportBlocks, |
| 831 | (int channel, std::vector<webrtc::ReportBlock>* receive_blocks)) { |
| 832 | WEBRTC_CHECK_CHANNEL(channel); |
| 833 | webrtc::ReportBlock block; |
| 834 | block.source_SSRC = channels_[channel]->send_ssrc; |
| 835 | webrtc::CodecInst send_codec = channels_[channel]->send_codec; |
| 836 | if (send_codec.pltype >= 0) { |
| 837 | block.fraction_lost = (unsigned char)(kFractionLostStatValue * 256); |
| 838 | if (send_codec.plfreq / 1000 > 0) { |
| 839 | block.interarrival_jitter = kIntStatValue * (send_codec.plfreq / 1000); |
| 840 | } |
| 841 | block.cumulative_num_packets_lost = kIntStatValue; |
| 842 | block.extended_highest_sequence_number = kIntStatValue; |
| 843 | receive_blocks->push_back(block); |
| 844 | } |
| 845 | return 0; |
| 846 | } |
| 847 | WEBRTC_STUB(SendApplicationDefinedRTCPPacket, (int channel, |
| 848 | unsigned char subType, |
| 849 | unsigned int name, |
| 850 | const char* data, |
| 851 | unsigned short dataLength)); |
| 852 | WEBRTC_STUB(GetRTPStatistics, (int channel, unsigned int& averageJitterMs, |
| 853 | unsigned int& maxJitterMs, |
| 854 | unsigned int& discardedPackets)); |
| 855 | WEBRTC_FUNC(GetRTCPStatistics, (int channel, webrtc::CallStatistics& stats)) { |
| 856 | WEBRTC_CHECK_CHANNEL(channel); |
| 857 | stats.fractionLost = static_cast<int16>(kIntStatValue); |
| 858 | stats.cumulativeLost = kIntStatValue; |
| 859 | stats.extendedMax = kIntStatValue; |
| 860 | stats.jitterSamples = kIntStatValue; |
| 861 | stats.rttMs = kIntStatValue; |
| 862 | stats.bytesSent = kIntStatValue; |
| 863 | stats.packetsSent = kIntStatValue; |
| 864 | stats.bytesReceived = kIntStatValue; |
| 865 | stats.packetsReceived = kIntStatValue; |
| 866 | return 0; |
| 867 | } |
buildbot@webrtc.org | ae740dd | 2014-06-17 10:56:41 +0000 | [diff] [blame] | 868 | #ifdef USE_WEBRTC_DEV_BRANCH |
| 869 | WEBRTC_FUNC(SetREDStatus, (int channel, bool enable, int redPayloadtype)) { |
buildbot@webrtc.org | bfa758a | 2014-06-27 16:04:43 +0000 | [diff] [blame] | 870 | return SetFECStatus(channel, enable, redPayloadtype); |
| 871 | } |
| 872 | #endif |
| 873 | // TODO(minyue): remove the below function when transition to SetREDStatus |
| 874 | // is finished. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 875 | WEBRTC_FUNC(SetFECStatus, (int channel, bool enable, int redPayloadtype)) { |
| 876 | WEBRTC_CHECK_CHANNEL(channel); |
buildbot@webrtc.org | ae740dd | 2014-06-17 10:56:41 +0000 | [diff] [blame] | 877 | channels_[channel]->red = enable; |
| 878 | channels_[channel]->red_type = redPayloadtype; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 879 | return 0; |
| 880 | } |
buildbot@webrtc.org | ae740dd | 2014-06-17 10:56:41 +0000 | [diff] [blame] | 881 | #ifdef USE_WEBRTC_DEV_BRANCH |
| 882 | WEBRTC_FUNC(GetREDStatus, (int channel, bool& enable, int& redPayloadtype)) { |
buildbot@webrtc.org | bfa758a | 2014-06-27 16:04:43 +0000 | [diff] [blame] | 883 | return GetFECStatus(channel, enable, redPayloadtype); |
| 884 | } |
| 885 | #endif |
| 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 | } |
| 900 | WEBRTC_STUB(StartRTPDump, (int channel, const char* fileNameUTF8, |
| 901 | webrtc::RTPDirections direction)); |
| 902 | WEBRTC_STUB(StopRTPDump, (int channel, webrtc::RTPDirections direction)); |
| 903 | WEBRTC_STUB(RTPDumpIsActive, (int channel, webrtc::RTPDirections direction)); |
| 904 | WEBRTC_STUB(InsertExtraRTPPacket, (int channel, unsigned char payloadType, |
| 905 | bool markerBit, const char* payloadData, |
| 906 | unsigned short payloadSize)); |
| 907 | WEBRTC_STUB(GetLastRemoteTimeStamp, (int channel, |
| 908 | uint32_t* lastRemoteTimeStamp)); |
buildbot@webrtc.org | f875f15 | 2014-04-14 16:06:21 +0000 | [diff] [blame] | 909 | WEBRTC_FUNC(SetVideoEngineBWETarget, (int channel, |
| 910 | webrtc::ViENetwork* vie_network, |
| 911 | int video_channel)) { |
| 912 | WEBRTC_CHECK_CHANNEL(channel); |
| 913 | channels_[channel]->vie_network = vie_network; |
| 914 | channels_[channel]->video_channel = video_channel; |
| 915 | return 0; |
| 916 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 917 | |
| 918 | // webrtc::VoEVideoSync |
| 919 | WEBRTC_STUB(GetPlayoutBufferSize, (int& bufferMs)); |
| 920 | WEBRTC_STUB(GetPlayoutTimestamp, (int channel, unsigned int& timestamp)); |
wu@webrtc.org | 822fbd8 | 2013-08-15 23:38:54 +0000 | [diff] [blame] | 921 | WEBRTC_STUB(GetRtpRtcp, (int, webrtc::RtpRtcp**, webrtc::RtpReceiver**)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 922 | WEBRTC_STUB(SetInitTimestamp, (int channel, unsigned int timestamp)); |
| 923 | WEBRTC_STUB(SetInitSequenceNumber, (int channel, short sequenceNumber)); |
| 924 | WEBRTC_STUB(SetMinimumPlayoutDelay, (int channel, int delayMs)); |
| 925 | WEBRTC_STUB(SetInitialPlayoutDelay, (int channel, int delay_ms)); |
| 926 | WEBRTC_STUB(GetDelayEstimate, (int channel, int* jitter_buffer_delay_ms, |
| 927 | int* playout_buffer_delay_ms)); |
| 928 | WEBRTC_STUB_CONST(GetLeastRequiredDelayMs, (int channel)); |
| 929 | |
| 930 | // webrtc::VoEVolumeControl |
| 931 | WEBRTC_STUB(SetSpeakerVolume, (unsigned int)); |
| 932 | WEBRTC_STUB(GetSpeakerVolume, (unsigned int&)); |
| 933 | WEBRTC_STUB(SetSystemOutputMute, (bool)); |
| 934 | WEBRTC_STUB(GetSystemOutputMute, (bool&)); |
| 935 | WEBRTC_STUB(SetMicVolume, (unsigned int)); |
| 936 | WEBRTC_STUB(GetMicVolume, (unsigned int&)); |
| 937 | WEBRTC_STUB(SetInputMute, (int, bool)); |
| 938 | WEBRTC_STUB(GetInputMute, (int, bool&)); |
| 939 | WEBRTC_STUB(SetSystemInputMute, (bool)); |
| 940 | WEBRTC_STUB(GetSystemInputMute, (bool&)); |
| 941 | WEBRTC_STUB(GetSpeechInputLevel, (unsigned int&)); |
| 942 | WEBRTC_STUB(GetSpeechOutputLevel, (int, unsigned int&)); |
| 943 | WEBRTC_STUB(GetSpeechInputLevelFullRange, (unsigned int&)); |
| 944 | WEBRTC_STUB(GetSpeechOutputLevelFullRange, (int, unsigned int&)); |
| 945 | WEBRTC_FUNC(SetChannelOutputVolumeScaling, (int channel, float scale)) { |
| 946 | WEBRTC_CHECK_CHANNEL(channel); |
| 947 | channels_[channel]->volume_scale= scale; |
| 948 | return 0; |
| 949 | } |
| 950 | WEBRTC_FUNC(GetChannelOutputVolumeScaling, (int channel, float& scale)) { |
| 951 | WEBRTC_CHECK_CHANNEL(channel); |
| 952 | scale = channels_[channel]->volume_scale; |
| 953 | return 0; |
| 954 | } |
| 955 | WEBRTC_FUNC(SetOutputVolumePan, (int channel, float left, float right)) { |
| 956 | WEBRTC_CHECK_CHANNEL(channel); |
| 957 | channels_[channel]->volume_pan_left = left; |
| 958 | channels_[channel]->volume_pan_right = right; |
| 959 | return 0; |
| 960 | } |
| 961 | WEBRTC_FUNC(GetOutputVolumePan, (int channel, float& left, float& right)) { |
| 962 | WEBRTC_CHECK_CHANNEL(channel); |
| 963 | left = channels_[channel]->volume_pan_left; |
| 964 | right = channels_[channel]->volume_pan_right; |
| 965 | return 0; |
| 966 | } |
| 967 | |
| 968 | // webrtc::VoEAudioProcessing |
| 969 | WEBRTC_FUNC(SetNsStatus, (bool enable, webrtc::NsModes mode)) { |
| 970 | ns_enabled_ = enable; |
| 971 | ns_mode_ = mode; |
| 972 | return 0; |
| 973 | } |
| 974 | WEBRTC_FUNC(GetNsStatus, (bool& enabled, webrtc::NsModes& mode)) { |
| 975 | enabled = ns_enabled_; |
| 976 | mode = ns_mode_; |
| 977 | return 0; |
| 978 | } |
| 979 | |
| 980 | WEBRTC_FUNC(SetAgcStatus, (bool enable, webrtc::AgcModes mode)) { |
| 981 | agc_enabled_ = enable; |
| 982 | agc_mode_ = mode; |
| 983 | return 0; |
| 984 | } |
| 985 | WEBRTC_FUNC(GetAgcStatus, (bool& enabled, webrtc::AgcModes& mode)) { |
| 986 | enabled = agc_enabled_; |
| 987 | mode = agc_mode_; |
| 988 | return 0; |
| 989 | } |
| 990 | |
| 991 | WEBRTC_FUNC(SetAgcConfig, (webrtc::AgcConfig config)) { |
| 992 | agc_config_ = config; |
| 993 | return 0; |
| 994 | } |
| 995 | WEBRTC_FUNC(GetAgcConfig, (webrtc::AgcConfig& config)) { |
| 996 | config = agc_config_; |
| 997 | return 0; |
| 998 | } |
| 999 | WEBRTC_FUNC(SetEcStatus, (bool enable, webrtc::EcModes mode)) { |
| 1000 | ec_enabled_ = enable; |
| 1001 | ec_mode_ = mode; |
| 1002 | return 0; |
| 1003 | } |
| 1004 | WEBRTC_FUNC(GetEcStatus, (bool& enabled, webrtc::EcModes& mode)) { |
| 1005 | enabled = ec_enabled_; |
| 1006 | mode = ec_mode_; |
| 1007 | return 0; |
| 1008 | } |
| 1009 | WEBRTC_STUB(EnableDriftCompensation, (bool enable)) |
| 1010 | WEBRTC_BOOL_STUB(DriftCompensationEnabled, ()) |
| 1011 | WEBRTC_VOID_STUB(SetDelayOffsetMs, (int offset)) |
| 1012 | WEBRTC_STUB(DelayOffsetMs, ()); |
| 1013 | WEBRTC_FUNC(SetAecmMode, (webrtc::AecmModes mode, bool enableCNG)) { |
| 1014 | aecm_mode_ = mode; |
| 1015 | cng_enabled_ = enableCNG; |
| 1016 | return 0; |
| 1017 | } |
| 1018 | WEBRTC_FUNC(GetAecmMode, (webrtc::AecmModes& mode, bool& enabledCNG)) { |
| 1019 | mode = aecm_mode_; |
| 1020 | enabledCNG = cng_enabled_; |
| 1021 | return 0; |
| 1022 | } |
| 1023 | WEBRTC_STUB(SetRxNsStatus, (int channel, bool enable, webrtc::NsModes mode)); |
| 1024 | WEBRTC_STUB(GetRxNsStatus, (int channel, bool& enabled, |
| 1025 | webrtc::NsModes& mode)); |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 1026 | WEBRTC_FUNC(SetRxAgcStatus, (int channel, bool enable, |
| 1027 | webrtc::AgcModes mode)) { |
| 1028 | channels_[channel]->rx_agc_enabled = enable; |
| 1029 | channels_[channel]->rx_agc_mode = mode; |
| 1030 | return 0; |
| 1031 | } |
| 1032 | WEBRTC_FUNC(GetRxAgcStatus, (int channel, bool& enabled, |
| 1033 | webrtc::AgcModes& mode)) { |
| 1034 | enabled = channels_[channel]->rx_agc_enabled; |
| 1035 | mode = channels_[channel]->rx_agc_mode; |
| 1036 | return 0; |
| 1037 | } |
| 1038 | |
| 1039 | WEBRTC_FUNC(SetRxAgcConfig, (int channel, webrtc::AgcConfig config)) { |
| 1040 | channels_[channel]->rx_agc_config = config; |
| 1041 | return 0; |
| 1042 | } |
| 1043 | WEBRTC_FUNC(GetRxAgcConfig, (int channel, webrtc::AgcConfig& config)) { |
| 1044 | config = channels_[channel]->rx_agc_config; |
| 1045 | return 0; |
| 1046 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1047 | |
| 1048 | WEBRTC_STUB(RegisterRxVadObserver, (int, webrtc::VoERxVadCallback&)); |
| 1049 | WEBRTC_STUB(DeRegisterRxVadObserver, (int channel)); |
| 1050 | WEBRTC_STUB(VoiceActivityIndicator, (int channel)); |
| 1051 | WEBRTC_FUNC(SetEcMetricsStatus, (bool enable)) { |
| 1052 | ec_metrics_enabled_ = enable; |
| 1053 | return 0; |
| 1054 | } |
| 1055 | WEBRTC_FUNC(GetEcMetricsStatus, (bool& enabled)) { |
| 1056 | enabled = ec_metrics_enabled_; |
| 1057 | return 0; |
| 1058 | } |
| 1059 | WEBRTC_STUB(GetEchoMetrics, (int& ERL, int& ERLE, int& RERL, int& A_NLP)); |
| 1060 | WEBRTC_STUB(GetEcDelayMetrics, (int& delay_median, int& delay_std)); |
| 1061 | |
| 1062 | WEBRTC_STUB(StartDebugRecording, (const char* fileNameUTF8)); |
wu@webrtc.org | 9caf276 | 2013-12-11 18:25:07 +0000 | [diff] [blame] | 1063 | WEBRTC_STUB(StartDebugRecording, (FILE* handle)); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1064 | WEBRTC_STUB(StopDebugRecording, ()); |
| 1065 | |
| 1066 | WEBRTC_FUNC(SetTypingDetectionStatus, (bool enable)) { |
| 1067 | typing_detection_enabled_ = enable; |
| 1068 | return 0; |
| 1069 | } |
| 1070 | WEBRTC_FUNC(GetTypingDetectionStatus, (bool& enabled)) { |
| 1071 | enabled = typing_detection_enabled_; |
| 1072 | return 0; |
| 1073 | } |
| 1074 | |
| 1075 | WEBRTC_STUB(TimeSinceLastTyping, (int& seconds)); |
| 1076 | WEBRTC_STUB(SetTypingDetectionParameters, (int timeWindow, |
| 1077 | int costPerTyping, |
| 1078 | int reportingThreshold, |
| 1079 | int penaltyDecay, |
| 1080 | int typeEventDelay)); |
| 1081 | int EnableHighPassFilter(bool enable) { |
| 1082 | highpass_filter_enabled_ = enable; |
| 1083 | return 0; |
| 1084 | } |
| 1085 | bool IsHighPassFilterEnabled() { |
| 1086 | return highpass_filter_enabled_; |
| 1087 | } |
| 1088 | bool IsStereoChannelSwappingEnabled() { |
| 1089 | return stereo_swapping_enabled_; |
| 1090 | } |
| 1091 | void EnableStereoChannelSwapping(bool enable) { |
| 1092 | stereo_swapping_enabled_ = enable; |
| 1093 | } |
| 1094 | bool WasSendTelephoneEventCalled(int channel, int event_code, int length_ms) { |
| 1095 | return (channels_[channel]->dtmf_info.dtmf_event_code == event_code && |
| 1096 | channels_[channel]->dtmf_info.dtmf_out_of_band == true && |
| 1097 | channels_[channel]->dtmf_info.dtmf_length_ms == length_ms); |
| 1098 | } |
| 1099 | bool WasPlayDtmfToneCalled(int event_code, int length_ms) { |
| 1100 | return (dtmf_info_.dtmf_event_code == event_code && |
| 1101 | dtmf_info_.dtmf_length_ms == length_ms); |
| 1102 | } |
| 1103 | // webrtc::VoEExternalMedia |
| 1104 | WEBRTC_FUNC(RegisterExternalMediaProcessing, |
| 1105 | (int channel, webrtc::ProcessingTypes type, |
| 1106 | webrtc::VoEMediaProcess& processObject)) { |
| 1107 | WEBRTC_CHECK_CHANNEL(channel); |
| 1108 | if (channels_[channel]->media_processor_registered) { |
| 1109 | return -1; |
| 1110 | } |
| 1111 | channels_[channel]->media_processor_registered = true; |
| 1112 | media_processor_ = &processObject; |
| 1113 | return 0; |
| 1114 | } |
| 1115 | WEBRTC_FUNC(DeRegisterExternalMediaProcessing, |
| 1116 | (int channel, webrtc::ProcessingTypes type)) { |
| 1117 | WEBRTC_CHECK_CHANNEL(channel); |
| 1118 | if (!channels_[channel]->media_processor_registered) { |
| 1119 | return -1; |
| 1120 | } |
| 1121 | channels_[channel]->media_processor_registered = false; |
| 1122 | media_processor_ = NULL; |
| 1123 | return 0; |
| 1124 | } |
| 1125 | WEBRTC_STUB(SetExternalRecordingStatus, (bool enable)); |
| 1126 | WEBRTC_STUB(SetExternalPlayoutStatus, (bool enable)); |
| 1127 | WEBRTC_STUB(ExternalRecordingInsertData, |
| 1128 | (const int16_t speechData10ms[], int lengthSamples, |
| 1129 | int samplingFreqHz, int current_delay_ms)); |
| 1130 | WEBRTC_STUB(ExternalPlayoutGetData, |
| 1131 | (int16_t speechData10ms[], int samplingFreqHz, |
| 1132 | int current_delay_ms, int& lengthSamples)); |
| 1133 | WEBRTC_STUB(GetAudioFrame, (int channel, int desired_sample_rate_hz, |
| 1134 | webrtc::AudioFrame* frame)); |
| 1135 | WEBRTC_STUB(SetExternalMixing, (int channel, bool enable)); |
| 1136 | |
| 1137 | private: |
| 1138 | int GetNumDevices(int& num) { |
| 1139 | #ifdef WIN32 |
| 1140 | num = 1; |
| 1141 | #else |
| 1142 | // On non-Windows platforms VE adds a special entry for the default device, |
| 1143 | // so if there is one physical device then there are two entries in the |
| 1144 | // list. |
| 1145 | num = 2; |
| 1146 | #endif |
| 1147 | return 0; |
| 1148 | } |
| 1149 | |
| 1150 | int GetDeviceName(int i, char* name, char* guid) { |
| 1151 | const char *s; |
| 1152 | #ifdef WIN32 |
| 1153 | if (0 == i) { |
| 1154 | s = kFakeDeviceName; |
| 1155 | } else { |
| 1156 | return -1; |
| 1157 | } |
| 1158 | #else |
| 1159 | // See comment above. |
| 1160 | if (0 == i) { |
| 1161 | s = kFakeDefaultDeviceName; |
| 1162 | } else if (1 == i) { |
| 1163 | s = kFakeDeviceName; |
| 1164 | } else { |
| 1165 | return -1; |
| 1166 | } |
| 1167 | #endif |
| 1168 | strcpy(name, s); |
| 1169 | guid[0] = '\0'; |
| 1170 | return 0; |
| 1171 | } |
| 1172 | |
| 1173 | bool inited_; |
| 1174 | int last_channel_; |
| 1175 | std::map<int, Channel*> channels_; |
| 1176 | bool fail_create_channel_; |
| 1177 | const cricket::AudioCodec* const* codecs_; |
| 1178 | int num_codecs_; |
wu@webrtc.org | 05e7b44 | 2014-04-01 17:44:24 +0000 | [diff] [blame] | 1179 | int num_set_send_codecs_; // how many times we call SetSendCodec(). |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1180 | bool ec_enabled_; |
| 1181 | bool ec_metrics_enabled_; |
| 1182 | bool cng_enabled_; |
| 1183 | bool ns_enabled_; |
| 1184 | bool agc_enabled_; |
| 1185 | bool highpass_filter_enabled_; |
| 1186 | bool stereo_swapping_enabled_; |
| 1187 | bool typing_detection_enabled_; |
| 1188 | webrtc::EcModes ec_mode_; |
| 1189 | webrtc::AecmModes aecm_mode_; |
| 1190 | webrtc::NsModes ns_mode_; |
| 1191 | webrtc::AgcModes agc_mode_; |
| 1192 | webrtc::AgcConfig agc_config_; |
| 1193 | webrtc::VoiceEngineObserver* observer_; |
| 1194 | int playout_fail_channel_; |
| 1195 | int send_fail_channel_; |
| 1196 | bool fail_start_recording_microphone_; |
| 1197 | bool recording_microphone_; |
wu@webrtc.org | 97077a3 | 2013-10-25 21:18:33 +0000 | [diff] [blame] | 1198 | int recording_sample_rate_; |
| 1199 | int playout_sample_rate_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1200 | DtmfInfo dtmf_info_; |
| 1201 | webrtc::VoEMediaProcess* media_processor_; |
| 1202 | }; |
| 1203 | |
henrike@webrtc.org | 79047f9 | 2014-03-06 23:46:59 +0000 | [diff] [blame] | 1204 | #undef WEBRTC_CHECK_HEADER_EXTENSION_ID |
| 1205 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1206 | } // namespace cricket |
| 1207 | |
| 1208 | #endif // TALK_SESSION_PHONE_FAKEWEBRTCVOICEENGINE_H_ |