Skip to content

Commit

Permalink
[APPS-533] Setup AudioSamplesInterceptor correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
katelyn-gallagher authored and Gandri committed Apr 29, 2024
1 parent ba5e404 commit 944ebe7
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -1351,9 +1357,6 @@ public void mediaRecorderCreate(String recorderId, String streamId) {
// Get track info
HashMap<String, Integer> 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);
Expand Down

0 comments on commit 944ebe7

Please sign in to comment.