-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from haiyangwu/release/2.1.0-candidate
release v2.1.0
- Loading branch information
Showing
25 changed files
with
983 additions
and
281 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file renamed
BIN
+774 KB
...oidRTCDemo/app/libs/qndroid-rtc-2.0.0.jar → ...oidRTCDemo/app/libs/qndroid-rtc-2.1.0.jar
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
363 changes: 149 additions & 214 deletions
363
QNDroidRTCDemo/app/src/main/java/com/qiniu/droid/rtc/demo/activity/LiveRoomActivity.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
QNDroidRTCDemo/app/src/main/java/com/qiniu/droid/rtc/demo/model/RemoteTrack.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
QNDroidRTCDemo/app/src/main/java/com/qiniu/droid/rtc/demo/model/RemoteUser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
78 changes: 78 additions & 0 deletions
78
QNDroidRTCDemo/app/src/main/java/com/qiniu/droid/rtc/demo/model/RemoteUserList.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
Oops, something went wrong.