diff --git a/README.md b/README.md
index 268727bf..2503a0dd 100644
--- a/README.md
+++ b/README.md
@@ -5,40 +5,52 @@
Java native interface implementation based on the free, open [WebRTC](https://webrtc.org) project. The goal of this project is to enable development of RTC applications for desktop platforms running Java. This project wraps the [WebRTC Native API](https://webrtc.github.io/webrtc-org/native-code/native-apis) and is similar to the [JS API](https://w3c.github.io/webrtc-pc).
+### Repository
+
+```xml
+
+ singlerrrepo
+ https://github.com/singlerr/mvn-repo/raw/maven2/
+
+```
+
### Maven
```xml
dev.onvoid.webrtc
webrtc-java
- 0.9.0
+ 0.11.0-SNAPSHOT
```
### Gradle
```groovy
-implementation "dev.onvoid.webrtc:webrtc-java:0.9.0"
-implementation group: "dev.onvoid.webrtc", name: "webrtc-java", version: "0.9.0", classifier: "windows-x86_64"
-implementation group: "dev.onvoid.webrtc", name: "webrtc-java", version: "0.9.0", classifier: "macos-x86_64"
-implementation group: "dev.onvoid.webrtc", name: "webrtc-java", version: "0.9.0", classifier: "macos-aarch64"
-implementation group: "dev.onvoid.webrtc", name: "webrtc-java", version: "0.9.0", classifier: "linux-x86_64"
-implementation group: "dev.onvoid.webrtc", name: "webrtc-java", version: "0.9.0", classifier: "linux-aarch64"
-implementation group: "dev.onvoid.webrtc", name: "webrtc-java", version: "0.9.0", classifier: "linux-aarch32"
+implementation "dev.onvoid.webrtc:webrtc-java:0.11.0-SNAPSHOT"
+implementation group: "dev.onvoid.webrtc", name: "webrtc-java", version: "0.11.0-SNAPSHOT", classifier: "windows-x86_64"
```
### Supported Platforms
Maven Central artifacts contain native libraries that can be loaded on the following platforms:
-
- Linux |
- x86_64, arm64, arm32 |
-
-
- macOS |
- x86_64, arm64 |
-
+
+[//]: # ( )
+
+[//]: # ( Linux | )
+
+[//]: # ( x86_64, arm64, arm32 | )
+
+[//]: # (
)
+
+[//]: # ( )
+
+[//]: # ( macOS | )
+
+[//]: # ( x86_64, arm64 | )
+
+[//]: # (
)
Windows |
x86_64 |
diff --git a/pom.xml b/pom.xml
index 2819e8f8..03ef0e9f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
dev.onvoid.webrtc
webrtc-java-parent
- 0.10.0-SNAPSHOT
+ 0.11.0-SNAPSHOT
pom
webrtc-java-parent
diff --git a/webrtc-jni/pom.xml b/webrtc-jni/pom.xml
index 4edf8910..75f34dc8 100644
--- a/webrtc-jni/pom.xml
+++ b/webrtc-jni/pom.xml
@@ -5,7 +5,7 @@
dev.onvoid.webrtc
webrtc-java-parent
- 0.10.0-SNAPSHOT
+ 0.11.0-SNAPSHOT
webrtc-java-jni
@@ -13,10 +13,11 @@
branch-heads/4844
- ${user.home}/webrtc
- ${user.home}/webrtc/build
+ ${project.build.directory}/webrtcbuild/webrtc
+ ${project.build.directory}/webrtcbuild/build
Release
-
+ x64-windows-static
+ C:/vcpkg/scripts/buildsystems/vcpkg.cmake
@@ -113,6 +114,9 @@
+
diff --git a/webrtc-jni/src/main/cpp/CMakeLists.txt b/webrtc-jni/src/main/cpp/CMakeLists.txt
index 6529fa13..5a4e3c60 100644
--- a/webrtc-jni/src/main/cpp/CMakeLists.txt
+++ b/webrtc-jni/src/main/cpp/CMakeLists.txt
@@ -27,6 +27,7 @@ endif()
add_subdirectory(dependencies/webrtc)
add_subdirectory(dependencies/jni-voithos)
+add_subdirectory(dependencies/ffmpeg)
file(GLOB SOURCES_ROOT "src/*.cpp")
file(GLOB SOURCES_API "src/api/*.cpp")
@@ -72,6 +73,7 @@ set_target_properties(${PROJECT_NAME} PROPERTIES
target_link_libraries(${PROJECT_NAME} jni-voithos)
target_link_libraries(${PROJECT_NAME} webrtc)
+target_link_libraries(${PROJECT_NAME} ffmpeg)
if(APPLE)
set_source_files_properties(${SOURCES} PROPERTIES COMPILE_FLAGS "-x objective-c++")
diff --git a/webrtc-jni/src/main/cpp/dependencies/ffmpeg/CMakeLists.txt b/webrtc-jni/src/main/cpp/dependencies/ffmpeg/CMakeLists.txt
new file mode 100644
index 00000000..4730da19
--- /dev/null
+++ b/webrtc-jni/src/main/cpp/dependencies/ffmpeg/CMakeLists.txt
@@ -0,0 +1,23 @@
+cmake_minimum_required(VERSION 3.13)
+project(ffmpeg)
+
+FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/pseudo.hxx
+"template class pseudo{}\n")
+FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/pseudo.cxx
+"static void pseudo(void){}\n")
+
+
+add_library(${PROJECT_NAME} STATIC pseudo.cxx pseudo.hxx)
+
+set_target_properties(${PROJECT_NAME} PROPERTIES
+ CXX_STANDARD 17
+ CXX_STANDARD_REQUIRED ON
+ CXX_EXTENSIONS OFF
+)
+target_compile_definitions(${PROJECT_NAME} PUBLIC FFMPEG_STATIC_DEFINE)
+
+find_package(FFMPEG REQUIRED)
+
+target_include_directories(${PROJECT_NAME} PUBLIC ${FFMPEG_INCLUDE_DIRS})
+target_link_directories(${PROJECT_NAME} PUBLIC ${FFMPEG_LIBRARY_DIRS})
+target_link_libraries(${PROJECT_NAME} PRIVATE ${FFMPEG_LIBRARIES})
diff --git a/webrtc-jni/src/main/cpp/dependencies/webrtc/CMakeLists.txt b/webrtc-jni/src/main/cpp/dependencies/webrtc/CMakeLists.txt
index d7353f09..15a72d09 100644
--- a/webrtc-jni/src/main/cpp/dependencies/webrtc/CMakeLists.txt
+++ b/webrtc-jni/src/main/cpp/dependencies/webrtc/CMakeLists.txt
@@ -121,14 +121,18 @@ set(WEBRTC_SRC ${WEBRTC_DIR}/src)
set(WEBRTC_BUILD out/${TARGET_CPU})
set(WEBRTC_LIB_PATH ${WEBRTC_SRC}/${WEBRTC_BUILD}/obj/${WEBRTC_LIB})
set(WEBRTC_LIB_PATH_INSTALLED ${WEBRTC_INSTALL_DIR}/lib/${WEBRTC_LIB})
+set(FFMPEG_LIB_PATH ${WEBRTC_SRC}/${WEBRTC_BUILD}/obj/third_party/ffmpeg/ffmpeg_internal.lib)
+set(FFMPEG_LIB_PATH_INSTALLED ${WEBRTC_INSTALL_DIR}/lib/ffmpeg_internal.lib)
+
file(TO_CMAKE_PATH "${WEBRTC_DIR}" WEBRTC_DIR)
file(TO_CMAKE_PATH "${WEBRTC_INSTALL_DIR}" WEBRTC_INSTALL_DIR)
file(TO_CMAKE_PATH "${WEBRTC_LIB_PATH}" WEBRTC_LIB_PATH)
+
file(TO_CMAKE_PATH "${WEBRTC_LIB_PATH_INSTALLED}" WEBRTC_LIB_PATH_INSTALLED)
message(STATUS "WebRTC checkout path: ${WEBRTC_DIR}")
-message(STATUS "WebRTC checkout branch: ${WEBRTC_BRANCH}")
+message(STATUS "WebRTC heckout branch: ${WEBRTC_BRANCH}")
message(STATUS "WebRTC target: ${SOURCE_TARGET} ${TARGET_CPU}")
message(STATUS "WebRTC build type: ${CMAKE_BUILD_TYPE}")
message(STATUS "WebRTC install path: ${WEBRTC_INSTALL_DIR}")
@@ -166,7 +170,7 @@ elseif(WIN32)
endif()
if(EXISTS "${WEBRTC_LIB_PATH}" OR EXISTS "${WEBRTC_LIB_PATH_INSTALLED}")
- message(STATUS "WebRTC: Compiled version found '${TARGET_LINK_LIB}'")
+ message(STATUS "WebRTC: Compiled version found '${WEBRTC_LIB_PATH_INSTALLED}'")
if(LINUX)
sysroot_install()
@@ -237,12 +241,14 @@ if (PATCHES)
endif()
message(STATUS "WebRTC: generate")
-set(COMPILE_ARGS "is_debug=false target_cpu=\"${TARGET_CPU}\" treat_warnings_as_errors=false rtc_build_examples=false rtc_include_tests=false use_rtti=true use_custom_libcxx=false symbol_level=0 rtc_use_h264=true")
+set(COMPILE_ARGS "is_debug=false target_cpu=\"${TARGET_CPU}\" treat_warnings_as_errors=false rtc_build_examples=false rtc_include_tests=false use_rtti=true use_custom_libcxx=false symbol_level=0 rtc_use_h264=false")
execute_command(
COMMAND gn gen ${WEBRTC_BUILD} --args=${COMPILE_ARGS}
WORKING_DIRECTORY "${WEBRTC_SRC}"
)
+message(STATUS "gn gen ${WEBRTC_BUILD} --args=${COMPILE_ARGS}")
+
message(STATUS "WebRTC: compile")
execute_command(
COMMAND ninja -C "${WEBRTC_BUILD}"
diff --git a/webrtc-jni/src/main/cpp/include/JNI_AudioDecoderFactory.h b/webrtc-jni/src/main/cpp/include/JNI_AudioDecoderFactory.h
new file mode 100644
index 00000000..0c6de4e0
--- /dev/null
+++ b/webrtc-jni/src/main/cpp/include/JNI_AudioDecoderFactory.h
@@ -0,0 +1,30 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include
+/* Header for class dev_onvoid_webrtc_media_audio_AudioDecoderFactory */
+
+#ifndef _Included_dev_onvoid_webrtc_media_audio_AudioDecoderFactory
+#define _Included_dev_onvoid_webrtc_media_audio_AudioDecoderFactory
+#ifdef __cplusplus
+extern "C" {
+#endif
+/*
+ * Class: dev_onvoid_webrtc_media_audio_AudioDecoderFactory
+ * Method: getSupportedDecoders
+ * Signature: ()Ljava/util/List;
+ */
+JNIEXPORT jobject JNICALL Java_dev_onvoid_webrtc_media_audio_AudioDecoderFactory_getSupportedDecoders
+ (JNIEnv *, jobject);
+
+/*
+ * Class: dev_onvoid_webrtc_media_audio_AudioDecoderFactory
+ * Method: isSupportedDecoder
+ * Signature: (Ldev/onvoid/webrtc/media/audio/SdpAudioFormat;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_dev_onvoid_webrtc_media_audio_AudioDecoderFactory_isSupportedDecoder
+ (JNIEnv *, jobject, jobject);
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/webrtc-jni/src/main/cpp/include/JNI_AudioDeviceModule.h b/webrtc-jni/src/main/cpp/include/JNI_AudioDeviceModule.h
index 7b3a3280..6a32bf45 100644
--- a/webrtc-jni/src/main/cpp/include/JNI_AudioDeviceModule.h
+++ b/webrtc-jni/src/main/cpp/include/JNI_AudioDeviceModule.h
@@ -7,6 +7,23 @@
#ifdef __cplusplus
extern "C" {
#endif
+
+ /*
+ * Class: dev_onvoid_webrtc_media_audio_AudioDeviceModule
+ * Method: setStereoPlayout
+ * Signature: (Z)V
+ */
+ JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_media_audio_AudioDeviceModule_setStereoPlayout
+ (JNIEnv *, jobject, jboolean);
+
+ /*
+ * Class: dev_onvoid_webrtc_media_audio_AudioDeviceModule
+ * Method: setStereoRecording
+ * Signature: (Z)V
+ */
+ JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_media_audio_AudioDeviceModule_setStereoRecording
+ (JNIEnv *, jobject, jboolean);
+
/*
* Class: dev_onvoid_webrtc_media_audio_AudioDeviceModule
* Method: initPlayout
diff --git a/webrtc-jni/src/main/cpp/include/JNI_AudioEncoderFactory.h b/webrtc-jni/src/main/cpp/include/JNI_AudioEncoderFactory.h
new file mode 100644
index 00000000..3674fbf1
--- /dev/null
+++ b/webrtc-jni/src/main/cpp/include/JNI_AudioEncoderFactory.h
@@ -0,0 +1,30 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include
+/* Header for class dev_onvoid_webrtc_media_audio_AudioEncoderFactory */
+
+#ifndef _Included_dev_onvoid_webrtc_media_audio_AudioEncoderFactory
+#define _Included_dev_onvoid_webrtc_media_audio_AudioEncoderFactory
+#ifdef __cplusplus
+extern "C" {
+#endif
+/*
+ * Class: dev_onvoid_webrtc_media_audio_AudioEncoderFactory
+ * Method: getSupportedEncoders
+ * Signature: ()Ljava/util/List;
+ */
+JNIEXPORT jobject JNICALL Java_dev_onvoid_webrtc_media_audio_AudioEncoderFactory_getSupportedEncoders
+ (JNIEnv *, jobject);
+
+/*
+ * Class: dev_onvoid_webrtc_media_audio_AudioEncoderFactory
+ * Method: queryAudioEncoder
+ * Signature: (Ldev/onvoid/webrtc/media/audio/SdpAudioFormat;)Ldev/onvoid/webrtc/media/audio/AudioCodecInfo;
+ */
+JNIEXPORT jobject JNICALL Java_dev_onvoid_webrtc_media_audio_AudioEncoderFactory_queryAudioEncoder
+ (JNIEnv *, jobject, jobject);
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/webrtc-jni/src/main/cpp/include/JNI_AudioProcessing.h b/webrtc-jni/src/main/cpp/include/JNI_AudioProcessing.h
index 8e8644ed..d377a35b 100644
--- a/webrtc-jni/src/main/cpp/include/JNI_AudioProcessing.h
+++ b/webrtc-jni/src/main/cpp/include/JNI_AudioProcessing.h
@@ -63,6 +63,22 @@ extern "C" {
JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_media_audio_AudioProcessing_initialize
(JNIEnv*, jobject);
+ /*
+ * Class: dev_onvoid_webrtc_media_audio_AudioProcessing
+ * Method: initialize
+ * Signature: (IIILdev/onvoid/webrtc/media/audio/ChannelLayout;Ldev/onvoid/webrtc/media/audio/ChannelLayout;Ldev/onvoid/webrtc/media/audio/ChannelLayout;)V
+ */
+ JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_media_audio_AudioProcessing_initialize__IIILdev_onvoid_webrtc_media_audio_ChannelLayout_2Ldev_onvoid_webrtc_media_audio_ChannelLayout_2Ldev_onvoid_webrtc_media_audio_ChannelLayout_2
+ (JNIEnv *, jobject, jint, jint, jint, jobject, jobject, jobject);
+
+ /*
+ * Class: dev_onvoid_webrtc_media_audio_AudioProcessing
+ * Method: initialize
+ * Signature: (Ldev/onvoid/webrtc/media/audio/ProcessingConfig;)V
+ */
+ JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_media_audio_AudioProcessing_initialize__Ldev_onvoid_webrtc_media_audio_ProcessingConfig_2
+ (JNIEnv *, jobject, jobject);
+
/*
* Class: dev_onvoid_webrtc_media_audio_AudioProcessing
* Method: updateStats
diff --git a/webrtc-jni/src/main/cpp/include/JNI_AudioTrack.h b/webrtc-jni/src/main/cpp/include/JNI_AudioTrack.h
index 8261a1fe..83b64dd3 100644
--- a/webrtc-jni/src/main/cpp/include/JNI_AudioTrack.h
+++ b/webrtc-jni/src/main/cpp/include/JNI_AudioTrack.h
@@ -7,29 +7,37 @@
#ifdef __cplusplus
extern "C" {
#endif
- /*
- * Class: dev_onvoid_webrtc_media_audio_AudioTrack
- * Method: getSignalLevel
- * Signature: ()I
- */
- JNIEXPORT jint JNICALL Java_dev_onvoid_webrtc_media_audio_AudioTrack_getSignalLevel
- (JNIEnv *, jobject);
+/*
+ * Class: dev_onvoid_webrtc_media_audio_AudioTrack
+ * Method: getSignalLevel
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_dev_onvoid_webrtc_media_audio_AudioTrack_getSignalLevel
+ (JNIEnv *, jobject);
- /*
- * Class: dev_onvoid_webrtc_media_audio_AudioTrack
- * Method: addSinkInternal
- * Signature: (Ldev/onvoid/webrtc/media/audio/AudioTrackSink;)J
- */
- JNIEXPORT jlong JNICALL Java_dev_onvoid_webrtc_media_audio_AudioTrack_addSinkInternal
- (JNIEnv *, jobject, jobject);
+/*
+ * Class: dev_onvoid_webrtc_media_audio_AudioTrack
+ * Method: addSinkInternal
+ * Signature: (Ldev/onvoid/webrtc/media/audio/AudioTrackSink;)J
+ */
+JNIEXPORT jlong JNICALL Java_dev_onvoid_webrtc_media_audio_AudioTrack_addSinkInternal
+ (JNIEnv *, jobject, jobject);
- /*
- * Class: dev_onvoid_webrtc_media_audio_AudioTrack
- * Method: removeSinkInternal
- * Signature: (J)V
- */
- JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_media_audio_AudioTrack_removeSinkInternal
- (JNIEnv *, jobject, jlong);
+/*
+ * Class: dev_onvoid_webrtc_media_audio_AudioTrack
+ * Method: removeSinkInternal
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_media_audio_AudioTrack_removeSinkInternal
+ (JNIEnv *, jobject, jlong);
+
+/*
+ * Class: dev_onvoid_webrtc_media_audio_AudioTrack
+ * Method: getSource
+ * Signature: ()Ldev/onvoid/webrtc/media/audio/AudioTrackSource;
+ */
+JNIEXPORT jobject JNICALL Java_dev_onvoid_webrtc_media_audio_AudioTrack_getSource
+ (JNIEnv *, jobject);
#ifdef __cplusplus
}
diff --git a/webrtc-jni/src/main/cpp/include/JNI_AudioTrackSource.h b/webrtc-jni/src/main/cpp/include/JNI_AudioTrackSource.h
new file mode 100644
index 00000000..94bb4abb
--- /dev/null
+++ b/webrtc-jni/src/main/cpp/include/JNI_AudioTrackSource.h
@@ -0,0 +1,37 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include
+/* Header for class dev_onvoid_webrtc_media_audio_AudioTrackSource */
+
+#ifndef _Included_dev_onvoid_webrtc_media_audio_AudioTrackSource
+#define _Included_dev_onvoid_webrtc_media_audio_AudioTrackSource
+#ifdef __cplusplus
+extern "C" {
+#endif
+/*
+ * Class: dev_onvoid_webrtc_media_audio_AudioTrackSource
+ * Method: addSinkInternal
+ * Signature: (Ldev/onvoid/webrtc/media/audio/AudioTrackSink;)J
+ */
+JNIEXPORT jlong JNICALL Java_dev_onvoid_webrtc_media_audio_AudioTrackSource_addSinkInternal
+ (JNIEnv *, jobject, jobject);
+
+/*
+ * Class: dev_onvoid_webrtc_media_audio_AudioTrackSource
+ * Method: removeSinkInternal
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_media_audio_AudioTrackSource_removeSinkInternal
+ (JNIEnv *, jobject, jlong);
+
+/*
+ * Class: dev_onvoid_webrtc_media_audio_AudioTrackSource
+ * Method: setVolume
+ * Signature: (D)V
+ */
+JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_media_audio_AudioTrackSource_setVolume
+ (JNIEnv *, jobject, jdouble);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/webrtc-jni/src/main/cpp/include/JNI_ProcessingConfig.h b/webrtc-jni/src/main/cpp/include/JNI_ProcessingConfig.h
new file mode 100644
index 00000000..bf9ea503
--- /dev/null
+++ b/webrtc-jni/src/main/cpp/include/JNI_ProcessingConfig.h
@@ -0,0 +1,29 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include
+/* Header for class dev_onvoid_webrtc_media_audio_ProcessingConfig */
+
+#ifndef _Included_dev_onvoid_webrtc_media_audio_ProcessingConfig
+#define _Included_dev_onvoid_webrtc_media_audio_ProcessingConfig
+#ifdef __cplusplus
+extern "C" {
+#endif
+/*
+ * Class: dev_onvoid_webrtc_media_audio_ProcessingConfig
+ * Method: setProcessingConfig
+ * Signature: (Ldev/onvoid/webrtc/media/audio/StreamName;Ldev/onvoid/webrtc/media/audio/AudioProcessingStreamConfig;)V
+ */
+JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_media_audio_ProcessingConfig_setProcessingConfig
+ (JNIEnv *, jobject, jobject, jobject);
+
+/*
+ * Class: dev_onvoid_webrtc_media_audio_ProcessingConfig
+ * Method: getProcessingConfig
+ * Signature: (Ldev/onvoid/webrtc/media/audio/StreamName;)Ldev/onvoid/webrtc/media/audio/AudioProcessingStreamConfig;
+ */
+JNIEXPORT jobject JNICALL Java_dev_onvoid_webrtc_media_audio_ProcessingConfig_getProcessingConfig
+ (JNIEnv *, jobject, jobject);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/webrtc-jni/src/main/cpp/include/JNI_RTCPeerConnection.h b/webrtc-jni/src/main/cpp/include/JNI_RTCPeerConnection.h
index 5ad409dc..64a80b88 100644
--- a/webrtc-jni/src/main/cpp/include/JNI_RTCPeerConnection.h
+++ b/webrtc-jni/src/main/cpp/include/JNI_RTCPeerConnection.h
@@ -7,245 +7,253 @@
#ifdef __cplusplus
extern "C" {
#endif
- /*
- * Class: dev_onvoid_webrtc_RTCPeerConnection
- * Method: getSenders
- * Signature: ()[Ldev/onvoid/webrtc/RTCRtpSender;
- */
- JNIEXPORT jobjectArray JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_getSenders
- (JNIEnv *, jobject);
-
- /*
- * Class: dev_onvoid_webrtc_RTCPeerConnection
- * Method: getReceivers
- * Signature: ()[Ldev/onvoid/webrtc/RTCRtpReceiver;
- */
- JNIEXPORT jobjectArray JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_getReceivers
- (JNIEnv *, jobject);
-
- /*
- * Class: dev_onvoid_webrtc_RTCPeerConnection
- * Method: getTransceivers
- * Signature: ()[Ldev/onvoid/webrtc/RTCRtpTransceiver;
- */
- JNIEXPORT jobjectArray JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_getTransceivers
- (JNIEnv *, jobject);
-
- /*
- * Class: dev_onvoid_webrtc_RTCPeerConnection
- * Method: addTrack
- * Signature: (Ldev/onvoid/webrtc/media/MediaStreamTrack;Ljava/util/List;)Ldev/onvoid/webrtc/RTCRtpSender;
- */
- JNIEXPORT jobject JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_addTrack
- (JNIEnv *, jobject, jobject, jobject);
-
- /*
- * Class: dev_onvoid_webrtc_RTCPeerConnection
- * Method: removeTrack
- * Signature: (Ldev/onvoid/webrtc/RTCRtpSender;)V
- */
- JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_removeTrack
- (JNIEnv *, jobject, jobject);
-
- /*
- * Class: dev_onvoid_webrtc_RTCPeerConnection
- * Method: addTransceiver
- * Signature: (Ldev/onvoid/webrtc/media/MediaStreamTrack;Ldev/onvoid/webrtc/RTCRtpTransceiverInit;)Ldev/onvoid/webrtc/RTCRtpTransceiver;
- */
- JNIEXPORT jobject JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_addTransceiver
- (JNIEnv *, jobject, jobject, jobject);
-
- /*
- * Class: dev_onvoid_webrtc_RTCPeerConnection
- * Method: createDataChannel
- * Signature: (Ljava/lang/String;Ldev/onvoid/webrtc/RTCDataChannelInit;)Ldev/onvoid/webrtc/RTCDataChannel;
- */
- JNIEXPORT jobject JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_createDataChannel
- (JNIEnv *, jobject, jstring, jobject);
-
- /*
- * Class: dev_onvoid_webrtc_RTCPeerConnection
- * Method: createOffer
- * Signature: (Ldev/onvoid/webrtc/RTCOfferOptions;Ldev/onvoid/webrtc/CreateSessionDescriptionObserver;)V
- */
- JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_createOffer
- (JNIEnv *, jobject, jobject, jobject);
-
- /*
- * Class: dev_onvoid_webrtc_RTCPeerConnection
- * Method: createAnswer
- * Signature: (Ldev/onvoid/webrtc/RTCAnswerOptions;Ldev/onvoid/webrtc/CreateSessionDescriptionObserver;)V
- */
- JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_createAnswer
- (JNIEnv *, jobject, jobject, jobject);
-
- /*
- * Class: dev_onvoid_webrtc_RTCPeerConnection
- * Method: getCurrentLocalDescription
- * Signature: ()Ldev/onvoid/webrtc/RTCSessionDescription;
- */
- JNIEXPORT jobject JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_getCurrentLocalDescription
- (JNIEnv *, jobject);
-
- /*
- * Class: dev_onvoid_webrtc_RTCPeerConnection
- * Method: getLocalDescription
- * Signature: ()Ldev/onvoid/webrtc/RTCSessionDescription;
- */
- JNIEXPORT jobject JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_getLocalDescription
- (JNIEnv *, jobject);
-
- /*
- * Class: dev_onvoid_webrtc_RTCPeerConnection
- * Method: getPendingLocalDescription
- * Signature: ()Ldev/onvoid/webrtc/RTCSessionDescription;
- */
- JNIEXPORT jobject JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_getPendingLocalDescription
- (JNIEnv *, jobject);
-
- /*
- * Class: dev_onvoid_webrtc_RTCPeerConnection
- * Method: getCurrentRemoteDescription
- * Signature: ()Ldev/onvoid/webrtc/RTCSessionDescription;
- */
- JNIEXPORT jobject JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_getCurrentRemoteDescription
- (JNIEnv *, jobject);
-
- /*
- * Class: dev_onvoid_webrtc_RTCPeerConnection
- * Method: getRemoteDescription
- * Signature: ()Ldev/onvoid/webrtc/RTCSessionDescription;
- */
- JNIEXPORT jobject JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_getRemoteDescription
- (JNIEnv *, jobject);
-
- /*
- * Class: dev_onvoid_webrtc_RTCPeerConnection
- * Method: getPendingRemoteDescription
- * Signature: ()Ldev/onvoid/webrtc/RTCSessionDescription;
- */
- JNIEXPORT jobject JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_getPendingRemoteDescription
- (JNIEnv *, jobject);
-
- /*
- * Class: dev_onvoid_webrtc_RTCPeerConnection
- * Method: setLocalDescription
- * Signature: (Ldev/onvoid/webrtc/RTCSessionDescription;Ldev/onvoid/webrtc/SetSessionDescriptionObserver;)V
- */
- JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_setLocalDescription
- (JNIEnv *, jobject, jobject, jobject);
-
- /*
- * Class: dev_onvoid_webrtc_RTCPeerConnection
- * Method: setRemoteDescription
- * Signature: (Ldev/onvoid/webrtc/RTCSessionDescription;Ldev/onvoid/webrtc/SetSessionDescriptionObserver;)V
- */
- JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_setRemoteDescription
- (JNIEnv *, jobject, jobject, jobject);
-
- /*
- * Class: dev_onvoid_webrtc_RTCPeerConnection
- * Method: addIceCandidate
- * Signature: (Ldev/onvoid/webrtc/RTCIceCandidate;)V
- */
- JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_addIceCandidate
- (JNIEnv *, jobject, jobject);
-
- /*
- * Class: dev_onvoid_webrtc_RTCPeerConnection
- * Method: removeIceCandidates
- * Signature: ([Ldev/onvoid/webrtc/RTCIceCandidate;)V
- */
- JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_removeIceCandidates
- (JNIEnv *, jobject, jobject);
-
- /*
- * Class: dev_onvoid_webrtc_RTCPeerConnection
- * Method: getSignalingState
- * Signature: ()Ldev/onvoid/webrtc/RTCSignalingState;
- */
- JNIEXPORT jobject JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_getSignalingState
- (JNIEnv *, jobject);
-
- /*
- * Class: dev_onvoid_webrtc_RTCPeerConnection
- * Method: getIceGatheringState
- * Signature: ()Ldev/onvoid/webrtc/RTCIceGatheringState;
- */
- JNIEXPORT jobject JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_getIceGatheringState
- (JNIEnv *, jobject);
-
- /*
- * Class: dev_onvoid_webrtc_RTCPeerConnection
- * Method: getIceConnectionState
- * Signature: ()Ldev/onvoid/webrtc/RTCIceConnectionState;
- */
- JNIEXPORT jobject JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_getIceConnectionState
- (JNIEnv *, jobject);
-
- /*
- * Class: dev_onvoid_webrtc_RTCPeerConnection
- * Method: getConnectionState
- * Signature: ()Ldev/onvoid/webrtc/RTCPeerConnectionState;
- */
- JNIEXPORT jobject JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_getConnectionState
- (JNIEnv *, jobject);
-
- /*
- * Class: dev_onvoid_webrtc_RTCPeerConnection
- * Method: getConfiguration
- * Signature: ()Ldev/onvoid/webrtc/RTCConfiguration;
- */
- JNIEXPORT jobject JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_getConfiguration
- (JNIEnv *, jobject);
-
- /*
- * Class: dev_onvoid_webrtc_RTCPeerConnection
- * Method: setConfiguration
- * Signature: (Ldev/onvoid/webrtc/RTCConfiguration;)V
- */
- JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_setConfiguration
- (JNIEnv *, jobject, jobject);
-
- /*
- * Class: dev_onvoid_webrtc_RTCPeerConnection
- * Method: getStats
- * Signature: (Ldev/onvoid/webrtc/RTCStatsCollectorCallback;)V
- */
- JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_getStats__Ldev_onvoid_webrtc_RTCStatsCollectorCallback_2
- (JNIEnv *, jobject, jobject);
-
- /*
- * Class: dev_onvoid_webrtc_RTCPeerConnection
- * Method: getStats
- * Signature: (Ldev/onvoid/webrtc/RTCRtpReceiver;Ldev/onvoid/webrtc/RTCStatsCollectorCallback;)V
- */
- JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_getStats__Ldev_onvoid_webrtc_RTCRtpReceiver_2Ldev_onvoid_webrtc_RTCStatsCollectorCallback_2
- (JNIEnv *, jobject, jobject, jobject);
-
- /*
- * Class: dev_onvoid_webrtc_RTCPeerConnection
- * Method: getStats
- * Signature: (Ldev/onvoid/webrtc/RTCRtpSender;Ldev/onvoid/webrtc/RTCStatsCollectorCallback;)V
- */
- JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_getStats__Ldev_onvoid_webrtc_RTCRtpSender_2Ldev_onvoid_webrtc_RTCStatsCollectorCallback_2
- (JNIEnv *, jobject, jobject, jobject);
-
- /*
- * Class: dev_onvoid_webrtc_RTCPeerConnection
- * Method: restartIce
- * Signature: ()V
- */
- JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_restartIce
- (JNIEnv *, jobject);
-
- /*
- * Class: dev_onvoid_webrtc_RTCPeerConnection
- * Method: close
- * Signature: ()V
- */
- JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_close
- (JNIEnv *, jobject);
+/*
+ * Class: dev_onvoid_webrtc_RTCPeerConnection
+ * Method: getSenders
+ * Signature: ()[Ldev/onvoid/webrtc/RTCRtpSender;
+ */
+JNIEXPORT jobjectArray JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_getSenders
+ (JNIEnv *, jobject);
+
+/*
+ * Class: dev_onvoid_webrtc_RTCPeerConnection
+ * Method: getReceivers
+ * Signature: ()[Ldev/onvoid/webrtc/RTCRtpReceiver;
+ */
+JNIEXPORT jobjectArray JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_getReceivers
+ (JNIEnv *, jobject);
+
+/*
+ * Class: dev_onvoid_webrtc_RTCPeerConnection
+ * Method: getTransceivers
+ * Signature: ()[Ldev/onvoid/webrtc/RTCRtpTransceiver;
+ */
+JNIEXPORT jobjectArray JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_getTransceivers
+ (JNIEnv *, jobject);
+
+/*
+ * Class: dev_onvoid_webrtc_RTCPeerConnection
+ * Method: addTrack
+ * Signature: (Ldev/onvoid/webrtc/media/MediaStreamTrack;Ljava/util/List;)Ldev/onvoid/webrtc/RTCRtpSender;
+ */
+JNIEXPORT jobject JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_addTrack
+ (JNIEnv *, jobject, jobject, jobject);
+
+/*
+ * Class: dev_onvoid_webrtc_RTCPeerConnection
+ * Method: removeTrack
+ * Signature: (Ldev/onvoid/webrtc/RTCRtpSender;)V
+ */
+JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_removeTrack
+ (JNIEnv *, jobject, jobject);
+
+/*
+ * Class: dev_onvoid_webrtc_RTCPeerConnection
+ * Method: addTransceiver
+ * Signature: (Ldev/onvoid/webrtc/media/MediaStreamTrack;Ldev/onvoid/webrtc/RTCRtpTransceiverInit;)Ldev/onvoid/webrtc/RTCRtpTransceiver;
+ */
+JNIEXPORT jobject JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_addTransceiver
+ (JNIEnv *, jobject, jobject, jobject);
+
+/*
+ * Class: dev_onvoid_webrtc_RTCPeerConnection
+ * Method: createDataChannel
+ * Signature: (Ljava/lang/String;Ldev/onvoid/webrtc/RTCDataChannelInit;)Ldev/onvoid/webrtc/RTCDataChannel;
+ */
+JNIEXPORT jobject JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_createDataChannel
+ (JNIEnv *, jobject, jstring, jobject);
+
+/*
+ * Class: dev_onvoid_webrtc_RTCPeerConnection
+ * Method: createOffer
+ * Signature: (Ldev/onvoid/webrtc/RTCOfferOptions;Ldev/onvoid/webrtc/CreateSessionDescriptionObserver;)V
+ */
+JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_createOffer
+ (JNIEnv *, jobject, jobject, jobject);
+
+/*
+ * Class: dev_onvoid_webrtc_RTCPeerConnection
+ * Method: createAnswer
+ * Signature: (Ldev/onvoid/webrtc/RTCAnswerOptions;Ldev/onvoid/webrtc/CreateSessionDescriptionObserver;)V
+ */
+JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_createAnswer
+ (JNIEnv *, jobject, jobject, jobject);
+
+/*
+ * Class: dev_onvoid_webrtc_RTCPeerConnection
+ * Method: getCurrentLocalDescription
+ * Signature: ()Ldev/onvoid/webrtc/RTCSessionDescription;
+ */
+JNIEXPORT jobject JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_getCurrentLocalDescription
+ (JNIEnv *, jobject);
+
+/*
+ * Class: dev_onvoid_webrtc_RTCPeerConnection
+ * Method: getLocalDescription
+ * Signature: ()Ldev/onvoid/webrtc/RTCSessionDescription;
+ */
+JNIEXPORT jobject JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_getLocalDescription
+ (JNIEnv *, jobject);
+
+/*
+ * Class: dev_onvoid_webrtc_RTCPeerConnection
+ * Method: getPendingLocalDescription
+ * Signature: ()Ldev/onvoid/webrtc/RTCSessionDescription;
+ */
+JNIEXPORT jobject JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_getPendingLocalDescription
+ (JNIEnv *, jobject);
+
+/*
+ * Class: dev_onvoid_webrtc_RTCPeerConnection
+ * Method: getCurrentRemoteDescription
+ * Signature: ()Ldev/onvoid/webrtc/RTCSessionDescription;
+ */
+JNIEXPORT jobject JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_getCurrentRemoteDescription
+ (JNIEnv *, jobject);
+
+/*
+ * Class: dev_onvoid_webrtc_RTCPeerConnection
+ * Method: getRemoteDescription
+ * Signature: ()Ldev/onvoid/webrtc/RTCSessionDescription;
+ */
+JNIEXPORT jobject JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_getRemoteDescription
+ (JNIEnv *, jobject);
+
+/*
+ * Class: dev_onvoid_webrtc_RTCPeerConnection
+ * Method: getPendingRemoteDescription
+ * Signature: ()Ldev/onvoid/webrtc/RTCSessionDescription;
+ */
+JNIEXPORT jobject JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_getPendingRemoteDescription
+ (JNIEnv *, jobject);
+
+/*
+ * Class: dev_onvoid_webrtc_RTCPeerConnection
+ * Method: setLocalDescription
+ * Signature: (Ldev/onvoid/webrtc/RTCSessionDescription;Ldev/onvoid/webrtc/SetSessionDescriptionObserver;)V
+ */
+JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_setLocalDescription
+ (JNIEnv *, jobject, jobject, jobject);
+
+/*
+ * Class: dev_onvoid_webrtc_RTCPeerConnection
+ * Method: setRemoteDescription
+ * Signature: (Ldev/onvoid/webrtc/RTCSessionDescription;Ldev/onvoid/webrtc/SetSessionDescriptionObserver;)V
+ */
+JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_setRemoteDescription
+ (JNIEnv *, jobject, jobject, jobject);
+
+/*
+ * Class: dev_onvoid_webrtc_RTCPeerConnection
+ * Method: addIceCandidate
+ * Signature: (Ldev/onvoid/webrtc/RTCIceCandidate;)V
+ */
+JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_addIceCandidate
+ (JNIEnv *, jobject, jobject);
+
+/*
+ * Class: dev_onvoid_webrtc_RTCPeerConnection
+ * Method: removeIceCandidates
+ * Signature: ([Ldev/onvoid/webrtc/RTCIceCandidate;)V
+ */
+JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_removeIceCandidates
+ (JNIEnv *, jobject, jobjectArray);
+
+/*
+ * Class: dev_onvoid_webrtc_RTCPeerConnection
+ * Method: getSignalingState
+ * Signature: ()Ldev/onvoid/webrtc/RTCSignalingState;
+ */
+JNIEXPORT jobject JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_getSignalingState
+ (JNIEnv *, jobject);
+
+/*
+ * Class: dev_onvoid_webrtc_RTCPeerConnection
+ * Method: getIceGatheringState
+ * Signature: ()Ldev/onvoid/webrtc/RTCIceGatheringState;
+ */
+JNIEXPORT jobject JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_getIceGatheringState
+ (JNIEnv *, jobject);
+
+/*
+ * Class: dev_onvoid_webrtc_RTCPeerConnection
+ * Method: getIceConnectionState
+ * Signature: ()Ldev/onvoid/webrtc/RTCIceConnectionState;
+ */
+JNIEXPORT jobject JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_getIceConnectionState
+ (JNIEnv *, jobject);
+
+/*
+ * Class: dev_onvoid_webrtc_RTCPeerConnection
+ * Method: getConnectionState
+ * Signature: ()Ldev/onvoid/webrtc/RTCPeerConnectionState;
+ */
+JNIEXPORT jobject JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_getConnectionState
+ (JNIEnv *, jobject);
+
+/*
+ * Class: dev_onvoid_webrtc_RTCPeerConnection
+ * Method: getConfiguration
+ * Signature: ()Ldev/onvoid/webrtc/RTCConfiguration;
+ */
+JNIEXPORT jobject JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_getConfiguration
+ (JNIEnv *, jobject);
+
+/*
+ * Class: dev_onvoid_webrtc_RTCPeerConnection
+ * Method: setConfiguration
+ * Signature: (Ldev/onvoid/webrtc/RTCConfiguration;)V
+ */
+JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_setConfiguration
+ (JNIEnv *, jobject, jobject);
+
+/*
+ * Class: dev_onvoid_webrtc_RTCPeerConnection
+ * Method: getStats
+ * Signature: (Ldev/onvoid/webrtc/RTCStatsCollectorCallback;)V
+ */
+JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_getStats__Ldev_onvoid_webrtc_RTCStatsCollectorCallback_2
+ (JNIEnv *, jobject, jobject);
+
+/*
+ * Class: dev_onvoid_webrtc_RTCPeerConnection
+ * Method: getStats
+ * Signature: (Ldev/onvoid/webrtc/RTCRtpReceiver;Ldev/onvoid/webrtc/RTCStatsCollectorCallback;)V
+ */
+JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_getStats__Ldev_onvoid_webrtc_RTCRtpReceiver_2Ldev_onvoid_webrtc_RTCStatsCollectorCallback_2
+ (JNIEnv *, jobject, jobject, jobject);
+
+/*
+ * Class: dev_onvoid_webrtc_RTCPeerConnection
+ * Method: getStats
+ * Signature: (Ldev/onvoid/webrtc/RTCRtpSender;Ldev/onvoid/webrtc/RTCStatsCollectorCallback;)V
+ */
+JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_getStats__Ldev_onvoid_webrtc_RTCRtpSender_2Ldev_onvoid_webrtc_RTCStatsCollectorCallback_2
+ (JNIEnv *, jobject, jobject, jobject);
+
+/*
+ * Class: dev_onvoid_webrtc_RTCPeerConnection
+ * Method: restartIce
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_restartIce
+ (JNIEnv *, jobject);
+
+/*
+ * Class: dev_onvoid_webrtc_RTCPeerConnection
+ * Method: close
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_close
+ (JNIEnv *, jobject);
+
+/*
+ * Class: dev_onvoid_webrtc_RTCPeerConnection
+ * Method: setBitrate
+ * Signature: (Ldev/onvoid/webrtc/BitrateSettings;)V
+ */
+JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_RTCPeerConnection_setBitrate
+ (JNIEnv *, jobject, jobject);
#ifdef __cplusplus
}
diff --git a/webrtc-jni/src/main/cpp/include/api/AudioCodecInfo.h b/webrtc-jni/src/main/cpp/include/api/AudioCodecInfo.h
new file mode 100644
index 00000000..ff3a38d1
--- /dev/null
+++ b/webrtc-jni/src/main/cpp/include/api/AudioCodecInfo.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2019 Alex Andres
+ *
+ * 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.
+ */
+
+#ifndef JNI_WEBRTC_API_AUDIO_CODEC_INFO_H_
+#define JNI_WEBRTC_API_AUDIO_CODEC_INFO_H_
+
+#include "JavaClass.h"
+#include "JavaRef.h"
+
+#include "api/audio_codecs/audio_format.h"
+
+#include
+
+namespace jni
+{
+ namespace AudioCodecInfo
+ {
+ class JavaAudioCodecInfoClass : public JavaClass
+ {
+ public:
+ explicit JavaAudioCodecInfoClass(JNIEnv * env);
+
+ jclass cls;
+ jmethodID ctor;
+ jfieldID sampleRateHz;
+ jfieldID numChannels;
+ jfieldID defaultBitrateBps;
+ jfieldID minBitrateBps;
+ jfieldID maxBitrateBps;
+ jfieldID allowComfortNoise;
+ jfieldID supportsNetworkAdaption;
+ };
+
+ webrtc::AudioCodecInfo toNative(JNIEnv * env, const JavaRef & javaType);
+ JavaLocalRef toJava(JNIEnv * env, const webrtc::AudioCodecInfo & info);
+ }
+}
+
+#endif
\ No newline at end of file
diff --git a/webrtc-jni/src/main/cpp/include/api/AudioCodecSpec.h b/webrtc-jni/src/main/cpp/include/api/AudioCodecSpec.h
new file mode 100644
index 00000000..d26aaa6c
--- /dev/null
+++ b/webrtc-jni/src/main/cpp/include/api/AudioCodecSpec.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2019 Alex Andres
+ *
+ * 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.
+ */
+
+#ifndef JNI_WEBRTC_API_AUDIO_CODEC_SPEC_H_
+#define JNI_WEBRTC_API_AUDIO_CODEC_SPEC_H_
+
+#include "JavaClass.h"
+#include "JavaRef.h"
+
+#include "api/audio_codecs/audio_format.h"
+
+#include
+
+namespace jni
+{
+ namespace AudioCodecSpec
+ {
+ class JavaAudioCodecSpecClass : public JavaClass
+ {
+ public:
+ explicit JavaAudioCodecSpecClass(JNIEnv * env);
+
+ jclass cls;
+ jmethodID ctor;
+ jfieldID format;
+ jfieldID info;
+ };
+
+ webrtc::AudioCodecSpec toNative(JNIEnv * env, const JavaRef & javaType);
+ JavaLocalRef toJava(JNIEnv * env, const webrtc::AudioCodecSpec & info);
+ }
+}
+
+#endif
\ No newline at end of file
diff --git a/webrtc-jni/src/main/cpp/include/api/BitrateSettings.h b/webrtc-jni/src/main/cpp/include/api/BitrateSettings.h
new file mode 100644
index 00000000..57e3039e
--- /dev/null
+++ b/webrtc-jni/src/main/cpp/include/api/BitrateSettings.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2019 Alex Andres
+ *
+ * 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.
+ */
+
+#ifndef JNI_WEBRTC_API_BITRATE_SETTINGS_H_
+#define JNI_WEBRTC_API_BITRATE_SETTINGS_H_
+
+#include "JavaClass.h"
+#include "JavaRef.h"
+#include "api/transport/bitrate_settings.h"
+#include
+
+namespace jni
+{
+ namespace BitrateSettings
+ {
+ class JavaBitrateSettingsClass : public JavaClass
+ {
+ public:
+ explicit JavaBitrateSettingsClass(JNIEnv * env);
+
+ jclass cls;
+ jfieldID minBitrateBps;
+ jfieldID startBitrateBps;
+ jfieldID maxBitrateBps;
+ };
+
+ webrtc::BitrateSettings toNative(JNIEnv * env, const JavaRef & javaType);
+ }
+}
+
+#endif
\ No newline at end of file
diff --git a/webrtc-jni/src/main/cpp/include/api/SdpAudioFormat.h b/webrtc-jni/src/main/cpp/include/api/SdpAudioFormat.h
new file mode 100644
index 00000000..2e544268
--- /dev/null
+++ b/webrtc-jni/src/main/cpp/include/api/SdpAudioFormat.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2019 Alex Andres
+ *
+ * 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.
+ */
+
+#ifndef JNI_WEBRTC_API_SDP_AUDIO_FORMAT_INFO_H_
+#define JNI_WEBRTC_API_SDP_AUDIO_FORMAT_INFO_H_
+
+#include "JavaClass.h"
+#include "JavaRef.h"
+
+#include "api/audio_codecs/audio_format.h"
+
+#include
+
+namespace jni
+{
+ namespace SdpAudioFormat
+ {
+ class JavaSdpAudioFormatClass : public JavaClass
+ {
+ public:
+ explicit JavaSdpAudioFormatClass(JNIEnv * env);
+
+ jclass cls;
+ jmethodID ctor;
+ jfieldID name;
+ jfieldID clockRateHz;
+ jfieldID numChannels;
+ jfieldID parameters;
+ };
+
+ webrtc::SdpAudioFormat toNative(JNIEnv * env, const JavaRef & javaType);
+ JavaLocalRef toJava(JNIEnv * env, const webrtc::SdpAudioFormat & info);
+ }
+}
+
+#endif
\ No newline at end of file
diff --git a/webrtc-jni/src/main/cpp/include/media/audio/AudioProcessingConfig.h b/webrtc-jni/src/main/cpp/include/media/audio/AudioProcessingConfig.h
index ce95ca30..071fed9a 100644
--- a/webrtc-jni/src/main/cpp/include/media/audio/AudioProcessingConfig.h
+++ b/webrtc-jni/src/main/cpp/include/media/audio/AudioProcessingConfig.h
@@ -34,6 +34,8 @@ namespace jni
explicit JavaAudioProcessingConfigClass(JNIEnv * env);
jclass cls;
+ jfieldID preAmplifier;
+ jfieldID captureLevelAdjustment;
jfieldID echoCanceller;
jfieldID gainControl;
jfieldID highPassFilter;
@@ -45,8 +47,41 @@ namespace jni
webrtc::AudioProcessing::Config toNative(JNIEnv * env, const JavaRef & javaType);
webrtc::AudioProcessing::Config::GainController2 toGainController2(JNIEnv * env, const JavaLocalRef & javaType);
+ webrtc::AudioProcessing::Config::CaptureLevelAdjustment::AnalogMicGainEmulation toAnalogMicGainEmulation(JNIEnv* env, const JavaLocalRef& javaType);
+
+ class JavaPreAmplifierClass : public JavaClass
+ {
+ public:
+ explicit JavaPreAmplifierClass(JNIEnv * env);
+ jclass cls;
+ jfieldID enabled;
+ jfieldID fixedGainFactor;
+ };
+ class JavaCaptureLevelAdjustmentClass : public JavaClass
+ {
+ public:
+ explicit JavaCaptureLevelAdjustmentClass(JNIEnv * env);
+
+ jclass cls;
+ jfieldID enabled;
+ jfieldID preGainFactor;
+ jfieldID postGainFactor;
+ jfieldID analogMicGainEmulation;
+
+ };
+ class JavaAnalogMicGainEmulationClass : public JavaClass
+ {
+ public:
+ explicit JavaAnalogMicGainEmulationClass(JNIEnv * env);
+
+ jclass cls;
+ jfieldID enabled;
+ jfieldID initialLevel;
+
+ };
+
class JavaEchoCancellerClass : public JavaClass
{
public:
diff --git a/webrtc-jni/src/main/cpp/include/media/audio/AudioProcessingStreamConfig.h b/webrtc-jni/src/main/cpp/include/media/audio/AudioProcessingStreamConfig.h
index 851df9d3..554360e9 100644
--- a/webrtc-jni/src/main/cpp/include/media/audio/AudioProcessingStreamConfig.h
+++ b/webrtc-jni/src/main/cpp/include/media/audio/AudioProcessingStreamConfig.h
@@ -40,6 +40,7 @@ namespace jni
};
webrtc::StreamConfig toNative(JNIEnv * env, const JavaRef & javaType);
+ JavaLocalRef toJava(JNIEnv * env, webrtc::StreamConfig& config);
}
}
diff --git a/webrtc-jni/src/main/cpp/include/media/audio/AudioTransportSource.h b/webrtc-jni/src/main/cpp/include/media/audio/AudioTransportSource.h
index 3af8fd1e..52656025 100644
--- a/webrtc-jni/src/main/cpp/include/media/audio/AudioTransportSource.h
+++ b/webrtc-jni/src/main/cpp/include/media/audio/AudioTransportSource.h
@@ -21,12 +21,12 @@
#include "JavaRef.h"
#include "AudioSource.h"
-
+#include "modules/audio_device/include/audio_device_defines.h"
#include
namespace jni
{
- class AudioTransportSource : public AudioSource
+ class AudioTransportSource : public webrtc::AudioTransport
{
public:
AudioTransportSource(JNIEnv * env, const JavaGlobalRef & sink);
@@ -43,6 +43,26 @@ namespace jni
int64_t * elapsed_time_ms,
int64_t * ntp_time_ms) override;
+ int32_t RecordedDataIsAvailable(const void* audioSamples,
+ const size_t nSamples,
+ const size_t nBytesPerSample,
+ const size_t nChannels,
+ const uint32_t samplesPerSec,
+ const uint32_t totalDelayMS,
+ const int32_t clockDrift,
+ const uint32_t currentMicLevel,
+ const bool keyPressed,
+ uint32_t& newMicLevel) override;
+
+ void PullRenderData(int bits_per_sample,
+ int sample_rate,
+ size_t number_of_channels,
+ size_t number_of_frames,
+ void* audio_data,
+ int64_t* elapsed_time_ms,
+ int64_t* ntp_time_ms)
+ {
+ }
private:
class JavaAudioSourceClass : public JavaClass
{
diff --git a/webrtc-jni/src/main/cpp/include/media/audio/FfmpegAudioDecoder.h b/webrtc-jni/src/main/cpp/include/media/audio/FfmpegAudioDecoder.h
new file mode 100644
index 00000000..6375f5cb
--- /dev/null
+++ b/webrtc-jni/src/main/cpp/include/media/audio/FfmpegAudioDecoder.h
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#ifndef API_AUDIO_CODECS_FFMPEG_AUDIO_DECODER_FFMPEG_H_
+#define API_AUDIO_CODECS_FFMPEG_AUDIO_DECODER_FFMPEG_H_
+
+#include
+#include
+#include
+#include
+
+#include "absl/types/optional.h"
+#include "api/audio_codecs/audio_decoder.h"
+#include "api/audio_codecs/audio_format.h"
+#include "rtc_base/system/rtc_export.h"
+
+extern "C"
+{
+#include
+#include
+#include
+}
+
+namespace webrtc
+{
+
+ // FFmpeg 오디오 디코더 구성 클래스
+ struct RTC_EXPORT AudioDecoderFfmpegConfig
+ {
+ std::string codec_name;
+ int sample_rate_hz = 48000;
+ int num_channels = 2;
+ int bitrate_bps = 64000;
+ int frame_size_ms = 20;
+ bool IsOk() const
+ {
+ return !codec_name.empty() && sample_rate_hz > 0 && num_channels > 0 &&
+ bitrate_bps > 0 && frame_size_ms > 0;
+ }
+ };
+
+ struct RTC_EXPORT AudioDecoderFfmpeg
+ {
+ static absl::optional SdpToConfig(
+ const SdpAudioFormat &audio_format);
+ static void AppendSupportedDecoders(std::vector *specs);
+ static std::unique_ptr MakeAudioDecoder(
+ const AudioDecoderFfmpegConfig &config);
+ };
+
+ class AudioDecoderFfmpegImpl : public webrtc::AudioDecoder
+ {
+ public:
+ explicit AudioDecoderFfmpegImpl(const AudioDecoderFfmpegConfig &config);
+ ~AudioDecoderFfmpegImpl() override;
+
+ // AudioDecoder 인터페이스 구현
+ int SampleRateHz() const override;
+ size_t Channels() const override;
+ int DecodeInternal(const uint8_t* encoded,
+ size_t encoded_len,
+ int sample_rate_hz,
+ int16_t* decoded,
+ SpeechType* speech_type) override;
+ void Reset() override;
+ bool HasDecodePlc() const override;
+ int PacketDuration(const uint8_t* encoded, size_t encoded_len) const override;
+
+ private:
+ bool InitializeDecoder();
+
+ // 구성 정보
+ AudioDecoderFfmpegConfig config_;
+
+ // FFmpeg 관련 객체
+ const AVCodec *codec_;
+ AVCodecContext *codec_context_;
+ AVFrame *av_frame_;
+ AVPacket *av_packet_;
+
+ // 디코딩 관련
+ bool decoder_initialized_;
+ int output_sample_rate_hz_;
+ size_t output_channels_;
+
+ RTC_DISALLOW_COPY_AND_ASSIGN(AudioDecoderFfmpegImpl);
+ };
+
+} // namespace webrtc
+
+#endif // API_AUDIO_CODECS_FFMPEG_AUDIO_DECODER_FFMPEG_H_
diff --git a/webrtc-jni/src/main/cpp/include/media/audio/FfmpegAudioDecoderFactory.h b/webrtc-jni/src/main/cpp/include/media/audio/FfmpegAudioDecoderFactory.h
new file mode 100644
index 00000000..972097af
--- /dev/null
+++ b/webrtc-jni/src/main/cpp/include/media/audio/FfmpegAudioDecoderFactory.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2019 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#ifndef JNI_WEBRTC_API_AUDIO_DECODER_FACTORY_H_
+#define JNI_WEBRTC_API_AUDIO_DECODER_FACTORY_H_
+
+#include
+#include
+#include
+
+#include "api/audio_codecs/audio_decoder_factory.h"
+
+extern "C"
+{
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+}
+
+namespace webrtc
+{
+
+ // FFmpeg 오디오 디코더 팩토리 생성
+ rtc::scoped_refptr CreateFfmpegAudioDecoderFactory();
+
+ // 특정 코덱만 지원하는 FFmpeg 오디오 디코더 팩토리 생성
+ rtc::scoped_refptr CreateFfmpegAudioDecoderFactory(
+ const std::vector &codec_names);
+
+ // 사용 가능한 FFmpeg 오디오 디코더 목록 가져오기
+ std::vector GetSupportedFfmpegAudioDecoders();
+
+ // 특정 오디오 코덱이 지원되는지 확인
+ bool IsSupportedAudioDecoder(const std::string& codec_name);
+
+} // namespace webrtc
+
+#endif // JNI_WEBRTC_API_AUDIO_DECODER_FACTORY_H_
diff --git a/webrtc-jni/src/main/cpp/include/media/audio/FfmpegAudioEncoder.h b/webrtc-jni/src/main/cpp/include/media/audio/FfmpegAudioEncoder.h
new file mode 100644
index 00000000..f0395c14
--- /dev/null
+++ b/webrtc-jni/src/main/cpp/include/media/audio/FfmpegAudioEncoder.h
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#ifndef API_AUDIO_CODECS_FFMPEG_AUDIO_ENCODER_FFMPEG_H_
+#define API_AUDIO_CODECS_FFMPEG_AUDIO_ENCODER_FFMPEG_H_
+
+#include
+#include
+#include
+#include
+
+#include "absl/types/optional.h"
+#include "api/audio_codecs/audio_codec_pair_id.h"
+#include "api/audio_codecs/audio_encoder.h"
+#include "api/audio_codecs/audio_format.h"
+#include "modules/audio_coding/audio_network_adaptor/include/audio_network_adaptor.h"
+
+#include "rtc_base/system/rtc_export.h"
+
+extern "C"
+{
+#include
+#include
+#include
+}
+
+namespace webrtc
+{
+
+ // FFmpeg 오디오 인코더 구성 클래스
+ struct RTC_EXPORT AudioEncoderFfmpegConfig
+ {
+ std::string codec_name;
+ int sample_rate_hz = 48000;
+ int num_channels = 2;
+ int bitrate_bps = 64000;
+ int frame_size_ms = 20;
+
+ bool IsOk() const
+ {
+ return !codec_name.empty() && sample_rate_hz > 0 && num_channels > 0 &&
+ bitrate_bps > 0 && frame_size_ms > 0;
+ }
+ };
+
+ struct RTC_EXPORT AudioEncoderFfmpeg
+ {
+ static absl::optional SdpToConfig(
+ const SdpAudioFormat &audio_format);
+ static void AppendSupportedEncoders(std::vector *specs);
+ static AudioCodecInfo QueryAudioEncoder(const AudioEncoderFfmpegConfig &config);
+ static std::unique_ptr MakeAudioEncoder(
+ const AudioEncoderFfmpegConfig &config,
+ int payload_type,
+ absl::optional codec_pair_id = absl::nullopt);
+ };
+
+ class AudioEncoderFfmpegImpl : public webrtc::AudioEncoder
+ {
+ public:
+ AudioEncoderFfmpegImpl(const AudioEncoderFfmpegConfig &config, int payload_type);
+ ~AudioEncoderFfmpegImpl() override;
+
+ // AudioEncoder 인터페이스 구현
+ int SampleRateHz() const override;
+ size_t NumChannels() const override;
+ int RtpTimestampRateHz() const override;
+ size_t Num10MsFramesInNextPacket() const override;
+ size_t Max10MsFramesInAPacket() const override;
+ int GetTargetBitrate() const override;
+ void Reset() override;
+ absl::optional> GetFrameLengthRange() const override;
+
+ protected:
+ EncodedInfo EncodeImpl(uint32_t rtp_timestamp,
+ rtc::ArrayView audio,
+ rtc::Buffer *encoded) override;
+
+ private:
+ bool InitializeEncoder();
+
+ // 구성 정보
+ AudioEncoderFfmpegConfig config_;
+ int payload_type_;
+ int target_bitrate_bps_;
+
+ // FFmpeg 관련 객체
+ const AVCodec *codec_;
+ AVCodecContext *codec_context_;
+ AVFrame *av_frame_;
+ AVPacket *av_packet_;
+
+ // 버퍼링 관련
+ std::vector input_buffer_;
+ uint32_t first_timestamp_in_buffer_;
+ size_t num_10ms_frames_per_packet_;
+ size_t num_10ms_frames_buffered_;
+ bool encoder_initialized_;
+
+ RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderFfmpegImpl);
+ };
+
+} // namespace webrtc
+
+#endif // API_AUDIO_CODECS_FFMPEG_AUDIO_ENCODER_FFMPEG_H_
diff --git a/webrtc-jni/src/main/cpp/include/media/audio/FfmpegAudioEncoderFactory.h b/webrtc-jni/src/main/cpp/include/media/audio/FfmpegAudioEncoderFactory.h
new file mode 100644
index 00000000..007f0d84
--- /dev/null
+++ b/webrtc-jni/src/main/cpp/include/media/audio/FfmpegAudioEncoderFactory.h
@@ -0,0 +1,36 @@
+#ifndef JNI_WEBRTC_API_AUDIO_ENCODER_FACTORY_H_
+#define JNI_WEBRTC_API_AUDIO_ENCODER_FACTORY_H_
+
+#include
+#include
+#include
+
+#include "api/audio_codecs/audio_encoder_factory.h"
+
+extern "C"
+{
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+}
+
+namespace webrtc
+{
+
+ // FFmpeg 오디오 인코더 팩토리 생성
+ rtc::scoped_refptr CreateFfmpegAudioEncoderFactory();
+
+ // 특정 코덱만 지원하는 FFmpeg 오디오 인코더 팩토리 생성
+ rtc::scoped_refptr CreateFfmpegAudioEncoderFactory(
+ const std::vector &codec_names);
+
+ // 사용 가능한 FFmpeg 오디오 인코더 목록 가져오기
+ std::vector GetSupportedFfmpegAudioEncoders();
+
+} // namespace webrtc
+
+#endif // JNI_WEBRTC_API_AUDIO_ENCODER_FACTORY_H_
\ No newline at end of file
diff --git a/webrtc-jni/src/main/cpp/include/media/audio/ProcessingConfig.h b/webrtc-jni/src/main/cpp/include/media/audio/ProcessingConfig.h
new file mode 100644
index 00000000..547a596c
--- /dev/null
+++ b/webrtc-jni/src/main/cpp/include/media/audio/ProcessingConfig.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2021 Alex Andres
+ *
+ * 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.
+ */
+
+#ifndef JNI_WEBRTC_MEDIA_AUDIO_PROCESSING_CONFIG_H_
+#define JNI_WEBRTC_MEDIA_AUDIO_PROCESSING_CONFIG_H_
+
+#include "JavaClass.h"
+#include "JavaRef.h"
+
+#include "modules/audio_processing/include/audio_processing.h"
+
+#include
+
+namespace jni
+{
+ namespace ProcessingConfig
+ {
+ class JavaProcessingConfigClass : public JavaClass
+ {
+ public:
+ explicit JavaProcessingConfigClass(JNIEnv * env);
+
+ jclass cls;
+ jmethodID ctor;
+ jfieldID streams;
+ };
+
+ webrtc::ProcessingConfig toNative(JNIEnv * env, const JavaRef & javaType);
+ JavaLocalRef toJava(JNIEnv * env, webrtc::ProcessingConfig config);
+ }
+}
+
+#endif
\ No newline at end of file
diff --git a/webrtc-jni/src/main/cpp/src/JNI_AudioConverter.cpp b/webrtc-jni/src/main/cpp/src/JNI_AudioConverter.cpp
index 0caf4633..da66967d 100644
--- a/webrtc-jni/src/main/cpp/src/JNI_AudioConverter.cpp
+++ b/webrtc-jni/src/main/cpp/src/JNI_AudioConverter.cpp
@@ -18,48 +18,52 @@
#include "media/audio/AudioConverter.h"
#include "JavaUtils.h"
+
JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_media_audio_AudioConverter_convertInternal
-(JNIEnv * env, jobject caller, jbyteArray src, jint nSrcSamples, jbyteArray dst, jint nDstSamples)
+(JNIEnv* env, jobject caller, jbyteArray src, jint nSrcSamples, jbyteArray dst, jint nDstSamples)
{
- jni::AudioConverter * converter = GetHandle(env, caller);
- CHECK_HANDLE(converter);
+ jni::AudioConverter* converter = GetHandle(env, caller);
+ CHECK_HANDLE(converter);
- jboolean isDstCopy = JNI_FALSE;
+ jboolean isDstCopy = JNI_FALSE;
- jbyte * srcPtr = env->GetByteArrayElements(src, nullptr);
- jbyte * dstPtr = env->GetByteArrayElements(dst, &isDstCopy);
+ jbyte* srcPtr = env->GetByteArrayElements(src, nullptr);
+ jbyte* dstPtr = env->GetByteArrayElements(dst, &isDstCopy);
- converter->convert(reinterpret_cast(srcPtr), nSrcSamples, reinterpret_cast(dstPtr), nDstSamples);
+ converter->convert(reinterpret_cast(srcPtr), nSrcSamples, reinterpret_cast(dstPtr),
+ nDstSamples);
- if (isDstCopy == JNI_TRUE) {
- jsize dstLength = env->GetArrayLength(dst);
+ if (isDstCopy == JNI_TRUE)
+ {
+ jsize dstLength = env->GetArrayLength(dst);
- env->SetByteArrayRegion(dst, 0, dstLength, dstPtr);
- }
+ env->SetByteArrayRegion(dst, 0, dstLength, dstPtr);
+ }
- env->ReleaseByteArrayElements(src, srcPtr, JNI_ABORT);
- env->ReleaseByteArrayElements(dst, dstPtr, JNI_ABORT);
+ env->ReleaseByteArrayElements(src, srcPtr, JNI_ABORT);
+ env->ReleaseByteArrayElements(dst, dstPtr, JNI_ABORT);
}
JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_media_audio_AudioConverter_dispose
-(JNIEnv * env, jobject caller)
+(JNIEnv* env, jobject caller)
{
- jni::AudioConverter * converter = GetHandle(env, caller);
- CHECK_HANDLE(converter);
+ jni::AudioConverter* converter = GetHandle(env, caller);
+ CHECK_HANDLE(converter);
- SetHandle(env, caller, nullptr);
+ SetHandle(env, caller, nullptr);
- delete converter;
+ delete converter;
}
JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_media_audio_AudioConverter_initialize
-(JNIEnv * env, jobject caller, jint srcSampleRate, jint srcChannels, jint dstSampleRate, jint dstChannels)
+(JNIEnv* env, jobject caller, jint srcSampleRate, jint srcChannels, jint dstSampleRate, jint dstChannels)
{
- // 10 ms frames
- size_t srcFrames = srcSampleRate / 100;
- size_t dstFrames = dstSampleRate / 100;
+ // 10 ms frames
+ size_t srcFrames = srcSampleRate / 100;
+ size_t dstFrames = dstSampleRate / 100;
- jni::AudioConverter * converter = jni::AudioConverter::create(srcFrames, srcChannels, dstFrames, dstChannels).release();
+ jni::AudioConverter* converter = jni::AudioConverter::create(srcFrames, srcChannels, dstFrames, dstChannels).
+ release();
- SetHandle(env, caller, converter);
-}
\ No newline at end of file
+ SetHandle(env, caller, converter);
+}
diff --git a/webrtc-jni/src/main/cpp/src/JNI_AudioDecoderFactory.cpp b/webrtc-jni/src/main/cpp/src/JNI_AudioDecoderFactory.cpp
new file mode 100644
index 00000000..824b334d
--- /dev/null
+++ b/webrtc-jni/src/main/cpp/src/JNI_AudioDecoderFactory.cpp
@@ -0,0 +1,58 @@
+#include "JNI_AudioDecoderFactory.h"
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "JavaArrayList.h"
+#include "JavaFactories.h"
+#include "JavaUtils.h"
+/*
+ * Class: dev_onvoid_webrtc_media_audio_AudioDecoderFactory
+ * Method: getSupportedDecoders
+ * Signature: ()Ljava/util/List;
+ */
+JNIEXPORT jobject JNICALL Java_dev_onvoid_webrtc_media_audio_AudioDecoderFactory_getSupportedDecoders
+(JNIEnv* env, jobject caller)
+{
+ webrtc::AudioDecoderFactory* factory = GetHandle(env, caller);
+ CHECK_HANDLEV(factory, nullptr);
+
+ try
+ {
+ auto decoders = factory->GetSupportedDecoders();
+ jni::JavaArrayList decoderList(env, decoders.size());
+
+ for (const auto& decoder : decoders)
+ {
+ decoderList.add(jni::AudioCodecSpec::toJava(env, decoder));
+ }
+ return decoderList.listObject().release();
+ }
+ catch (...)
+ {
+ ThrowCxxJavaException(env);
+ }
+
+ return nullptr;
+}
+
+/*
+ * Class: dev_onvoid_webrtc_media_audio_AudioDecoderFactory
+ * Method: isSupportedDecoder
+ * Signature: (Ldev/onvoid/webrtc/media/audio/SdpAudioFormat;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_dev_onvoid_webrtc_media_audio_AudioDecoderFactory_isSupportedDecoder
+(JNIEnv* env, jobject caller, jobject jformat)
+{
+ webrtc::AudioDecoderFactory* factory = GetHandle(env, caller);
+ CHECK_HANDLEV(factory, false);
+
+ webrtc::SdpAudioFormat format = jni::SdpAudioFormat::toNative(env, jni::JavaLocalRef(env, jformat));
+
+ auto result = factory->IsSupportedDecoder(format);
+ return result;
+}
diff --git a/webrtc-jni/src/main/cpp/src/JNI_AudioDeviceModule.cpp b/webrtc-jni/src/main/cpp/src/JNI_AudioDeviceModule.cpp
index aebc6656..a1939d39 100644
--- a/webrtc-jni/src/main/cpp/src/JNI_AudioDeviceModule.cpp
+++ b/webrtc-jni/src/main/cpp/src/JNI_AudioDeviceModule.cpp
@@ -32,467 +32,522 @@
#include "modules/audio_device/include/audio_device.h"
#include "rtc_base/logging.h"
+JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_media_audio_AudioDeviceModule_setStereoPlayout
+(JNIEnv* env, jobject caller, jboolean enabled)
+{
+ webrtc::AudioDeviceModule* audioModule = GetHandle(env, caller);
+ CHECK_HANDLE(audioModule);
+
+
+ if (audioModule->SetStereoPlayout(enabled) != 0)
+ {
+ env->Throw(jni::JavaError(env, "Set stereo playout failed"));
+ }
+}
+
+JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_media_audio_AudioDeviceModule_setStereoRecording
+(JNIEnv* env, jobject caller, jboolean enabled)
+{
+ webrtc::AudioDeviceModule* audioModule = GetHandle(env, caller);
+ CHECK_HANDLE(audioModule);
+
+
+ if (audioModule->SetStereoRecording(enabled) != 0)
+ {
+ env->Throw(jni::JavaError(env, "Set stereo recording failed"));
+ }
+}
+
JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_media_audio_AudioDeviceModule_initPlayout
-(JNIEnv * env, jobject caller)
+(JNIEnv* env, jobject caller)
{
- webrtc::AudioDeviceModule * audioModule = GetHandle(env, caller);
- CHECK_HANDLE(audioModule);
+ webrtc::AudioDeviceModule* audioModule = GetHandle(env, caller);
+ CHECK_HANDLE(audioModule);
- if (audioModule->InitPlayout() != 0) {
- env->Throw(jni::JavaError(env, "Init playout failed"));
- return;
- }
+ if (audioModule->InitPlayout() != 0)
+ {
+ env->Throw(jni::JavaError(env, "Init playout failed"));
+ }
}
JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_media_audio_AudioDeviceModule_stopPlayout
(JNIEnv* env, jobject caller)
{
- webrtc::AudioDeviceModule* audioModule = GetHandle(env, caller);
- CHECK_HANDLE(audioModule);
+ webrtc::AudioDeviceModule* audioModule = GetHandle(env, caller);
+ CHECK_HANDLE(audioModule);
- if (audioModule->StopPlayout() != 0) {
- env->Throw(jni::JavaError(env, "Stop playout failed"));
- return;
- }
+ if (audioModule->StopPlayout() != 0)
+ {
+ env->Throw(jni::JavaError(env, "Stop playout failed"));
+ }
}
JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_media_audio_AudioDeviceModule_startPlayout
(JNIEnv* env, jobject caller)
{
- webrtc::AudioDeviceModule* audioModule = GetHandle(env, caller);
- CHECK_HANDLE(audioModule);
+ webrtc::AudioDeviceModule* audioModule = GetHandle(env, caller);
+ CHECK_HANDLE(audioModule);
- if (audioModule->StartPlayout() != 0) {
- env->Throw(jni::JavaError(env, "Start playout failed"));
- return;
- }
+ if (audioModule->StartPlayout() != 0)
+ {
+ env->Throw(jni::JavaError(env, "Start playout failed"));
+ }
}
JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_media_audio_AudioDeviceModule_initRecording
-(JNIEnv * env, jobject caller)
+(JNIEnv* env, jobject caller)
{
- webrtc::AudioDeviceModule * audioModule = GetHandle(env, caller);
- CHECK_HANDLE(audioModule);
+ webrtc::AudioDeviceModule* audioModule = GetHandle(env, caller);
+ CHECK_HANDLE(audioModule);
- if (audioModule->InitRecording() != 0) {
- env->Throw(jni::JavaError(env, "Init recording failed"));
- return;
- }
+ if (audioModule->InitRecording() != 0)
+ {
+ env->Throw(jni::JavaError(env, "Init recording failed"));
+ }
}
JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_media_audio_AudioDeviceModule_stopRecording
(JNIEnv* env, jobject caller)
{
- webrtc::AudioDeviceModule* audioModule = GetHandle(env, caller);
- CHECK_HANDLE(audioModule);
+ webrtc::AudioDeviceModule* audioModule = GetHandle(env, caller);
+ CHECK_HANDLE(audioModule);
- if (audioModule->StopRecording() != 0) {
- env->Throw(jni::JavaError(env, "Stop recording failed"));
- return;
- }
+ if (audioModule->StopRecording() != 0)
+ {
+ env->Throw(jni::JavaError(env, "Stop recording failed"));
+ }
}
JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_media_audio_AudioDeviceModule_startRecording
(JNIEnv* env, jobject caller)
{
- webrtc::AudioDeviceModule* audioModule = GetHandle(env, caller);
- CHECK_HANDLE(audioModule);
+ webrtc::AudioDeviceModule* audioModule = GetHandle(env, caller);
+ CHECK_HANDLE(audioModule);
- if (audioModule->StartRecording() != 0) {
- env->Throw(jni::JavaError(env, "Start recording failed"));
- return;
- }
+ if (audioModule->StartRecording() != 0)
+ {
+ env->Throw(jni::JavaError(env, "Start recording failed"));
+ }
}
JNIEXPORT jobject JNICALL Java_dev_onvoid_webrtc_media_audio_AudioDeviceModule_getPlayoutDevices
(JNIEnv* env, jobject caller)
{
- webrtc::AudioDeviceModule * audioModule = GetHandle(env, caller);
- CHECK_HANDLEV(audioModule, nullptr);
+ webrtc::AudioDeviceModule* audioModule = GetHandle(env, caller);
+ CHECK_HANDLEV(audioModule, nullptr);
- char name[webrtc::kAdmMaxDeviceNameSize];
- char guid[webrtc::kAdmMaxGuidSize];
+ char name[webrtc::kAdmMaxDeviceNameSize];
+ char guid[webrtc::kAdmMaxGuidSize];
- int16_t deviceCount = audioModule->PlayoutDevices();
+ int16_t deviceCount = audioModule->PlayoutDevices();
- jni::JavaArrayList deviceList(env, deviceCount);
+ jni::JavaArrayList deviceList(env, deviceCount);
- for (int i = 0; i < deviceCount; ++i) {
- if (audioModule->PlayoutDeviceName(i, name, guid) == 0) {
- auto device = std::make_shared(name, guid);
+ for (int i = 0; i < deviceCount; ++i)
+ {
+ if (audioModule->PlayoutDeviceName(i, name, guid) == 0)
+ {
+ auto device = std::make_shared(name, guid);
- deviceList.add(jni::AudioDevice::toJavaAudioDevice(env, device));
- }
- }
+ deviceList.add(jni::AudioDevice::toJavaAudioDevice(env, device));
+ }
+ }
- return deviceList.listObject().release();
+ return deviceList.listObject().release();
}
JNIEXPORT jobject JNICALL Java_dev_onvoid_webrtc_media_audio_AudioDeviceModule_getRecordingDevices
-(JNIEnv * env, jobject caller)
+(JNIEnv* env, jobject caller)
{
- webrtc::AudioDeviceModule * audioModule = GetHandle(env, caller);
- CHECK_HANDLEV(audioModule, nullptr);
+ webrtc::AudioDeviceModule* audioModule = GetHandle(env, caller);
+ CHECK_HANDLEV(audioModule, nullptr);
- char name[webrtc::kAdmMaxDeviceNameSize];
- char guid[webrtc::kAdmMaxGuidSize];
+ char name[webrtc::kAdmMaxDeviceNameSize];
+ char guid[webrtc::kAdmMaxGuidSize];
- int16_t deviceCount = audioModule->RecordingDevices();
+ int16_t deviceCount = audioModule->RecordingDevices();
- jni::JavaArrayList deviceList(env, deviceCount);
+ jni::JavaArrayList deviceList(env, deviceCount);
- for (int i = 0; i < deviceCount; ++i) {
- if (audioModule->RecordingDeviceName(i, name, guid) == 0) {
- auto device = std::make_shared(name, guid);
+ for (int i = 0; i < deviceCount; ++i)
+ {
+ if (audioModule->RecordingDeviceName(i, name, guid) == 0)
+ {
+ auto device = std::make_shared(name, guid);
- deviceList.add(jni::AudioDevice::toJavaAudioDevice(env, device));
- }
- }
+ deviceList.add(jni::AudioDevice::toJavaAudioDevice(env, device));
+ }
+ }
- return deviceList.listObject().release();
+ return deviceList.listObject().release();
}
JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_media_audio_AudioDeviceModule_setPlayoutDevice
-(JNIEnv * env, jobject caller, jobject device)
+(JNIEnv* env, jobject caller, jobject device)
{
- webrtc::AudioDeviceModule * audioModule = GetHandle(env, caller);
- CHECK_HANDLE(audioModule);
-
- if (!device) {
- env->Throw(jni::JavaNullPointerException(env, "AudioDevice is null"));
- return;
- }
-
- jni::JavaObject obj(env, jni::JavaLocalRef(env, device));
-
- const auto javaClass = jni::JavaClasses::get(env);
- const std::string devGuid = jni::JavaString::toNative(env, obj.getString(javaClass->descriptor));
-
- uint16_t index = 0;
- int16_t deviceCount = audioModule->PlayoutDevices();
-
- char name[webrtc::kAdmMaxDeviceNameSize];
- char guid[webrtc::kAdmMaxGuidSize];
-
- for (int i = 0; i < deviceCount; ++i) {
- if ((audioModule->PlayoutDeviceName(i, name, guid) == 0) && devGuid == std::string(guid)) {
- index = i;
- break;
- }
- }
-
- if (audioModule->SetPlayoutDevice(index) != 0) {
- env->Throw(jni::JavaError(env, "Set playout device failed"));
- return;
- }
+ webrtc::AudioDeviceModule* audioModule = GetHandle(env, caller);
+ CHECK_HANDLE(audioModule);
+
+ if (!device)
+ {
+ env->Throw(jni::JavaNullPointerException(env, "AudioDevice is null"));
+ return;
+ }
+
+ jni::JavaObject obj(env, jni::JavaLocalRef(env, device));
+
+ const auto javaClass = jni::JavaClasses::get(env);
+ const std::string devGuid = jni::JavaString::toNative(env, obj.getString(javaClass->descriptor));
+
+ uint16_t index = 0;
+ int16_t deviceCount = audioModule->PlayoutDevices();
+
+ char name[webrtc::kAdmMaxDeviceNameSize];
+ char guid[webrtc::kAdmMaxGuidSize];
+
+ for (int i = 0; i < deviceCount; ++i)
+ {
+ if ((audioModule->PlayoutDeviceName(i, name, guid) == 0) && devGuid == std::string(guid))
+ {
+ index = i;
+ break;
+ }
+ }
+
+ if (audioModule->SetPlayoutDevice(index) != 0)
+ {
+ env->Throw(jni::JavaError(env, "Set playout device failed"));
+ }
}
JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_media_audio_AudioDeviceModule_setRecordingDevice
-(JNIEnv * env, jobject caller, jobject device)
+(JNIEnv* env, jobject caller, jobject device)
{
- webrtc::AudioDeviceModule * audioModule = GetHandle(env, caller);
- CHECK_HANDLE(audioModule);
-
- if (!device) {
- env->Throw(jni::JavaNullPointerException(env, "AudioDevice is null"));
- return;
- }
-
- jni::JavaObject obj(env, jni::JavaLocalRef(env, device));
-
- const auto javaClass = jni::JavaClasses::get(env);
- const std::string devGuid = jni::JavaString::toNative(env, obj.getString(javaClass->descriptor));
-
- uint16_t index = 0;
- int16_t deviceCount = audioModule->RecordingDevices();
-
- char name[webrtc::kAdmMaxDeviceNameSize];
- char guid[webrtc::kAdmMaxGuidSize];
-
- for (int i = 0; i < deviceCount; ++i) {
- if ((audioModule->RecordingDeviceName(i, name, guid) == 0) && devGuid == std::string(guid)) {
- index = i;
- break;
- }
- }
-
- if (audioModule->SetRecordingDevice(index) != 0) {
- env->Throw(jni::JavaError(env, "Set recording device failed"));
- return;
- }
+ webrtc::AudioDeviceModule* audioModule = GetHandle(env, caller);
+ CHECK_HANDLE(audioModule);
+
+ if (!device)
+ {
+ env->Throw(jni::JavaNullPointerException(env, "AudioDevice is null"));
+ return;
+ }
+
+ jni::JavaObject obj(env, jni::JavaLocalRef(env, device));
+
+ const auto javaClass = jni::JavaClasses::get(env);
+ const std::string devGuid = jni::JavaString::toNative(env, obj.getString(javaClass->descriptor));
+
+ uint16_t index = 0;
+ int16_t deviceCount = audioModule->RecordingDevices();
+
+ char name[webrtc::kAdmMaxDeviceNameSize];
+ char guid[webrtc::kAdmMaxGuidSize];
+
+ for (int i = 0; i < deviceCount; ++i)
+ {
+ if ((audioModule->RecordingDeviceName(i, name, guid) == 0) && devGuid == std::string(guid))
+ {
+ index = i;
+ break;
+ }
+ }
+
+ if (audioModule->SetRecordingDevice(index) != 0)
+ {
+ env->Throw(jni::JavaError(env, "Set recording device failed"));
+ }
}
JNIEXPORT jboolean JNICALL Java_dev_onvoid_webrtc_media_audio_AudioDeviceModule_isSpeakerMuted
-(JNIEnv * env, jobject caller)
+(JNIEnv* env, jobject caller)
{
- webrtc::AudioDeviceModule * audioModule = GetHandle(env, caller);
- CHECK_HANDLEV(audioModule, true);
+ webrtc::AudioDeviceModule* audioModule = GetHandle(env, caller);
+ CHECK_HANDLEV(audioModule, true);
- bool mute = true;
+ bool mute = true;
- audioModule->SpeakerMute(&mute);
+ audioModule->SpeakerMute(&mute);
- return mute;
+ return mute;
}
JNIEXPORT jboolean JNICALL Java_dev_onvoid_webrtc_media_audio_AudioDeviceModule_isMicrophoneMuted
-(JNIEnv * env, jobject caller)
+(JNIEnv* env, jobject caller)
{
- webrtc::AudioDeviceModule * audioModule = GetHandle(env, caller);
- CHECK_HANDLEV(audioModule, true);
+ webrtc::AudioDeviceModule* audioModule = GetHandle(env, caller);
+ CHECK_HANDLEV(audioModule, true);
- bool mute = true;
+ bool mute = true;
- audioModule->MicrophoneMute(&mute);
+ audioModule->MicrophoneMute(&mute);
- return mute;
+ return mute;
}
JNIEXPORT jint JNICALL Java_dev_onvoid_webrtc_media_audio_AudioDeviceModule_getSpeakerVolume
-(JNIEnv * env, jobject caller)
+(JNIEnv* env, jobject caller)
{
- webrtc::AudioDeviceModule * audioModule = GetHandle(env, caller);
- CHECK_HANDLEV(audioModule, 0);
+ webrtc::AudioDeviceModule* audioModule = GetHandle(env, caller);
+ CHECK_HANDLEV(audioModule, 0);
- uint32_t volume = 0;
+ uint32_t volume = 0;
- if (audioModule->SpeakerVolume(&volume) != 0) {
- env->Throw(jni::JavaError(env, "Get speaker volume failed"));
- }
+ if (audioModule->SpeakerVolume(&volume) != 0)
+ {
+ env->Throw(jni::JavaError(env, "Get speaker volume failed"));
+ }
- return volume;
+ return volume;
}
JNIEXPORT jint JNICALL Java_dev_onvoid_webrtc_media_audio_AudioDeviceModule_getMaxSpeakerVolume
-(JNIEnv * env, jobject caller)
+(JNIEnv* env, jobject caller)
{
- webrtc::AudioDeviceModule * audioModule = GetHandle(env, caller);
- CHECK_HANDLEV(audioModule, 0);
+ webrtc::AudioDeviceModule* audioModule = GetHandle(env, caller);
+ CHECK_HANDLEV(audioModule, 0);
- uint32_t volume = 0;
+ uint32_t volume = 0;
- if (audioModule->MaxSpeakerVolume(&volume) != 0) {
- env->Throw(jni::JavaError(env, "Get max speaker volume failed"));
- }
+ if (audioModule->MaxSpeakerVolume(&volume) != 0)
+ {
+ env->Throw(jni::JavaError(env, "Get max speaker volume failed"));
+ }
- return volume;
+ return volume;
}
JNIEXPORT jint JNICALL Java_dev_onvoid_webrtc_media_audio_AudioDeviceModule_getMinSpeakerVolume
-(JNIEnv * env, jobject caller)
+(JNIEnv* env, jobject caller)
{
- webrtc::AudioDeviceModule * audioModule = GetHandle(env, caller);
- CHECK_HANDLEV(audioModule, 0);
+ webrtc::AudioDeviceModule* audioModule = GetHandle(env, caller);
+ CHECK_HANDLEV(audioModule, 0);
- uint32_t volume = 0;
+ uint32_t volume = 0;
- if (audioModule->MinSpeakerVolume(&volume) != 0) {
- env->Throw(jni::JavaError(env, "Get min speaker volume failed"));
- }
+ if (audioModule->MinSpeakerVolume(&volume) != 0)
+ {
+ env->Throw(jni::JavaError(env, "Get min speaker volume failed"));
+ }
- return volume;
+ return volume;
}
JNIEXPORT jint JNICALL Java_dev_onvoid_webrtc_media_audio_AudioDeviceModule_getMicrophoneVolume
-(JNIEnv * env, jobject caller)
+(JNIEnv* env, jobject caller)
{
- webrtc::AudioDeviceModule * audioModule = GetHandle(env, caller);
- CHECK_HANDLEV(audioModule, 0);
+ webrtc::AudioDeviceModule* audioModule = GetHandle(env, caller);
+ CHECK_HANDLEV(audioModule, 0);
- uint32_t volume = 0;
+ uint32_t volume = 0;
- if (audioModule->MicrophoneVolume(&volume) != 0) {
- env->Throw(jni::JavaError(env, "Get microphone volume failed"));
- }
+ if (audioModule->MicrophoneVolume(&volume) != 0)
+ {
+ env->Throw(jni::JavaError(env, "Get microphone volume failed"));
+ }
- return volume;
+ return volume;
}
JNIEXPORT jint JNICALL Java_dev_onvoid_webrtc_media_audio_AudioDeviceModule_getMaxMicrophoneVolume
-(JNIEnv * env, jobject caller)
+(JNIEnv* env, jobject caller)
{
- webrtc::AudioDeviceModule * audioModule = GetHandle(env, caller);
- CHECK_HANDLEV(audioModule, 0);
+ webrtc::AudioDeviceModule* audioModule = GetHandle(env, caller);
+ CHECK_HANDLEV(audioModule, 0);
- uint32_t volume = 0;
+ uint32_t volume = 0;
- if (audioModule->MaxMicrophoneVolume(&volume) != 0) {
- env->Throw(jni::JavaError(env, "Get max microphone volume failed"));
- }
+ if (audioModule->MaxMicrophoneVolume(&volume) != 0)
+ {
+ env->Throw(jni::JavaError(env, "Get max microphone volume failed"));
+ }
- return volume;
+ return volume;
}
JNIEXPORT jint JNICALL Java_dev_onvoid_webrtc_media_audio_AudioDeviceModule_getMinMicrophoneVolume
-(JNIEnv * env, jobject caller)
+(JNIEnv* env, jobject caller)
{
- webrtc::AudioDeviceModule * audioModule = GetHandle(env, caller);
- CHECK_HANDLEV(audioModule, 0);
+ webrtc::AudioDeviceModule* audioModule = GetHandle(env, caller);
+ CHECK_HANDLEV(audioModule, 0);
- uint32_t volume = 0;
+ uint32_t volume = 0;
- if (audioModule->MinMicrophoneVolume(&volume) != 0) {
- env->Throw(jni::JavaError(env, "Get min microphone volume failed"));
- }
+ if (audioModule->MinMicrophoneVolume(&volume) != 0)
+ {
+ env->Throw(jni::JavaError(env, "Get min microphone volume failed"));
+ }
- return volume;
+ return volume;
}
JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_media_audio_AudioDeviceModule_setSpeakerVolume
-(JNIEnv * env, jobject caller, jint volume)
+(JNIEnv* env, jobject caller, jint volume)
{
- webrtc::AudioDeviceModule * audioModule = GetHandle(env, caller);
- CHECK_HANDLE(audioModule);
+ webrtc::AudioDeviceModule* audioModule = GetHandle(env, caller);
+ CHECK_HANDLE(audioModule);
- if (audioModule->SetSpeakerVolume(static_cast(volume)) != 0) {
- env->Throw(jni::JavaError(env, "Set speaker volume failed"));
- }
+ if (audioModule->SetSpeakerVolume(static_cast(volume)) != 0)
+ {
+ env->Throw(jni::JavaError(env, "Set speaker volume failed"));
+ }
}
JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_media_audio_AudioDeviceModule_setSpeakerMute
-(JNIEnv * env, jobject caller, jboolean mute)
+(JNIEnv* env, jobject caller, jboolean mute)
{
- webrtc::AudioDeviceModule * audioModule = GetHandle(env, caller);
- CHECK_HANDLE(audioModule);
+ webrtc::AudioDeviceModule* audioModule = GetHandle(env, caller);
+ CHECK_HANDLE(audioModule);
- if (audioModule->SetSpeakerMute(mute) != 0) {
- env->Throw(jni::JavaError(env, "Set speaker mute failed"));
- }
+ if (audioModule->SetSpeakerMute(mute) != 0)
+ {
+ env->Throw(jni::JavaError(env, "Set speaker mute failed"));
+ }
}
JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_media_audio_AudioDeviceModule_setMicrophoneVolume
-(JNIEnv * env, jobject caller, jint volume)
+(JNIEnv* env, jobject caller, jint volume)
{
- webrtc::AudioDeviceModule * audioModule = GetHandle(env, caller);
- CHECK_HANDLE(audioModule);
+ webrtc::AudioDeviceModule* audioModule = GetHandle(env, caller);
+ CHECK_HANDLE(audioModule);
- if (audioModule->SetMicrophoneVolume(static_cast(volume)) != 0) {
- env->Throw(jni::JavaError(env, "Set microphone volume failed"));
- }
+ if (audioModule->SetMicrophoneVolume(static_cast(volume)) != 0)
+ {
+ env->Throw(jni::JavaError(env, "Set microphone volume failed"));
+ }
}
JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_media_audio_AudioDeviceModule_setMicrophoneMute
-(JNIEnv * env, jobject caller, jboolean mute)
+(JNIEnv* env, jobject caller, jboolean mute)
{
- webrtc::AudioDeviceModule * audioModule = GetHandle(env, caller);
- CHECK_HANDLE(audioModule);
+ webrtc::AudioDeviceModule* audioModule = GetHandle(env, caller);
+ CHECK_HANDLE(audioModule);
- if (audioModule->SetMicrophoneMute(mute) != 0) {
- env->Throw(jni::JavaError(env, "Set microphone mute failed"));
- }
+ if (audioModule->SetMicrophoneMute(mute) != 0)
+ {
+ env->Throw(jni::JavaError(env, "Set microphone mute failed"));
+ }
}
JNIEXPORT jlong JNICALL Java_dev_onvoid_webrtc_media_audio_AudioDeviceModule_addSinkInternal
-(JNIEnv * env, jobject caller, jobject jSink)
+(JNIEnv* env, jobject caller, jobject jSink)
{
- if (jSink == nullptr) {
- env->Throw(jni::JavaNullPointerException(env, "AudioSink must not be null"));
- return 0;
- }
+ if (jSink == nullptr)
+ {
+ env->Throw(jni::JavaNullPointerException(env, "AudioSink must not be null"));
+ return 0;
+ }
- webrtc::AudioDeviceModule * audioModule = GetHandle(env, caller);
- CHECK_HANDLEV(audioModule, 0);
+ webrtc::AudioDeviceModule* audioModule = GetHandle(env, caller);
+ CHECK_HANDLEV(audioModule, 0);
- auto sink = new jni::AudioTransportSink(env, jni::JavaGlobalRef(env, jSink));
+ auto sink = new jni::AudioTransportSink(env, jni::JavaGlobalRef(env, jSink));
- audioModule->RegisterAudioCallback(sink);
+ audioModule->RegisterAudioCallback(sink);
- return reinterpret_cast(sink);
+ return reinterpret_cast(sink);
}
JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_media_audio_AudioDeviceModule_removeSinkInternal
-(JNIEnv * env, jobject caller, jlong sinkHandle)
+(JNIEnv* env, jobject caller, jlong sinkHandle)
{
- webrtc::AudioDeviceModule * audioModule = GetHandle(env, caller);
- CHECK_HANDLE(audioModule);
+ webrtc::AudioDeviceModule* audioModule = GetHandle(env, caller);
+ CHECK_HANDLE(audioModule);
- auto sink = reinterpret_cast(sinkHandle);
+ auto sink = reinterpret_cast(sinkHandle);
- if (sink != nullptr) {
- audioModule->RegisterAudioCallback(nullptr);
+ if (sink != nullptr)
+ {
+ audioModule->RegisterAudioCallback(nullptr);
- delete sink;
- }
+ delete sink;
+ }
}
JNIEXPORT jlong JNICALL Java_dev_onvoid_webrtc_media_audio_AudioDeviceModule_addSourceInternal
-(JNIEnv * env, jobject caller, jobject jSource)
+(JNIEnv* env, jobject caller, jobject jSource)
{
- if (jSource == nullptr) {
- env->Throw(jni::JavaNullPointerException(env, "AudioSource must not be null"));
- return 0;
- }
+ if (jSource == nullptr)
+ {
+ env->Throw(jni::JavaNullPointerException(env, "AudioSource must not be null"));
+ return 0;
+ }
- webrtc::AudioDeviceModule * audioModule = GetHandle(env, caller);
- CHECK_HANDLEV(audioModule, 0);
+ webrtc::AudioDeviceModule* audioModule = GetHandle(env, caller);
+ CHECK_HANDLEV(audioModule, 0);
- auto source = new jni::AudioTransportSource(env, jni::JavaGlobalRef(env, jSource));
+ auto source = new jni::AudioTransportSource(env, jni::JavaGlobalRef(env, jSource));
- audioModule->RegisterAudioCallback(source);
+ audioModule->RegisterAudioCallback(source);
- return reinterpret_cast(source);
+ return reinterpret_cast(source);
}
JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_media_audio_AudioDeviceModule_removeSourceInternal
-(JNIEnv * env, jobject caller, jlong sourceHandle)
+(JNIEnv* env, jobject caller, jlong sourceHandle)
{
- webrtc::AudioDeviceModule * audioModule = GetHandle(env, caller);
- CHECK_HANDLE(audioModule);
+ webrtc::AudioDeviceModule* audioModule = GetHandle(env, caller);
+ CHECK_HANDLE(audioModule);
- auto source = reinterpret_cast(sourceHandle);
+ auto source = reinterpret_cast(sourceHandle);
- if (source != nullptr) {
- audioModule->RegisterAudioCallback(nullptr);
+ if (source != nullptr)
+ {
+ audioModule->RegisterAudioCallback(nullptr);
- delete source;
- }
+ delete source;
+ }
}
JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_media_audio_AudioDeviceModule_disposeInternal
-(JNIEnv * env, jobject caller)
+(JNIEnv* env, jobject caller)
{
- webrtc::AudioDeviceModule * audioModule = GetHandle(env, caller);
- CHECK_HANDLE(audioModule);
+ webrtc::AudioDeviceModule* audioModule = GetHandle(env, caller);
+ CHECK_HANDLE(audioModule);
- if (audioModule->Initialized()) {
- audioModule->Terminate();
- }
+ if (audioModule->Initialized())
+ {
+ audioModule->Terminate();
+ }
- rtc::RefCountReleaseStatus status = audioModule->Release();
+ rtc::RefCountReleaseStatus status = audioModule->Release();
- if (status != rtc::RefCountReleaseStatus::kDroppedLastRef) {
- RTC_LOG(LS_WARNING) << "Native object was not deleted. A reference is still around somewhere.";
- }
+ if (status != rtc::RefCountReleaseStatus::kDroppedLastRef)
+ {
+ RTC_LOG(LS_WARNING) << "Native object was not deleted. A reference is still around somewhere.";
+ }
- SetHandle(env, caller, nullptr);
+ SetHandle(env, caller, nullptr);
- audioModule = nullptr;
+ audioModule = nullptr;
}
JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_media_audio_AudioDeviceModule_initialize
-(JNIEnv * env, jobject caller, jobject jAudioLayer)
+(JNIEnv* env, jobject caller, jobject jAudioLayer)
{
- std::unique_ptr taskQueueFactory = webrtc::CreateDefaultTaskQueueFactory();
+ std::unique_ptr taskQueueFactory = webrtc::CreateDefaultTaskQueueFactory();
- if (!taskQueueFactory) {
- env->Throw(jni::JavaError(env, "Create TaskQueueFactory failed"));
- return;
- }
+ if (!taskQueueFactory)
+ {
+ env->Throw(jni::JavaError(env, "Create TaskQueueFactory failed"));
+ return;
+ }
- auto audioLayer = jni::JavaEnums::toNative(env, jAudioLayer);
+ auto audioLayer = jni::JavaEnums::toNative(env, jAudioLayer);
- rtc::scoped_refptr audioModule = webrtc::AudioDeviceModule::Create(
- audioLayer, taskQueueFactory.release());
+ rtc::scoped_refptr audioModule = webrtc::AudioDeviceModule::Create(
+ audioLayer, taskQueueFactory.release());
- if (!audioModule) {
- env->Throw(jni::JavaError(env, "Create AudioDeviceModule failed"));
- return;
- }
+ if (!audioModule)
+ {
+ env->Throw(jni::JavaError(env, "Create AudioDeviceModule failed"));
+ return;
+ }
- if (audioModule->Init() != 0) {
- env->Throw(jni::JavaError(env, "Initialize AudioDeviceModule failed"));
- return;
- }
+ if (audioModule->Init() != 0)
+ {
+ env->Throw(jni::JavaError(env, "Initialize AudioDeviceModule failed"));
+ return;
+ }
- SetHandle(env, caller, audioModule.release());
+ SetHandle(env, caller, audioModule.release());
}
diff --git a/webrtc-jni/src/main/cpp/src/JNI_AudioEncoderFactory.cpp b/webrtc-jni/src/main/cpp/src/JNI_AudioEncoderFactory.cpp
new file mode 100644
index 00000000..1ad6e03c
--- /dev/null
+++ b/webrtc-jni/src/main/cpp/src/JNI_AudioEncoderFactory.cpp
@@ -0,0 +1,64 @@
+#include "JNI_AudioEncoderFactory.h"
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "JavaArrayList.h"
+#include "JavaFactories.h"
+#include "JavaList.h"
+
+/*
+ * Class: dev_onvoid_webrtc_media_audio_AudioEncoderFactory
+ * Method: getSupportedEncoders
+ * Signature: ()Ljava/util/List;
+ */
+JNIEXPORT jobject JNICALL Java_dev_onvoid_webrtc_media_audio_AudioEncoderFactory_getSupportedEncoders
+(JNIEnv* env, jobject caller)
+{
+ webrtc::AudioEncoderFactory* factory = GetHandle(env, caller);
+ CHECK_HANDLEV(factory, nullptr);
+ try
+ {
+ auto encoders = factory->GetSupportedEncoders();
+ jni::JavaArrayList encoderList(env, encoders.size());
+
+ for (const auto& encoder : encoders)
+ {
+ encoderList.add(jni::AudioCodecSpec::toJava(env, encoder));
+ }
+ return encoderList.listObject().release();
+ }
+ catch (...)
+ {
+ ThrowCxxJavaException(env);
+ }
+
+ return nullptr;
+}
+
+/*
+ * Class: dev_onvoid_webrtc_media_audio_AudioEncoderFactory
+ * Method: queryAudioEncoder
+ * Signature: (Ldev/onvoid/webrtc/media/audio/SdpAudioFormat;)Ldev/onvoid/webrtc/media/audio/AudioCodecInfo;
+ */
+JNIEXPORT jobject JNICALL Java_dev_onvoid_webrtc_media_audio_AudioEncoderFactory_queryAudioEncoder
+(JNIEnv* env, jobject caller, jobject jformat)
+{
+ webrtc::AudioEncoderFactory* factory = GetHandle(env, caller);
+ CHECK_HANDLEV(factory, nullptr);
+
+ webrtc::SdpAudioFormat format = jni::SdpAudioFormat::toNative(env, jni::JavaLocalRef(env, jformat));
+
+ auto result = factory->QueryAudioEncoder(format);
+
+ if (!result.has_value())
+ {
+ return nullptr;
+ }
+
+ return jni::AudioCodecInfo::toJava(env, *result).release();
+}
diff --git a/webrtc-jni/src/main/cpp/src/JNI_AudioProcessing.cpp b/webrtc-jni/src/main/cpp/src/JNI_AudioProcessing.cpp
index aa1985c6..f0d79a54 100644
--- a/webrtc-jni/src/main/cpp/src/JNI_AudioProcessing.cpp
+++ b/webrtc-jni/src/main/cpp/src/JNI_AudioProcessing.cpp
@@ -33,183 +33,239 @@
#include "rtc_base/logging.h"
JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_media_audio_AudioProcessing_applyConfig
-(JNIEnv * env, jobject caller, jobject config)
+(JNIEnv* env, jobject caller, jobject config)
{
- webrtc::AudioProcessing * apm = GetHandle(env, caller);
- CHECK_HANDLE(apm);
+ webrtc::AudioProcessing* apm = GetHandle(env, caller);
+ CHECK_HANDLE(apm);
- apm->ApplyConfig(jni::AudioProcessingConfig::toNative(env, jni::JavaLocalRef(env, config)));
+ apm->ApplyConfig(jni::AudioProcessingConfig::toNative(env, jni::JavaLocalRef(env, config)));
}
JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_media_audio_AudioProcessing_setStreamDelayMs
-(JNIEnv * env, jobject caller, jint delayMs)
+(JNIEnv* env, jobject caller, jint delayMs)
{
- webrtc::AudioProcessing * apm = GetHandle(env, caller);
- CHECK_HANDLE(apm);
+ webrtc::AudioProcessing* apm = GetHandle(env, caller);
+ CHECK_HANDLE(apm);
- apm->set_stream_delay_ms(delayMs);
+ apm->set_stream_delay_ms(delayMs);
}
JNIEXPORT jint JNICALL Java_dev_onvoid_webrtc_media_audio_AudioProcessing_getStreamDelayMs
-(JNIEnv * env, jobject caller)
+(JNIEnv* env, jobject caller)
{
- webrtc::AudioProcessing * apm = GetHandle(env, caller);
- CHECK_HANDLEV(apm, 0);
+ webrtc::AudioProcessing* apm = GetHandle(env, caller);
+ CHECK_HANDLEV(apm, 0);
- return apm->stream_delay_ms();
+ return apm->stream_delay_ms();
}
JNIEXPORT jint JNICALL Java_dev_onvoid_webrtc_media_audio_AudioProcessing_processStream
-(JNIEnv * env, jobject caller, jbyteArray src, jobject inputConfig, jobject outputConfig, jbyteArray dest)
+(JNIEnv* env, jobject caller, jbyteArray src, jobject inputConfig, jobject outputConfig, jbyteArray dest)
{
- webrtc::AudioProcessing * apm = GetHandle(env, caller);
- CHECK_HANDLEV(apm, 0);
+ webrtc::AudioProcessing* apm = GetHandle(env, caller);
+ CHECK_HANDLEV(apm, 0);
- webrtc::StreamConfig srcConfig = jni::AudioProcessingStreamConfig::toNative(env, jni::JavaLocalRef(env, inputConfig));
- webrtc::StreamConfig dstConfig = jni::AudioProcessingStreamConfig::toNative(env, jni::JavaLocalRef(env, outputConfig));
+ webrtc::StreamConfig srcConfig = jni::AudioProcessingStreamConfig::toNative(
+ env, jni::JavaLocalRef(env, inputConfig));
+ webrtc::StreamConfig dstConfig = jni::AudioProcessingStreamConfig::toNative(
+ env, jni::JavaLocalRef(env, outputConfig));
- jboolean isDstCopy = JNI_FALSE;
+ jboolean isDstCopy = JNI_FALSE;
- jbyte * srcPtr = env->GetByteArrayElements(src, NULL);
- jbyte * dstPtr = env->GetByteArrayElements(dest, &isDstCopy);
+ jbyte* srcPtr = env->GetByteArrayElements(src, nullptr);
+ jbyte* dstPtr = env->GetByteArrayElements(dest, &isDstCopy);
- const int16_t * srcFrame = reinterpret_cast(srcPtr);
- int16_t * dstFrame = reinterpret_cast(dstPtr);
+ auto srcFrame = reinterpret_cast(srcPtr);
+ auto dstFrame = reinterpret_cast(dstPtr);
- int result;
+ int result;
- if (srcConfig.num_channels() == 1 && dstConfig.num_channels() == 2) {
- // Up-mixing, only mono to stereo.
- // For complex channel layouts a channel mixer is required.
+ if (srcConfig.num_channels() == 1 && dstConfig.num_channels() == 2)
+ {
+ // Up-mixing, only mono to stereo.
+ // For complex channel layouts a channel mixer is required.
- const size_t srcNumSamples = srcConfig.num_samples();
- const size_t dstNumChannels = dstConfig.num_channels();
- const size_t frameSize = srcNumSamples * dstNumChannels;
+ const size_t srcNumSamples = srcConfig.num_samples();
+ const size_t dstNumChannels = dstConfig.num_channels();
+ const size_t frameSize = srcNumSamples * dstNumChannels;
- if (frameSize > webrtc::AudioFrame::kMaxDataSizeSamples) {
- return -9;
- }
+ if (frameSize > webrtc::AudioFrame::kMaxDataSizeSamples)
+ {
+ return -9;
+ }
- for (int i = static_cast(srcNumSamples) - 1; i >= 0; i--) {
- for (size_t j = 0; j < dstNumChannels; ++j) {
- dstFrame[dstNumChannels * i + j] = srcFrame[i];
- }
- }
+ for (int i = static_cast(srcNumSamples) - 1; i >= 0; i--)
+ {
+ for (size_t j = 0; j < dstNumChannels; ++j)
+ {
+ dstFrame[dstNumChannels * i + j] = srcFrame[i];
+ }
+ }
- srcConfig.set_num_channels(dstNumChannels);
+ srcConfig.set_num_channels(dstNumChannels);
- result = apm->ProcessStream(dstFrame, srcConfig, dstConfig, dstFrame);
- }
- else {
- // Will also down-mix if required, e.g. from stereo to mono.
- result = apm->ProcessStream(srcFrame, srcConfig, dstConfig, dstFrame);
- }
+ result = apm->ProcessStream(dstFrame, srcConfig, dstConfig, dstFrame);
+ }
+ else
+ {
+ // Will also down-mix if required, e.g. from stereo to mono.
+ result = apm->ProcessStream(srcFrame, srcConfig, dstConfig, dstFrame);
+ }
- if (isDstCopy == JNI_TRUE) {
- jsize dstLength = env->GetArrayLength(dest);
+ if (isDstCopy == JNI_TRUE)
+ {
+ jsize dstLength = env->GetArrayLength(dest);
- env->SetByteArrayRegion(dest, 0, dstLength, dstPtr);
- }
+ env->SetByteArrayRegion(dest, 0, dstLength, dstPtr);
+ }
- env->ReleaseByteArrayElements(src, srcPtr, JNI_ABORT);
- env->ReleaseByteArrayElements(dest, dstPtr, JNI_ABORT);
+ env->ReleaseByteArrayElements(src, srcPtr, JNI_ABORT);
+ env->ReleaseByteArrayElements(dest, dstPtr, JNI_ABORT);
- return result;
+ return result;
}
JNIEXPORT jint JNICALL Java_dev_onvoid_webrtc_media_audio_AudioProcessing_processReverseStream
-(JNIEnv * env, jobject caller, jbyteArray src, jobject inputConfig, jobject outputConfig, jbyteArray dest)
+(JNIEnv* env, jobject caller, jbyteArray src, jobject inputConfig, jobject outputConfig, jbyteArray dest)
{
- webrtc::AudioProcessing * apm = GetHandle(env, caller);
- CHECK_HANDLEV(apm, 0);
+ webrtc::AudioProcessing* apm = GetHandle(env, caller);
+ CHECK_HANDLEV(apm, 0);
- webrtc::StreamConfig srcConfig = jni::AudioProcessingStreamConfig::toNative(env, jni::JavaLocalRef(env, inputConfig));
- webrtc::StreamConfig dstConfig = jni::AudioProcessingStreamConfig::toNative(env, jni::JavaLocalRef(env, outputConfig));
+ webrtc::StreamConfig srcConfig = jni::AudioProcessingStreamConfig::toNative(
+ env, jni::JavaLocalRef(env, inputConfig));
+ webrtc::StreamConfig dstConfig = jni::AudioProcessingStreamConfig::toNative(
+ env, jni::JavaLocalRef(env, outputConfig));
- jboolean isDstCopy = JNI_FALSE;
+ jboolean isDstCopy = JNI_FALSE;
- jbyte * srcPtr = env->GetByteArrayElements(src, nullptr);
- jbyte * dstPtr = env->GetByteArrayElements(dest, &isDstCopy);
+ jbyte* srcPtr = env->GetByteArrayElements(src, nullptr);
+ jbyte* dstPtr = env->GetByteArrayElements(dest, &isDstCopy);
- const int16_t * srcFrame = reinterpret_cast(srcPtr);
- int16_t * dstFrame = reinterpret_cast(dstPtr);
+ auto srcFrame = reinterpret_cast(srcPtr);
+ auto dstFrame = reinterpret_cast(dstPtr);
- int result;
+ int result;
- if (srcConfig.num_channels() == 1 && dstConfig.num_channels() == 2) {
- // Up-mixing, only mono to stereo.
- // For complex channel layouts a channel mixer is required.
+ if (srcConfig.num_channels() == 1 && dstConfig.num_channels() == 2)
+ {
+ // Up-mixing, only mono to stereo.
+ // For complex channel layouts a channel mixer is required.
- const size_t srcNumSamples = srcConfig.num_samples();
- const size_t dstNumChannels = dstConfig.num_channels();
- const size_t frameSize = srcNumSamples * dstNumChannels;
+ const size_t srcNumSamples = srcConfig.num_samples();
+ const size_t dstNumChannels = dstConfig.num_channels();
+ const size_t frameSize = srcNumSamples * dstNumChannels;
- if (frameSize > webrtc::AudioFrame::kMaxDataSizeSamples) {
- return -9;
- }
+ if (frameSize > webrtc::AudioFrame::kMaxDataSizeSamples)
+ {
+ return -9;
+ }
- for (int i = static_cast(srcNumSamples) - 1; i >= 0; i--) {
- for (size_t j = 0; j < dstNumChannels; ++j) {
- dstFrame[dstNumChannels * i + j] = srcFrame[i];
- }
- }
+ for (int i = static_cast(srcNumSamples) - 1; i >= 0; i--)
+ {
+ for (size_t j = 0; j < dstNumChannels; ++j)
+ {
+ dstFrame[dstNumChannels * i + j] = srcFrame[i];
+ }
+ }
- srcConfig.set_num_channels(dstNumChannels);
+ srcConfig.set_num_channels(dstNumChannels);
- result = apm->ProcessReverseStream(dstFrame, srcConfig, dstConfig, dstFrame);
- }
- else {
- // Will also down-mix if required, e.g. from stereo to mono.
- result = apm->ProcessReverseStream(srcFrame, srcConfig, dstConfig, dstFrame);
- }
+ result = apm->ProcessReverseStream(dstFrame, srcConfig, dstConfig, dstFrame);
+ }
+ else
+ {
+ // Will also down-mix if required, e.g. from stereo to mono.
+ result = apm->ProcessReverseStream(srcFrame, srcConfig, dstConfig, dstFrame);
+ }
- if (isDstCopy == JNI_TRUE) {
- jsize dstLength = env->GetArrayLength(dest);
+ if (isDstCopy == JNI_TRUE)
+ {
+ jsize dstLength = env->GetArrayLength(dest);
- env->SetByteArrayRegion(dest, 0, dstLength, dstPtr);
- }
+ env->SetByteArrayRegion(dest, 0, dstLength, dstPtr);
+ }
- env->ReleaseByteArrayElements(src, srcPtr, JNI_ABORT);
- env->ReleaseByteArrayElements(dest, dstPtr, JNI_ABORT);
+ env->ReleaseByteArrayElements(src, srcPtr, JNI_ABORT);
+ env->ReleaseByteArrayElements(dest, dstPtr, JNI_ABORT);
- return result;
+ return result;
}
JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_media_audio_AudioProcessing_dispose
-(JNIEnv * env, jobject caller)
+(JNIEnv* env, jobject caller)
{
- webrtc::AudioProcessing * apm = GetHandle(env, caller);
- CHECK_HANDLE(apm);
+ webrtc::AudioProcessing* apm = GetHandle(env, caller);
+ CHECK_HANDLE(apm);
- rtc::RefCountReleaseStatus status = apm->Release();
+ rtc::RefCountReleaseStatus status = apm->Release();
- if (status != rtc::RefCountReleaseStatus::kDroppedLastRef) {
- RTC_LOG(LS_WARNING) << "Native object was not deleted. A reference is still around somewhere.";
- }
+ if (status != rtc::RefCountReleaseStatus::kDroppedLastRef)
+ {
+ RTC_LOG(LS_WARNING) << "Native object was not deleted. A reference is still around somewhere.";
+ }
- SetHandle(env, caller, nullptr);
+ SetHandle(env, caller, nullptr);
- apm = nullptr;
+ apm = nullptr;
}
JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_media_audio_AudioProcessing_initialize
-(JNIEnv * env, jobject caller)
+(JNIEnv* env, jobject caller)
{
- rtc::scoped_refptr apm = webrtc::AudioProcessingBuilder().Create();
+ rtc::scoped_refptr apm = webrtc::AudioProcessingBuilder().Create();
- if (!apm) {
- env->Throw(jni::JavaError(env, "Create AudioProcessing failed"));
- return;
- }
+ if (!apm)
+ {
+ env->Throw(jni::JavaError(env, "Create AudioProcessing failed"));
+ return;
+ }
- SetHandle(env, caller, apm.release());
+ SetHandle(env, caller, apm.release());
+}
+
+JNIEXPORT void JNICALL
+Java_dev_onvoid_webrtc_media_audio_AudioProcessing_initialize__IIILdev_onvoid_webrtc_media_audio_ChannelLayout_2Ldev_onvoid_webrtc_media_audio_ChannelLayout_2Ldev_onvoid_webrtc_media_audio_ChannelLayout_2
+(JNIEnv* env, jobject caller, jint capture_input_sample_rate_hz, jint capture_output_sample_rate_hz,
+ jint render_sample_rate_hz, jobject capture_input_layout, jobject capture_output_layout, jobject render_input_layout)
+{
+ rtc::scoped_refptr apm = webrtc::AudioProcessingBuilder().Create();
+
+ apm->Initialize(capture_input_sample_rate_hz, capture_output_sample_rate_hz, render_sample_rate_hz,
+ jni::JavaEnums::toNative(env, capture_input_layout),
+ jni::JavaEnums::toNative(env, capture_output_layout),
+ jni::JavaEnums::toNative(env, render_input_layout));
+
+ if (!apm)
+ {
+ env->Throw(jni::JavaError(env, "Create AudioProcessing failed"));
+ return;
+ }
+
+ SetHandle(env, caller, apm.release());
+}
+
+JNIEXPORT void JNICALL
+Java_dev_onvoid_webrtc_media_audio_AudioProcessing_initialize__Ldev_onvoid_webrtc_media_audio_ProcessingConfig_2
+(JNIEnv* env, jobject caller, jobject jconfig)
+{
+ rtc::scoped_refptr apm = webrtc::AudioProcessingBuilder().Create();
+ webrtc::ProcessingConfig* config = GetHandle(env, jconfig);
+ apm->Initialize(*config);
+
+ if (!apm)
+ {
+ env->Throw(jni::JavaError(env, "Create AudioProcessing failed"));
+ return;
+ }
+
+ SetHandle(env, caller, apm.release());
}
JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_media_audio_AudioProcessing_updateStats
(JNIEnv* env, jobject caller)
{
- webrtc::AudioProcessing * apm = GetHandle(env, caller);
- CHECK_HANDLE(apm);
+ webrtc::AudioProcessing* apm = GetHandle(env, caller);
+ CHECK_HANDLE(apm);
- jni::AudioProcessing::updateStats(apm->GetStatistics(), env, jni::JavaLocalRef(env, caller));
-}
\ No newline at end of file
+ jni::AudioProcessing::updateStats(apm->GetStatistics(), env, jni::JavaLocalRef(env, caller));
+}
diff --git a/webrtc-jni/src/main/cpp/src/JNI_AudioResampler.cpp b/webrtc-jni/src/main/cpp/src/JNI_AudioResampler.cpp
index e5989b05..9d567c1c 100644
--- a/webrtc-jni/src/main/cpp/src/JNI_AudioResampler.cpp
+++ b/webrtc-jni/src/main/cpp/src/JNI_AudioResampler.cpp
@@ -23,54 +23,56 @@
#include "common_audio/resampler/include/push_resampler.h"
JNIEXPORT void JNICALL Java_dev_onvoid_webrtc_media_audio_AudioResampler_dispose
-(JNIEnv * env, jobject caller)
+(JNIEnv* env, jobject caller)
{
- webrtc::PushResampler * resampler = GetHandle>(env, caller);
- CHECK_HANDLE(resampler);
+ webrtc::PushResampler* resampler = GetHandle>(env, caller);
+ CHECK_HANDLE(resampler);
- delete resampler;
+ delete resampler;
- SetHandle