Skip to content

Commit 6d06a40

Browse files
cloudwebrtcdavidliu
authored andcommitted
feat: support bypass voice processing for iOS. (webrtc-sdk#15)
1 parent f333421 commit 6d06a40

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
@@ -68,9 +68,9 @@ @implementation RTC_OBJC_TYPE (RTCPeerConnectionFactory) {
6868

6969
@synthesize nativeFactory = _nativeFactory;
7070

71-
- (rtc::scoped_refptr<webrtc::AudioDeviceModule>)audioDeviceModule {
71+
- (rtc::scoped_refptr<webrtc::AudioDeviceModule>)audioDeviceModule:(BOOL)bypassVoiceProcessing {
7272
#if defined(WEBRTC_IOS)
73-
return webrtc::CreateAudioDeviceModule();
73+
return webrtc::CreateAudioDeviceModule(bypassVoiceProcessing);
7474
#else
7575
return nullptr;
7676
#endif
@@ -87,7 +87,7 @@ - (instancetype)init {
8787
RTCVideoEncoderFactoryH264) alloc] init])
8888
nativeVideoDecoderFactory:webrtc::ObjCToNativeVideoDecoderFactory([[RTC_OBJC_TYPE(
8989
RTCVideoDecoderFactoryH264) alloc] init])
90-
audioDeviceModule:[self audioDeviceModule]
90+
audioDeviceModule:[self audioDeviceModule:false]
9191
audioProcessingModule:nullptr];
9292
#endif
9393
}
@@ -110,10 +110,36 @@ - (instancetype)init {
110110
nativeAudioDecoderFactory:webrtc::CreateBuiltinAudioDecoderFactory()
111111
nativeVideoEncoderFactory:std::move(native_encoder_factory)
112112
nativeVideoDecoderFactory:std::move(native_decoder_factory)
113-
audioDeviceModule:[self audioDeviceModule]
113+
audioDeviceModule:[self audioDeviceModule:false]
114114
audioProcessingModule:nullptr];
115115
#endif
116116
}
117+
118+
- (instancetype)
119+
initWithBypassVoiceProcessing:(BOOL)bypassVoiceProcessing
120+
encoderFactory:(nullable id<RTC_OBJC_TYPE(RTCVideoEncoderFactory)>)encoderFactory
121+
decoderFactory:
122+
(nullable id<RTC_OBJC_TYPE(RTCVideoDecoderFactory)>)decoderFactory {
123+
#ifdef HAVE_NO_MEDIA
124+
return [self initWithNoMedia];
125+
#else
126+
std::unique_ptr<webrtc::VideoEncoderFactory> native_encoder_factory;
127+
std::unique_ptr<webrtc::VideoDecoderFactory> native_decoder_factory;
128+
if (encoderFactory) {
129+
native_encoder_factory = webrtc::ObjCToNativeVideoEncoderFactory(encoderFactory);
130+
}
131+
if (decoderFactory) {
132+
native_decoder_factory = webrtc::ObjCToNativeVideoDecoderFactory(decoderFactory);
133+
}
134+
return [self initWithNativeAudioEncoderFactory:webrtc::CreateBuiltinAudioEncoderFactory()
135+
nativeAudioDecoderFactory:webrtc::CreateBuiltinAudioDecoderFactory()
136+
nativeVideoEncoderFactory:std::move(native_encoder_factory)
137+
nativeVideoDecoderFactory:std::move(native_decoder_factory)
138+
audioDeviceModule:[self audioDeviceModule:bypassVoiceProcessing]
139+
audioProcessingModule:nullptr];
140+
#endif
141+
}
142+
117143
- (instancetype)initNative {
118144
if (self = [super init]) {
119145
_networkThread = rtc::Thread::CreateWithSocketServer();

0 commit comments

Comments
 (0)