Create a connection only for offers instead of for any message

The Android app creates a connection with a participant when that
participant joins the call and ends it when the participant leaves the
call. However, it also created a connection when any signaling message
was received from a participant that had no connection yet. Due to this
if a signaling message was received from a participant before that
participant was in the call the Android app tried to establish a
connection too soon, which would be rejected by the HPB.

Similarly, if a signaling message was received from a participant after
that participant left the call a connection will try to be established.
That would fail, but the connection object was not removed, and if that
participant joined the call again no connection would be established, as
a connection for that participant was already found, even if it was not
usable.

To solve that now a connection is created when a signaling message is
received only if that message is an offer (which is necessary without
HPB if the other participant sends the offer before this participant
"noticed" that she is in the call); otherwise the message is ignored.

Besides that a connection will no longer be created either when setting
up the video stream. However, this would be just for correctness and it
should not make any difference, as the MediaStreamEvents that cause that
are only emitted by changes in peer connections, so they should be
already created.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This commit is contained in:
Daniel Calviño Sánchez 2022-04-22 02:32:21 +02:00
parent a8045880f9
commit 5bd920142c

View file

@ -1543,10 +1543,6 @@ public class CallActivity extends CallBaseActivity {
private void processMessage(NCSignalingMessage ncSignalingMessage) {
if (ncSignalingMessage.getRoomType().equals("video") || ncSignalingMessage.getRoomType().equals("screen")) {
PeerConnectionWrapper peerConnectionWrapper =
getOrCreatePeerConnectionWrapperForSessionIdAndType(ncSignalingMessage.getFrom(),
ncSignalingMessage.getRoomType(), false);
String type = null;
if (ncSignalingMessage.getPayload() != null && ncSignalingMessage.getPayload().getType() != null) {
type = ncSignalingMessage.getPayload().getType();
@ -1554,7 +1550,24 @@ public class CallActivity extends CallBaseActivity {
type = ncSignalingMessage.getType();
}
if (type != null) {
PeerConnectionWrapper peerConnectionWrapper = null;
if ("offer".equals(type)) {
peerConnectionWrapper =
getOrCreatePeerConnectionWrapperForSessionIdAndType(ncSignalingMessage.getFrom(),
ncSignalingMessage.getRoomType(), false);
} else {
peerConnectionWrapper =
getPeerConnectionWrapperForSessionIdAndType(ncSignalingMessage.getFrom(),
ncSignalingMessage.getRoomType());
}
if ("unshareScreen".equals(type) ||
(("offer".equals(type) ||
"answer".equals(type) ||
"candidate".equals(type) ||
"endOfCandidates".equals(type)) &&
peerConnectionWrapper != null)) {
switch (type) {
case "unshareScreen":
endPeerConnection(ncSignalingMessage.getFrom(), true);
@ -2181,7 +2194,9 @@ public class CallActivity extends CallBaseActivity {
if (hasExternalSignalingServer) {
nick = webSocketClient.getDisplayNameForSession(session);
} else {
nick = getOrCreatePeerConnectionWrapperForSessionIdAndType(session, videoStreamType, false).getNick();
PeerConnectionWrapper peerConnectionWrapper = getPeerConnectionWrapperForSessionIdAndType(session,
videoStreamType);
nick = peerConnectionWrapper != null ? peerConnectionWrapper.getNick() : "";
}
String userId = "";