Skip to content

Commit

Permalink
Merge pull request #54 from OurEra/master
Browse files Browse the repository at this point in the history
Release for v3.0.1
  • Loading branch information
OurEra authored Nov 23, 2020
2 parents 8e6d1cb + 6bdaafa commit e336fdb
Show file tree
Hide file tree
Showing 24 changed files with 129 additions and 237 deletions.
6 changes: 3 additions & 3 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 29
versionName "3.0.0"
versionCode 30
versionName "3.0.1"
buildConfigField "long", "BUILD_TIMESTAMP", System.currentTimeMillis() + "L"
}

Expand Down Expand Up @@ -36,7 +36,7 @@ dependencies {
implementation 'de.greenrobot:eventbus:2.4.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.qiniu:happy-dns:0.2.16'
implementation 'com.qiniu:happy-dns:0.2.17'

// QNDroidRTCLibrary
if (buildWithQNDroidRTCLibrary) {
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ public void onCreate() {
QNRTCEnv.init(getApplicationContext());
QNRTCEnv.setLogFileEnabled(true);
// 设置自定义 DNS manager,不设置则使用 SDK 默认 DNS 服务
QNRTCEnv.setDnsManager(Utils.getDefaultDnsManager(getApplicationContext()));
new Thread(() -> QNRTCEnv.setDnsManager(Utils.getDefaultDnsManager(getApplicationContext()))).start();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@

import com.qiniu.droid.rtc.QNBeautySetting;
import com.qiniu.droid.rtc.QNCameraSwitchResultCallback;
import com.qiniu.droid.rtc.QNCaptureVideoCallback;
import com.qiniu.droid.rtc.QNCustomMessage;
import com.qiniu.droid.rtc.QNErrorCode;
import com.qiniu.droid.rtc.QNLocalAudioPacketCallback;
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;
Expand All @@ -61,12 +62,16 @@
import com.qiniu.droid.rtc.model.QNMergeJob;
import com.qiniu.droid.rtc.model.QNMergeTrackOption;

import org.webrtc.VideoFrame;

import java.util.concurrent.Semaphore;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.TimeUnit;

import static com.qiniu.droid.rtc.demo.utils.Config.DEFAULT_BITRATE;
import static com.qiniu.droid.rtc.demo.utils.Config.DEFAULT_FPS;
Expand Down Expand Up @@ -173,6 +178,8 @@ public class RoomActivity extends Activity implements QNRTCEngineEventListener,
*/
private int mSerialNum = 0;

private Semaphore mCaptureStoppedSem = new Semaphore(1);

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down Expand Up @@ -259,13 +266,25 @@ public boolean onLongClick(View v) {
protected void onResume() {
super.onResume();
// 开始视频采集
mEngine.startCapture();
startCaptureAfterAcquire();
if (!mIsJoinedRoom) {
// 加入房间
mEngine.joinRoom(mRoomToken);
}
}

private void startCaptureAfterAcquire() {
boolean acquired = false;
try {
acquired = mCaptureStoppedSem.tryAcquire(2000, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
e.printStackTrace();
}
if (acquired) {
mEngine.startCapture();
}
}

@Override
protected void onPause() {
super.onPause();
Expand Down Expand Up @@ -335,6 +354,28 @@ private void initQNRTCEngine() {
.setVideoEncodeFormat(format)
.setVideoPreviewFormat(format);
mEngine = QNRTCEngine.createEngine(getApplicationContext(), setting, this);
mEngine.setCaptureVideoCallBack(new QNCaptureVideoCallback() {
@Override
public void onCaptureStarted() {

}

@Override
public void onRenderingFrame(VideoFrame.TextureBuffer texBuf, long timestampNs) {

}

@Override
public void onPreviewFrame(byte[] data, int width, int height, int rotation, int fmt, long timestampNs) {

}

@Override
public void onCaptureStopped() {
mCaptureStoppedSem.drainPermits();
mCaptureStoppedSem.release();
}
});
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.qiniu.droid.rtc.demo.model;

import com.qiniu.droid.rtc.QNTrackInfo;
import com.qiniu.droid.rtc.QNTrackKind;
import com.qiniu.droid.rtc.demo.utils.QNAppServer;
import com.qiniu.droid.rtc.model.QNMergeTrackOption;
import com.qiniu.droid.rtc.model.QNStretchMode;

public class RTCTrackMergeOption {

Expand All @@ -12,13 +14,16 @@ public class RTCTrackMergeOption {
private boolean mTrackInclude = true;
private final QNMergeTrackOption mQNMergeTrackOption;

public RTCTrackMergeOption(QNTrackInfo QNTrackInfo) {
mQNTrackInfo = QNTrackInfo;
public RTCTrackMergeOption(QNTrackInfo trackInfo) {
mQNTrackInfo = trackInfo;
mTrackId = mQNTrackInfo.getTrackId();

mQNMergeTrackOption = new QNMergeTrackOption();
mQNMergeTrackOption.setWidth(QNAppServer.STREAMING_WIDTH);
mQNMergeTrackOption.setHeight(QNAppServer.STREAMING_HEIGHT);
if (trackInfo.getTrackKind().equals(QNTrackKind.VIDEO)) {
mQNMergeTrackOption.setWidth(QNAppServer.STREAMING_WIDTH);
mQNMergeTrackOption.setHeight(QNAppServer.STREAMING_HEIGHT);
mQNMergeTrackOption.setStretchMode(QNStretchMode.ASPECT_FILL);
}
mQNMergeTrackOption.setTrackId(mTrackId);
}

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ public static void showAlertDialog(Context context, String message) {
.show();
}

/**
* 创建自定义 dns manager
*
* 注意:该方法需要在子线程中调用,否则可能会抛异常
*
* @param context 上下文
* @return dns manager
*/
public static DnsManager getDefaultDnsManager(Context context) {
IResolver r0 = null;
try {
Expand Down
Binary file not shown.
Binary file not shown.
Binary file modified QNDroidRTCDemo/app/src/main/jniLibs/armeabi/libqndroid_rtc.so
Binary file not shown.
Binary file modified QNDroidRTCDemo/app/src/main/jniLibs/x86/libqndroid_rtc.so
Binary file not shown.
Loading

0 comments on commit e336fdb

Please sign in to comment.