Skip to content

Commit

Permalink
Update patches m125.4
Browse files Browse the repository at this point in the history
  • Loading branch information
skydoves committed Dec 17, 2024
1 parent 78cb2e0 commit 37b8867
Show file tree
Hide file tree
Showing 7 changed files with 176 additions and 16 deletions.
20 changes: 18 additions & 2 deletions stream-webrtc-android/api/stream-webrtc-android.api
Original file line number Diff line number Diff line change
Expand Up @@ -437,9 +437,19 @@ public final class org/webrtc/EncodedImage$FrameType : java/lang/Enum {
}

public class org/webrtc/ExternalAudioProcessingFactory : org/webrtc/AudioProcessingFactory {
public fun <init> (Ljava/lang/String;)V
public fun <init> ()V
public fun createNative ()J
public fun destroyNative ()V
public fun destroy ()V
public fun setBypassFlagForCapturePost (Z)V
public fun setBypassFlagForRenderPre (Z)V
public fun setCapturePostProcessing (Lorg/webrtc/ExternalAudioProcessingFactory$AudioProcessing;)V
public fun setRenderPreProcessing (Lorg/webrtc/ExternalAudioProcessingFactory$AudioProcessing;)V
}

public abstract interface class org/webrtc/ExternalAudioProcessingFactory$AudioProcessing {
public abstract fun initialize (II)V
public abstract fun process (IILjava/nio/ByteBuffer;)V
public abstract fun reset (I)V
}

public abstract interface class org/webrtc/FecControllerFactoryFactoryInterface {
Expand Down Expand Up @@ -812,6 +822,12 @@ public class org/webrtc/NV21Buffer : org/webrtc/VideoFrame$Buffer {
public fun toI420 ()Lorg/webrtc/VideoFrame$I420Buffer;
}

public class org/webrtc/NativeExternalAudioProcessingFactory : org/webrtc/AudioProcessingFactory {
public fun <init> (Ljava/lang/String;)V
public fun createNative ()J
public fun destroyNative ()V
}

public abstract interface class org/webrtc/NativeLibraryLoader {
public abstract fun load (Ljava/lang/String;)Z
}
Expand Down
Binary file not shown.
Binary file not shown.
Binary file modified stream-webrtc-android/libs/x86/libjingle_peerconnection_so.so
Binary file not shown.
Binary file modified stream-webrtc-android/libs/x86_64/libjingle_peerconnection_so.so
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,31 +1,144 @@
/*
* Copyright 2022 LiveKit
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.webrtc;

import java.nio.ByteBuffer;

import androidx.annotation.Nullable;
import org.webrtc.AudioProcessingFactory;


public class ExternalAudioProcessingFactory implements AudioProcessingFactory {

private final String libname;
/**
* Interface for external audio processing.
*/
public static interface AudioProcessing {
/**
* Called when the processor should be initialized with a new sample rate and
* number of channels.
*/
@CalledByNative("AudioProcessing")
void initialize(int sampleRateHz, int numChannels);
/** Called when the processor should be reset with a new sample rate. */
@CalledByNative("AudioProcessing")
void reset(int newRate);
/**
* Processes the given capture or render signal. NOTE: `buffer.data` will be
* freed once this function returns so callers who want to use the data
* asynchronously must make sure to copy it first.
*/
@CalledByNative("AudioProcessing")
void process(int numBands, int numFrames, ByteBuffer buffer);
}

public ExternalAudioProcessingFactory(String libname) {
if (libname == null) {
throw new NullPointerException("libname must not be null.");
}
if (libname.isEmpty()) {
throw new IllegalArgumentException("libname must not be empty.");
}
this.libname = libname;
private long apmPtr;
private long capturePostProcessingPtr;
private long renderPreProcessingPtr;

public ExternalAudioProcessingFactory() {
apmPtr = nativeGetDefaultApm();
capturePostProcessingPtr = 0;
renderPreProcessingPtr = 0;
}

@Override
public long createNative() {
return nativeCreateAudioProcessingModule(libname);
if(apmPtr == 0) {
apmPtr = nativeGetDefaultApm();
}
return apmPtr;
}

public void destroyNative() {
nativeDestroyAudioProcessingModule();
/**
* Sets the capture post processing module.
* This module is applied to the audio signal after capture and before sending
* to the audio encoder.
*/
public void setCapturePostProcessing(@Nullable AudioProcessing processing) {
checkExternalAudioProcessorExists();
long newPtr = nativeSetCapturePostProcessing(processing);
if (capturePostProcessingPtr != 0) {
JniCommon.nativeReleaseRef(capturePostProcessingPtr);
capturePostProcessingPtr = 0;
}
capturePostProcessingPtr = newPtr;
}

private static native long nativeCreateAudioProcessingModule(String libname);
/**
* Sets the render pre processing module.
* This module is applied to the audio signal after receiving from the audio
* decoder and before rendering.
*/
public void setRenderPreProcessing(@Nullable AudioProcessing processing) {
checkExternalAudioProcessorExists();
long newPtr = nativeSetRenderPreProcessing(processing);
if (renderPreProcessingPtr != 0) {
JniCommon.nativeReleaseRef(renderPreProcessingPtr);
renderPreProcessingPtr = 0;
}
renderPreProcessingPtr = newPtr;
}

/**
* Sets the bypass flag for the capture post processing module.
* If true, the registered audio processing will be bypassed.
*/
public void setBypassFlagForCapturePost( boolean bypass) {
checkExternalAudioProcessorExists();
nativeSetBypassFlagForCapturePost(bypass);
}

/**
* Sets the bypass flag for the render pre processing module.
* If true, the registered audio processing will be bypassed.
*/
public void setBypassFlagForRenderPre( boolean bypass) {
checkExternalAudioProcessorExists();
nativeSetBypassFlagForRenderPre(bypass);
}

/**
* Destroys the ExternalAudioProcessor.
*/
public void destroy() {
checkExternalAudioProcessorExists();
if (renderPreProcessingPtr != 0) {
JniCommon.nativeReleaseRef(renderPreProcessingPtr);
renderPreProcessingPtr = 0;
}
if (capturePostProcessingPtr != 0) {
JniCommon.nativeReleaseRef(capturePostProcessingPtr);
capturePostProcessingPtr = 0;
}
nativeDestroy();
apmPtr = 0;
}

private static native void nativeDestroyAudioProcessingModule();
private void checkExternalAudioProcessorExists() {
if (apmPtr == 0) {
throw new IllegalStateException("ExternalAudioProcessor has been disposed.");
}
}

private static native long nativeGetDefaultApm();
private static native long nativeSetCapturePostProcessing(AudioProcessing processing);
private static native long nativeSetRenderPreProcessing(AudioProcessing processing);
private static native void nativeSetBypassFlagForCapturePost(boolean bypass);
private static native void nativeSetBypassFlagForRenderPre(boolean bypass);
private static native void nativeDestroy();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.webrtc;

public class NativeExternalAudioProcessingFactory implements AudioProcessingFactory {

private final String libname;

public NativeExternalAudioProcessingFactory(String libname) {
if (libname == null) {
throw new NullPointerException("libname must not be null.");
}
if (libname.isEmpty()) {
throw new IllegalArgumentException("libname must not be empty.");
}
this.libname = libname;
}

@Override
public long createNative() {
return nativeCreateAudioProcessingModule(libname);
}

public void destroyNative() {
nativeDestroyAudioProcessingModule();
}

private static native long nativeCreateAudioProcessingModule(String libname);


private static native void nativeDestroyAudioProcessingModule();

}

0 comments on commit 37b8867

Please sign in to comment.