Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit bbc017b

Browse files
author
chenyouwei
committed
feat:集成webrtc 降噪和增益模块
1 parent f139ddd commit bbc017b

File tree

99 files changed

+15986
-3808
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+15986
-3808
lines changed

‎libwebrtc/CMakeLists.txt‎

Lines changed: 0 additions & 60 deletions
This file was deleted.

‎libwebrtc/build.gradle‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ android {
3838

3939
externalNativeBuild {
4040
cmake {
41-
path "CMakeLists.txt"
41+
path "src/main/cpp/CMakeLists.txt"
4242
}
4343
}
4444
}
@@ -52,4 +52,5 @@ dependencies {
5252
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
5353
implementation "io.reactivex.rxjava2:rxjava:2.1.12"
5454
implementation "io.reactivex.rxjava2:rxandroid:2.0.2"
55+
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
5556
}

‎libwebrtc/src/main/AndroidManifest.xml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
package="com.hugh.libwebrtc" >
33
<application >
44
<activity android:name=".RtcActivity"/>
5+
<activity android:name=".AFRtcMainActivity"/>
56
</application>
67
</manifest>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
cmake_minimum_required(VERSION 3.4.1)
2+
add_subdirectory(legacy_ns)
3+
add_subdirectory(legacy_agc)

‎libwebrtc/src/main/cpp/_android_log_print.h‎

Lines changed: 0 additions & 37 deletions
This file was deleted.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
cmake_minimum_required(VERSION 3.4.1)
2+
3+
file(GLOB SRC_FILES
4+
*/*.cc
5+
*/*/*.c
6+
*/*/*.cc
7+
*/*/*/*/*.c
8+
agc-lib.cpp
9+
)
10+
11+
add_library(legacy_agc-lib SHARED ${SRC_FILES})
12+
include_directories(./)
13+
add_definitions(
14+
-DWEBRTC_ANDROID
15+
-DWEBRTC_POSIX
16+
)
17+
18+
find_library(log-lib log)
19+
20+
target_link_libraries(legacy_agc-lib ${log-lib})
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
#include <jni.h>
2+
#include <string>
3+
#include <cstdlib>
4+
5+
#include "modules/audio_processing/agc/legacy/gain_control.h"
6+
7+
#if defined(__cplusplus)
8+
extern "C" {
9+
#endif
10+
11+
JNIEXPORT jlong JNICALL
12+
Java_com_hugh_libwebrtc_WebRtcAGCUtils_WebRtcAgc_1Create(JNIEnv *env, jobject obj) {
13+
return (long) WebRtcAgc_Create();
14+
}
15+
16+
17+
JNIEXPORT jint JNICALL
18+
Java_com_hugh_libwebrtc_WebRtcAGCUtils_agcFree(JNIEnv *env, jobject obj,
19+
jlong agcInst) {
20+
void *_agcInst = (void *) agcInst;
21+
if (_agcInst == nullptr)
22+
return -3;
23+
WebRtcAgc_Free(_agcInst);
24+
return 0;
25+
}
26+
27+
JNIEXPORT jint JNICALL
28+
Java_com_hugh_libwebrtc_WebRtcAGCUtils_WebRtcAgc_1Init(JNIEnv *env,
29+
jobject obj, jlong agcInst,
30+
jint minLevel, jint maxLevel,
31+
jint agcMode, jint fs) {
32+
void *_agcInst = (void *) agcInst;
33+
if (_agcInst == nullptr)
34+
return -3;
35+
return WebRtcAgc_Init(_agcInst, minLevel, maxLevel, agcMode, fs);
36+
}
37+
38+
JNIEXPORT jint JNICALL
39+
Java_com_hugh_libwebrtc_WebRtcAGCUtils_agcSetConfig(JNIEnv *env, jobject obj,
40+
jlong agcInst,
41+
jshort targetLevelDbfs,
42+
jshort compressionGaindB,
43+
jboolean limiterEnable
44+
) {
45+
void *_agcInst = (void *) agcInst;
46+
if (_agcInst == nullptr)
47+
return -3;
48+
WebRtcAgcConfig setConfig;
49+
setConfig.targetLevelDbfs = targetLevelDbfs;
50+
setConfig.compressionGaindB = compressionGaindB;
51+
setConfig.limiterEnable = limiterEnable;
52+
return WebRtcAgc_set_config(_agcInst, setConfig);
53+
}
54+
55+
JNIEXPORT jint JNICALL
56+
Java_com_hugh_libwebrtc_WebRtcAGCUtils_agcProcess(JNIEnv *env, jobject obj,
57+
jlong agcInst,
58+
jshortArray inNear,
59+
jint num_bands,
60+
jint samples, jshortArray out,
61+
jint inMicLevel,
62+
jint outMicLevel,
63+
jint echo,
64+
jboolean saturationWarning) {
65+
void *_agcInst = (void *) agcInst;
66+
if (_agcInst == nullptr)
67+
return -3;
68+
jshort *cinNear = env->GetShortArrayElements(inNear, nullptr);
69+
jshort *cout = env->GetShortArrayElements(out, nullptr);
70+
71+
int32_t gains[11] = {};
72+
jint ret = WebRtcAgc_Analyze(_agcInst, &cinNear, num_bands, samples, inMicLevel, &outMicLevel,
73+
echo, &saturationWarning, gains);
74+
if (ret == 0)
75+
ret = WebRtcAgc_Process(_agcInst, gains, &cinNear, num_bands, &cout);
76+
env->ReleaseShortArrayElements(inNear, cinNear, 0);
77+
env->ReleaseShortArrayElements(out, cout, 0);
78+
return ret;
79+
}
80+
81+
82+
JNIEXPORT jint JNICALL
83+
Java_com_hugh_libwebrtc_WebRtcAGCUtils_agcAddFarend(JNIEnv *env, jobject obj,
84+
jlong agcInst,
85+
jshortArray inFar,
86+
jint samples) {
87+
void *_agcInst = (void *) agcInst;
88+
if (_agcInst == nullptr)
89+
return -3;
90+
short *cinFar = env->GetShortArrayElements(inFar, nullptr);
91+
jint ret = WebRtcAgc_AddFarend(_agcInst, cinFar, samples);
92+
env->ReleaseShortArrayElements(inFar, cinFar, 0);
93+
return ret;
94+
}
95+
96+
97+
JNIEXPORT jint JNICALL
98+
Java_com_hugh_libwebrtc_WebRtcAGCUtils_agcAddMic(JNIEnv *env, jobject obj,
99+
jlong agcInst,
100+
jshortArray inMic,
101+
jint num_bands, jint samples
102+
) {
103+
void *_agcInst = (void *) agcInst;
104+
if (_agcInst == nullptr)
105+
return -3;
106+
short *cinMic = env->GetShortArrayElements(inMic, nullptr);
107+
jint ret = WebRtcAgc_AddMic(_agcInst, &cinMic, num_bands, samples);
108+
env->ReleaseShortArrayElements(inMic, cinMic, 0);
109+
return ret;
110+
}
111+
112+
113+
JNIEXPORT jint JNICALL
114+
Java_com_hugh_libwebrtc_WebRtcAGCUtils_agcVirtualMic(JNIEnv *env, jobject obj,
115+
jlong agcInst,
116+
jshortArray inMic,
117+
jint num_bands,
118+
jint samples,
119+
jint micLevelIn,
120+
jint micLevelOut
121+
) {
122+
void *_agcInst = (void *) agcInst;
123+
if (_agcInst == nullptr)
124+
return -3;
125+
jshort *cinMic = env->GetShortArrayElements(inMic, nullptr);
126+
jint ret = WebRtcAgc_VirtualMic(_agcInst, &cinMic, num_bands, samples, micLevelIn,
127+
&micLevelOut);
128+
env->ReleaseShortArrayElements(inMic, cinMic, 0);
129+
return ret;
130+
}
131+
132+
133+
#if defined(__cplusplus)
134+
}
135+
#endif
136+
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
3+
*
4+
* Use of this source code is governed by a BSD-style license
5+
* that can be found in the LICENSE file in the root of the source
6+
* tree. An additional intellectual property rights grant can be found
7+
* in the file PATENTS. All contributing project authors may
8+
* be found in the AUTHORS file in the root of the source tree.
9+
*/
10+
11+
12+
/*
13+
* This file contains the implementation of functions
14+
* WebRtcSpl_MemSetW16()
15+
* WebRtcSpl_MemSetW32()
16+
* WebRtcSpl_MemCpyReversedOrder()
17+
* WebRtcSpl_CopyFromEndW16()
18+
* WebRtcSpl_ZerosArrayW16()
19+
* WebRtcSpl_ZerosArrayW32()
20+
*
21+
* The description header can be found in signal_processing_library.h
22+
*
23+
*/
24+
25+
#include <string.h>
26+
#include "common_audio/signal_processing/include/signal_processing_library.h"
27+
28+
29+
void WebRtcSpl_MemSetW16(int16_t *ptr, int16_t set_value, size_t length) {
30+
size_t j;
31+
int16_t *arrptr = ptr;
32+
33+
for (j = length; j > 0; j--) {
34+
*arrptr++ = set_value;
35+
}
36+
}
37+
38+
void WebRtcSpl_MemSetW32(int32_t *ptr, int32_t set_value, size_t length) {
39+
size_t j;
40+
int32_t *arrptr = ptr;
41+
42+
for (j = length; j > 0; j--) {
43+
*arrptr++ = set_value;
44+
}
45+
}
46+
47+
void WebRtcSpl_MemCpyReversedOrder(int16_t *dest,
48+
int16_t *source,
49+
size_t length) {
50+
size_t j;
51+
int16_t *destPtr = dest;
52+
int16_t *sourcePtr = source;
53+
54+
for (j = 0; j < length; j++) {
55+
*destPtr-- = *sourcePtr++;
56+
}
57+
}
58+
59+
void WebRtcSpl_CopyFromEndW16(const int16_t *vector_in,
60+
size_t length,
61+
size_t samples,
62+
int16_t *vector_out) {
63+
// Copy the last <samples> of the input vector to vector_out
64+
WEBRTC_SPL_MEMCPY_W16(vector_out, &vector_in[length - samples], samples);
65+
}
66+
67+
void WebRtcSpl_ZerosArrayW16(int16_t *vector, size_t length) {
68+
WebRtcSpl_MemSetW16(vector, 0, length);
69+
}
70+
71+
void WebRtcSpl_ZerosArrayW32(int32_t *vector, size_t length) {
72+
WebRtcSpl_MemSetW32(vector, 0, length);
73+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /