Skip to content

Commit c5cb7a2

Browse files
committed
add AudioEffectBridge
1 parent d460f67 commit c5cb7a2

14 files changed

+696
-230
lines changed

Diff for: rtc/build.gradle

+5-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ android {
1313
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1414
}
1515

16+
viewBinding {
17+
enabled = true
18+
}
19+
1620
buildTypes {
1721
release {
1822
minifyEnabled false
@@ -32,7 +36,7 @@ dependencies {
3236
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
3337

3438
implementation "io.agora.rtc:full-rtc-basic:3.7.1"
35-
implementation 'com.aliyun.ams:alicloud-android-httpdns:1.2.5'
39+
// implementation "io.agora.rtc:full-sdk:4.2.2"
3640
implementation 'androidx.appcompat:appcompat:1.2.0'
3741

3842
// test

Diff for: rtc/src/main/AndroidManifest.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
</activity>
3434
<activity
3535
android:name=".MainRtcActivity"
36-
android:screenOrientation="landscape">
36+
android:screenOrientation="landscape"
37+
android:theme="@style/AppTheme.NoActionBar">
3738

3839
</activity>
3940
</application>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
package com.herewhite.rtc.demo;
2+
3+
import android.util.Log;
4+
5+
import com.herewhite.sdk.AudioEffectBridge;
6+
7+
import io.agora.rtc.IAudioEffectManager;
8+
import io.agora.rtc.RtcEngine;
9+
10+
public class AgoraAudioEffectBridge implements AudioEffectBridge {
11+
private String TAG = "AgoraAudioEffectBridge";
12+
13+
private final IAudioEffectManager audioEffectManager;
14+
15+
public AgoraAudioEffectBridge(RtcEngine rtcEngine) {
16+
this.audioEffectManager = rtcEngine.getAudioEffectManager();
17+
}
18+
19+
@Override
20+
public double getEffectsVolume() {
21+
return audioEffectManager.getEffectsVolume();
22+
}
23+
24+
@Override
25+
public int setEffectsVolume(double volume) {
26+
Log.i(TAG, "setEffectsVolume: " + volume);
27+
return audioEffectManager.setEffectsVolume(volume);
28+
}
29+
30+
@Override
31+
public int setVolumeOfEffect(int soundId, double volume) {
32+
Log.i(TAG, "setVolumeOfEffect: " + soundId + " " + volume);
33+
return audioEffectManager.setVolumeOfEffect(soundId, volume);
34+
}
35+
36+
@Override
37+
public int playEffect(int soundId, String filePath, int loopCount, double pitch, double pan, double gain, boolean publish, int startPos) {
38+
Log.i(TAG, "playEffect: " + soundId + " " + filePath + " " + loopCount + " " + pitch + " " + pan + " " + gain + " " + publish + " " + startPos);
39+
return audioEffectManager.playEffect(soundId, filePath, loopCount, pitch, pan, gain, publish, startPos);
40+
}
41+
42+
@Override
43+
public int stopEffect(int soundId) {
44+
Log.i(TAG, "stopEffect: " + soundId);
45+
return audioEffectManager.stopEffect(soundId);
46+
}
47+
48+
@Override
49+
public int stopAllEffects() {
50+
Log.i(TAG, "stopAllEffects: ");
51+
return audioEffectManager.stopAllEffects();
52+
}
53+
54+
@Override
55+
public int preloadEffect(int soundId, String filePath, int startPos) {
56+
Log.i(TAG, "preloadEffect: " + soundId + " " + filePath + " " + startPos);
57+
return audioEffectManager.preloadEffect(soundId, filePath);
58+
}
59+
60+
@Override
61+
public int unloadEffect(int soundId) {
62+
Log.i(TAG, "unloadEffect: " + soundId);
63+
return audioEffectManager.unloadEffect(soundId);
64+
}
65+
66+
@Override
67+
public int pauseEffect(int soundId) {
68+
Log.i(TAG, "pauseEffect: " + soundId);
69+
return audioEffectManager.pauseEffect(soundId);
70+
}
71+
72+
@Override
73+
public int pauseAllEffects() {
74+
Log.i(TAG, "pauseAllEffects: ");
75+
return audioEffectManager.pauseAllEffects();
76+
}
77+
78+
@Override
79+
public int resumeEffect(int soundId) {
80+
Log.i(TAG, "resumeEffect: " + soundId);
81+
return audioEffectManager.resumeEffect(soundId);
82+
}
83+
84+
@Override
85+
public int resumeAllEffects() {
86+
Log.i(TAG, "resumeAllEffects: ");
87+
return audioEffectManager.resumeAllEffects();
88+
}
89+
90+
@Override
91+
public int getEffectDuration(String filePath) {
92+
Log.i(TAG, "getEffectDuration: " + filePath);
93+
return audioEffectManager.getEffectDuration(filePath);
94+
}
95+
96+
@Override
97+
public int setEffectPosition(int soundId, int pos) {
98+
Log.i(TAG, "setEffectPosition: " + soundId + " " + pos);
99+
return audioEffectManager.setEffectPosition(soundId, pos);
100+
}
101+
102+
@Override
103+
public int getEffectCurrentPosition(int soundId) {
104+
// Log.i(TAG, "getEffectCurrentPosition: " + soundId);
105+
return audioEffectManager.getEffectCurrentPosition(soundId);
106+
}
107+
}

Diff for: rtc/src/main/java/com/herewhite/rtc/demo/AudioMixerBridgeImpl.java renamed to rtc/src/main/java/com/herewhite/rtc/demo/AgoraAudioMixerBridge.java

+8-7
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,24 @@
99
/**
1010
* 用户需要自己实现 rtc 混音逻辑
1111
*/
12-
public class AudioMixerBridgeImpl implements AudioMixerBridge {
13-
public static final String TAG = AudioMixerBridgeImpl.class.getSimpleName();
12+
public class AgoraAudioMixerBridge implements AudioMixerBridge {
13+
public static final String TAG = AgoraAudioMixerBridge.class.getSimpleName();
14+
public static final int AUDIO_MIXING_STATE_FAILED = 714;
1415

1516
private RtcEngine rtcEngine;
16-
private ResultCallback callback;
17+
private ResultCallback resultCallback;
1718

18-
public AudioMixerBridgeImpl(RtcEngine rtcEngine, ResultCallback callback) {
19+
public AgoraAudioMixerBridge(RtcEngine rtcEngine, ResultCallback resultCallback) {
1920
this.rtcEngine = rtcEngine;
20-
this.callback = callback;
21+
this.resultCallback = resultCallback;
2122
}
2223

2324
@Override
2425
public void startAudioMixing(String filepath, boolean loopback, boolean replace, int cycle) {
2526
int code = rtcEngine.startAudioMixing(filepath, loopback, replace, cycle);
2627
Log.d(TAG, "rtcMix startAudioMixing " + filepath + " " + code);
2728
if (code != 0) {
28-
onMediaStateChanged(714, code);
29+
onMediaStateChanged(AUDIO_MIXING_STATE_FAILED, code);
2930
}
3031
}
3132

@@ -67,7 +68,7 @@ public void resumeAudioMixing() {
6768

6869
private void onMediaStateChanged(int state, int code) {
6970
Log.d(TAG, "rtcMix onMediaStateChanged " + code);
70-
callback.onMediaStateChanged(state, code);
71+
resultCallback.onMediaStateChanged(state, code);
7172
}
7273

7374
public interface ResultCallback {

0 commit comments

Comments
 (0)