OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2010 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2010 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 | 50 |
51 #define WEBRTC_FUNC(method, args) int method args override | 51 #define WEBRTC_FUNC(method, args) int method args override |
52 | 52 |
53 class FakeWebRtcVoiceEngine | 53 class FakeWebRtcVoiceEngine |
54 : public webrtc::VoEAudioProcessing, | 54 : public webrtc::VoEAudioProcessing, |
55 public webrtc::VoEBase, public webrtc::VoECodec, | 55 public webrtc::VoEBase, public webrtc::VoECodec, |
56 public webrtc::VoEHardware, | 56 public webrtc::VoEHardware, |
57 public webrtc::VoEVolumeControl { | 57 public webrtc::VoEVolumeControl { |
58 public: | 58 public: |
59 struct Channel { | 59 struct Channel { |
60 int associate_send_channel = -1; | |
61 std::vector<webrtc::CodecInst> recv_codecs; | 60 std::vector<webrtc::CodecInst> recv_codecs; |
62 size_t neteq_capacity = 0; | 61 size_t neteq_capacity = 0; |
63 bool neteq_fast_accelerate = false; | 62 bool neteq_fast_accelerate = false; |
64 }; | 63 }; |
65 | 64 |
66 explicit FakeWebRtcVoiceEngine(webrtc::AudioProcessing* apm) : apm_(apm) { | 65 explicit FakeWebRtcVoiceEngine(webrtc::AudioProcessing* apm) : apm_(apm) { |
67 memset(&agc_config_, 0, sizeof(agc_config_)); | 66 memset(&agc_config_, 0, sizeof(agc_config_)); |
68 } | 67 } |
69 ~FakeWebRtcVoiceEngine() override { | 68 ~FakeWebRtcVoiceEngine() override { |
70 RTC_CHECK(channels_.empty()); | 69 RTC_CHECK(channels_.empty()); |
71 } | 70 } |
72 | 71 |
73 bool ec_metrics_enabled() const { return ec_metrics_enabled_; } | 72 bool ec_metrics_enabled() const { return ec_metrics_enabled_; } |
74 | 73 |
75 bool IsInited() const { return inited_; } | 74 bool IsInited() const { return inited_; } |
76 int GetLastChannel() const { return last_channel_; } | 75 int GetLastChannel() const { return last_channel_; } |
77 int GetNumChannels() const { return static_cast<int>(channels_.size()); } | 76 int GetNumChannels() const { return static_cast<int>(channels_.size()); } |
78 void set_fail_create_channel(bool fail_create_channel) { | 77 void set_fail_create_channel(bool fail_create_channel) { |
79 fail_create_channel_ = fail_create_channel; | 78 fail_create_channel_ = fail_create_channel; |
80 } | 79 } |
81 | 80 |
82 int GetAssociateSendChannel(int channel) { | |
83 return channels_[channel]->associate_send_channel; | |
84 } | |
85 | |
86 WEBRTC_STUB(Release, ()); | 81 WEBRTC_STUB(Release, ()); |
87 | 82 |
88 // webrtc::VoEBase | 83 // webrtc::VoEBase |
89 WEBRTC_STUB(RegisterVoiceEngineObserver, ( | 84 WEBRTC_STUB(RegisterVoiceEngineObserver, ( |
90 webrtc::VoiceEngineObserver& observer)); | 85 webrtc::VoiceEngineObserver& observer)); |
91 WEBRTC_STUB(DeRegisterVoiceEngineObserver, ()); | 86 WEBRTC_STUB(DeRegisterVoiceEngineObserver, ()); |
92 WEBRTC_FUNC(Init, | 87 WEBRTC_FUNC(Init, |
93 (webrtc::AudioDeviceModule* adm, | 88 (webrtc::AudioDeviceModule* adm, |
94 webrtc::AudioProcessing* audioproc, | 89 webrtc::AudioProcessing* audioproc, |
95 const rtc::scoped_refptr<webrtc::AudioDecoderFactory>& | 90 const rtc::scoped_refptr<webrtc::AudioDecoderFactory>& |
(...skipping 22 matching lines...) Expand all Loading... |
118 auto db = webrtc::acm2::RentACodec::Database(); | 113 auto db = webrtc::acm2::RentACodec::Database(); |
119 ch->recv_codecs.assign(db.begin(), db.end()); | 114 ch->recv_codecs.assign(db.begin(), db.end()); |
120 ch->neteq_capacity = config.acm_config.neteq_config.max_packets_in_buffer; | 115 ch->neteq_capacity = config.acm_config.neteq_config.max_packets_in_buffer; |
121 ch->neteq_fast_accelerate = | 116 ch->neteq_fast_accelerate = |
122 config.acm_config.neteq_config.enable_fast_accelerate; | 117 config.acm_config.neteq_config.enable_fast_accelerate; |
123 channels_[++last_channel_] = ch; | 118 channels_[++last_channel_] = ch; |
124 return last_channel_; | 119 return last_channel_; |
125 } | 120 } |
126 WEBRTC_FUNC(DeleteChannel, (int channel)) { | 121 WEBRTC_FUNC(DeleteChannel, (int channel)) { |
127 WEBRTC_CHECK_CHANNEL(channel); | 122 WEBRTC_CHECK_CHANNEL(channel); |
128 for (const auto& ch : channels_) { | |
129 if (ch.second->associate_send_channel == channel) { | |
130 ch.second->associate_send_channel = -1; | |
131 } | |
132 } | |
133 delete channels_[channel]; | 123 delete channels_[channel]; |
134 channels_.erase(channel); | 124 channels_.erase(channel); |
135 return 0; | 125 return 0; |
136 } | 126 } |
137 WEBRTC_STUB(StartReceive, (int channel)); | 127 WEBRTC_STUB(StartReceive, (int channel)); |
138 WEBRTC_STUB(StartPlayout, (int channel)); | 128 WEBRTC_STUB(StartPlayout, (int channel)); |
139 WEBRTC_STUB(StartSend, (int channel)); | 129 WEBRTC_STUB(StartSend, (int channel)); |
140 WEBRTC_STUB(StopReceive, (int channel)); | 130 WEBRTC_STUB(StopReceive, (int channel)); |
141 WEBRTC_STUB(StopPlayout, (int channel)); | 131 WEBRTC_STUB(StopPlayout, (int channel)); |
142 WEBRTC_STUB(StopSend, (int channel)); | 132 WEBRTC_STUB(StopSend, (int channel)); |
143 WEBRTC_STUB(GetVersion, (char version[1024])); | 133 WEBRTC_STUB(GetVersion, (char version[1024])); |
144 WEBRTC_STUB(LastError, ()); | 134 WEBRTC_STUB(LastError, ()); |
145 WEBRTC_FUNC(AssociateSendChannel, (int channel, | 135 WEBRTC_STUB(AssociateSendChannel, (int channel, |
146 int accociate_send_channel)) { | 136 int accociate_send_channel)); |
147 WEBRTC_CHECK_CHANNEL(channel); | |
148 channels_[channel]->associate_send_channel = accociate_send_channel; | |
149 return 0; | |
150 } | |
151 | 137 |
152 // webrtc::VoECodec | 138 // webrtc::VoECodec |
153 WEBRTC_STUB(NumOfCodecs, ()); | 139 WEBRTC_STUB(NumOfCodecs, ()); |
154 WEBRTC_STUB(GetCodec, (int index, webrtc::CodecInst& codec)); | 140 WEBRTC_STUB(GetCodec, (int index, webrtc::CodecInst& codec)); |
155 WEBRTC_STUB(SetSendCodec, (int channel, const webrtc::CodecInst& codec)); | 141 WEBRTC_STUB(SetSendCodec, (int channel, const webrtc::CodecInst& codec)); |
156 WEBRTC_STUB(GetSendCodec, (int channel, webrtc::CodecInst& codec)); | 142 WEBRTC_STUB(GetSendCodec, (int channel, webrtc::CodecInst& codec)); |
157 WEBRTC_STUB(SetBitRate, (int channel, int bitrate_bps)); | 143 WEBRTC_STUB(SetBitRate, (int channel, int bitrate_bps)); |
158 WEBRTC_STUB(GetRecCodec, (int channel, webrtc::CodecInst& codec)); | 144 WEBRTC_STUB(GetRecCodec, (int channel, webrtc::CodecInst& codec)); |
159 WEBRTC_FUNC(SetRecPayloadType, (int channel, | 145 WEBRTC_FUNC(SetRecPayloadType, (int channel, |
160 const webrtc::CodecInst& codec)) { | 146 const webrtc::CodecInst& codec)) { |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 webrtc::AgcModes agc_mode_ = webrtc::kAgcDefault; | 353 webrtc::AgcModes agc_mode_ = webrtc::kAgcDefault; |
368 webrtc::AgcConfig agc_config_; | 354 webrtc::AgcConfig agc_config_; |
369 webrtc::AudioProcessing* apm_ = nullptr; | 355 webrtc::AudioProcessing* apm_ = nullptr; |
370 | 356 |
371 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(FakeWebRtcVoiceEngine); | 357 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(FakeWebRtcVoiceEngine); |
372 }; | 358 }; |
373 | 359 |
374 } // namespace cricket | 360 } // namespace cricket |
375 | 361 |
376 #endif // WEBRTC_MEDIA_ENGINE_FAKEWEBRTCVOICEENGINE_H_ | 362 #endif // WEBRTC_MEDIA_ENGINE_FAKEWEBRTCVOICEENGINE_H_ |
OLD | NEW |