Skip to content

Commit

Permalink
Merge pull request #91 from OurEra/master
Browse files Browse the repository at this point in the history
Release for v5.2.4
  • Loading branch information
OurEra authored Aug 17, 2023
2 parents b015fcb + 54b77f3 commit aeec173
Show file tree
Hide file tree
Showing 41 changed files with 172 additions and 67 deletions.
4 changes: 2 additions & 2 deletions QNDroidRTCDemo/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ android {
applicationId "com.qiniu.droid.rtc.demo"
minSdkVersion 18
targetSdkVersion 30
versionCode 43
versionName "5.2.3"
versionCode 44
versionName "5.2.4"
buildConfigField "long", "BUILD_TIMESTAMP", System.currentTimeMillis() + "L"
}

Expand Down
Binary file removed QNDroidRTCDemo/app/libs/qndroid-rtc-5.2.3.jar
Binary file not shown.
Binary file added QNDroidRTCDemo/app/libs/qndroid-rtc-5.2.4.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
import com.qiniu.droid.rtc.demo.utils.Utils;
import com.qiniu.droid.rtc.model.QNAudioDevice;

import org.webrtc.Size;
import org.qnwebrtc.Size;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -408,10 +408,6 @@ private void initClient() {
SharedPreferences preferences = getSharedPreferences(getString(R.string.app_name), Context.MODE_PRIVATE);
boolean isHwCodec = preferences.getInt(Config.CODEC_MODE, Config.SW) == Config.HW;

/**
* 如果您的使用场景需要双讲,建议 QNRTCSetting#setAEC3Enabled 为 true 以防止出现对讲回声
*/
boolean isAec3Enabled = preferences.getBoolean(Config.AEC3_ENABLE, true);
/**
* 设置音频场景,不同的音频场景,系统音量模式是不一样的
*/
Expand All @@ -428,7 +424,6 @@ private void initClient() {

QNRTCSetting setting = new QNRTCSetting();
setting.setHWCodecEnabled(isHwCodec)
.setAEC3Enabled(isAec3Enabled)
.setAudioScene(audioScene);
QNRTC.init(this, setting, mRTCEventListener);
mClient = QNRTC.createClient(mClientEventListener);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public class SettingActivity extends AppCompatActivity {
private int mEncodeMode = 0;
private int mSampleRatePos = 0;
private int mAudioScenePos = 0;
private boolean mIsAec3Enabled = false;
private final List<String> mVideoDefaultConfiguration = new ArrayList<>();
private ArrayAdapter<String> mVideoConfigAdapter;
private SpinnerPopupWindow mVideoConfigPopupWindow;
Expand Down Expand Up @@ -85,8 +84,6 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
RadioButton soundEqualizeAudioSceneBtn = findViewById(R.id.sound_equalize_audio_scene);

mAppIdEditText = findViewById(R.id.app_id_edit_text);
SwitchCompat aec3Switch = findViewById(R.id.webrtc_aec3_enable_btn);
aec3Switch.setOnCheckedChangeListener((buttonView, isChecked) -> mIsAec3Enabled = isChecked);

versionCodeTextView.setText(String.format(getString(R.string.version_code), getVersionDescription(), getBuildTimeDescription(), getSdkVersion()));

Expand Down Expand Up @@ -135,9 +132,6 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
soundEqualizeAudioSceneBtn.setChecked(true);
}

mIsAec3Enabled = preferences.getBoolean(Config.AEC3_ENABLE, true);
aec3Switch.setChecked(mIsAec3Enabled);

mVideoConfigPopupWindow = new SpinnerPopupWindow(this);
mVideoConfigPopupWindow.setOnSpinnerItemClickListener(pos -> {
mVideoConfigSelectPos = pos;
Expand Down Expand Up @@ -207,7 +201,6 @@ public void onClickSaveConfiguration(View v) {
editor.putInt(Config.CODEC_MODE, mEncodeMode);
editor.putInt(Config.SAMPLE_RATE, mSampleRatePos);
editor.putInt(Config.AUDIO_SCENE, mAudioScenePos);
editor.putBoolean(Config.AEC3_ENABLE, mIsAec3Enabled);

editor.putInt(Config.WIDTH, Config.DEFAULT_RESOLUTION[mVideoConfigSelectPos][0]);
editor.putInt(Config.HEIGHT, Config.DEFAULT_RESOLUTION[mVideoConfigSelectPos][1]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import com.qiniu.droid.rtc.QNTrack;
import com.qiniu.droid.rtc.demo.R;

import org.webrtc.RendererCommon;
import org.qnwebrtc.RendererCommon;

import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public class Config {
public static final String AUDIO_SCENE = "audioScene";
public static final String CAPTURE_MODE = "captureMode";
public static final String BITRATE = "bitrate";
public static final String AEC3_ENABLE = "aec3Enable";

public static final int HW = 0;
public static final int SW = 1;
Expand Down
Binary file modified QNDroidRTCDemo/app/src/main/jniLibs/arm64-v8a/libqndroid_rtc.so
Binary file not shown.
Binary file not shown.
Binary file modified QNDroidRTCDemo/app/src/main/jniLibs/x86/libqndroid_rtc.so
Binary file not shown.
13 changes: 1 addition & 12 deletions QNDroidRTCDemo/app/src/main/res/layout/activity_setting.xml
Original file line number Diff line number Diff line change
Expand Up @@ -260,22 +260,11 @@
android:textColorHint="@color/textColor"
android:textSize="15sp" />

<androidx.appcompat.widget.SwitchCompat
android:id="@+id/webrtc_aec3_enable_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/app_id_edit_text"
android:layout_marginLeft="45dp"
android:layout_marginTop="16dp"
android:switchPadding="10dp"
android:text="启用 AEC3"
android:textColor="@color/textColor" />

<LinearLayout
android:id="@+id/test_mode_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/webrtc_aec3_enable_btn"
android:layout_below="@id/app_id_edit_text"
android:layout_marginLeft="30dp"
android:layout_marginTop="16dp"
android:layout_marginRight="30dp"
Expand Down
Binary file removed QNRTC-API-Examples/app/libs/qndroid-rtc-5.2.3.jar
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion QNRTC-API-Examples/app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
# hide the original source file name.
#-renamesourcefileattribute SourceFile

-keep class org.webrtc.** {*;}
-keep class org.qnwebrtc.** {*;}
-keep class com.qiniu.droid.rtc.**{*;}
-keep interface com.qiniu.droid.rtc.**{*;}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

public class APIApplication extends Application {

// indicate rtc init, shared by application
public static boolean mRTCInit = false;

@Override
public void onCreate() {
super.onCreate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.qiniu.droid.rtc.QNRemoteAudioTrack;
import com.qiniu.droid.rtc.QNRemoteTrack;
import com.qiniu.droid.rtc.QNRemoteVideoTrack;
import com.qiniu.droid.rtc.api.examples.APIApplication;
import com.qiniu.droid.rtc.api.examples.R;
import com.qiniu.droid.rtc.api.examples.adapter.AudioEffectAdapter;
import com.qiniu.droid.rtc.api.examples.model.AudioEffect;
Expand Down Expand Up @@ -110,6 +111,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
mSubThreadHandler.post(() -> checkAudioEffectFiles(getApplicationContext()));
// 2. 初始化 RTC
QNRTC.init(this, mRTCEventListener);
APIApplication.mRTCInit = true;
// 3. 创建 QNRTCClient 对象
mClient = QNRTC.createClient(mClientEventListener);
// 本示例仅针对 1v1 连麦场景,因此,关闭自动订阅选项。关于自动订阅的配置,可参考 https://developer.qiniu.com/rtc/8769/publish-and-subscribe-android#3
Expand Down Expand Up @@ -156,8 +158,11 @@ protected void onDestroy() {
mMicrophoneAudioTrack.destroy();
mMicrophoneAudioTrack = null;
}
// 10. 反初始化 RTC 释放资源
QNRTC.deinit();
if (APIApplication.mRTCInit) {
// 10. 反初始化 RTC 释放资源
QNRTC.deinit();
APIApplication.mRTCInit = false;
}
}

/**
Expand Down Expand Up @@ -297,11 +302,16 @@ private void initEffectsView() {
// 创建音效混音控制器,仅需创建一次即可
mAudioEffectMixer = mMicrophoneAudioTrack.createAudioEffectMixer(new QNAudioEffectMixerListener() {
@Override
public void onFinished(int effectID) {
public void onEffectFinished(int effectID) {
ToastUtils.showShortToast(getApplicationContext(), "音效混音完成 : " + effectID);
audioEffectAdapter.audioEffectMixFinished(effectID);
}

@Override
public void onEffectError(int effectID, int errCode, String errorMessage) {
ToastUtils.showShortToast(getApplicationContext(), "音效 " + effectID + " 混音出错 : " + errCode + " " + errorMessage);
}

@Override
public void onError(int errorCode, String errorMessage) {
ToastUtils.showShortToast(getApplicationContext(), "音效混音出错 : " + errorCode + " " + errorMessage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import com.qiniu.droid.rtc.QNRemoteAudioTrack;
import com.qiniu.droid.rtc.QNRemoteTrack;
import com.qiniu.droid.rtc.QNRemoteVideoTrack;
import com.qiniu.droid.rtc.api.examples.APIApplication;
import com.qiniu.droid.rtc.api.examples.R;
import com.qiniu.droid.rtc.api.examples.utils.Config;
import com.qiniu.droid.rtc.api.examples.utils.ToastUtils;
Expand Down Expand Up @@ -117,6 +118,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
initView();
// 2. 初始化 RTC
QNRTC.init(this, mRTCEventListener);
APIApplication.mRTCInit = true;
// 3. 创建 QNRTCClient 对象
mClient = QNRTC.createClient(mClientEventListener);
// 本示例仅针对 1v1 连麦场景,因此,关闭自动订阅选项。关于自动订阅的配置,可参考 https://developer.qiniu.com/rtc/8769/publish-and-subscribe-android#3
Expand Down Expand Up @@ -163,8 +165,11 @@ protected void onDestroy() {
mMicrophoneAudioTrack.destroy();
mMicrophoneAudioTrack = null;
}
// 10. 反初始化 RTC 释放资源
QNRTC.deinit();
if (APIApplication.mRTCInit) {
// 10. 反初始化 RTC 释放资源
QNRTC.deinit();
APIApplication.mRTCInit = false;
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import com.qiniu.droid.rtc.QNRemoteAudioTrack;
import com.qiniu.droid.rtc.QNRemoteTrack;
import com.qiniu.droid.rtc.QNRemoteVideoTrack;
import com.qiniu.droid.rtc.api.examples.APIApplication;
import com.qiniu.droid.rtc.api.examples.R;
import com.qiniu.droid.rtc.api.examples.adapter.AudioEffectAdapter;
import com.qiniu.droid.rtc.api.examples.adapter.AudioSourceAdapter;
Expand Down Expand Up @@ -113,6 +114,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
mSubThreadHandler.post(() -> checkAudioEffectFiles(getApplicationContext()));
// 2. 初始化 RTC
QNRTC.init(this, mRTCEventListener);
APIApplication.mRTCInit = true;
// 3. 创建 QNRTCClient 对象
mClient = QNRTC.createClient(mClientEventListener);
// 本示例仅针对 1v1 连麦场景,因此,关闭自动订阅选项。关于自动订阅的配置,可参考 https://developer.qiniu.com/rtc/8769/publish-and-subscribe-android#3
Expand Down Expand Up @@ -163,8 +165,11 @@ protected void onDestroy() {
mMicrophoneAudioTrack.destroy();
mMicrophoneAudioTrack = null;
}
// 10. 反初始化 RTC 释放资源
QNRTC.deinit();
if (APIApplication.mRTCInit) {
// 10. 反初始化 RTC 释放资源
QNRTC.deinit();
APIApplication.mRTCInit = false;
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@
import com.qiniu.droid.rtc.QNSurfaceView;
import com.qiniu.droid.rtc.QNVideoCaptureConfigPreset;
import com.qiniu.droid.rtc.QNVideoEncoderConfig;
import com.qiniu.droid.rtc.api.examples.APIApplication;
import com.qiniu.droid.rtc.api.examples.R;
import com.qiniu.droid.rtc.api.examples.utils.Config;
import com.qiniu.droid.rtc.api.examples.utils.ToastUtils;
import com.qiniu.droid.rtc.model.QNAudioDevice;

import org.webrtc.Size;
import org.qnwebrtc.Size;

import java.util.List;

Expand Down Expand Up @@ -83,6 +84,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
initView();
// 2. 初始化 RTC
QNRTC.init(this, mRTCEventListener);
APIApplication.mRTCInit = true;
// 3. 创建 QNRTCClient 对象
mClient = QNRTC.createClient(mClientEventListener);
// 本示例仅针对 1v1 连麦场景,因此,关闭自动订阅选项。关于自动订阅的配置,可参考 https://developer.qiniu.com/rtc/8769/publish-and-subscribe-android#3
Expand Down Expand Up @@ -133,8 +135,11 @@ protected void onDestroy() {
mClient = null;
}
destroyLocalTracks();
// 9. 反初始化 RTC 释放资源
QNRTC.deinit();
if (APIApplication.mRTCInit) {
// 9. 反初始化 RTC 释放资源
QNRTC.deinit();
APIApplication.mRTCInit = false;
}
}

private void initView() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@
import com.qiniu.droid.rtc.QNVideoEncoderConfig;
import com.qiniu.droid.rtc.QNVideoFrame;
import com.qiniu.droid.rtc.QNVideoFrameType;
import com.qiniu.droid.rtc.api.examples.APIApplication;
import com.qiniu.droid.rtc.api.examples.R;
import com.qiniu.droid.rtc.api.examples.capture.ExtAudioCapture;
import com.qiniu.droid.rtc.api.examples.capture.ExtVideoCapture;
import com.qiniu.droid.rtc.api.examples.utils.Config;
import com.qiniu.droid.rtc.api.examples.utils.ToastUtils;
import com.qiniu.droid.rtc.model.QNAudioDevice;

import org.webrtc.RendererCommon;
import org.qnwebrtc.RendererCommon;

import java.nio.ByteBuffer;
import java.util.List;
Expand Down Expand Up @@ -88,6 +89,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
initView();
// 2. 初始化 RTC
QNRTC.init(this, mRTCEventListener);
APIApplication.mRTCInit = true;
// 3. 创建 QNRTCClient 对象
mClient = QNRTC.createClient(mClientEventListener);
// 本示例仅针对 1v1 连麦场景,因此,关闭自动订阅选项。关于自动订阅的配置,可参考 https://developer.qiniu.com/rtc/8769/publish-and-subscribe-android#3
Expand Down Expand Up @@ -121,8 +123,11 @@ protected void onDestroy() {
mClient = null;
}
destroyLocalTracks();
// 9. 反初始化 RTC 释放资源
QNRTC.deinit();
if (APIApplication.mRTCInit) {
// 9. 反初始化 RTC 释放资源
QNRTC.deinit();
APIApplication.mRTCInit = false;
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.qiniu.droid.rtc.QNRemoteAudioTrack;
import com.qiniu.droid.rtc.QNRemoteTrack;
import com.qiniu.droid.rtc.QNRemoteVideoTrack;
import com.qiniu.droid.rtc.api.examples.APIApplication;
import com.qiniu.droid.rtc.api.examples.R;
import com.qiniu.droid.rtc.api.examples.capture.ExtAudioCapture;
import com.qiniu.droid.rtc.api.examples.utils.Config;
Expand Down Expand Up @@ -73,6 +74,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
initView();
// 2. 初始化 RTC
QNRTC.init(this, mRTCEventListener);
APIApplication.mRTCInit = true;
// 3. 创建 QNRTCClient 对象
mClient = QNRTC.createClient(mClientEventListener);
// 本示例仅针对 1v1 连麦场景,因此,关闭自动订阅选项。关于自动订阅的配置,可参考 https://developer.qiniu.com/rtc/8769/publish-and-subscribe-android#3
Expand All @@ -94,7 +96,6 @@ protected void onResume() {
@Override
protected void onPause() {
super.onPause();
mExtAudioCapture.stopCapture();
if (isFinishing() && mClient != null) {
// 8. 离开房间
mClient.leave();
Expand All @@ -104,12 +105,16 @@ protected void onPause() {
@Override
protected void onDestroy() {
super.onDestroy();
mExtAudioCapture.stopCapture();
if (mCustomAudioTrack != null) {
mCustomAudioTrack.destroy();
mCustomAudioTrack = null;
}
// 9. 反初始化 RTC 释放资源
QNRTC.deinit();
if (APIApplication.mRTCInit) {
// 9. 反初始化 RTC 释放资源
QNRTC.deinit();
APIApplication.mRTCInit = false;
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import com.qiniu.droid.rtc.QNSurfaceView;
import com.qiniu.droid.rtc.QNVideoCaptureConfigPreset;
import com.qiniu.droid.rtc.QNVideoEncoderConfig;
import com.qiniu.droid.rtc.api.examples.APIApplication;
import com.qiniu.droid.rtc.api.examples.R;
import com.qiniu.droid.rtc.api.examples.utils.Config;
import com.qiniu.droid.rtc.api.examples.utils.ToastUtils;
Expand Down Expand Up @@ -98,6 +99,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
initView();
// 2. 初始化 RTC
QNRTC.init(this, mRTCEventListener);
APIApplication.mRTCInit = true;
// 3. 创建 QNRTCClient 对象
mClient = QNRTC.createClient(mClientEventListener);
// 本示例仅针对 1v1 连麦场景,因此,关闭自动订阅选项。关于自动订阅的配置,可参考 https://developer.qiniu.com/rtc/8769/publish-and-subscribe-android#3
Expand Down Expand Up @@ -149,8 +151,11 @@ protected void onDestroy() {
mClient = null;
}
destroyLocalTracks();
// 10. 反初始化 RTC 释放资源
QNRTC.deinit();
if (APIApplication.mRTCInit) {
// 10. 反初始化 RTC 释放资源
QNRTC.deinit();
APIApplication.mRTCInit = false;
}
}

/**
Expand Down
Loading

0 comments on commit aeec173

Please sign in to comment.