mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-29 01:48:53 +03:00
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:
parent
2e2e96c91f
commit
339d65dff8
2 changed files with 20 additions and 49 deletions
|
@ -2072,7 +2072,10 @@ public class CallActivity extends CallBaseActivity {
|
||||||
updateSelfVideoViewPosition();
|
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
|
// 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
|
// nowhere. However, a way to signal that the local participant is not connected to the HPB is still need in
|
||||||
// that case.
|
// 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() {
|
private void startSendingNick() {
|
||||||
DataChannelMessage dataChannelMessage = new DataChannelMessage();
|
DataChannelMessage dataChannelMessage = new DataChannelMessage();
|
||||||
dataChannelMessage.setType("nickChanged");
|
dataChannelMessage.setType("nickChanged");
|
||||||
|
@ -2211,11 +2192,9 @@ public class CallActivity extends CallBaseActivity {
|
||||||
PeerConnectionWrapper peerConnectionWrapper = getPeerConnectionWrapperForSessionIdAndType(session,
|
PeerConnectionWrapper peerConnectionWrapper = getPeerConnectionWrapperForSessionIdAndType(session,
|
||||||
videoStreamType);
|
videoStreamType);
|
||||||
|
|
||||||
boolean connected = false;
|
PeerConnection.IceConnectionState iceConnectionState = null;
|
||||||
if (peerConnectionWrapper != null) {
|
if (peerConnectionWrapper != null) {
|
||||||
PeerConnection.IceConnectionState iceConnectionState = peerConnectionWrapper.getPeerConnection().iceConnectionState();
|
iceConnectionState = peerConnectionWrapper.getPeerConnection().iceConnectionState();
|
||||||
connected = iceConnectionState == PeerConnection.IceConnectionState.CONNECTED ||
|
|
||||||
iceConnectionState == PeerConnection.IceConnectionState.COMPLETED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String nick;
|
String nick;
|
||||||
|
@ -2232,7 +2211,7 @@ public class CallActivity extends CallBaseActivity {
|
||||||
ParticipantDisplayItem participantDisplayItem = new ParticipantDisplayItem(baseUrl,
|
ParticipantDisplayItem participantDisplayItem = new ParticipantDisplayItem(baseUrl,
|
||||||
userId,
|
userId,
|
||||||
session,
|
session,
|
||||||
connected,
|
iceConnectionState,
|
||||||
nick,
|
nick,
|
||||||
defaultGuestNick,
|
defaultGuestNick,
|
||||||
mediaStream,
|
mediaStream,
|
||||||
|
@ -2692,19 +2671,11 @@ public class CallActivity extends CallBaseActivity {
|
||||||
@Override
|
@Override
|
||||||
public void onIceConnectionStateChanged(PeerConnection.IceConnectionState iceConnectionState) {
|
public void onIceConnectionStateChanged(PeerConnection.IceConnectionState iceConnectionState) {
|
||||||
runOnUiThread(() -> {
|
runOnUiThread(() -> {
|
||||||
if (iceConnectionState == PeerConnection.IceConnectionState.CONNECTED ||
|
if (webSocketClient != null && webSocketClient.getSessionId() != null && webSocketClient.getSessionId().equals(sessionId)) {
|
||||||
iceConnectionState == PeerConnection.IceConnectionState.COMPLETED) {
|
updateSelfVideoViewIceConnectionState(iceConnectionState);
|
||||||
handlePeerConnected(sessionId, videoStreamType);
|
} else if (participantDisplayItems.get(participantDisplayItemId) != null) {
|
||||||
|
participantDisplayItems.get(participantDisplayItemId).setIceConnectionState(iceConnectionState);
|
||||||
return;
|
participantsAdapter.notifyDataSetChanged();
|
||||||
}
|
|
||||||
|
|
||||||
if (iceConnectionState == PeerConnection.IceConnectionState.DISCONNECTED ||
|
|
||||||
iceConnectionState == PeerConnection.IceConnectionState.NEW ||
|
|
||||||
iceConnectionState == PeerConnection.IceConnectionState.CHECKING) {
|
|
||||||
handlePeerDisconnected(sessionId, videoStreamType);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iceConnectionState == PeerConnection.IceConnectionState.CLOSED) {
|
if (iceConnectionState == PeerConnection.IceConnectionState.CLOSED) {
|
||||||
|
@ -2718,8 +2689,6 @@ public class CallActivity extends CallBaseActivity {
|
||||||
setCallState(CallStatus.PUBLISHER_FAILED);
|
setCallState(CallStatus.PUBLISHER_FAILED);
|
||||||
webSocketClient.clearResumeId();
|
webSocketClient.clearResumeId();
|
||||||
hangup(false);
|
hangup(false);
|
||||||
} else {
|
|
||||||
handlePeerDisconnected(sessionId, videoStreamType);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -6,12 +6,13 @@ import com.nextcloud.talk.utils.ApiUtils;
|
||||||
|
|
||||||
import org.webrtc.EglBase;
|
import org.webrtc.EglBase;
|
||||||
import org.webrtc.MediaStream;
|
import org.webrtc.MediaStream;
|
||||||
|
import org.webrtc.PeerConnection;
|
||||||
|
|
||||||
public class ParticipantDisplayItem {
|
public class ParticipantDisplayItem {
|
||||||
private String baseUrl;
|
private String baseUrl;
|
||||||
private String userId;
|
private String userId;
|
||||||
private String session;
|
private String session;
|
||||||
private boolean connected;
|
private PeerConnection.IceConnectionState iceConnectionState;
|
||||||
private String nick;
|
private String nick;
|
||||||
private final String defaultGuestNick;
|
private final String defaultGuestNick;
|
||||||
private String urlForAvatar;
|
private String urlForAvatar;
|
||||||
|
@ -21,11 +22,11 @@ public class ParticipantDisplayItem {
|
||||||
private EglBase rootEglBase;
|
private EglBase rootEglBase;
|
||||||
private boolean isAudioEnabled;
|
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.baseUrl = baseUrl;
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
this.session = session;
|
this.session = session;
|
||||||
this.connected = connected;
|
this.iceConnectionState = iceConnectionState;
|
||||||
this.nick = nick;
|
this.nick = nick;
|
||||||
this.defaultGuestNick = defaultGuestNick;
|
this.defaultGuestNick = defaultGuestNick;
|
||||||
this.mediaStream = mediaStream;
|
this.mediaStream = mediaStream;
|
||||||
|
@ -55,11 +56,12 @@ public class ParticipantDisplayItem {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isConnected() {
|
public boolean isConnected() {
|
||||||
return connected;
|
return iceConnectionState == PeerConnection.IceConnectionState.CONNECTED ||
|
||||||
|
iceConnectionState == PeerConnection.IceConnectionState.COMPLETED;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setConnected(boolean connected) {
|
public void setIceConnectionState(PeerConnection.IceConnectionState iceConnectionState) {
|
||||||
this.connected = connected;
|
this.iceConnectionState = iceConnectionState;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNick() {
|
public String getNick() {
|
||||||
|
|
Loading…
Reference in a new issue