diff --git a/QNDroidRTCDemo/app/build.gradle b/QNDroidRTCDemo/app/build.gradle index bfa959d..741f2ac 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 28 - versionCode 28 - versionName "2.5.0" + versionCode 29 + versionName "3.0.0" buildConfigField "long", "BUILD_TIMESTAMP", System.currentTimeMillis() + "L" } diff --git a/QNDroidRTCDemo/app/libs/qndroid-rtc-2.5.0.jar b/QNDroidRTCDemo/app/libs/qndroid-rtc-3.0.0.jar similarity index 70% rename from QNDroidRTCDemo/app/libs/qndroid-rtc-2.5.0.jar rename to QNDroidRTCDemo/app/libs/qndroid-rtc-3.0.0.jar index 384e47b..744f065 100644 Binary files a/QNDroidRTCDemo/app/libs/qndroid-rtc-2.5.0.jar and b/QNDroidRTCDemo/app/libs/qndroid-rtc-3.0.0.jar differ diff --git a/QNDroidRTCDemo/app/src/main/java/com/qiniu/droid/rtc/demo/RTCApplication.java b/QNDroidRTCDemo/app/src/main/java/com/qiniu/droid/rtc/demo/RTCApplication.java index b254279..b161ff0 100644 --- a/QNDroidRTCDemo/app/src/main/java/com/qiniu/droid/rtc/demo/RTCApplication.java +++ b/QNDroidRTCDemo/app/src/main/java/com/qiniu/droid/rtc/demo/RTCApplication.java @@ -4,6 +4,7 @@ import com.qiniu.droid.rtc.QNLogLevel; import com.qiniu.droid.rtc.QNRTCEnv; +import com.qiniu.droid.rtc.demo.utils.Utils; public class RTCApplication extends Application { @@ -16,5 +17,7 @@ public void onCreate() { */ QNRTCEnv.init(getApplicationContext()); QNRTCEnv.setLogFileEnabled(true); + // 设置自定义 DNS manager,不设置则使用 SDK 默认 DNS 服务 + QNRTCEnv.setDnsManager(Utils.getDefaultDnsManager(getApplicationContext())); } } 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 7b1dc8a..096c013 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 @@ -34,6 +34,8 @@ import com.qiniu.droid.rtc.QNRTCEngine; import com.qiniu.droid.rtc.QNRTCEngineEventListener; import com.qiniu.droid.rtc.QNRTCSetting; +import com.qiniu.droid.rtc.QNLocalAudioPacketCallback; +import com.qiniu.droid.rtc.QNRemoteAudioPacketCallback; import com.qiniu.droid.rtc.QNRoomState; import com.qiniu.droid.rtc.QNSourceType; import com.qiniu.droid.rtc.QNStatisticsReport; @@ -59,6 +61,7 @@ import com.qiniu.droid.rtc.model.QNMergeJob; import com.qiniu.droid.rtc.model.QNMergeTrackOption; +import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -103,6 +106,8 @@ public class RoomActivity extends Activity implements QNRTCEngineEventListener, private boolean mIsError = false; private boolean mIsAdmin = false; private boolean mIsJoinedRoom = false; + private boolean mAddExtraAudioData = false; + private boolean mEnableAudioEncrypt = false; private ControlFragment mControlFragment; private List mLocalTrackList; @@ -328,8 +333,7 @@ private void initQNRTCEngine() { .setLowAudioSampleRateEnabled(isLowSampleRateEnabled) .setAEC3Enabled(isAec3Enabled) .setVideoEncodeFormat(format) - .setVideoPreviewFormat(format) - .setDnsManager(Utils.getDefaultDnsManager(getApplicationContext())); + .setVideoPreviewFormat(format); mEngine = QNRTCEngine.createEngine(getApplicationContext(), setting, this); } @@ -343,6 +347,43 @@ private void initLocalTrackInfoList() { .setSourceType(QNSourceType.AUDIO) .setMaster(true) .create(); + mEngine.setLocalAudioPacketCallback(mLocalAudioTrack, new QNLocalAudioPacketCallback() { + @Override + public int onPutExtraData(ByteBuffer extraData, int extraDataMaxSize) { + // 可以向 extraData 填充自定义数据并在对端通过 QNRemoteAudioPacketCallback 解析 + if (mAddExtraAudioData) { + extraData.rewind(); + extraData.put((byte) 0x11); + extraData.flip(); + return extraData.remaining(); + } + return 0; + } + + @Override + public int onSetMaxEncryptSize(int frameSize) { + // 当需要根据自己的算法加密音频数据时,需要在该方法告知 SDK 加密后的最大数据大小 + if (mEnableAudioEncrypt) { + return frameSize + 10; + } + return 0; + } + + @Override + public int onEncrypt(ByteBuffer frame, int frameSize, ByteBuffer encryptedFrame) { + // 自主加密接口,将加密后的数据放置到 encryptedFrame 中,并返回加密后大小 + if (mEnableAudioEncrypt) { + encryptedFrame.rewind(); + frame.rewind(); + encryptedFrame.put((byte) 0x18); + encryptedFrame.put((byte) 0x19); + encryptedFrame.put(frame); + encryptedFrame.flip(); + return encryptedFrame.remaining(); + } + return 0; + } + }); mLocalTrackList.add(mLocalAudioTrack); QNVideoFormat screenEncodeFormat = new QNVideoFormat(mScreenWidth/2, mScreenHeight/2, 15); @@ -669,6 +710,16 @@ public void onRemoteUserJoined(String remoteUserId, String userData) { } } + @Override + public void onRemoteUserReconnecting(String remoteUserId) { + logAndToast("远端用户: " + remoteUserId + " 重连中"); + } + + @Override + public void onRemoteUserReconnected(String remoteUserId) { + logAndToast("远端用户: " + remoteUserId + " 重连成功"); + } + /** * 远端用户离开房间时会回调此方法 * @@ -706,6 +757,45 @@ public void onLocalPublished(List trackInfoList) { @Override public void onRemotePublished(String remoteUserId, List trackInfoList) { updateRemoteLogText("onRemotePublished:remoteUserId = " + remoteUserId); + for (QNTrackInfo info : trackInfoList) { + if (info.isAudio()) { + mEngine.setRemoteAudioPacketCallback(info, new QNRemoteAudioPacketCallback() { + @Override + public void onGetExtraData(ByteBuffer extraData, int extraDataSize) { + // 如果对端有发送自定义数据,则数据会在 extraData + if (extraDataSize > 0) { + extraData.rewind(); + Log.i(TAG, "extra size " + extraDataSize + " data " + extraData.get()); + } + } + + @Override + public int onSetMaxDecryptSize(int encryptedFrameSize) { + // 当需要根据自己的算法解密音频数据时,需要在该方法告知 SDK 解密后的最大数据大小 + if (mEnableAudioEncrypt) { + return encryptedFrameSize; + } else { + return 0; + } + } + + @Override + public int onDecrypt(ByteBuffer encryptedFrame, int encryptedSize, ByteBuffer frame) { + // 自主解密接口,将解密后的数据放置到 frame 中,并返回解密后大小 + if (mEnableAudioEncrypt) { + encryptedFrame.rewind(); + frame.rewind(); + if (encryptedFrame.get(0) == 0x18 && encryptedFrame.get(1) == 0x19) { + encryptedFrame.position(2); + frame.put(encryptedFrame); + return encryptedSize - 2; + } + } + return 0; + } + }); + } + } mRoomUsersMergeOption.onTracksPublished(remoteUserId, trackInfoList); // 如果希望在远端发布音视频的时候,自动配置合流,则可以在此处重新调用 setMergeStreamLayouts 进行配置 if (mIsAdmin) { 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 a796d53..843bdd0 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 @@ -41,12 +41,16 @@ public static DnsManager getDefaultDnsManager(Context context) { IResolver r0 = null; try { // 默认使用阿里云公共 DNS 服务,避免系统 DNS 解析可能出现的跨运营商、重定向等问题,详情可参考 https://www.alidns.com/ - r0 = new Resolver(InetAddress.getByName("223.5.5.5")); + // 超时时间参数可选,不指定默认为 10s 的超时 + // 超时时间单位:s + r0 = new Resolver(InetAddress.getByName("223.5.5.5"), 3); } catch (IOException e) { e.printStackTrace(); } // 默认 Dnspod 服务,使用腾讯公共 DNS 服务,详情可参考 https://www.dnspod.cn/Products/Public.DNS - IResolver r1 = new DnspodFree(); + // 超时时间参数可选,不指定默认为 10s 的超时 + // 超时时间单位:s + IResolver r1 = new DnspodFree("119.29.29.29", 3); // 系统默认 DNS 解析,可能会出现解析跨运营商等问题 IResolver r2 = AndroidDnsServer.defaultResolver(context); return new DnsManager(NetworkInfo.normal, new IResolver[]{r0, r1, r2}); 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 30b5b05..e96e166 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/libqndroid_rtc.so b/QNDroidRTCDemo/app/src/main/jniLibs/armeabi-v7a/libqndroid_rtc.so index 3408318..dfea293 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/armeabi/libqndroid_rtc.so b/QNDroidRTCDemo/app/src/main/jniLibs/armeabi/libqndroid_rtc.so index 17c11d6..7f251b1 100755 Binary files a/QNDroidRTCDemo/app/src/main/jniLibs/armeabi/libqndroid_rtc.so and b/QNDroidRTCDemo/app/src/main/jniLibs/armeabi/libqndroid_rtc.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 c209fc3..367a8c4 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-3.0.0.md b/ReleaseNotes/release-notes-3.0.0.md new file mode 100644 index 0000000..64c1a9a --- /dev/null +++ b/ReleaseNotes/release-notes-3.0.0.md @@ -0,0 +1,23 @@ +# QNDroidRTC Release Notes for 3.0.0 + +## 简介 + +QNDroidRTC 是七牛推出的一款适用于 Android 平台的音视频通话 SDK,提供了包括美颜、滤镜、音视频通话等多种功能,提供灵活的接口,支持高度定制以及二次开发。 + +## 版本 + +- 发布 qndroid-rtc-3.0.0.jar + +## 功能 + +- 新增支持远端音频 Track 音量调节 +- 新增远端用户正在重连,重连成功回调 +- 新增音频数据自定义加解密接口 + +## 缺陷 + +- 修复丢包率统计信息不准 + +## 问题反馈 + +当你遇到任何问题时,可以通过在 GitHub 的 repo 提交 `issues` 来反馈问题,请尽可能的描述清楚遇到的问题,如果有错误信息也一同附带,并且在 ```Labels``` 中指明类型为 bug 或者其他。 [通过这里查看已有的 issues 和提交 bug](https://github.com/pili-engineering/QNRTC-Android/issues) diff --git a/releases/arm64-v8a/libqndroid_rtc.so b/releases/arm64-v8a/libqndroid_rtc.so index 30b5b05..e96e166 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 3408318..dfea293 100755 Binary files a/releases/armeabi-v7a/libqndroid_rtc.so and b/releases/armeabi-v7a/libqndroid_rtc.so differ diff --git a/releases/armeabi/libqndroid_rtc.so b/releases/armeabi/libqndroid_rtc.so index 17c11d6..7f251b1 100755 Binary files a/releases/armeabi/libqndroid_rtc.so and b/releases/armeabi/libqndroid_rtc.so differ diff --git a/releases/qndroid-rtc-2.5.0.jar b/releases/qndroid-rtc-3.0.0.jar similarity index 70% rename from releases/qndroid-rtc-2.5.0.jar rename to releases/qndroid-rtc-3.0.0.jar index 384e47b..744f065 100644 Binary files a/releases/qndroid-rtc-2.5.0.jar and b/releases/qndroid-rtc-3.0.0.jar differ diff --git a/releases/x86/libqndroid_rtc.so b/releases/x86/libqndroid_rtc.so index c209fc3..367a8c4 100755 Binary files a/releases/x86/libqndroid_rtc.so and b/releases/x86/libqndroid_rtc.so differ