Handle the raw ICE connection state in the views

Rather than just providing a coarse "connected" or "not connected" value
now the views receive the raw ICE connection state. Combined with other
properties this will make possible to show a finer grained status (like
done in the WebUI), although for now just "connected" or "not connected"
is still shown as before.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This commit is contained in:
Daniel Calviño Sánchez 2022-11-24 12:15:10 +01:00 committed by Marcel Hibbe (Rebase PR Action)
parent 2e2e96c91f
commit 339d65dff8
2 changed files with 20 additions and 49 deletions

View file

@ -2072,7 +2072,10 @@ public class CallActivity extends CallBaseActivity {
updateSelfVideoViewPosition();
}
private void updateSelfVideoViewConnected(boolean connected) {
private void updateSelfVideoViewIceConnectionState(PeerConnection.IceConnectionState iceConnectionState) {
boolean connected = iceConnectionState == PeerConnection.IceConnectionState.CONNECTED ||
iceConnectionState == PeerConnection.IceConnectionState.COMPLETED;
// FIXME In voice only calls there is no video view, so the progress bar would appear floating in the middle of
// nowhere. However, a way to signal that the local participant is not connected to the HPB is still need in
// that case.
@ -2133,28 +2136,6 @@ public class CallActivity extends CallBaseActivity {
}
}
private void handlePeerConnected(String sessionId, String videoStreamType) {
String participantDisplayItemId = sessionId + "-" + videoStreamType;
if (webSocketClient != null && webSocketClient.getSessionId() != null && webSocketClient.getSessionId().equals(sessionId)) {
updateSelfVideoViewConnected(true);
} else if (participantDisplayItems.get(participantDisplayItemId) != null) {
participantDisplayItems.get(participantDisplayItemId).setConnected(true);
participantsAdapter.notifyDataSetChanged();
}
}
private void handlePeerDisconnected(String sessionId, String videoStreamType) {
String participantDisplayItemId = sessionId + "-" + videoStreamType;
if (webSocketClient != null && webSocketClient.getSessionId() != null && webSocketClient.getSessionId().equals(sessionId)) {
updateSelfVideoViewConnected(false);
} else if (participantDisplayItems.get(participantDisplayItemId) != null) {
participantDisplayItems.get(participantDisplayItemId).setConnected(false);
participantsAdapter.notifyDataSetChanged();
}
}
private void startSendingNick() {
DataChannelMessage dataChannelMessage = new DataChannelMessage();
dataChannelMessage.setType("nickChanged");
@ -2211,11 +2192,9 @@ public class CallActivity extends CallBaseActivity {
PeerConnectionWrapper peerConnectionWrapper = getPeerConnectionWrapperForSessionIdAndType(session,
videoStreamType);
boolean connected = false;
PeerConnection.IceConnectionState iceConnectionState = null;
if (peerConnectionWrapper != null) {
PeerConnection.IceConnectionState iceConnectionState = peerConnectionWrapper.getPeerConnection().iceConnectionState();
connected = iceConnectionState == PeerConnection.IceConnectionState.CONNECTED ||
iceConnectionState == PeerConnection.IceConnectionState.COMPLETED;
iceConnectionState = peerConnectionWrapper.getPeerConnection().iceConnectionState();
}
String nick;
@ -2232,7 +2211,7 @@ public class CallActivity extends CallBaseActivity {
ParticipantDisplayItem participantDisplayItem = new ParticipantDisplayItem(baseUrl,
userId,
session,
connected,
iceConnectionState,
nick,
defaultGuestNick,
mediaStream,
@ -2692,19 +2671,11 @@ public class CallActivity extends CallBaseActivity {
@Override
public void onIceConnectionStateChanged(PeerConnection.IceConnectionState iceConnectionState) {
runOnUiThread(() -> {
if (iceConnectionState == PeerConnection.IceConnectionState.CONNECTED ||
iceConnectionState == PeerConnection.IceConnectionState.COMPLETED) {
handlePeerConnected(sessionId, videoStreamType);
return;
}
if (iceConnectionState == PeerConnection.IceConnectionState.DISCONNECTED ||
iceConnectionState == PeerConnection.IceConnectionState.NEW ||
iceConnectionState == PeerConnection.IceConnectionState.CHECKING) {
handlePeerDisconnected(sessionId, videoStreamType);
return;
if (webSocketClient != null && webSocketClient.getSessionId() != null && webSocketClient.getSessionId().equals(sessionId)) {
updateSelfVideoViewIceConnectionState(iceConnectionState);
} else if (participantDisplayItems.get(participantDisplayItemId) != null) {
participantDisplayItems.get(participantDisplayItemId).setIceConnectionState(iceConnectionState);
participantsAdapter.notifyDataSetChanged();
}
if (iceConnectionState == PeerConnection.IceConnectionState.CLOSED) {
@ -2718,8 +2689,6 @@ public class CallActivity extends CallBaseActivity {
setCallState(CallStatus.PUBLISHER_FAILED);
webSocketClient.clearResumeId();
hangup(false);
} else {
handlePeerDisconnected(sessionId, videoStreamType);
}
return;

View file

@ -6,12 +6,13 @@ import com.nextcloud.talk.utils.ApiUtils;
import org.webrtc.EglBase;
import org.webrtc.MediaStream;
import org.webrtc.PeerConnection;
public class ParticipantDisplayItem {
private String baseUrl;
private String userId;
private String session;
private boolean connected;
private PeerConnection.IceConnectionState iceConnectionState;
private String nick;
private final String defaultGuestNick;
private String urlForAvatar;
@ -21,11 +22,11 @@ public class ParticipantDisplayItem {
private EglBase rootEglBase;
private boolean isAudioEnabled;
public ParticipantDisplayItem(String baseUrl, String userId, String session, boolean connected, String nick, String defaultGuestNick, MediaStream mediaStream, String streamType, boolean streamEnabled, EglBase rootEglBase) {
public ParticipantDisplayItem(String baseUrl, String userId, String session, PeerConnection.IceConnectionState iceConnectionState, String nick, String defaultGuestNick, MediaStream mediaStream, String streamType, boolean streamEnabled, EglBase rootEglBase) {
this.baseUrl = baseUrl;
this.userId = userId;
this.session = session;
this.connected = connected;
this.iceConnectionState = iceConnectionState;
this.nick = nick;
this.defaultGuestNick = defaultGuestNick;
this.mediaStream = mediaStream;
@ -55,11 +56,12 @@ public class ParticipantDisplayItem {
}
public boolean isConnected() {
return connected;
return iceConnectionState == PeerConnection.IceConnectionState.CONNECTED ||
iceConnectionState == PeerConnection.IceConnectionState.COMPLETED;
}
public void setConnected(boolean connected) {
this.connected = connected;
public void setIceConnectionState(PeerConnection.IceConnectionState iceConnectionState) {
this.iceConnectionState = iceConnectionState;
}
public String getNick() {