forked from livekit/react-native-webrtc
-
Notifications
You must be signed in to change notification settings - Fork 2
feat: add noise cancellation apis #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
690fdf7
siwth to stream fork and add audio files
santhoshvai 10aa49e
125.2.0-alpha.1
santhoshvai 2f356c2
add to options
santhoshvai 6d075ad
Merge branch 'master' into noise-cancellation
santhoshvai a8145c4
125.3.0-alpha.1
santhoshvai a4a8dca
ios: Add audioProcessingModule to WebRTCModuleOptions (#13)
davidliu 6c5be0e
125.3.0-alpha.2
santhoshvai 68173a6
wrong package name fix
santhoshvai 501c9c3
125.3.0-alpha.3
santhoshvai 79a1aa4
fix missing package word
santhoshvai 98be4a6
125.3.0-alpha.4
santhoshvai bece224
update peer dep of rn
santhoshvai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
android/src/main/java/com/oney/WebRTCModule/audio/AudioProcessingAdapter.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package com.oney.WebRTCModule.audio; | ||
|
||
import org.webrtc.ExternalAudioProcessingFactory; | ||
|
||
import java.nio.ByteBuffer; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class AudioProcessingAdapter implements ExternalAudioProcessingFactory.AudioProcessing { | ||
public interface ExternalAudioFrameProcessing { | ||
void initialize(int sampleRateHz, int numChannels); | ||
|
||
void reset(int newRate); | ||
|
||
void process(int numBands, int numFrames, ByteBuffer buffer); | ||
} | ||
|
||
public AudioProcessingAdapter() {} | ||
List<ExternalAudioFrameProcessing> audioProcessors = new ArrayList<>(); | ||
|
||
public void addProcessor(ExternalAudioFrameProcessing audioProcessor) { | ||
synchronized (audioProcessors) { | ||
audioProcessors.add(audioProcessor); | ||
} | ||
} | ||
|
||
public void removeProcessor(ExternalAudioFrameProcessing audioProcessor) { | ||
synchronized (audioProcessors) { | ||
audioProcessors.remove(audioProcessor); | ||
} | ||
} | ||
|
||
@Override | ||
public void initialize(int sampleRateHz, int numChannels) { | ||
synchronized (audioProcessors) { | ||
for (ExternalAudioFrameProcessing audioProcessor : audioProcessors) { | ||
audioProcessor.initialize(sampleRateHz, numChannels); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void reset(int newRate) { | ||
synchronized (audioProcessors) { | ||
for (ExternalAudioFrameProcessing audioProcessor : audioProcessors) { | ||
audioProcessor.reset(newRate); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void process(int numBands, int numFrames, ByteBuffer buffer) { | ||
synchronized (audioProcessors) { | ||
for (ExternalAudioFrameProcessing audioProcessor : audioProcessors) { | ||
audioProcessor.process(numBands, numFrames, buffer); | ||
} | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
android/src/main/java/com/oney/WebRTCModule/audio/AudioProcessingController.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.oney.WebRTCModule.audio; | ||
|
||
import org.webrtc.AudioProcessingFactory; | ||
import org.webrtc.ExternalAudioProcessingFactory; | ||
|
||
public class AudioProcessingController implements AudioProcessingFactoryProvider { | ||
/** | ||
* This is the audio processing module that will be applied to the audio stream after it is captured from the microphone. | ||
* This is useful for adding echo cancellation, noise suppression, etc. | ||
*/ | ||
public final AudioProcessingAdapter capturePostProcessing = new AudioProcessingAdapter(); | ||
/** | ||
* This is the audio processing module that will be applied to the audio stream before it is rendered to the speaker. | ||
*/ | ||
public final AudioProcessingAdapter renderPreProcessing = new AudioProcessingAdapter(); | ||
|
||
public ExternalAudioProcessingFactory externalAudioProcessingFactory; | ||
|
||
public AudioProcessingController() { | ||
this.externalAudioProcessingFactory = new ExternalAudioProcessingFactory(); | ||
this.externalAudioProcessingFactory.setCapturePostProcessing(capturePostProcessing); | ||
this.externalAudioProcessingFactory.setRenderPreProcessing(renderPreProcessing); | ||
} | ||
|
||
@Override | ||
public AudioProcessingFactory getFactory() { | ||
return this.externalAudioProcessingFactory; | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
android/src/main/java/com/oney/WebRTCModule/audio/AudioProcessingFactoryProvider.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.oney.WebRTCModule.audio; | ||
|
||
import org.webrtc.AudioProcessingFactory; | ||
|
||
// Define the common interface | ||
public interface AudioProcessingFactoryProvider { | ||
AudioProcessingFactory getFactory(); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.