Skip to content

Commit

Permalink
Merge pull request #52 from OurEra/master
Browse files Browse the repository at this point in the history
release v2.5.0
  • Loading branch information
OurEra authored Sep 21, 2020
2 parents ade39fd + 617c24c commit 7a3111a
Show file tree
Hide file tree
Showing 31 changed files with 992 additions and 487 deletions.
5 changes: 3 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 27
versionName "2.4.0"
versionCode 28
versionName "2.5.0"
buildConfigField "long", "BUILD_TIMESTAMP", System.currentTimeMillis() + "L"
}

Expand Down Expand Up @@ -36,6 +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'

// QNDroidRTCLibrary
if (buildWithQNDroidRTCLibrary) {
Expand Down
Binary file removed QNDroidRTCDemo/app/libs/qndroid-rtc-2.4.0.jar
Binary file not shown.
Binary file added QNDroidRTCDemo/app/libs/qndroid-rtc-2.5.0.jar
Binary file not shown.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
}
});

mVersionCodeTextView.setText(String.format(getString(R.string.version_code), getVersionDescription(), getBuildTimeDescription()));
mVersionCodeTextView.setText(String.format(getString(R.string.version_code), getVersionDescription(), getBuildTimeDescription(), getSdkVersion()));

SharedPreferences preferences = getSharedPreferences(getString(R.string.app_name), Context.MODE_PRIVATE);
mUserName = preferences.getString(Config.USER_NAME, "");
Expand Down Expand Up @@ -237,6 +237,10 @@ protected String getBuildTimeDescription() {
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA).format(BuildConfig.BUILD_TIMESTAMP);
}

protected String getSdkVersion() {
return com.qiniu.droid.rtc.BuildConfig.VERSION_NAME + "-" + com.qiniu.droid.rtc.BuildConfig.GIT_HASH;
}

private boolean isTestMode() {
// if (mAppIdEditText.getText().toString().compareTo(QNAppServer.TEST_MODE_APP_ID) == 0) {
// return true;
Expand All @@ -259,11 +263,9 @@ public void onCheckedChanged(RadioGroup group, int checkedId) {
switch (group.getCheckedRadioButtonId()) {
case R.id.hw_radio_button:
mEncodeMode = Config.HW;
mMaintainResRadioGroup.setVisibility(View.GONE);
break;
case R.id.sw_radio_button:
mEncodeMode = Config.SW;
mMaintainResRadioGroup.setVisibility(View.VISIBLE);
break;
case R.id.low_sample_rate_button:
mSampleRatePos = Config.LOW_SAMPLE_RATE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ public class ControlFragment extends Fragment {
private ImageButton mToggleSpeakerButton;
private ImageButton mToggleVideoButton;
private ImageButton mLogShownButton;
private ImageButton mStreamingConfigButton;
private LinearLayout mLogView;
private TextView mStreamingConfigButton;
private TextView mForwardJobButton;
private TextView mLocalTextViewForVideo;
private TextView mLocalTextViewForAudio;
private TextView mRemoteTextView;
Expand Down Expand Up @@ -57,6 +58,8 @@ public interface OnCallEvents {
boolean onToggleBeauty();

void onCallStreamingConfig();

void onToggleForwardJob();
}

public void setScreenCaptureEnabled(boolean isScreenCaptureEnabled) {
Expand All @@ -81,6 +84,7 @@ public View onCreateView(
mLogShownButton = (ImageButton) mControlView.findViewById(R.id.log_shown_button);
mLogView = (LinearLayout) mControlView.findViewById(R.id.log_text);
mStreamingConfigButton = mControlView.findViewById(R.id.streaming_config_button);
mForwardJobButton = mControlView.findViewById(R.id.forward_job_button);
mLocalTextViewForVideo = (TextView) mControlView.findViewById(R.id.local_log_text_video);
mLocalTextViewForVideo.setMovementMethod(ScrollingMovementMethod.getInstance());
mLocalTextViewForAudio = (TextView) mControlView.findViewById(R.id.local_log_text_audio);
Expand Down Expand Up @@ -157,6 +161,13 @@ public void onClick(View v) {
mCallEvents.onCallStreamingConfig();
}
});

mForwardJobButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mCallEvents.onToggleForwardJob();
}
});
return mControlView;
}

Expand Down Expand Up @@ -190,6 +201,12 @@ public void updateRemoteLogText(String logText) {
}
}

public void updateForwardJobText(String forwardJobText) {
if (mForwardJobButton != null) {
mForwardJobButton.setText(forwardJobText);
}
}

@Override
public void onStart() {
super.onStart();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package com.qiniu.droid.rtc.demo.model;

import com.qiniu.droid.rtc.QNTrackInfo;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class RTCRoomUsersMergeOption {

private Map<String, RTCUserMergeOptions> mRTCUserMap;
private List<RTCUserMergeOptions> mRTCUsers;
private List<RTCTrackMergeOption> mRTCVideoMergeOptions;

public RTCRoomUsersMergeOption() {
mRTCUserMap = new HashMap<>();
mRTCUsers = new ArrayList<>();
mRTCVideoMergeOptions = new ArrayList<>();
}

public RTCUserMergeOptions getRoomUserByPosition(int pos) {
return mRTCUsers.get(pos);
}

public RTCUserMergeOptions getRoomUserByUserId(String userId) {
return mRTCUserMap.get(userId);
}

public List<RTCTrackMergeOption> getRTCVideoMergeOptions() {
return mRTCVideoMergeOptions;
}

public List<RTCTrackMergeOption> getRTCAudioTracks() {
List<RTCTrackMergeOption> rtcAudioTracks = new ArrayList<>();
for (RTCUserMergeOptions item : mRTCUsers) {
if (item.getAudioTrack() != null) {
rtcAudioTracks.add(item.getAudioTrack());
}
}
return rtcAudioTracks;
}

public void onUserJoined(String userId, String userData) {
if (mRTCUserMap.get(userId) == null) {
RTCUserMergeOptions userMergeOptions = new RTCUserMergeOptions(userId, userData);
mRTCUserMap.put(userId, userMergeOptions);
mRTCUsers.add(userMergeOptions);
}
}

public void onUserLeft(String userId) {
RTCUserMergeOptions userMergeOptions = mRTCUserMap.remove(userId);
if (userMergeOptions != null) {
mRTCUsers.remove(userMergeOptions);
}
}

public void onTracksPublished(String userId, List<QNTrackInfo> trackInfoList) {
RTCUserMergeOptions userMergeOptions = getRoomUserByUserId(userId);
if (userMergeOptions == null) {
return;
}
List<RTCTrackMergeOption> userVideoTracks = userMergeOptions.addTracks(trackInfoList);
mRTCVideoMergeOptions.addAll(userVideoTracks);
}

public void onTracksUnPublished(String userId, List<QNTrackInfo> trackInfoList) {
RTCUserMergeOptions userMergeOptions = getRoomUserByUserId(userId);
if (userMergeOptions == null) {
return;
}
List<RTCTrackMergeOption> userVideoTracks = userMergeOptions.removeTracks(trackInfoList);
mRTCVideoMergeOptions.removeAll(userVideoTracks);
}

public int size() {
return mRTCUsers.size();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package com.qiniu.droid.rtc.demo.model;

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

public class RTCTrackMergeOption {

private final String mTrackId;
private final QNTrackInfo mQNTrackInfo;

private boolean mTrackInclude = true;
private final QNMergeTrackOption mQNMergeTrackOption;

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

mQNMergeTrackOption = new QNMergeTrackOption();
mQNMergeTrackOption.setWidth(QNAppServer.STREAMING_WIDTH);
mQNMergeTrackOption.setHeight(QNAppServer.STREAMING_HEIGHT);
mQNMergeTrackOption.setTrackId(mTrackId);
}

public String getTrackId() {
return mTrackId;
}

public QNTrackInfo getQNTrackInfo() {
return mQNTrackInfo;
}

public QNMergeTrackOption getQNMergeTrackOption() {
return mQNMergeTrackOption;
}

public boolean isTrackInclude() {
return mTrackInclude;
}

public void setTrackInclude(boolean trackInclude) {
mTrackInclude = trackInclude;
}

public void updateQNMergeTrackOption(QNMergeTrackOption option) {
if (option == null) {
return;
}
mQNMergeTrackOption.setX(option.getX());
mQNMergeTrackOption.setY(option.getY());
mQNMergeTrackOption.setZ(option.getZ());
mQNMergeTrackOption.setWidth(option.getWidth());
mQNMergeTrackOption.setHeight(option.getHeight());
}

@Override
public boolean equals(Object obj) {
if (obj instanceof RTCTrackMergeOption) {
return mQNTrackInfo.equals(((RTCTrackMergeOption) obj).mQNTrackInfo);
} else {
return false;
}
}

@Override
public int hashCode() {
return mQNTrackInfo.hashCode();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package com.qiniu.droid.rtc.demo.model;

import com.qiniu.droid.rtc.QNRTCUser;
import com.qiniu.droid.rtc.QNTrackInfo;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

public class RTCUserMergeOptions extends QNRTCUser {

private RTCTrackMergeOption mAudioTrack;
private List<RTCTrackMergeOption> mVideoTracks = new LinkedList<>();

public RTCUserMergeOptions(String userId, String userData) {
super(userId, userData);
}

public RTCTrackMergeOption getAudioTrack() {
return mAudioTrack;
}

public List<RTCTrackMergeOption> getVideoTracks() {
return mVideoTracks;
}

public List<RTCTrackMergeOption> addTracks(List<QNTrackInfo> trackInfoList) {
List<RTCTrackMergeOption> videoTracks = new ArrayList<>();
for (QNTrackInfo item : trackInfoList) {
RTCTrackMergeOption newVideoTrack = addTrack(item);
if (newVideoTrack != null) {
videoTracks.add(newVideoTrack);
}
}
return videoTracks;
}

private RTCTrackMergeOption addTrack(QNTrackInfo trackInfo) {
if (trackInfo.isAudio()) {
mAudioTrack = new RTCTrackMergeOption(trackInfo);
return null;
} else {
RTCTrackMergeOption newVideoTrack = new RTCTrackMergeOption(trackInfo);
// replace
mVideoTracks.remove(newVideoTrack);
mVideoTracks.add(newVideoTrack);
return newVideoTrack;
}
}

public List<RTCTrackMergeOption> removeTracks(List<QNTrackInfo> trackInfoList) {
List<RTCTrackMergeOption> videoTracks = new ArrayList<>();
for (QNTrackInfo item : trackInfoList) {
RTCTrackMergeOption removedVideoTrack = removeTracks(item);
if (removedVideoTrack != null) {
videoTracks.add(removedVideoTrack);
}
}
return videoTracks;
}

private RTCTrackMergeOption removeTracks(QNTrackInfo trackInfo) {
if (trackInfo.isAudio()) {
mAudioTrack = null;
return null;
} else {
RTCTrackMergeOption newUserTrack = new RTCTrackMergeOption(trackInfo);
mVideoTracks.remove(newUserTrack);
return newUserTrack;
}
}
}
Loading

0 comments on commit 7a3111a

Please sign in to comment.