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

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

Issue 2948763002: Allow an external audio processing module to be used in WebRTC (Closed)
Patch Set: tracking linux32_rel issue Created 3 years, 6 months 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
OLDNEW
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
11 #ifndef WEBRTC_MEDIA_ENGINE_FAKEWEBRTCVOICEENGINE_H_ 11 #ifndef WEBRTC_MEDIA_ENGINE_FAKEWEBRTCVOICEENGINE_H_
12 #define WEBRTC_MEDIA_ENGINE_FAKEWEBRTCVOICEENGINE_H_ 12 #define WEBRTC_MEDIA_ENGINE_FAKEWEBRTCVOICEENGINE_H_
13 13
14 #include <map> 14 #include <map>
15 #include <vector> 15 #include <vector>
16 16
17 #include "webrtc/base/checks.h" 17 #include "webrtc/base/checks.h"
18 #include "webrtc/media/engine/webrtcvoe.h" 18 #include "webrtc/media/engine/webrtcvoe.h"
19 #include "webrtc/modules/audio_processing/include/audio_processing.h"
20 19
21 namespace webrtc { 20 namespace webrtc {
22 namespace voe { 21 namespace voe {
23 class TransmitMixer; 22 class TransmitMixer;
24 } // namespace voe 23 } // namespace voe
25 } // namespace webrtc 24 } // namespace webrtc
26 25
27 namespace cricket { 26 namespace cricket {
28 27
29 #define WEBRTC_CHECK_CHANNEL(channel) \ 28 #define WEBRTC_CHECK_CHANNEL(channel) \
30 if (channels_.find(channel) == channels_.end()) return -1; 29 if (channels_.find(channel) == channels_.end()) return -1;
31 30
32 #define WEBRTC_STUB(method, args) \ 31 #define WEBRTC_STUB(method, args) \
33 int method args override { return 0; } 32 int method args override { return 0; }
34 33
35 #define WEBRTC_FUNC(method, args) int method args override 34 #define WEBRTC_FUNC(method, args) int method args override
36 35
37 class FakeWebRtcVoiceEngine : public webrtc::VoEBase { 36 class FakeWebRtcVoiceEngine : public webrtc::VoEBase {
38 public: 37 public:
39 struct Channel { 38 struct Channel {
40 std::vector<webrtc::CodecInst> recv_codecs; 39 std::vector<webrtc::CodecInst> recv_codecs;
41 size_t neteq_capacity = 0; 40 size_t neteq_capacity = 0;
42 bool neteq_fast_accelerate = false; 41 bool neteq_fast_accelerate = false;
43 }; 42 };
44 43
45 explicit FakeWebRtcVoiceEngine(webrtc::AudioProcessing* apm, 44 explicit FakeWebRtcVoiceEngine(webrtc::voe::TransmitMixer* transmit_mixer)
46 webrtc::voe::TransmitMixer* transmit_mixer) 45 : transmit_mixer_(transmit_mixer) {}
47 : apm_(apm), transmit_mixer_(transmit_mixer) {
48 }
49 ~FakeWebRtcVoiceEngine() override { 46 ~FakeWebRtcVoiceEngine() override {
50 RTC_CHECK(channels_.empty()); 47 RTC_CHECK(channels_.empty());
51 } 48 }
52 49
53 bool IsInited() const { return inited_; } 50 bool IsInited() const { return inited_; }
54 int GetLastChannel() const { return last_channel_; } 51 int GetLastChannel() const { return last_channel_; }
55 int GetNumChannels() const { return static_cast<int>(channels_.size()); } 52 int GetNumChannels() const { return static_cast<int>(channels_.size()); }
56 void set_fail_create_channel(bool fail_create_channel) { 53 void set_fail_create_channel(bool fail_create_channel) {
57 fail_create_channel_ = fail_create_channel; 54 fail_create_channel_ = fail_create_channel;
58 } 55 }
59 56
60 WEBRTC_STUB(Release, ()); 57 WEBRTC_STUB(Release, ());
61 58
62 // webrtc::VoEBase 59 // webrtc::VoEBase
63 WEBRTC_STUB(RegisterVoiceEngineObserver, ( 60 WEBRTC_STUB(RegisterVoiceEngineObserver, (
64 webrtc::VoiceEngineObserver& observer)); 61 webrtc::VoiceEngineObserver& observer));
65 WEBRTC_STUB(DeRegisterVoiceEngineObserver, ()); 62 WEBRTC_STUB(DeRegisterVoiceEngineObserver, ());
66 WEBRTC_FUNC(Init, 63 WEBRTC_FUNC(Init,
67 (webrtc::AudioDeviceModule* adm, 64 (webrtc::AudioDeviceModule* adm,
68 webrtc::AudioProcessing* audioproc, 65 webrtc::AudioProcessing* audioproc,
69 const rtc::scoped_refptr<webrtc::AudioDecoderFactory>& 66 const rtc::scoped_refptr<webrtc::AudioDecoderFactory>&
70 decoder_factory)) { 67 decoder_factory)) {
71 inited_ = true; 68 inited_ = true;
72 return 0; 69 return 0;
73 } 70 }
74 WEBRTC_FUNC(Terminate, ()) { 71 WEBRTC_FUNC(Terminate, ()) {
75 inited_ = false; 72 inited_ = false;
76 return 0; 73 return 0;
77 } 74 }
78 webrtc::AudioProcessing* audio_processing() override { 75
79 return apm_;
80 }
81 webrtc::AudioDeviceModule* audio_device_module() override { 76 webrtc::AudioDeviceModule* audio_device_module() override {
82 return nullptr; 77 return nullptr;
83 } 78 }
84 webrtc::voe::TransmitMixer* transmit_mixer() override { 79 webrtc::voe::TransmitMixer* transmit_mixer() override {
85 return transmit_mixer_; 80 return transmit_mixer_;
86 } 81 }
87 WEBRTC_FUNC(CreateChannel, ()) { 82 WEBRTC_FUNC(CreateChannel, ()) {
88 return CreateChannel(webrtc::VoEBase::ChannelConfig()); 83 return CreateChannel(webrtc::VoEBase::ChannelConfig());
89 } 84 }
90 WEBRTC_FUNC(CreateChannel, (const webrtc::VoEBase::ChannelConfig& config)) { 85 WEBRTC_FUNC(CreateChannel, (const webrtc::VoEBase::ChannelConfig& config)) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 auto ch = channels_.find(last_channel_); 119 auto ch = channels_.find(last_channel_);
125 RTC_CHECK(ch != channels_.end()); 120 RTC_CHECK(ch != channels_.end());
126 return ch->second->neteq_fast_accelerate; 121 return ch->second->neteq_fast_accelerate;
127 } 122 }
128 123
129 private: 124 private:
130 bool inited_ = false; 125 bool inited_ = false;
131 int last_channel_ = -1; 126 int last_channel_ = -1;
132 std::map<int, Channel*> channels_; 127 std::map<int, Channel*> channels_;
133 bool fail_create_channel_ = false; 128 bool fail_create_channel_ = false;
134 webrtc::AudioProcessing* apm_ = nullptr;
135 webrtc::voe::TransmitMixer* transmit_mixer_ = nullptr; 129 webrtc::voe::TransmitMixer* transmit_mixer_ = nullptr;
136 130
137 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(FakeWebRtcVoiceEngine); 131 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(FakeWebRtcVoiceEngine);
138 }; 132 };
139 133
140 } // namespace cricket 134 } // namespace cricket
141 135
142 #endif // WEBRTC_MEDIA_ENGINE_FAKEWEBRTCVOICEENGINE_H_ 136 #endif // WEBRTC_MEDIA_ENGINE_FAKEWEBRTCVOICEENGINE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698