Skip to content

Commit b099459

Browse files
committed
chore: code cleanup
1 parent 9fa28d3 commit b099459

5 files changed

Lines changed: 6 additions & 49 deletions

File tree

android/src/main/java/com/oney/WebRTCModule/audio/AudioProcessingController.java

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,13 @@ public class AudioProcessingController implements AudioProcessingFactoryProvider
1717
public ExternalAudioProcessingFactory externalAudioProcessingFactory;
1818

1919
public AudioProcessingController() {
20-
// ExternalAudioProcessingFactory creation is deferred to getFactory()
21-
// because its constructor calls JNI native methods that require the
22-
// WebRTC native library to be loaded first (via PeerConnectionFactory.initialize()).
23-
// This allows AudioProcessingController to be safely instantiated in
24-
// MainApplication.onCreate() before the native library is loaded.
20+
this.externalAudioProcessingFactory = new ExternalAudioProcessingFactory();
21+
this.externalAudioProcessingFactory.setCapturePostProcessing(capturePostProcessing);
22+
this.externalAudioProcessingFactory.setRenderPreProcessing(renderPreProcessing);
2523
}
2624

2725
@Override
2826
public AudioProcessingFactory getFactory() {
29-
if (this.externalAudioProcessingFactory == null) {
30-
this.externalAudioProcessingFactory = new ExternalAudioProcessingFactory();
31-
this.externalAudioProcessingFactory.setCapturePostProcessing(capturePostProcessing);
32-
this.externalAudioProcessingFactory.setRenderPreProcessing(renderPreProcessing);
33-
}
3427
return this.externalAudioProcessingFactory;
3528
}
3629
}

ios/RCTWebRTC/WebRTCModule+RTCMediaStream.m

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -224,19 +224,6 @@ - (RTCVideoTrack *)createScreenCaptureVideoTrack {
224224
// Store weak reference for audio mixing wiring
225225
options.activeInAppScreenCapturer = capturer;
226226

227-
// If audio mixing is requested, set up the audio buffer handler.
228-
// The handler forwards .audioApp CMSampleBuffers to the mixer's enqueue method.
229-
// The mixer may not exist yet (created by startScreenShareAudioMixing),
230-
// so we check at each callback invocation.
231-
if (options.includeScreenShareAudio) {
232-
capturer.audioBufferHandler = ^(CMSampleBufferRef sampleBuffer) {
233-
ScreenShareAudioMixer *mixer = [WebRTCModuleOptions sharedInstance].screenShareAudioMixer;
234-
if (mixer) {
235-
[mixer enqueue:sampleBuffer];
236-
}
237-
};
238-
}
239-
240227
captureController = controller;
241228
} else {
242229
// Existing broadcast extension path

ios/RCTWebRTC/WebRTCModule.m

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,6 @@ - (instancetype)init {
9898
}
9999
RCTLogInfo(@"Using audio processing module: %@", NSStringFromClass([audioProcessingModule class]));
100100

101-
// Store reference to the default APM if it is one.
102-
if ([audioProcessingModule isKindOfClass:[RTCDefaultAudioProcessingModule class]]) {
103-
options.defaultAudioProcessingModule = (RTCDefaultAudioProcessingModule *)audioProcessingModule;
104-
}
105-
106101
_peerConnectionFactory =
107102
[[RTCPeerConnectionFactory alloc] initWithAudioDeviceModuleType:RTCAudioDeviceModuleTypeAudioEngine
108103
bypassVoiceProcessing:NO
@@ -115,17 +110,12 @@ - (instancetype)init {
115110
decoderFactory:decoderFactory
116111
audioDevice:audioDevice];
117112
} else {
118-
// No custom APM provided — create a default one (no capturePostProcessingDelegate needed;
119-
// screen share audio mixing uses the AVAudioEngine graph approach via audioGraphDelegate).
120-
RTCDefaultAudioProcessingModule *defaultAPM = [[RTCDefaultAudioProcessingModule alloc] init];
121-
options.defaultAudioProcessingModule = defaultAPM;
122-
123113
_peerConnectionFactory =
124114
[[RTCPeerConnectionFactory alloc] initWithAudioDeviceModuleType:RTCAudioDeviceModuleTypeAudioEngine
125115
bypassVoiceProcessing:NO
126116
encoderFactory:encoderFactory
127117
decoderFactory:decoderFactory
128-
audioProcessingModule:defaultAPM];
118+
audioProcessingModule:nil];
129119
}
130120

131121
_rtcAudioDeviceModuleObserver = [[AudioDeviceModuleObserver alloc] initWithWebRTCModule:self];

ios/RCTWebRTC/WebRTCModuleOptions.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
#import <WebRTC/WebRTC.h>
33

44
@class InAppScreenCapturer;
5-
@class RTCDefaultAudioProcessingModule;
6-
75
NS_ASSUME_NONNULL_BEGIN
86

97
// Forward declare the Swift class — the actual import happens in the .m file.
@@ -16,10 +14,6 @@ NS_ASSUME_NONNULL_BEGIN
1614
@property(nonatomic, strong, nullable) id<RTCAudioDevice> audioDevice;
1715
@property(nonatomic, strong, nullable) id<RTCAudioProcessingModule> audioProcessingModule;
1816

19-
/// Retained reference to the default audio processing module.
20-
/// Used to dynamically set capturePostProcessingDelegate for screen share audio mixing.
21-
@property(nonatomic, strong, nullable) RTCDefaultAudioProcessingModule *defaultAudioProcessingModule;
22-
2317
@property(nonatomic, strong, nullable) NSDictionary *fieldTrials;
2418
@property(nonatomic, assign) RTCLoggingSeverity loggingSeverity;
2519
@property(nonatomic, assign) BOOL enableMultitaskingCameraAccess;
@@ -31,8 +25,8 @@ NS_ASSUME_NONNULL_BEGIN
3125
/// When YES, in-app screen capture will route .audioApp buffers to the audio mixer.
3226
@property(nonatomic, assign) BOOL includeScreenShareAudio;
3327

34-
/// The active screen share audio mixer instance. Created by
35-
/// `startScreenShareAudioMixing` and cleared by `stopScreenShareAudioMixing`.
28+
/// The screen share audio mixer instance. Created eagerly during WebRTCModule
29+
/// init and retained for the lifetime of the module (never cleared).
3630
@property(nonatomic, strong, nullable) ScreenShareAudioMixer *screenShareAudioMixer;
3731

3832
/// Weak reference to the current in-app screen capturer, set during

ios/RCTWebRTC/WebRTCModuleOptions.m

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
#import "WebRTCModuleOptions.h"
22

3-
// Import Swift-generated header for ScreenShareAudioMixer
4-
#if __has_include(<stream_react_native_webrtc/stream_react_native_webrtc-Swift.h>)
5-
#import <stream_react_native_webrtc/stream_react_native_webrtc-Swift.h>
6-
#elif __has_include("stream_react_native_webrtc-Swift.h")
7-
#import "stream_react_native_webrtc-Swift.h"
8-
#endif
9-
103
@implementation WebRTCModuleOptions
114

125
#pragma mark - This class is a singleton

0 commit comments

Comments
 (0)