Skip to content

Commit

Permalink
Merge pull request #53 from OurEra/master
Browse files Browse the repository at this point in the history
release v3.0.0
  • Loading branch information
OurEra authored Sep 21, 2020
2 parents 7a3111a + adfa236 commit 8e6d1cb
Show file tree
Hide file tree
Showing 15 changed files with 126 additions and 6 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 28
versionCode 28
versionName "2.5.0"
versionCode 29
versionName "3.0.0"
buildConfigField "long", "BUILD_TIMESTAMP", System.currentTimeMillis() + "L"
}

Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -16,5 +17,7 @@ public void onCreate() {
*/
QNRTCEnv.init(getApplicationContext());
QNRTCEnv.setLogFileEnabled(true);
// 设置自定义 DNS manager,不设置则使用 SDK 默认 DNS 服务
QNRTCEnv.setDnsManager(Utils.getDefaultDnsManager(getApplicationContext()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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<QNTrackInfo> mLocalTrackList;

Expand Down Expand Up @@ -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);
}

Expand All @@ -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);
Expand Down Expand Up @@ -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 + " 重连成功");
}

/**
* 远端用户离开房间时会回调此方法
*
Expand Down Expand Up @@ -706,6 +757,45 @@ public void onLocalPublished(List<QNTrackInfo> trackInfoList) {
@Override
public void onRemotePublished(String remoteUserId, List<QNTrackInfo> 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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});
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified QNDroidRTCDemo/app/src/main/jniLibs/x86/libqndroid_rtc.so
Binary file not shown.
23 changes: 23 additions & 0 deletions ReleaseNotes/release-notes-3.0.0.md
Original file line number Diff line number Diff line change
@@ -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)
Binary file modified releases/arm64-v8a/libqndroid_rtc.so
Binary file not shown.
Binary file modified releases/armeabi-v7a/libqndroid_rtc.so
Binary file not shown.
Binary file modified releases/armeabi/libqndroid_rtc.so
Binary file not shown.
Binary file not shown.
Binary file modified releases/x86/libqndroid_rtc.so
Binary file not shown.

0 comments on commit 8e6d1cb

Please sign in to comment.