Skip to content

Commit

Permalink
Merge pull request #60 from OurEra/master
Browse files Browse the repository at this point in the history
Release v3.1.0
  • Loading branch information
OurEra authored Aug 9, 2021
2 parents 4149c26 + e0e3c76 commit dee046a
Show file tree
Hide file tree
Showing 29 changed files with 359 additions and 78 deletions.
8 changes: 4 additions & 4 deletions QNDroidRTCDemo/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
compileSdkVersion 29

defaultConfig {
applicationId "com.qiniu.droid.rtc.demo"
minSdkVersion 18
targetSdkVersion 28
versionCode 31
versionName "3.0.2"
targetSdkVersion 29
versionCode 32
versionName "3.1.0"
buildConfigField "long", "BUILD_TIMESTAMP", System.currentTimeMillis() + "L"
}

Expand Down
Binary file not shown.
8 changes: 7 additions & 1 deletion QNDroidRTCDemo/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_LOGS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

<application
android:name=".RTCApplication"
Expand Down Expand Up @@ -73,6 +73,12 @@
android:launchMode="singleTop"
android:screenOrientation="portrait"
android:theme="@style/AppTheme" />

<!-- foreground service for screen capture -->
<service
android:name=".service.ForegroundService"
android:foregroundServiceType="mediaProjection"
android:enabled="true" />
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public void onCreate() {
* init must be called before any other func
*/
QNRTCEnv.init(getApplicationContext());
QNRTCEnv.setLogFileEnabled(true);
QNRTCEnv.setLogFileEnabled(true, "牛会议");
// 设置自定义 DNS manager,不设置则使用 SDK 默认 DNS 服务
new Thread(() -> QNRTCEnv.setDnsManager(Utils.getDefaultDnsManager(getApplicationContext()))).start();
}
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import android.widget.Switch;
import android.widget.TextView;

import com.qiniu.droid.rtc.QNFileLogHelper;
import com.qiniu.droid.rtc.demo.BuildConfig;
import com.qiniu.droid.rtc.demo.R;
import com.qiniu.droid.rtc.demo.ui.SpinnerPopupWindow;
Expand All @@ -38,6 +39,7 @@ public class SettingActivity extends AppCompatActivity {
private EditText mUserNameEditText;
private TextView mConfigTextView;
private TextView mVersionCodeTextView;
private TextView mUploadTextView;
private RadioGroup mCodecModeRadioGroup;
private RadioButton mHwCodecMode;
private RadioButton mSwCodecMode;
Expand All @@ -57,8 +59,10 @@ public class SettingActivity extends AppCompatActivity {
private boolean mMaintainResolution = false;
private boolean mIsAec3Enabled = false;
private List<String> mDefaultConfiguration = new ArrayList<>();
private ArrayAdapter<String> mAdapter;
private SpinnerPopupWindow mSpinnerPopupWindow;
private ArrayAdapter<String> mConfigAdapter;
private SpinnerPopupWindow mConfigPopupWindow;
private List<String> mLogFileNames;
private SpinnerPopupWindow mLogFilePopupWindow;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
Expand All @@ -71,6 +75,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
mUserNameEditText = (EditText) findViewById(R.id.user_name_edit_text);
mConfigTextView = (TextView) findViewById(R.id.config_text_view);
mVersionCodeTextView = (TextView) findViewById(R.id.version_code);
mUploadTextView = (TextView) findViewById(R.id.report_log);
mCodecModeRadioGroup = (RadioGroup) findViewById(R.id.codec_mode_button);
mCodecModeRadioGroup.setOnCheckedChangeListener(mOnCheckedChangeListener);
mHwCodecMode = (RadioButton) findViewById(R.id.hw_radio_button);
Expand Down Expand Up @@ -122,7 +127,7 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mSwCodecMode.setChecked(true);
}

int sampleRatePos = preferences.getInt(Config.SAMPLE_RATE, Config.HIGH_SAMPLE_RATE);
int sampleRatePos = preferences.getInt(Config.SAMPLE_RATE, Config.LOW_SAMPLE_RATE);
if (sampleRatePos == Config.LOW_SAMPLE_RATE) {
mLowSampleRateBtn.setChecked(true);
} else {
Expand All @@ -136,21 +141,25 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mMaintainResolutionNo.setChecked(true);
}

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

mSpinnerPopupWindow = new SpinnerPopupWindow(this);
mSpinnerPopupWindow.setOnSpinnerItemClickListener(mOnSpinnerItemClickListener);
mConfigPopupWindow = new SpinnerPopupWindow(this);
mConfigPopupWindow.setOnSpinnerItemClickListener(mOnSpinnerItemClickListener);

mAdapter = new ArrayAdapter<String>(this, R.layout.spinner_item, mDefaultConfiguration);
mConfigAdapter = new ArrayAdapter<String>(this, R.layout.spinner_item, mDefaultConfiguration);
}

public void onClickBack(View v) {
finish();
}

public void onClickConfigParams(View v) {
showPopupWindow();
showConfigPopupWindow();
}

public void onClickUploadLog(View v) {
showLogFilePopupWindow();
}

public void onClickSaveConfiguration(View v) {
Expand Down Expand Up @@ -216,10 +225,43 @@ private void saveTestMode(SharedPreferences.Editor editor) {
}
}

private void showPopupWindow() {
mSpinnerPopupWindow.setAdapter(mAdapter);
mSpinnerPopupWindow.setWidth(mConfigTextView.getWidth());
mSpinnerPopupWindow.showAsDropDown(mConfigTextView);
private void showConfigPopupWindow() {
mConfigPopupWindow.setAdapter(mConfigAdapter);
mConfigPopupWindow.setWidth(mConfigTextView.getWidth());
mConfigPopupWindow.showAsDropDown(mConfigTextView);
}

private void showLogFilePopupWindow() {
if (mLogFilePopupWindow == null) {
mLogFilePopupWindow = new SpinnerPopupWindow(this);
mLogFilePopupWindow.setOnSpinnerItemClickListener(new SpinnerPopupWindow.OnSpinnerItemClickListener() {
@Override
public void onItemClick(int pos) {
QNFileLogHelper.getInstance().reportLogFile(mLogFileNames.get(pos), new QNFileLogHelper.LogReportCallback() {
@Override
public void onReportSuccess(String name) {
ToastUtils.s(SettingActivity.this, "上传成功:" + name);
}

@Override
public void onReportError(String name, String errorMsg) {
ToastUtils.s(SettingActivity.this, "上传失败:" + name + ";" + errorMsg);
}
});
mLogFilePopupWindow.dismiss();
}
});
}
mLogFileNames = QNFileLogHelper.getInstance().getLogFiles();
if (mLogFileNames == null || mLogFileNames.size() == 0) {
ToastUtils.s(SettingActivity.this, "当前无可上报日志");
return;
}

ArrayAdapter<String> adapter = new ArrayAdapter<>(this, R.layout.spinner_item, mLogFileNames);
mLogFilePopupWindow.setAdapter(adapter);
mLogFilePopupWindow.setWidth(mAppIdEditText.getWidth());
mLogFilePopupWindow.showAsDropDown(mUploadTextView);
}

private String getVersionDescription() {
Expand Down Expand Up @@ -253,7 +295,7 @@ private boolean isTestMode() {
public void onItemClick(int pos) {
mSelectPos = pos;
mConfigTextView.setText(mDefaultConfiguration.get(mSelectPos));
mSpinnerPopupWindow.dismiss();
mConfigPopupWindow.dismiss();
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ public void onUserLeft(String userId) {
}
}

public void onUserLeft() {
mRTCVideoMergeOptions.clear();
mRTCUsers.clear();
mRTCUserMap.clear();
}

public void onTracksPublished(String userId, List<QNTrackInfo> trackInfoList) {
RTCUserMergeOptions userMergeOptions = getRoomUserByUserId(userId);
if (userMergeOptions == null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package com.qiniu.droid.rtc.demo.service;

import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.Binder;
import android.os.Build;
import android.os.IBinder;
import android.support.v4.app.NotificationCompat;
import android.util.Log;

public class ForegroundService extends Service {

private static final String TAG = "ForegroundService";
private final IBinder mBinder = new LocalBinder();

public class LocalBinder extends Binder {
ForegroundService getService() {
return ForegroundService.this;
}
}

@Override
public void onCreate() {
super.onCreate();
if (Build.VERSION.SDK_INT >= 26) {
String CHANNEL_ID = "screen share";
NotificationChannel channel = new NotificationChannel(CHANNEL_ID,
"screen share",
NotificationManager.IMPORTANCE_DEFAULT);

((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)).createNotificationChannel(channel);
Notification notification = new NotificationCompat.Builder(this, CHANNEL_ID)
.setContentTitle("")
.setContentText("").build();
startForeground(1, notification);
Log.i(TAG, "start foreground");
}
}

@Override
public void onDestroy() {
super.onDestroy();
if (Build.VERSION.SDK_INT >= 26) {
stopForeground(true);
}
}

@Override
public IBinder onBind(Intent intent) {
return mBinder;
}

@Override
public int onStartCommand(final Intent intent, int flags, int startId) {
return super.onStartCommand(intent, flags, startId);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
Expand Down Expand Up @@ -68,6 +67,7 @@ public class MergeLayoutConfigView extends FrameLayout {
private RadioGroup mStretchModeRadioGroup;
private QNStretchMode mStretchMode;
private QNMergeJob mCurrentMergeJob;
private boolean mCurrentMergeJobValid;

private String mRoomId;
private boolean mIsStreamingEnabled;
Expand Down Expand Up @@ -160,15 +160,11 @@ public void updateConfigInfo(RTCUserMergeOptions chooseUser) {
}

/**
* 获取选中用户更新后的合流配置信息
*
* @return 选中用户的合流配置信息
* 同步 UI 选择的合流参数到合流配置类
*/
public List<RTCTrackMergeOption> updateMergeOptions() {
List<RTCTrackMergeOption> result = new ArrayList<>();
public void updateMergeOptions() {
if (mUserAudioTrack != null) {
mUserAudioTrack.setTrackInclude(mAudioSwitch.isChecked());
result.add(mUserAudioTrack);
}
if (mUserFirstVideoTrack != null) {
mUserFirstVideoTrack.setTrackInclude(mFirstVideoSwitch.isChecked());
Expand All @@ -187,7 +183,6 @@ public List<RTCTrackMergeOption> updateMergeOptions() {
} catch (Exception e) {
ToastUtils.s(getContext(), "请输入所有值");//处理空值
}
result.add(mUserFirstVideoTrack);
}
if (mUserSecondVideoTrack != null) {
mUserSecondVideoTrack.setTrackInclude(mSecondVideoSwitch.isChecked());
Expand All @@ -206,9 +201,7 @@ public List<RTCTrackMergeOption> updateMergeOptions() {
} catch (Exception e) {
ToastUtils.s(getContext(), "请输入所有值");//处理空值
}
result.add(mUserSecondVideoTrack);
}
return result;
}

/**
Expand All @@ -233,6 +226,7 @@ public QNMergeJob getCustomMergeJob() {
mCurrentMergeJob.setMaxBitrate(Integer.parseInt(mStreamMaxBitrateText.getText().toString().trim()) * 1000);
mCurrentMergeJob.setFps(Integer.parseInt(mStreamFpsText.getText().toString().trim()));
mCurrentMergeJob.setStretchMode(mStretchMode);
mCurrentMergeJobValid = true;
return mCurrentMergeJob;
}

Expand Down Expand Up @@ -271,6 +265,22 @@ public void updateMergeJobConfigInfo() {
}
}

/**
* 更新当前合流任务是否可用
* @param valid 是否可用
*/
public void updateMergeJobValid(boolean valid) {
mCurrentMergeJobValid = valid;
}

/**
* 当前合流任务是否可用
* @return valid 是否可用
*/
public boolean isMergeJobValid() {
return mCurrentMergeJobValid;
}

public void updateSerialNum(int serialNum) {
mSerialNum = serialNum;
}
Expand Down Expand Up @@ -454,8 +464,9 @@ private boolean isNeedUpdateMergeJob() {
if (mCurrentMergeJob == null) {
return true;
}
return !mCustomJobIdText.getText().toString().trim().equals(mCurrentMergeJob.getMergeJobId())
|| !mPublishUrlText.getText().toString().trim().equals(mCurrentMergeJob.getPublishUrl())
return !mCurrentMergeJobValid
|| !mCustomJobIdText.getText().toString().trim().equals(mCurrentMergeJob.getMergeJobId())
|| !isPublishUrlIdentity()
|| Integer.parseInt(mStreamWidthText.getText().toString().trim()) != mCurrentMergeJob.getWidth()
|| Integer.parseInt(mStreamHeightText.getText().toString().trim()) != mCurrentMergeJob.getHeight()
|| Integer.parseInt(mStreamBitrateText.getText().toString().trim()) != mCurrentMergeJob.getBitrate() / 1000
Expand All @@ -464,4 +475,10 @@ private boolean isNeedUpdateMergeJob() {
|| Integer.parseInt(mStreamFpsText.getText().toString().trim()) != mCurrentMergeJob.getFps()
|| mStretchMode != mCurrentMergeJob.getStretchMode();
}

private boolean isPublishUrlIdentity() {
String url1 = mPublishUrlText.getText().toString().trim();
String url2 = mCurrentMergeJob.getPublishUrl();
return url1.substring(0, url1.indexOf("?serialnum")).equals(url2.substring(0, url2.indexOf("?serialnum")));
}
}
Loading

0 comments on commit dee046a

Please sign in to comment.