diff --git a/android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java b/android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java index f4affcd41..797eff955 100644 --- a/android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java +++ b/android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java @@ -42,6 +42,7 @@ public class WebRTCModule extends ReactContextBaseJavaModule { static final String TAG = WebRTCModule.class.getCanonicalName(); private AudioDeviceModule audioDeviceModule; + private final AudioSamplesInterceptor audioSamplesInterceptor; PeerConnectionFactory mFactory; VideoEncoderFactory mVideoEncoderFactory; @@ -64,6 +65,7 @@ public WebRTCModule(ReactApplicationContext reactContext) { WebRTCModuleOptions options = WebRTCModuleOptions.getInstance(); audioDeviceModule = options.audioDeviceModule; + audioSamplesInterceptor = new AudioSamplesInterceptor(); VideoEncoderFactory encoderFactory = options.videoEncoderFactory; VideoDecoderFactory decoderFactory = options.videoDecoderFactory; Loggable injectableLogger = options.injectableLogger; @@ -94,7 +96,11 @@ public WebRTCModule(ReactApplicationContext reactContext) { } if (audioDeviceModule == null) { - audioDeviceModule = JavaAudioDeviceModule.builder(reactContext).setEnableVolumeLogger(false).createAudioDeviceModule(); + audioDeviceModule = JavaAudioDeviceModule + .builder(reactContext) + .setEnableVolumeLogger(false) + .setSamplesReadyCallback(audioSamplesInterceptor) + .createAudioDeviceModule(); } Log.d(TAG, "Using video encoder factory: " + encoderFactory.getClass().getCanonicalName()); @@ -1351,9 +1357,6 @@ public void mediaRecorderCreate(String recorderId, String streamId) { // Get track info HashMap videoTrackInfo = getUserMediaImpl.getVideoTrackInfo(videoTrack); - // Create new audio interceptor - AudioSamplesInterceptor audioSamplesInterceptor = new AudioSamplesInterceptor(); - // Create new media recorder MediaRecorderImpl recorder = new MediaRecorderImpl(recorderId, videoTrack, videoTrackInfo, audioSamplesInterceptor); mediaRecorders.put(recorderId, recorder);