Update displayed nick when received in offers or answers

The nick was displayed when updated through a data channel message, or
when a ParticipantDisplayItem was created and the nick was already
received. However, when the HPB is not used the nick is not sent after a
connection is established, as it was sent already in the offer or
answer. The nick from the offer or answer has not been received yet when
the ParticipantDisplayItem is initially created, so the nick only
appeared because a new ParticipantDisplayItem is created again when the
connection is finally established. Due to all that the displayed nick is
now updated as soon as it is received in an offer or answer, which
ensures that the nick is shown independently of when was the
ParticipantDisplayItem created.

Note that this only applies to non-HPB scenarios; when the HPB is used
the nick is got from the participant list update sent through signaling
messages, so it is already known when creating the display item (in some
very strange cases it might happen that an offer is received before the
participant list was updated, but this should not happen, and in any
case it will be handled at a later point).

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This commit is contained in:
Daniel Calviño Sánchez 2022-11-25 10:59:32 +01:00
parent 5786baaeb7
commit dc53023572

View file

@ -2018,7 +2018,7 @@ public class CallActivity extends CallBaseActivity {
} }
if (!publisher && !hasExternalSignalingServer && offerAnswerNickProviders.get(sessionId) == null) { if (!publisher && !hasExternalSignalingServer && offerAnswerNickProviders.get(sessionId) == null) {
OfferAnswerNickProvider offerAnswerNickProvider = new OfferAnswerNickProvider(); OfferAnswerNickProvider offerAnswerNickProvider = new OfferAnswerNickProvider(sessionId);
offerAnswerNickProviders.put(sessionId, offerAnswerNickProvider); offerAnswerNickProviders.put(sessionId, offerAnswerNickProvider);
signalingMessageReceiver.addListener(offerAnswerNickProvider.getVideoWebRtcMessageListener(), sessionId, "video"); signalingMessageReceiver.addListener(offerAnswerNickProvider.getVideoWebRtcMessageListener(), sessionId, "video");
signalingMessageReceiver.addListener(offerAnswerNickProvider.getScreenWebRtcMessageListener(), sessionId, "screen"); signalingMessageReceiver.addListener(offerAnswerNickProvider.getScreenWebRtcMessageListener(), sessionId, "screen");
@ -2570,18 +2570,18 @@ public class CallActivity extends CallBaseActivity {
} }
} }
private static class OfferAnswerNickProvider { private class OfferAnswerNickProvider {
private class WebRtcMessageListener implements SignalingMessageReceiver.WebRtcMessageListener { private class WebRtcMessageListener implements SignalingMessageReceiver.WebRtcMessageListener {
@Override @Override
public void onOffer(String sdp, String nick) { public void onOffer(String sdp, String nick) {
(OfferAnswerNickProvider.this).nick = nick; onOfferOrAnswer(nick);
} }
@Override @Override
public void onAnswer(String sdp, String nick) { public void onAnswer(String sdp, String nick) {
(OfferAnswerNickProvider.this).nick = nick; onOfferOrAnswer(nick);
} }
@Override @Override
@ -2596,8 +2596,31 @@ public class CallActivity extends CallBaseActivity {
private final WebRtcMessageListener videoWebRtcMessageListener = new WebRtcMessageListener(); private final WebRtcMessageListener videoWebRtcMessageListener = new WebRtcMessageListener();
private final WebRtcMessageListener screenWebRtcMessageListener = new WebRtcMessageListener(); private final WebRtcMessageListener screenWebRtcMessageListener = new WebRtcMessageListener();
private final String sessionId;
private String nick; private String nick;
private OfferAnswerNickProvider(String sessionId) {
this.sessionId = sessionId;
}
private void onOfferOrAnswer(String nick) {
this.nick = nick;
boolean notifyDataSetChanged = false;
if (participantDisplayItems.get(sessionId + "-video") != null) {
participantDisplayItems.get(sessionId + "-video").setNick(nick);
notifyDataSetChanged = true;
}
if (participantDisplayItems.get(sessionId + "-screen") != null) {
participantDisplayItems.get(sessionId + "-screen").setNick(nick);
notifyDataSetChanged = true;
}
if (notifyDataSetChanged) {
participantsAdapter.notifyDataSetChanged();
}
}
public WebRtcMessageListener getVideoWebRtcMessageListener() { public WebRtcMessageListener getVideoWebRtcMessageListener() {
return videoWebRtcMessageListener; return videoWebRtcMessageListener;
} }