diff --git a/QNDroidRTCDemo/app/build.gradle b/QNDroidRTCDemo/app/build.gradle index e187162..31746f4 100644 --- a/QNDroidRTCDemo/app/build.gradle +++ b/QNDroidRTCDemo/app/build.gradle @@ -6,8 +6,8 @@ android { applicationId "com.qiniu.droid.rtc.demo" minSdkVersion 18 targetSdkVersion 30 - versionCode 33 - versionName "4.0.1" + versionCode 34 + versionName "5.0.0" buildConfigField "long", "BUILD_TIMESTAMP", System.currentTimeMillis() + "L" } @@ -41,11 +41,13 @@ dependencies { implementation 'androidx.recyclerview:recyclerview:1.2.1' implementation 'androidx.constraintlayout:constraintlayout:2.1.0' implementation 'com.qiniu:happy-dns:0.2.18' + // xCrash + implementation 'com.iqiyi.xcrash:xcrash-android-lib:3.0.0' // QNDroidRTCLibrary if (buildWithQNDroidRTCLibrary) { implementation project(':library') - implementation files('libs/pldroid-player-2.1.4.jar') + implementation files('libs/pldroid-player-2.4.0.jar') } else { implementation fileTree(include: ['*.jar'], dir: 'libs') } diff --git a/QNDroidRTCDemo/app/libs/pldroid-player-2.1.4.jar b/QNDroidRTCDemo/app/libs/pldroid-player-2.1.4.jar deleted file mode 100755 index 464b225..0000000 Binary files a/QNDroidRTCDemo/app/libs/pldroid-player-2.1.4.jar and /dev/null differ diff --git a/QNDroidRTCDemo/app/libs/pldroid-player-2.4.0.jar b/QNDroidRTCDemo/app/libs/pldroid-player-2.4.0.jar new file mode 100644 index 0000000..d96a2a8 Binary files /dev/null and b/QNDroidRTCDemo/app/libs/pldroid-player-2.4.0.jar differ diff --git a/QNDroidRTCDemo/app/libs/qndroid-rtc-4.0.1.jar b/QNDroidRTCDemo/app/libs/qndroid-rtc-4.0.1.jar deleted file mode 100644 index f00d7aa..0000000 Binary files a/QNDroidRTCDemo/app/libs/qndroid-rtc-4.0.1.jar and /dev/null differ diff --git a/QNDroidRTCDemo/app/libs/qndroid-rtc-5.0.0.jar b/QNDroidRTCDemo/app/libs/qndroid-rtc-5.0.0.jar new file mode 100644 index 0000000..9a9a745 Binary files /dev/null and b/QNDroidRTCDemo/app/libs/qndroid-rtc-5.0.0.jar differ diff --git a/QNDroidRTCDemo/app/src/main/AndroidManifest.xml b/QNDroidRTCDemo/app/src/main/AndroidManifest.xml index c62a68b..231dbb3 100644 --- a/QNDroidRTCDemo/app/src/main/AndroidManifest.xml +++ b/QNDroidRTCDemo/app/src/main/AndroidManifest.xml @@ -16,6 +16,7 @@ { + mVideoView.setOnErrorListener((errorCode, extraData) -> { switch (errorCode) { case PLOnErrorListener.ERROR_CODE_OPEN_FAILED: logAndToast("播放器打开失败,请确认是否在推流!"); @@ -91,7 +91,7 @@ protected void onCreate(Bundle savedInstanceState) { } return false; }); - mVideoView.setOnInfoListener((what, extra) -> { + mVideoView.setOnInfoListener((what, extra, extraData) -> { switch (what) { case PLOnInfoListener.MEDIA_INFO_VIDEO_RENDERING_START: break; diff --git a/QNDroidRTCDemo/app/src/main/java/com/qiniu/droid/rtc/demo/activity/RoomActivity.java b/QNDroidRTCDemo/app/src/main/java/com/qiniu/droid/rtc/demo/activity/RoomActivity.java index 7b3cb17..524b563 100644 --- a/QNDroidRTCDemo/app/src/main/java/com/qiniu/droid/rtc/demo/activity/RoomActivity.java +++ b/QNDroidRTCDemo/app/src/main/java/com/qiniu/droid/rtc/demo/activity/RoomActivity.java @@ -1,9 +1,5 @@ package com.qiniu.droid.rtc.demo.activity; -import static com.qiniu.droid.rtc.demo.utils.Config.DEFAULT_FPS; -import static com.qiniu.droid.rtc.demo.utils.Config.DEFAULT_RESOLUTION; -import static com.qiniu.droid.rtc.demo.utils.Utils.getSystemUiVisibility; - import android.app.AlertDialog; import android.content.ComponentName; import android.content.Context; @@ -16,8 +12,8 @@ import android.graphics.drawable.ColorDrawable; import android.os.Build; import android.os.Bundle; -import android.os.Handler; import android.os.IBinder; +import android.text.TextUtils; import android.util.DisplayMetrics; import android.util.Log; import android.view.Gravity; @@ -102,6 +98,10 @@ import java.util.concurrent.Semaphore; import java.util.concurrent.TimeUnit; +import static com.qiniu.droid.rtc.demo.utils.Config.DEFAULT_FPS; +import static com.qiniu.droid.rtc.demo.utils.Config.DEFAULT_RESOLUTION; +import static com.qiniu.droid.rtc.demo.utils.Utils.getSystemUiVisibility; + public class RoomActivity extends FragmentActivity implements ControlFragment.OnCallEvents { private static final String TAG = "RoomActivity"; @@ -135,7 +135,6 @@ public class RoomActivity extends FragmentActivity implements ControlFragment.On private boolean mBeautyEnabled = false; private boolean mVideoEnabled = true; private boolean mSpeakerEnabled = true; - private boolean mIsError = false; private boolean mIsAdmin = false; private boolean mIsJoinedRoom = false; private ControlFragment mControlFragment; @@ -198,6 +197,12 @@ public class RoomActivity extends FragmentActivity implements ControlFragment.On */ private int mSerialNum = 0; + /** + * {@link QNRTC#init} 和 {@link QNRTC#deinit()} 为静态方法,需要对称调用; + * 为了避免在页面退出进入时存在顺序问题,建议保存是否初始化状态 + */ + private static boolean mInitRTC; + private final Semaphore mCaptureStoppedSem = new Semaphore(1); @Override @@ -267,20 +272,26 @@ protected void onCreate(Bundle savedInstanceState) { return; } } - // 初始化 Client 和本地 Track 列表 - initClient(); - // 初始化本地音视频 track - initLocalTracks(); - // 初始化合流相关配置 - initMergeLayoutConfig(); - // 多人显示窗口管理类 - mTrackWindowManager = new TrackWindowManager(mUserId, screenWidth, screenHeight, outMetrics.density, mClient, mTrackWindowFullScreen, mTrackWindowsList); - - List localTrackListExcludeScreenTrack = new ArrayList<>(mLocalTrackList); - localTrackListExcludeScreenTrack.remove(mLocalScreenTrack); - mTrackWindowManager.addTrack(mUserId, localTrackListExcludeScreenTrack); - new Timer().schedule(mUpdateNetWorkQualityInfoTask, 5000, 10000); + if (mInitRTC) { + ToastUtils.showShortToast(RoomActivity.this, "RTC 未释放完成,当前页面不可用,请退出后重试!"); + } else { + // 初始化 Client 和本地 Track 列表 + initClient(); + // 初始化本地音视频 track + initLocalTracks(); + // 初始化合流相关配置 + initMergeLayoutConfig(); + + // 多人显示窗口管理类 + mTrackWindowManager = new TrackWindowManager(mUserId, screenWidth, screenHeight, outMetrics.density, mClient, mTrackWindowFullScreen, mTrackWindowsList); + + List localTrackListExcludeScreenTrack = new ArrayList<>(mLocalTrackList); + localTrackListExcludeScreenTrack.remove(mLocalScreenTrack); + mTrackWindowManager.addTrack(mUserId, localTrackListExcludeScreenTrack); + new Timer().schedule(mUpdateNetWorkQualityInfoTask, 5000, 10000); + mInitRTC = true; + } } @Override @@ -288,7 +299,7 @@ protected void onResume() { super.onResume(); // 开始视频采集 startCaptureAfterAcquire(); - if (!mIsJoinedRoom) { + if (!mIsJoinedRoom && mClient != null) { // 加入房间 mClient.join(mRoomToken); } @@ -321,6 +332,24 @@ protected void onPause() { @Override protected void onDestroy() { super.onDestroy(); + releaseClient(); + if (mInitRTC) { + // 反初始化 + QNRTC.deinit(); + mInitRTC = false; + } + if (mTrackWindowFullScreen != null) { + mTrackWindowFullScreen.dispose(); + } + for (UserTrackView item : mTrackWindowsList) { + item.dispose(); + } + mTrackWindowsList.clear(); + mPopWindow = null; + } + + private void releaseClient() { + mUpdateNetWorkQualityInfoTask.cancel(); if (mClient != null) { if (mIsAdmin && mIsMergeStreaming) { // 如果当前正在合流,则停止 @@ -336,18 +365,6 @@ protected void onDestroy() { mClient.leave(); mClient = null; } - // 反初始化 - QNRTC.deinit(); - - mUpdateNetWorkQualityInfoTask.cancel(); - if (mTrackWindowFullScreen != null) { - mTrackWindowFullScreen.dispose(); - } - for (UserTrackView item : mTrackWindowsList) { - item.dispose(); - } - mTrackWindowsList.clear(); - mPopWindow = null; } /** @@ -522,6 +539,7 @@ private void initMergeLayoutConfig() { } } else { // 更新合流布局到默认合流配置 + mCurrentMergeConfig = new QNTranscodingLiveStreamingConfig(); setMergeStreamLayouts(); } if (mPopWindow != null) { @@ -552,14 +570,6 @@ private void disconnectWithErrorMessage(final String errorMessage) { .show(); } - private void reportError(final String description) { - // TODO: handle error. - if (!mIsError) { - mIsError = true; - disconnectWithErrorMessage(description); - } - } - private void showKickoutDialog(final String userId) { if (mKickOutDialog == null) { mKickOutDialog = new AlertDialog.Builder(this) @@ -586,13 +596,14 @@ private void resetMergeStream() { // video tracks merge layout options. List roomVideoTrackList = mRoomMergeOption.getVideoMergeOptions(); + boolean isDefaultStreaming = (mCurrentMergeConfig == null || TextUtils.isEmpty(mCurrentMergeConfig.getStreamID())); if (!roomVideoTrackList.isEmpty()) { List mergeTrackOptions = SplitUtils.split( roomVideoTrackList.size(), - mCurrentMergeConfig == null ? + isDefaultStreaming ? QNAppServer.STREAMING_WIDTH : mCurrentMergeConfig.getWidth(), - mCurrentMergeConfig == null ? + isDefaultStreaming ? QNAppServer.STREAMING_HEIGHT : mCurrentMergeConfig.getHeight() ); @@ -690,9 +701,7 @@ private void updateMergeTrack() { @Override public void onCallHangUp() { - if (mClient != null) { - mClient.leave(); - } + releaseClient(); finish(); } @@ -822,9 +831,11 @@ public void onToggleDirectLiving() { private final TimerTask mUpdateNetWorkQualityInfoTask = new TimerTask() { @Override public void run() { - Map qualityMap = mClient.getUserNetworkQuality(); - for (Map.Entry entry : qualityMap.entrySet()) { - Log.i(TAG, "remote user " + entry.getKey() + " " + entry.getValue().toString()); + if (mClient != null) { + Map qualityMap = mClient.getUserNetworkQuality(); + for (Map.Entry entry : qualityMap.entrySet()) { + Log.i(TAG, "remote user " + entry.getKey() + " " + entry.getValue().toString()); + } } } }; @@ -1088,8 +1099,8 @@ public void onSubscribed(String remoteUserID, List remoteAud tracks.addAll(remoteAudioTracks); tracks.addAll(remoteVideoTracks); mTrackWindowManager.addTrack(remoteUserID, tracks); - for (QNRemoteAudioTrack audioTrack : remoteAudioTracks) { - audioTrack.setTrackInfoChangedListener(new QNTrackInfoChangedListener() { + for (QNTrack track : tracks) { + ((QNRemoteTrack)track).setTrackInfoChangedListener(new QNTrackInfoChangedListener() { @Override public void onMuteStateChanged(boolean isMuted) { updateRemoteLogText("onRemoteUserMuted:remoteUserId = " + remoteUserID); @@ -1200,7 +1211,7 @@ public void onError(int errorCode, String errorMessage) { private final QNLiveStreamingListener mLiveStreamingListener = new QNLiveStreamingListener() { /** - * 当转推成功的时候会回调此方法 + * 当自定义合流任务和直接转推任务开启成功的时候会回调此方法 * * @param streamID 转推成功的 streamID */ @@ -1237,7 +1248,6 @@ public void onStarted(String streamID) { @Override public void onStopped(String streamID) { - } @Override diff --git a/QNDroidRTCDemo/app/src/main/java/com/qiniu/droid/rtc/demo/utils/Config.java b/QNDroidRTCDemo/app/src/main/java/com/qiniu/droid/rtc/demo/utils/Config.java index 3a7b4ae..b75fb70 100644 --- a/QNDroidRTCDemo/app/src/main/java/com/qiniu/droid/rtc/demo/utils/Config.java +++ b/QNDroidRTCDemo/app/src/main/java/com/qiniu/droid/rtc/demo/utils/Config.java @@ -58,9 +58,9 @@ public class Config { }; public static int[] DEFAULT_BITRATE = { - 600 * 1000, // (500 - 600kbps) - 1000 * 1000, // (900 - 1200kbps) - 1500 * 1000, // (1400 - 1500kbps) - 2000 * 1000 // (1800 - 2000kbps) + 600, // (500 - 600kbps) + 1000, // (900 - 1200kbps) + 1500, // (1400 - 1500kbps) + 2000 // (1800 - 2000kbps) }; } diff --git a/QNDroidRTCDemo/app/src/main/java/com/qiniu/droid/rtc/demo/utils/Utils.java b/QNDroidRTCDemo/app/src/main/java/com/qiniu/droid/rtc/demo/utils/Utils.java index 83e4a67..e529764 100644 --- a/QNDroidRTCDemo/app/src/main/java/com/qiniu/droid/rtc/demo/utils/Utils.java +++ b/QNDroidRTCDemo/app/src/main/java/com/qiniu/droid/rtc/demo/utils/Utils.java @@ -88,4 +88,16 @@ public static DnsManager getDefaultDnsManager(Context context) { IResolver r2 = AndroidDnsServer.defaultResolver(context); return new DnsManager(NetworkInfo.normal, new IResolver[]{r0, r1, r2}); } + + public static String getVersion(Context context) { + PackageManager packageManager = context.getPackageManager(); + try { + PackageInfo packageInfo = packageManager.getPackageInfo(context.getPackageName(), 0); + return packageInfo.versionName; + + } catch (PackageManager.NameNotFoundException e) { + e.printStackTrace(); + } + return ""; + } } diff --git a/QNDroidRTCDemo/app/src/main/jniLibs/arm64-v8a/libQPlayer.so b/QNDroidRTCDemo/app/src/main/jniLibs/arm64-v8a/libQPlayer.so index 6bd0281..f392e3c 100755 Binary files a/QNDroidRTCDemo/app/src/main/jniLibs/arm64-v8a/libQPlayer.so and b/QNDroidRTCDemo/app/src/main/jniLibs/arm64-v8a/libQPlayer.so differ diff --git a/QNDroidRTCDemo/app/src/main/jniLibs/arm64-v8a/libqcOpenSSL.so b/QNDroidRTCDemo/app/src/main/jniLibs/arm64-v8a/libqcOpenSSL.so index 706a507..37410a2 100755 Binary files a/QNDroidRTCDemo/app/src/main/jniLibs/arm64-v8a/libqcOpenSSL.so and b/QNDroidRTCDemo/app/src/main/jniLibs/arm64-v8a/libqcOpenSSL.so differ diff --git a/QNDroidRTCDemo/app/src/main/jniLibs/arm64-v8a/libqndroid_rtc.so b/QNDroidRTCDemo/app/src/main/jniLibs/arm64-v8a/libqndroid_rtc.so index d4e4f2b..0eb79f8 100755 Binary files a/QNDroidRTCDemo/app/src/main/jniLibs/arm64-v8a/libqndroid_rtc.so and b/QNDroidRTCDemo/app/src/main/jniLibs/arm64-v8a/libqndroid_rtc.so differ diff --git a/QNDroidRTCDemo/app/src/main/jniLibs/armeabi-v7a/libQPlayer.so b/QNDroidRTCDemo/app/src/main/jniLibs/armeabi-v7a/libQPlayer.so index e3ccf4c..5ac16aa 100755 Binary files a/QNDroidRTCDemo/app/src/main/jniLibs/armeabi-v7a/libQPlayer.so and b/QNDroidRTCDemo/app/src/main/jniLibs/armeabi-v7a/libQPlayer.so differ diff --git a/QNDroidRTCDemo/app/src/main/jniLibs/armeabi-v7a/libqcOpenSSL.so b/QNDroidRTCDemo/app/src/main/jniLibs/armeabi-v7a/libqcOpenSSL.so index 88ab3a3..f62f934 100755 Binary files a/QNDroidRTCDemo/app/src/main/jniLibs/armeabi-v7a/libqcOpenSSL.so and b/QNDroidRTCDemo/app/src/main/jniLibs/armeabi-v7a/libqcOpenSSL.so differ diff --git a/QNDroidRTCDemo/app/src/main/jniLibs/armeabi-v7a/libqndroid_rtc.so b/QNDroidRTCDemo/app/src/main/jniLibs/armeabi-v7a/libqndroid_rtc.so index e8dbee8..ca4401a 100755 Binary files a/QNDroidRTCDemo/app/src/main/jniLibs/armeabi-v7a/libqndroid_rtc.so and b/QNDroidRTCDemo/app/src/main/jniLibs/armeabi-v7a/libqndroid_rtc.so differ diff --git a/QNDroidRTCDemo/app/src/main/jniLibs/x86/libQPlayer.so b/QNDroidRTCDemo/app/src/main/jniLibs/x86/libQPlayer.so new file mode 100755 index 0000000..1242190 Binary files /dev/null and b/QNDroidRTCDemo/app/src/main/jniLibs/x86/libQPlayer.so differ diff --git a/QNDroidRTCDemo/app/src/main/jniLibs/x86/libqcOpenSSL.so b/QNDroidRTCDemo/app/src/main/jniLibs/x86/libqcOpenSSL.so new file mode 100755 index 0000000..3568577 Binary files /dev/null and b/QNDroidRTCDemo/app/src/main/jniLibs/x86/libqcOpenSSL.so differ diff --git a/QNDroidRTCDemo/app/src/main/jniLibs/x86/libqndroid_rtc.so b/QNDroidRTCDemo/app/src/main/jniLibs/x86/libqndroid_rtc.so index 6940e1f..2158e3b 100755 Binary files a/QNDroidRTCDemo/app/src/main/jniLibs/x86/libqndroid_rtc.so and b/QNDroidRTCDemo/app/src/main/jniLibs/x86/libqndroid_rtc.so differ diff --git a/ReleaseNotes/release-notes-5.0.0.md b/ReleaseNotes/release-notes-5.0.0.md new file mode 100644 index 0000000..bb468fd --- /dev/null +++ b/ReleaseNotes/release-notes-5.0.0.md @@ -0,0 +1,22 @@ +# QNDroidRTC Release Notes for 5.0.0 + +## 简介 + +QNDroidRTC 是七牛推出的一款适用于 Android 平台的音视频通话 SDK,提供了包括美颜、滤镜、音视频通话等多种功能,提供灵活的接口,支持高度定制以及二次开发。 + +## 版本 + +- 发布 qndroid-rtc-5.0.0.jar +- 更新 libqndroid_rtc.so + +## 注意 + +1. 本次升级为主版本升级(v4.0.1 -> v5.0.0),是基于 4.x 版本开发的重构版本,SDK 使用了统一的 c++ RTC 内核, 保证了七牛 RTC 在各个端上的一致性,同时接口和 4.x 完全兼容,开发文档请参考[新版文档站](https://developer.qiniu.com/rtc/8802/pd-overview)。 + +## 功能 + +- 新增 SDK 内部音视频弱网优化 + +## 问题反馈 + +当你遇到任何问题时,可以通过在 GitHub 的 repo 提交 `issues` 来反馈问题,请尽可能的描述清楚遇到的问题,如果有错误信息也一同附带,并且在 ```Labels``` 中指明类型为 bug 或者其他。 [通过这里查看已有的 issues 和提交 bug](https://github.com/pili-engineering/QNRTC-Android/issues) \ No newline at end of file diff --git a/releases/arm64-v8a/libqndroid_rtc.so b/releases/arm64-v8a/libqndroid_rtc.so index d4e4f2b..0eb79f8 100755 Binary files a/releases/arm64-v8a/libqndroid_rtc.so and b/releases/arm64-v8a/libqndroid_rtc.so differ diff --git a/releases/armeabi-v7a/libqndroid_rtc.so b/releases/armeabi-v7a/libqndroid_rtc.so index e8dbee8..ca4401a 100755 Binary files a/releases/armeabi-v7a/libqndroid_rtc.so and b/releases/armeabi-v7a/libqndroid_rtc.so differ diff --git a/releases/qndroid-rtc-4.0.1.jar b/releases/qndroid-rtc-4.0.1.jar deleted file mode 100644 index f00d7aa..0000000 Binary files a/releases/qndroid-rtc-4.0.1.jar and /dev/null differ diff --git a/releases/qndroid-rtc-5.0.0.jar b/releases/qndroid-rtc-5.0.0.jar new file mode 100644 index 0000000..9a9a745 Binary files /dev/null and b/releases/qndroid-rtc-5.0.0.jar differ diff --git a/releases/x86/libqndroid_rtc.so b/releases/x86/libqndroid_rtc.so index 6940e1f..2158e3b 100755 Binary files a/releases/x86/libqndroid_rtc.so and b/releases/x86/libqndroid_rtc.so differ