Skip to content

Commit 9ea05f1

Browse files
authored
feat: support bypass voice processing for iOS. (#15)
1 parent 09362d9 commit 9ea05f1

File tree

3 files changed

+43
-4
lines changed

3 files changed

+43
-4
lines changed

sdk/objc/api/peerconnection/RTCPeerConnectionFactory+Native.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ NS_ASSUME_NONNULL_BEGIN
7171
initWithEncoderFactory:(nullable id<RTC_OBJC_TYPE(RTCVideoEncoderFactory)>)encoderFactory
7272
decoderFactory:(nullable id<RTC_OBJC_TYPE(RTCVideoDecoderFactory)>)decoderFactory;
7373

74+
- (instancetype)
75+
initWithBypassVoiceProcessing:(BOOL)bypassVoiceProcessing
76+
encoderFactory:(nullable id<RTC_OBJC_TYPE(RTCVideoEncoderFactory)>)encoderFactory
77+
decoderFactory:
78+
(nullable id<RTC_OBJC_TYPE(RTCVideoDecoderFactory)>)decoderFactory;
79+
7480
/** Initialize an RTCPeerConnection with a configuration, constraints, and
7581
* dependencies.
7682
*/

sdk/objc/api/peerconnection/RTCPeerConnectionFactory.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ RTC_OBJC_EXPORT
4141
initWithEncoderFactory:(nullable id<RTC_OBJC_TYPE(RTCVideoEncoderFactory)>)encoderFactory
4242
decoderFactory:(nullable id<RTC_OBJC_TYPE(RTCVideoDecoderFactory)>)decoderFactory;
4343

44+
/* Initialize object with bypass voice processing */
45+
- (instancetype)
46+
initWithBypassVoiceProcessing:(BOOL)bypassVoiceProcessing
47+
encoderFactory:(nullable id<RTC_OBJC_TYPE(RTCVideoEncoderFactory)>)encoderFactory
48+
decoderFactory:
49+
(nullable id<RTC_OBJC_TYPE(RTCVideoDecoderFactory)>)decoderFactory;
50+
4451
/** Initialize an RTCAudioSource with constraints. */
4552
- (RTC_OBJC_TYPE(RTCAudioSource) *)audioSourceWithConstraints:
4653
(nullable RTC_OBJC_TYPE(RTCMediaConstraints) *)constraints;

sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ @implementation RTC_OBJC_TYPE (RTCPeerConnectionFactory) {
6767

6868
@synthesize nativeFactory = _nativeFactory;
6969

70-
- (rtc::scoped_refptr<webrtc::AudioDeviceModule>)audioDeviceModule {
70+
- (rtc::scoped_refptr<webrtc::AudioDeviceModule>)audioDeviceModule:(BOOL)bypassVoiceProcessing {
7171
#if defined(WEBRTC_IOS)
72-
return webrtc::CreateAudioDeviceModule();
72+
return webrtc::CreateAudioDeviceModule(bypassVoiceProcessing);
7373
#else
7474
return nullptr;
7575
#endif
@@ -86,7 +86,7 @@ - (instancetype)init {
8686
RTCVideoEncoderFactoryH264) alloc] init])
8787
nativeVideoDecoderFactory:webrtc::ObjCToNativeVideoDecoderFactory([[RTC_OBJC_TYPE(
8888
RTCVideoDecoderFactoryH264) alloc] init])
89-
audioDeviceModule:[self audioDeviceModule]
89+
audioDeviceModule:[self audioDeviceModule:false]
9090
audioProcessingModule:nullptr];
9191
#endif
9292
}
@@ -109,10 +109,36 @@ - (instancetype)init {
109109
nativeAudioDecoderFactory:webrtc::CreateBuiltinAudioDecoderFactory()
110110
nativeVideoEncoderFactory:std::move(native_encoder_factory)
111111
nativeVideoDecoderFactory:std::move(native_decoder_factory)
112-
audioDeviceModule:[self audioDeviceModule]
112+
audioDeviceModule:[self audioDeviceModule:false]
113113
audioProcessingModule:nullptr];
114114
#endif
115115
}
116+
117+
- (instancetype)
118+
initWithBypassVoiceProcessing:(BOOL)bypassVoiceProcessing
119+
encoderFactory:(nullable id<RTC_OBJC_TYPE(RTCVideoEncoderFactory)>)encoderFactory
120+
decoderFactory:
121+
(nullable id<RTC_OBJC_TYPE(RTCVideoDecoderFactory)>)decoderFactory {
122+
#ifdef HAVE_NO_MEDIA
123+
return [self initWithNoMedia];
124+
#else
125+
std::unique_ptr<webrtc::VideoEncoderFactory> native_encoder_factory;
126+
std::unique_ptr<webrtc::VideoDecoderFactory> native_decoder_factory;
127+
if (encoderFactory) {
128+
native_encoder_factory = webrtc::ObjCToNativeVideoEncoderFactory(encoderFactory);
129+
}
130+
if (decoderFactory) {
131+
native_decoder_factory = webrtc::ObjCToNativeVideoDecoderFactory(decoderFactory);
132+
}
133+
return [self initWithNativeAudioEncoderFactory:webrtc::CreateBuiltinAudioEncoderFactory()
134+
nativeAudioDecoderFactory:webrtc::CreateBuiltinAudioDecoderFactory()
135+
nativeVideoEncoderFactory:std::move(native_encoder_factory)
136+
nativeVideoDecoderFactory:std::move(native_decoder_factory)
137+
audioDeviceModule:[self audioDeviceModule:bypassVoiceProcessing]
138+
audioProcessingModule:nullptr];
139+
#endif
140+
}
141+
116142
- (instancetype)initNative {
117143
if (self = [super init]) {
118144
_networkThread = rtc::Thread::CreateWithSocketServer();

0 commit comments

Comments
 (0)