mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-11 14:54:09 +01:00
Simplify ending the peer connections
The peer connections will be of either "video" or "screen" type, so they can be simply removed based on the session id and an explicit type. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This commit is contained in:
parent
9ae969b0f8
commit
67e259f792
@ -1726,7 +1726,8 @@ public class CallActivity extends CallBaseActivity {
|
|||||||
peerConnectionIdsToEnd.add(wrapper.getSessionId());
|
peerConnectionIdsToEnd.add(wrapper.getSessionId());
|
||||||
}
|
}
|
||||||
for (String sessionId : peerConnectionIdsToEnd) {
|
for (String sessionId : peerConnectionIdsToEnd) {
|
||||||
endPeerConnection(sessionId, false);
|
endPeerConnection(sessionId, "video");
|
||||||
|
endPeerConnection(sessionId, "screen");
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> callParticipantIdsToEnd = new ArrayList<String>(peerConnectionWrapperList.size());
|
List<String> callParticipantIdsToEnd = new ArrayList<String>(peerConnectionWrapperList.size());
|
||||||
@ -1835,7 +1836,8 @@ public class CallActivity extends CallBaseActivity {
|
|||||||
for (Participant participant : participantsInCall) {
|
for (Participant participant : participantsInCall) {
|
||||||
String sessionId = participant.getSessionId();
|
String sessionId = participant.getSessionId();
|
||||||
Log.d(TAG, " session that will be removed is: " + sessionId);
|
Log.d(TAG, " session that will be removed is: " + sessionId);
|
||||||
endPeerConnection(sessionId, false);
|
endPeerConnection(sessionId, "video");
|
||||||
|
endPeerConnection(sessionId, "screen");
|
||||||
removeCallParticipant(sessionId);
|
removeCallParticipant(sessionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1904,7 +1906,8 @@ public class CallActivity extends CallBaseActivity {
|
|||||||
for (Participant participant : left) {
|
for (Participant participant : left) {
|
||||||
String sessionId = participant.getSessionId();
|
String sessionId = participant.getSessionId();
|
||||||
Log.d(TAG, " oldSession that will be removed is: " + sessionId);
|
Log.d(TAG, " oldSession that will be removed is: " + sessionId);
|
||||||
endPeerConnection(sessionId, false);
|
endPeerConnection(sessionId, "video");
|
||||||
|
endPeerConnection(sessionId, "screen");
|
||||||
removeCallParticipant(sessionId);
|
removeCallParticipant(sessionId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1918,11 +1921,6 @@ public class CallActivity extends CallBaseActivity {
|
|||||||
(!isVoiceOnlyCall && (participant.getInCall() & Participant.InCallFlags.WITH_VIDEO) > 0);
|
(!isVoiceOnlyCall && (participant.getInCall() & Participant.InCallFlags.WITH_VIDEO) > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deletePeerConnection(PeerConnectionWrapper peerConnectionWrapper) {
|
|
||||||
peerConnectionWrapper.removePeerConnection();
|
|
||||||
peerConnectionWrapperList.remove(peerConnectionWrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
private PeerConnectionWrapper getPeerConnectionWrapperForSessionIdAndType(String sessionId, String type) {
|
private PeerConnectionWrapper getPeerConnectionWrapperForSessionIdAndType(String sessionId, String type) {
|
||||||
for (PeerConnectionWrapper wrapper : peerConnectionWrapperList) {
|
for (PeerConnectionWrapper wrapper : peerConnectionWrapperList) {
|
||||||
if (wrapper.getSessionId().equals(sessionId)
|
if (wrapper.getSessionId().equals(sessionId)
|
||||||
@ -2057,42 +2055,27 @@ public class CallActivity extends CallBaseActivity {
|
|||||||
return callParticipant;
|
return callParticipant;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<PeerConnectionWrapper> getPeerConnectionWrapperListForSessionId(String sessionId) {
|
private void endPeerConnection(String sessionId, String type) {
|
||||||
List<PeerConnectionWrapper> internalList = new ArrayList<>();
|
PeerConnectionWrapper peerConnectionWrapper = getPeerConnectionWrapperForSessionIdAndType(sessionId, type);
|
||||||
for (PeerConnectionWrapper peerConnectionWrapper : peerConnectionWrapperList) {
|
if (peerConnectionWrapper == null) {
|
||||||
if (peerConnectionWrapper.getSessionId().equals(sessionId)) {
|
return;
|
||||||
internalList.add(peerConnectionWrapper);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return internalList;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void endPeerConnection(String sessionId, boolean justScreen) {
|
|
||||||
List<PeerConnectionWrapper> peerConnectionWrappers;
|
|
||||||
if (!(peerConnectionWrappers = getPeerConnectionWrapperListForSessionId(sessionId)).isEmpty()) {
|
|
||||||
for (PeerConnectionWrapper peerConnectionWrapper : peerConnectionWrappers) {
|
|
||||||
if (peerConnectionWrapper.getSessionId().equals(sessionId)) {
|
|
||||||
if (webSocketClient != null && webSocketClient.getSessionId() != null && webSocketClient.getSessionId().equals(sessionId)) {
|
if (webSocketClient != null && webSocketClient.getSessionId() != null && webSocketClient.getSessionId().equals(sessionId)) {
|
||||||
peerConnectionWrapper.removeObserver(selfPeerConnectionObserver);
|
peerConnectionWrapper.removeObserver(selfPeerConnectionObserver);
|
||||||
}
|
}
|
||||||
|
|
||||||
String videoStreamType = peerConnectionWrapper.getVideoStreamType();
|
|
||||||
if (VIDEO_STREAM_TYPE_SCREEN.equals(videoStreamType) || !justScreen) {
|
|
||||||
CallParticipant callParticipant = callParticipants.get(sessionId);
|
CallParticipant callParticipant = callParticipants.get(sessionId);
|
||||||
if (callParticipant != null) {
|
if (callParticipant != null) {
|
||||||
if ("screen".equals(videoStreamType)) {
|
if ("screen".equals(type)) {
|
||||||
callParticipant.setScreenPeerConnectionWrapper(null);
|
callParticipant.setScreenPeerConnectionWrapper(null);
|
||||||
} else {
|
} else {
|
||||||
callParticipant.setPeerConnectionWrapper(null);
|
callParticipant.setPeerConnectionWrapper(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
deletePeerConnection(peerConnectionWrapper);
|
peerConnectionWrapper.removePeerConnection();
|
||||||
}
|
peerConnectionWrapperList.remove(peerConnectionWrapper);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeCallParticipant(String sessionId) {
|
private void removeCallParticipant(String sessionId) {
|
||||||
@ -2599,7 +2582,7 @@ public class CallActivity extends CallBaseActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUnshareScreen() {
|
public void onUnshareScreen() {
|
||||||
endPeerConnection(sessionId, true);
|
endPeerConnection(sessionId, "screen");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user