Skip to content

Commit 0130420

Browse files
authored
fix: Add RTCAudioOptions and enable SW 3A for Linux. (#124)
* fix: Add RTCAudioOptions and enable SW 3A for Linux. * fix.
1 parent 5cf497f commit 0130420

File tree

5 files changed

+25
-7
lines changed

5 files changed

+25
-7
lines changed

include/rtc_peerconnection_factory.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ class RTCPeerConnectionFactory : public RefCountInterface {
4343
virtual scoped_refptr<RTCAudioSource> CreateAudioSource(
4444
const string audio_source_label,
4545
RTCAudioSource::SourceType source_type =
46-
RTCAudioSource::SourceType::kMicrophone) = 0;
46+
RTCAudioSource::SourceType::kMicrophone,
47+
RTCAudioOptions options = RTCAudioOptions()) = 0;
4748

4849
virtual scoped_refptr<RTCVideoSource> CreateVideoSource(
4950
scoped_refptr<RTCVideoCapturer> capturer, const string video_source_label,

include/rtc_types.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,18 @@ struct SdpParseError {
108108

109109
enum DesktopType { kScreen, kWindow };
110110

111+
struct RTCAudioOptions {
112+
RTCAudioOptions() {}
113+
114+
bool echo_cancellation = true;
115+
116+
bool auto_gain_control = true;
117+
118+
bool noise_suppression = true;
119+
120+
bool highpass_filter = false;
121+
};
122+
111123
} // namespace libwebrtc
112124

113125
#endif // LIB_WEBRTC_RTC_TYPES_HXX

src/libwebrtc.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ LibWebRTC::CreateRTCPeerConnectionFactory() {
3434
scoped_refptr<RTCPeerConnectionFactory> rtc_peerconnection_factory =
3535
scoped_refptr<RTCPeerConnectionFactory>(
3636
new RefCountedObject<RTCPeerConnectionFactoryImpl>());
37-
rtc_peerconnection_factory->Initialize();
3837
return rtc_peerconnection_factory;
3938
}
4039

src/rtc_peerconnection_factory_impl.cc

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,16 @@ RTCPeerConnectionFactoryImpl::CreateAudioSourceWithOptions(
203203
}
204204

205205
scoped_refptr<RTCAudioSource> RTCPeerConnectionFactoryImpl::CreateAudioSource(
206-
const string audio_source_label, RTCAudioSource::SourceType source_type) {
207-
auto options = webrtc::AudioOptions();
206+
const string audio_source_label, RTCAudioSource::SourceType source_type,
207+
RTCAudioOptions options) {
208+
auto rtc_options = webrtc::AudioOptions();
209+
rtc_options.echo_cancellation = options.echo_cancellation;
210+
rtc_options.auto_gain_control = options.auto_gain_control;
211+
rtc_options.noise_suppression = options.noise_suppression;
212+
rtc_options.highpass_filter = options.highpass_filter;
208213
webrtc::scoped_refptr<libwebrtc::LocalAudioSource> rtc_source_track =
209-
CreateAudioSourceWithOptions(&options, source_type == RTCAudioSource::SourceType::kCustom);
214+
CreateAudioSourceWithOptions(
215+
&rtc_options, source_type == RTCAudioSource::SourceType::kCustom);
210216
scoped_refptr<RTCAudioSourceImpl> source = scoped_refptr<RTCAudioSourceImpl>(
211217
new RefCountedObject<RTCAudioSourceImpl>(rtc_source_track, source_type));
212218
return source;

src/rtc_peerconnection_factory_impl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ class RTCPeerConnectionFactoryImpl : public RTCPeerConnectionFactory {
4747
scoped_refptr<RTCAudioProcessing> GetAudioProcessing() override;
4848

4949
virtual scoped_refptr<RTCAudioSource> CreateAudioSource(
50-
const string audio_source_label,
51-
RTCAudioSource::SourceType source_type) override;
50+
const string audio_source_label, RTCAudioSource::SourceType source_type,
51+
RTCAudioOptions options) override;
5252

5353
virtual scoped_refptr<RTCVideoSource> CreateVideoSource(
5454
scoped_refptr<RTCVideoCapturer> capturer, const string video_source_label,

0 commit comments

Comments
 (0)