Skip to content

Commit bbfb0c1

Browse files
authored
Merge pull request #143 from AgoraIO/dev/3.3.1
Dev/3.3.1
2 parents 356abeb + 31ab164 commit bbfb0c1

43 files changed

Lines changed: 736 additions & 401 deletions

File tree

Some content is hidden

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

Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/ARCore.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.agora.api.example.examples.advanced;
22

3+
import android.annotation.TargetApi;
34
import android.content.Context;
45
import android.graphics.Bitmap;
56
import android.opengl.GLES20;
@@ -747,12 +748,18 @@ public void onDrawFrame(GL10 gl10) {
747748
mVirtualObject.draw(viewmtx, projmtx, lightIntensity);
748749
mVirtualObjectShadow.draw(viewmtx, projmtx, lightIntensity);
749750
}
750-
751-
sendARViewMessage();
751+
sendmessage();
752752

753753
} catch (Throwable t) {
754754
// Avoid crashing the application due to unhandled exceptions.
755755
Log.e(TAG, "Exception on the OpenGL thread", t);
756756
}
757757
}
758+
759+
@TargetApi(24)
760+
private void sendmessage(){
761+
sendARViewMessage();
762+
}
763+
764+
758765
}

Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/SendDataStream.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ public void onStreamMessage(int uid, int streamId, byte[] data) {
470470
handler.post(new Runnable() {
471471
@Override
472472
public void run() {
473-
Toast.makeText(getContext(), String.format(getString(R.string.received), string), 300).show();
473+
Toast.makeText(getContext(), String.format(getString(R.string.received), string), Toast.LENGTH_LONG).show();
474474
}
475475
});
476476
Log.i(TAG, "onStreamMessage:" + data);

Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/VideoMetadata.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ public byte[] onReadyToSendMetadata(long timeStampMs)
302302
handler.post(new Runnable() {
303303
@Override
304304
public void run() {
305-
Toast.makeText(getContext(), String.format(getString(R.string.sent), data), 300).show();
305+
Toast.makeText(getContext(), String.format(getString(R.string.sent), data), Toast.LENGTH_LONG).show();
306306
}
307307
});
308308
Log.i(TAG, String.format("Metadata sent successfully! The content is %s", data));
@@ -320,7 +320,7 @@ public void onMetadataReceived(byte[] buffer, int uid, long timeStampMs)
320320
handler.post(new Runnable() {
321321
@Override
322322
public void run() {
323-
Toast.makeText(getContext(), String.format(getString(R.string.received), data), 300).show();
323+
Toast.makeText(getContext(), String.format(getString(R.string.received), data), Toast.LENGTH_LONG).show();
324324
}
325325
});
326326
Log.i(TAG, "onMetadataReceived:" + data);

Android/APIExample/app/src/main/java/io/agora/api/example/examples/advanced/VoiceEffects.java

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public class VoiceEffects extends BaseFragment implements View.OnClickListener,
5050
private RtcEngine engine;
5151
private int myUid;
5252
private boolean joined = false;
53-
private Spinner preset, beautifier, pitch1, pitch2;
53+
private Spinner preset, beautifier, pitch1, pitch2, conversion;
5454
private PopupWindow popupWindow;
5555
private Switch effectOption;
5656
private SeekBar voiceCircle;
@@ -79,8 +79,10 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
7979
view.findViewById(R.id.btn_join).setOnClickListener(this);
8080
preset = view.findViewById(R.id.audio_preset_spinner);
8181
beautifier = view.findViewById(R.id.voice_beautifier_spinner);
82+
conversion = view.findViewById(R.id.voice_conversion_spinner);
8283
preset.setOnItemSelectedListener(this);
8384
beautifier.setOnItemSelectedListener(this);
85+
conversion.setOnItemSelectedListener(this);
8486
effectOptions = view.findViewById(R.id.btn_effect_options);
8587
effectOptions.setOnClickListener(this);
8688
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
@@ -99,6 +101,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
99101
effectOptions.setEnabled(false);
100102
preset.setEnabled(false);
101103
beautifier.setEnabled(false);
104+
conversion.setEnabled(false);
102105
}
103106

104107
@Override
@@ -173,6 +176,7 @@ public void onClick(View v)
173176
joined = false;
174177
preset.setEnabled(false);
175178
beautifier.setEnabled(false);
179+
conversion.setEnabled(false);
176180
effectOptions.setEnabled(false);
177181
/**After joining a channel, the user must call the leaveChannel method to end the
178182
* call before joining another channel. This method returns 0 if the user leaves the
@@ -349,6 +353,7 @@ public void onJoinChannelSuccess(String channel, int uid, int elapsed)
349353
handler.post(() -> {
350354
join.setEnabled(true);
351355
join.setText(getString(R.string.leave));
356+
conversion.setEnabled(true);
352357
preset.setEnabled(true);
353358
beautifier.setEnabled(true);
354359
effectOptions.setEnabled(true);
@@ -434,6 +439,26 @@ else if(parent.getId() == R.id.voice_beautifier_spinner){
434439
String item = beautifier.getSelectedItem().toString();
435440
engine.setVoiceBeautifierPreset(getVoiceBeautifierValue(item));
436441
}
442+
else if(parent.getId() == R.id.voice_conversion_spinner){
443+
String item = conversion.getSelectedItem().toString();
444+
engine.setVoiceConversionPreset(getVoiceConversionValue(item));
445+
}
446+
}
447+
448+
private int getVoiceConversionValue(String label) {
449+
switch (label) {
450+
case "VOICE_CHANGER_NEUTRAL":
451+
return VOICE_CHANGER_NEUTRAL;
452+
case "VOICE_CHANGER_SWEET":
453+
return VOICE_CHANGER_SWEET;
454+
case "VOICE_CHANGER_SOLID":
455+
return VOICE_CHANGER_SOLID;
456+
case "VOICE_CHANGER_BASS":
457+
return VOICE_CHANGER_BASS;
458+
case "VOICE_CONVERSION_OFF":
459+
default:
460+
return VOICE_CONVERSION_OFF;
461+
}
437462
}
438463

439464
private int getVoiceBeautifierValue(String label) {

Android/APIExample/app/src/main/res/layout/fragment_voice_effects.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@
55
android:layout_height="match_parent"
66
tools:context=".examples.advanced.VoiceEffects">
77

8+
<Spinner
9+
android:id="@+id/voice_conversion_spinner"
10+
android:layout_width="match_parent"
11+
android:layout_height="48dp"
12+
android:layout_above="@id/audio_preset_spinner"
13+
android:layout_marginBottom="16dp"
14+
android:entries="@array/voiceConversion"
15+
android:hint="Select an Voice Conversion Preset"
16+
android:spinnerMode="dropdown" />
17+
818
<Spinner
919
android:id="@+id/audio_preset_spinner"
1020
android:layout_width="match_parent"

Android/APIExample/app/src/main/res/values/arrays.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@
2525
<item>JP</item>
2626
<item>IN</item>
2727
</string-array>
28+
<string-array name="voiceConversion">
29+
<item>VOICE_CONVERSION_OFF</item>
30+
<item>VOICE_CHANGER_NEUTRAL</item>
31+
<item>VOICE_CHANGER_SWEET</item>
32+
<item>VOICE_CHANGER_SOLID</item>
33+
<item>VOICE_CHANGER_BASS</item>
34+
</string-array>
2835
<string-array name="audioPreset">
2936
<item>ROOM_ACOUSTICS_KTV</item>
3037
<item>ROOM_ACOUSTICS_VOCAL_CONCERT</item>
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
3-
<!-- <string name="agora_app_id" translatable="false">YOUR APP ID</string>-->
4-
<!-- <string name="agora_access_token" translatable="false">YOUR ACCESS TOKEN</string>-->
53
<string name="agora_app_id" translatable="false">YOUR APP ID</string>
64
<string name="agora_access_token" translatable="false">YOUR ACCESS TOKEN</string>
75
</resources>

Android/APIExample/gradlew

100644100755
File mode changed.

Android/APIExample/lib-component/build.gradle

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,14 @@ android {
2323
}
2424

2525
dependencies {
26-
implementation fileTree(dir: 'libs', include: ['*.jar'])
26+
api fileTree(dir: 'libs', include: ['*.jar'])
2727

2828
implementation 'androidx.appcompat:appcompat:1.1.0'
2929
testImplementation 'junit:junit:4.12'
3030
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
3131
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
3232

33-
34-
// api 'io.agora.rtc:full-sdk:2.9.0.104'
35-
// api 'io.agora.rtc:full-sdk:3.0.0'
36-
// api 'io.agora.rtc:full-sdk:3.1.2'
37-
38-
api 'io.agora.rtc:full-sdk:3.3.0'
33+
api 'io.agora.rtc:full-sdk:3.3.1'
3934
api 'io.agora:agoraplayer:1.2.2'
4035

4136
}

Android/APIExample/lib-switch-external-video/src/main/java/io/agora/advancedvideo/externvideosource/ExternalVideoInputManager.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
import io.agora.api.component.gles.ProgramTextureOES;
1919
import io.agora.api.component.gles.core.EglCore;
2020
import io.agora.api.component.gles.core.GlUtil;
21+
import io.agora.rtc.gl.TextureTransformer;
2122
import io.agora.rtc.mediaio.IVideoFrameConsumer;
2223
import io.agora.rtc.mediaio.IVideoSource;
2324
import io.agora.rtc.mediaio.MediaIO;
2425

25-
import static android.media.MediaRecorder.VideoSource.CAMERA;
2626
import static io.agora.api.component.Constant.ENGINE;
2727
import static io.agora.api.component.Constant.TEXTUREVIEW;
2828
import static io.agora.rtc.mediaio.MediaIO.BufferType.TEXTURE;
@@ -67,6 +67,8 @@ public class ExternalVideoInputManager implements IVideoSource {
6767
private volatile IVideoFrameConsumer mConsumer;
6868

6969
private Context context;
70+
private TextureTransformer textureTransformer;
71+
private static final int MAX_TEXTURE_COPY = 1;
7072

7173
public ExternalVideoInputManager(Context context) {
7274
this.context = context;
@@ -85,6 +87,7 @@ boolean setExternalVideoInput(int type, Intent intent) {
8587
return false;
8688
}
8789

90+
type = TYPE_SCREEN_SHARE;
8891
IExternalVideoInput input;
8992
switch (type) {
9093
case TYPE_LOCAL_VIDEO:
@@ -221,6 +224,7 @@ private void prepare() {
221224
mThreadContext.eglCore = mEglCore;
222225
mThreadContext.context = mEglCore.getEGLContext();
223226
mThreadContext.program = new ProgramTextureOES();
227+
textureTransformer = new TextureTransformer(MAX_TEXTURE_COPY);
224228
/**Customizes the video source.
225229
* Call this method to add an external video source to the SDK.*/
226230
ENGINE.setVideoSource(ExternalVideoInputManager.this);
@@ -231,6 +235,7 @@ private void release() {
231235
return;
232236
}
233237
/**release external video source*/
238+
textureTransformer.release();
234239
ENGINE.setVideoSource(null);
235240
mSurface.release();
236241
mEglCore.makeNothingCurrent();
@@ -322,6 +327,7 @@ public void run() {
322327
* @param rotation Clockwise rotating angle (0, 90, 180, and 270 degrees) of the video frame
323328
* @param timestamp Timestamp of the video frame. For each video frame, you need to set a timestamp
324329
* @param matrix Matrix of the texture. The float value is between 0 and 1, such as 0.1, 0.2, and so on*/
330+
textureTransformer.copy(mTextureId, TEXTURE_OES.intValue(), mVideoWidth, mVideoHeight);
325331
mConsumer.consumeTextureFrame(mTextureId,
326332
TEXTURE_OES.intValue(),
327333
mVideoWidth, mVideoHeight, 0,

0 commit comments

Comments
 (0)