Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: talk/media/webrtc/fakewebrtcvoiceengine.h

Issue 1491743004: Refactor WVoE DTMF handling #2 (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@wvoe_dtmf
Patch Set: rebase Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « talk/media/webrtc/fakewebrtccall.cc ('k') | talk/media/webrtc/webrtcvoe.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2010 Google Inc. 3 * Copyright 2010 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 bool experimental_ns_enabled() { 138 bool experimental_ns_enabled() {
139 return experimental_ns_enabled_; 139 return experimental_ns_enabled_;
140 } 140 }
141 141
142 private: 142 private:
143 bool experimental_ns_enabled_; 143 bool experimental_ns_enabled_;
144 }; 144 };
145 145
146 class FakeWebRtcVoiceEngine 146 class FakeWebRtcVoiceEngine
147 : public webrtc::VoEAudioProcessing, 147 : public webrtc::VoEAudioProcessing,
148 public webrtc::VoEBase, public webrtc::VoECodec, public webrtc::VoEDtmf, 148 public webrtc::VoEBase, public webrtc::VoECodec,
149 public webrtc::VoEHardware, 149 public webrtc::VoEHardware,
150 public webrtc::VoENetwork, public webrtc::VoERTP_RTCP, 150 public webrtc::VoENetwork, public webrtc::VoERTP_RTCP,
151 public webrtc::VoEVolumeControl { 151 public webrtc::VoEVolumeControl {
152 public: 152 public:
153 struct DtmfInfo {
154 DtmfInfo()
155 : dtmf_event_code(-1),
156 dtmf_out_of_band(false),
157 dtmf_length_ms(-1) {}
158 int dtmf_event_code;
159 bool dtmf_out_of_band;
160 int dtmf_length_ms;
161 };
162 struct Channel { 153 struct Channel {
163 explicit Channel() 154 explicit Channel()
164 : external_transport(false), 155 : external_transport(false),
165 send(false), 156 send(false),
166 playout(false), 157 playout(false),
167 volume_scale(1.0), 158 volume_scale(1.0),
168 vad(false), 159 vad(false),
169 codec_fec(false), 160 codec_fec(false),
170 max_encoding_bandwidth(0), 161 max_encoding_bandwidth(0),
171 opus_dtx(false), 162 opus_dtx(false),
172 red(false), 163 red(false),
173 nack(false), 164 nack(false),
174 cn8_type(13), 165 cn8_type(13),
175 cn16_type(105), 166 cn16_type(105),
176 dtmf_type(106),
177 red_type(117), 167 red_type(117),
178 nack_max_packets(0), 168 nack_max_packets(0),
179 send_ssrc(0), 169 send_ssrc(0),
180 associate_send_channel(-1), 170 associate_send_channel(-1),
181 recv_codecs(), 171 recv_codecs(),
182 neteq_capacity(-1), 172 neteq_capacity(-1),
183 neteq_fast_accelerate(false) { 173 neteq_fast_accelerate(false) {
184 memset(&send_codec, 0, sizeof(send_codec)); 174 memset(&send_codec, 0, sizeof(send_codec));
185 } 175 }
186 bool external_transport; 176 bool external_transport;
187 bool send; 177 bool send;
188 bool playout; 178 bool playout;
189 float volume_scale; 179 float volume_scale;
190 bool vad; 180 bool vad;
191 bool codec_fec; 181 bool codec_fec;
192 int max_encoding_bandwidth; 182 int max_encoding_bandwidth;
193 bool opus_dtx; 183 bool opus_dtx;
194 bool red; 184 bool red;
195 bool nack; 185 bool nack;
196 int cn8_type; 186 int cn8_type;
197 int cn16_type; 187 int cn16_type;
198 int dtmf_type;
199 int red_type; 188 int red_type;
200 int nack_max_packets; 189 int nack_max_packets;
201 uint32_t send_ssrc; 190 uint32_t send_ssrc;
202 int associate_send_channel; 191 int associate_send_channel;
203 DtmfInfo dtmf_info;
204 std::vector<webrtc::CodecInst> recv_codecs; 192 std::vector<webrtc::CodecInst> recv_codecs;
205 webrtc::CodecInst send_codec; 193 webrtc::CodecInst send_codec;
206 webrtc::PacketTime last_rtp_packet_time; 194 webrtc::PacketTime last_rtp_packet_time;
207 std::list<std::string> packets; 195 std::list<std::string> packets;
208 int neteq_capacity; 196 int neteq_capacity;
209 bool neteq_fast_accelerate; 197 bool neteq_fast_accelerate;
210 }; 198 };
211 199
212 FakeWebRtcVoiceEngine() 200 FakeWebRtcVoiceEngine()
213 : inited_(false), 201 : inited_(false),
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 } 262 }
275 const webrtc::PacketTime& GetLastRtpPacketTime(int channel) { 263 const webrtc::PacketTime& GetLastRtpPacketTime(int channel) {
276 RTC_DCHECK(channels_.find(channel) != channels_.end()); 264 RTC_DCHECK(channels_.find(channel) != channels_.end());
277 return channels_[channel]->last_rtp_packet_time; 265 return channels_[channel]->last_rtp_packet_time;
278 } 266 }
279 int GetSendCNPayloadType(int channel, bool wideband) { 267 int GetSendCNPayloadType(int channel, bool wideband) {
280 return (wideband) ? 268 return (wideband) ?
281 channels_[channel]->cn16_type : 269 channels_[channel]->cn16_type :
282 channels_[channel]->cn8_type; 270 channels_[channel]->cn8_type;
283 } 271 }
284 int GetSendTelephoneEventPayloadType(int channel) {
285 return channels_[channel]->dtmf_type;
286 }
287 int GetSendREDPayloadType(int channel) { 272 int GetSendREDPayloadType(int channel) {
288 return channels_[channel]->red_type; 273 return channels_[channel]->red_type;
289 } 274 }
290 bool CheckPacket(int channel, const void* data, size_t len) { 275 bool CheckPacket(int channel, const void* data, size_t len) {
291 bool result = !CheckNoPacket(channel); 276 bool result = !CheckNoPacket(channel);
292 if (result) { 277 if (result) {
293 std::string packet = channels_[channel]->packets.front(); 278 std::string packet = channels_[channel]->packets.front();
294 result = (packet == std::string(static_cast<const char*>(data), len)); 279 result = (packet == std::string(static_cast<const char*>(data), len));
295 channels_[channel]->packets.pop_front(); 280 channels_[channel]->packets.pop_front();
296 } 281 }
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 WEBRTC_FUNC(SetOpusDtx, (int channel, bool enable_dtx)) { 530 WEBRTC_FUNC(SetOpusDtx, (int channel, bool enable_dtx)) {
546 WEBRTC_CHECK_CHANNEL(channel); 531 WEBRTC_CHECK_CHANNEL(channel);
547 if (_stricmp(channels_[channel]->send_codec.plname, "opus") != 0) { 532 if (_stricmp(channels_[channel]->send_codec.plname, "opus") != 0) {
548 // Return -1 if current send codec is not Opus. 533 // Return -1 if current send codec is not Opus.
549 return -1; 534 return -1;
550 } 535 }
551 channels_[channel]->opus_dtx = enable_dtx; 536 channels_[channel]->opus_dtx = enable_dtx;
552 return 0; 537 return 0;
553 } 538 }
554 539
555 // webrtc::VoEDtmf
556 WEBRTC_FUNC(SendTelephoneEvent, (int channel, int event_code,
557 bool out_of_band = true, int length_ms = 160, int attenuation_db = 10)) {
558 channels_[channel]->dtmf_info.dtmf_event_code = event_code;
559 channels_[channel]->dtmf_info.dtmf_out_of_band = out_of_band;
560 channels_[channel]->dtmf_info.dtmf_length_ms = length_ms;
561 return 0;
562 }
563 WEBRTC_FUNC(SetSendTelephoneEventPayloadType,
564 (int channel, unsigned char type)) {
565 channels_[channel]->dtmf_type = type;
566 return 0;
567 };
568 WEBRTC_STUB(GetSendTelephoneEventPayloadType,
569 (int channel, unsigned char& type));
570 WEBRTC_STUB(SetDtmfFeedbackStatus, (bool enable, bool directFeedback));
571 WEBRTC_STUB(GetDtmfFeedbackStatus, (bool& enabled, bool& directFeedback));
572 WEBRTC_STUB(PlayDtmfTone,
573 (int event_code, int length_ms = 200, int attenuation_db = 10));
574
575 // webrtc::VoEHardware 540 // webrtc::VoEHardware
576 WEBRTC_FUNC(GetNumOfRecordingDevices, (int& num)) { 541 WEBRTC_FUNC(GetNumOfRecordingDevices, (int& num)) {
577 return GetNumDevices(num); 542 return GetNumDevices(num);
578 } 543 }
579 WEBRTC_FUNC(GetNumOfPlayoutDevices, (int& num)) { 544 WEBRTC_FUNC(GetNumOfPlayoutDevices, (int& num)) {
580 return GetNumDevices(num); 545 return GetNumDevices(num);
581 } 546 }
582 WEBRTC_FUNC(GetRecordingDeviceName, (int i, char* name, char* guid)) { 547 WEBRTC_FUNC(GetRecordingDeviceName, (int i, char* name, char* guid)) {
583 return GetDeviceName(i, name, guid); 548 return GetDeviceName(i, name, guid);
584 } 549 }
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 } 789 }
825 bool IsHighPassFilterEnabled() { 790 bool IsHighPassFilterEnabled() {
826 return highpass_filter_enabled_; 791 return highpass_filter_enabled_;
827 } 792 }
828 bool IsStereoChannelSwappingEnabled() { 793 bool IsStereoChannelSwappingEnabled() {
829 return stereo_swapping_enabled_; 794 return stereo_swapping_enabled_;
830 } 795 }
831 void EnableStereoChannelSwapping(bool enable) { 796 void EnableStereoChannelSwapping(bool enable) {
832 stereo_swapping_enabled_ = enable; 797 stereo_swapping_enabled_ = enable;
833 } 798 }
834 bool WasSendTelephoneEventCalled(int channel, int event_code, int length_ms) {
835 return (channels_[channel]->dtmf_info.dtmf_event_code == event_code &&
836 channels_[channel]->dtmf_info.dtmf_out_of_band == true &&
837 channels_[channel]->dtmf_info.dtmf_length_ms == length_ms);
838 }
839 bool WasPlayDtmfToneCalled(int event_code, int length_ms) {
840 return (dtmf_info_.dtmf_event_code == event_code &&
841 dtmf_info_.dtmf_length_ms == length_ms);
842 }
843 int GetNetEqCapacity() const { 799 int GetNetEqCapacity() const {
844 auto ch = channels_.find(last_channel_); 800 auto ch = channels_.find(last_channel_);
845 ASSERT(ch != channels_.end()); 801 ASSERT(ch != channels_.end());
846 return ch->second->neteq_capacity; 802 return ch->second->neteq_capacity;
847 } 803 }
848 bool GetNetEqFastAccelerate() const { 804 bool GetNetEqFastAccelerate() const {
849 auto ch = channels_.find(last_channel_); 805 auto ch = channels_.find(last_channel_);
850 ASSERT(ch != channels_.end()); 806 ASSERT(ch != channels_.end());
851 return ch->second->neteq_fast_accelerate; 807 return ch->second->neteq_fast_accelerate;
852 } 808 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 webrtc::EcModes ec_mode_; 859 webrtc::EcModes ec_mode_;
904 webrtc::AecmModes aecm_mode_; 860 webrtc::AecmModes aecm_mode_;
905 webrtc::NsModes ns_mode_; 861 webrtc::NsModes ns_mode_;
906 webrtc::AgcModes agc_mode_; 862 webrtc::AgcModes agc_mode_;
907 webrtc::AgcConfig agc_config_; 863 webrtc::AgcConfig agc_config_;
908 webrtc::VoiceEngineObserver* observer_; 864 webrtc::VoiceEngineObserver* observer_;
909 int playout_fail_channel_; 865 int playout_fail_channel_;
910 int send_fail_channel_; 866 int send_fail_channel_;
911 int recording_sample_rate_; 867 int recording_sample_rate_;
912 int playout_sample_rate_; 868 int playout_sample_rate_;
913 DtmfInfo dtmf_info_;
914 FakeAudioProcessing audio_processing_; 869 FakeAudioProcessing audio_processing_;
915 }; 870 };
916 871
917 } // namespace cricket 872 } // namespace cricket
918 873
919 #endif // TALK_SESSION_PHONE_FAKEWEBRTCVOICEENGINE_H_ 874 #endif // TALK_SESSION_PHONE_FAKEWEBRTCVOICEENGINE_H_
OLDNEW
« no previous file with comments | « talk/media/webrtc/fakewebrtccall.cc ('k') | talk/media/webrtc/webrtcvoe.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698