mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-22 13:09:46 +01:00
Observe only the self peer connection
The observers were created for any peer connection, but after recent changes they ignored all changes but those from the self peer connection. Therefore it is enough to just add an explicit listener on that peer connection rather than on all of them. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This commit is contained in:
parent
6728e3f063
commit
0a3f515bb6
@ -264,7 +264,7 @@ public class CallActivity extends CallBaseActivity {
|
|||||||
private Map<String, SignalingMessageReceiver.CallParticipantMessageListener> callParticipantMessageListeners =
|
private Map<String, SignalingMessageReceiver.CallParticipantMessageListener> callParticipantMessageListeners =
|
||||||
new HashMap<>();
|
new HashMap<>();
|
||||||
|
|
||||||
private Map<String, PeerConnectionWrapper.PeerConnectionObserver> peerConnectionObservers = new HashMap<>();
|
private PeerConnectionWrapper.PeerConnectionObserver selfPeerConnectionObserver = new CallActivitySelfPeerConnectionObserver();
|
||||||
|
|
||||||
private Map<String, CallParticipant> callParticipants = new HashMap<>();
|
private Map<String, CallParticipant> callParticipants = new HashMap<>();
|
||||||
|
|
||||||
@ -1970,11 +1970,6 @@ public class CallActivity extends CallBaseActivity {
|
|||||||
|
|
||||||
peerConnectionWrapperList.add(peerConnectionWrapper);
|
peerConnectionWrapperList.add(peerConnectionWrapper);
|
||||||
|
|
||||||
PeerConnectionWrapper.PeerConnectionObserver peerConnectionObserver =
|
|
||||||
new CallActivityPeerConnectionObserver(sessionId);
|
|
||||||
peerConnectionObservers.put(sessionId + "-" + type, peerConnectionObserver);
|
|
||||||
peerConnectionWrapper.addObserver(peerConnectionObserver);
|
|
||||||
|
|
||||||
if (!publisher) {
|
if (!publisher) {
|
||||||
CallParticipant callParticipant = callParticipants.get(sessionId);
|
CallParticipant callParticipant = callParticipants.get(sessionId);
|
||||||
if (callParticipant == null) {
|
if (callParticipant == null) {
|
||||||
@ -2013,6 +2008,8 @@ public class CallActivity extends CallBaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (publisher) {
|
if (publisher) {
|
||||||
|
peerConnectionWrapper.addObserver(selfPeerConnectionObserver);
|
||||||
|
|
||||||
startSendingNick();
|
startSendingNick();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2036,11 +2033,12 @@ public class CallActivity extends CallBaseActivity {
|
|||||||
if (!(peerConnectionWrappers = getPeerConnectionWrapperListForSessionId(sessionId)).isEmpty()) {
|
if (!(peerConnectionWrappers = getPeerConnectionWrapperListForSessionId(sessionId)).isEmpty()) {
|
||||||
for (PeerConnectionWrapper peerConnectionWrapper : peerConnectionWrappers) {
|
for (PeerConnectionWrapper peerConnectionWrapper : peerConnectionWrappers) {
|
||||||
if (peerConnectionWrapper.getSessionId().equals(sessionId)) {
|
if (peerConnectionWrapper.getSessionId().equals(sessionId)) {
|
||||||
|
if (webSocketClient != null && webSocketClient.getSessionId() != null && webSocketClient.getSessionId().equals(sessionId)) {
|
||||||
|
peerConnectionWrapper.removeObserver(selfPeerConnectionObserver);
|
||||||
|
}
|
||||||
|
|
||||||
String videoStreamType = peerConnectionWrapper.getVideoStreamType();
|
String videoStreamType = peerConnectionWrapper.getVideoStreamType();
|
||||||
if (VIDEO_STREAM_TYPE_SCREEN.equals(videoStreamType) || !justScreen) {
|
if (VIDEO_STREAM_TYPE_SCREEN.equals(videoStreamType) || !justScreen) {
|
||||||
PeerConnectionWrapper.PeerConnectionObserver peerConnectionObserver = peerConnectionObservers.remove(sessionId + "-" + videoStreamType);
|
|
||||||
peerConnectionWrapper.removeObserver(peerConnectionObserver);
|
|
||||||
|
|
||||||
CallParticipant callParticipant = callParticipants.get(sessionId);
|
CallParticipant callParticipant = callParticipants.get(sessionId);
|
||||||
if (callParticipant != null) {
|
if (callParticipant != null) {
|
||||||
if ("screen".equals(videoStreamType)) {
|
if ("screen".equals(videoStreamType)) {
|
||||||
@ -2563,13 +2561,7 @@ public class CallActivity extends CallBaseActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class CallActivityPeerConnectionObserver implements PeerConnectionWrapper.PeerConnectionObserver {
|
private class CallActivitySelfPeerConnectionObserver implements PeerConnectionWrapper.PeerConnectionObserver {
|
||||||
|
|
||||||
private final String sessionId;
|
|
||||||
|
|
||||||
private CallActivityPeerConnectionObserver(String sessionId) {
|
|
||||||
this.sessionId = sessionId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStreamAdded(MediaStream mediaStream) {
|
public void onStreamAdded(MediaStream mediaStream) {
|
||||||
@ -2582,19 +2574,13 @@ public class CallActivity extends CallBaseActivity {
|
|||||||
@Override
|
@Override
|
||||||
public void onIceConnectionStateChanged(PeerConnection.IceConnectionState iceConnectionState) {
|
public void onIceConnectionStateChanged(PeerConnection.IceConnectionState iceConnectionState) {
|
||||||
runOnUiThread(() -> {
|
runOnUiThread(() -> {
|
||||||
if (webSocketClient != null && webSocketClient.getSessionId() != null && webSocketClient.getSessionId().equals(sessionId)) {
|
|
||||||
updateSelfVideoViewIceConnectionState(iceConnectionState);
|
updateSelfVideoViewIceConnectionState(iceConnectionState);
|
||||||
}
|
|
||||||
|
|
||||||
if (iceConnectionState == PeerConnection.IceConnectionState.FAILED) {
|
if (iceConnectionState == PeerConnection.IceConnectionState.FAILED) {
|
||||||
if (webSocketClient != null && webSocketClient.getSessionId() != null && webSocketClient.getSessionId().equals(sessionId)) {
|
|
||||||
setCallState(CallStatus.PUBLISHER_FAILED);
|
setCallState(CallStatus.PUBLISHER_FAILED);
|
||||||
webSocketClient.clearResumeId();
|
webSocketClient.clearResumeId();
|
||||||
hangup(false);
|
hangup(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user