Post MediaStreamEvents for each connection state

Rather than simplifying the states to "CONNECTED" and "DISCONNECTED" now
the raw state is posted, and the handler then decides how to treat them
(which, for now, is exactly 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-22 13:54:19 +01:00
parent 337f3d4b5e
commit fcbfc1926d
3 changed files with 19 additions and 9 deletions

View File

@ -2119,10 +2119,16 @@ public class CallActivity extends CallBaseActivity {
String sessionId = peerConnectionEvent.getSessionId();
if (peerConnectionEvent.getPeerConnectionEventType() ==
PeerConnectionEvent.PeerConnectionEventType.PEER_CONNECTED) {
PeerConnectionEvent.PeerConnectionEventType.PEER_CONNECTED ||
peerConnectionEvent.getPeerConnectionEventType() ==
PeerConnectionEvent.PeerConnectionEventType.PEER_COMPLETED) {
handlePeerConnected(sessionId, peerConnectionEvent.getVideoStreamType());
} else if (peerConnectionEvent.getPeerConnectionEventType() ==
PeerConnectionEvent.PeerConnectionEventType.PEER_DISCONNECTED) {
PeerConnectionEvent.PeerConnectionEventType.PEER_DISCONNECTED ||
peerConnectionEvent.getPeerConnectionEventType() ==
PeerConnectionEvent.PeerConnectionEventType.PEER_NEW ||
peerConnectionEvent.getPeerConnectionEventType() ==
PeerConnectionEvent.PeerConnectionEventType.PEER_CHECKING) {
handlePeerDisconnected(sessionId, peerConnectionEvent.getVideoStreamType());
} else if (peerConnectionEvent.getPeerConnectionEventType() ==
PeerConnectionEvent.PeerConnectionEventType.PEER_CLOSED) {
@ -2147,6 +2153,8 @@ public class CallActivity extends CallBaseActivity {
setCallState(CallStatus.PUBLISHER_FAILED);
webSocketClient.clearResumeId();
hangup(false);
} else {
handlePeerDisconnected(sessionId, peerConnectionEvent.getVideoStreamType());
}
}
}

View File

@ -120,6 +120,6 @@ public class PeerConnectionEvent {
}
public enum PeerConnectionEventType {
PEER_CONNECTED, PEER_DISCONNECTED, PEER_FAILED, PEER_CLOSED, SENSOR_FAR, SENSOR_NEAR
PEER_NEW, PEER_CHECKING, PEER_CONNECTED, PEER_COMPLETED, PEER_DISCONNECTED, PEER_FAILED, PEER_CLOSED, SENSOR_FAR, SENSOR_NEAR
}
}

View File

@ -419,19 +419,21 @@ public class PeerConnectionWrapper {
sendInitialMediaStatus();
}
} else if (iceConnectionState == PeerConnection.IceConnectionState.COMPLETED) {
EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType.PEER_CONNECTED,
EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType.PEER_COMPLETED,
sessionId, null, null, videoStreamType));
} else if (iceConnectionState == PeerConnection.IceConnectionState.CLOSED) {
EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType
.PEER_CLOSED, sessionId, null, null, videoStreamType));
} else if (iceConnectionState == PeerConnection.IceConnectionState.DISCONNECTED ||
iceConnectionState == PeerConnection.IceConnectionState.NEW ||
iceConnectionState == PeerConnection.IceConnectionState.CHECKING) {
} else if (iceConnectionState == PeerConnection.IceConnectionState.DISCONNECTED) {
EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType.PEER_DISCONNECTED,
sessionId, null, null, videoStreamType));
} else if (iceConnectionState == PeerConnection.IceConnectionState.NEW) {
EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType.PEER_NEW,
sessionId, null, null, videoStreamType));
} else if (iceConnectionState == PeerConnection.IceConnectionState.CHECKING) {
EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType.PEER_CHECKING,
sessionId, null, null, videoStreamType));
} else if (iceConnectionState == PeerConnection.IceConnectionState.FAILED) {
EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType.PEER_DISCONNECTED,
sessionId, null, null, videoStreamType));
EventBus.getDefault().post(new PeerConnectionEvent(PeerConnectionEvent.PeerConnectionEventType.PEER_FAILED,
sessionId, null, null, videoStreamType));
}