Skip to content

Commit

Permalink
Merge pull request #27 from haiyangwu/release/2.1.0-candidate
Browse files Browse the repository at this point in the history
release v2.1.0
  • Loading branch information
geeklok authored Jan 25, 2019
2 parents be841a1 + 176016e commit 6562866
Show file tree
Hide file tree
Showing 25 changed files with 983 additions and 281 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 12
versionName "2.0.0"
versionCode 18
versionName "2.1.0"
buildConfigField "long", "BUILD_TIMESTAMP", System.currentTimeMillis() + "L"
}

Expand Down
Binary file not shown.
1 change: 1 addition & 0 deletions QNDroidRTCDemo/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<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" />

<application
android:name=".RTCApplication"
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ private void disconnectWithErrorMessage(final String errorMessage) {
@Override
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
finish();
}
})
.create()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package com.qiniu.droid.rtc.demo.model;

import com.qiniu.droid.rtc.QNTrackInfo;
import com.qiniu.droid.rtc.model.QNMergeTrackOption;

public class RemoteTrack {

private final String mTrackId;
private final QNTrackInfo mQNTrackInfo;

private boolean mTrackInclude = true;
private final QNMergeTrackOption mQNMergeTrackOption;

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

mQNMergeTrackOption = new QNMergeTrackOption();
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 RemoteTrack) {
return mQNTrackInfo.equals(((RemoteTrack) 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 RemoteUser extends QNRTCUser {

private RemoteTrack mRemoteAudioTrack;
private List<RemoteTrack> mRemoteVideoTracks = new LinkedList<>();

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

public RemoteTrack getRemoteAudioTrack() {
return mRemoteAudioTrack;
}

public List<RemoteTrack> getRemoteVideoTracks() {
return mRemoteVideoTracks;
}

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

private RemoteTrack addTrack(QNTrackInfo trackInfo) {
if (trackInfo.isAudio()) {
mRemoteAudioTrack = new RemoteTrack(trackInfo);
return null;
} else {
RemoteTrack newRemoteVideoTrack = new RemoteTrack(trackInfo);
// replace
mRemoteVideoTracks.remove(newRemoteVideoTrack);
mRemoteVideoTracks.add(newRemoteVideoTrack);
return newRemoteVideoTrack;
}
}

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

private RemoteTrack removeTracks(QNTrackInfo trackInfo) {
if (trackInfo.isAudio()) {
mRemoteAudioTrack = null;
return null;
} else {
RemoteTrack newRemoteTrack = new RemoteTrack(trackInfo);
mRemoteVideoTracks.remove(newRemoteTrack);
return newRemoteTrack;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
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 RemoteUserList {

private Map<String, RemoteUser> mRemoteUserMap;
private List<RemoteUser> mRemoteUsers;
private List<RemoteTrack> mRemoteVideoTracks;

public RemoteUserList() {
mRemoteUserMap = new HashMap<>();
mRemoteUsers = new ArrayList<>();
mRemoteVideoTracks = new ArrayList<>();
}

public RemoteUser getRemoteUserByPosition(int pos) {
return mRemoteUsers.get(pos);
}

public RemoteUser getRemoteUserByUserId(String userId) {
return mRemoteUserMap.get(userId);
}

public List<RemoteTrack> getRemoteVideoTracks() {
return mRemoteVideoTracks;
}

public List<RemoteTrack> getRemoteAudioTracks() {
List<RemoteTrack> remoteAudioTracks = new ArrayList<>();
for (RemoteUser item : mRemoteUsers) {
if (item.getRemoteAudioTrack() != null) {
remoteAudioTracks.add(item.getRemoteAudioTrack());
}
}
return remoteAudioTracks;
}

public void onUserJoined(String userId, String userData) {
RemoteUser remoteUser = new RemoteUser(userId, userData);
mRemoteUserMap.put(userId, remoteUser);
mRemoteUsers.add(remoteUser);
}

public void onUserLeft(String userId) {
RemoteUser remoteUser = mRemoteUserMap.remove(userId);
if (remoteUser != null) {
mRemoteUsers.remove(remoteUser);
}
}

public void onTracksPublished(String userId, List<QNTrackInfo> trackInfoList) {
RemoteUser remoteUser = getRemoteUserByUserId(userId);
if (remoteUser == null) {
return;
}
List<RemoteTrack> remoteVideoTracks = remoteUser.addTracks(trackInfoList);
mRemoteVideoTracks.addAll(remoteVideoTracks);
}

public void onTracksUnPublished(String userId, List<QNTrackInfo> trackInfoList) {
RemoteUser remoteUser = getRemoteUserByUserId(userId);
if (remoteUser == null) {
return;
}
List<RemoteTrack> remoteVideoTracks = remoteUser.removeTracks(trackInfoList);
mRemoteVideoTracks.removeAll(remoteVideoTracks);
}

public int size() {
return mRemoteUsers.size();
}
}
Loading

0 comments on commit 6562866

Please sign in to comment.