mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 12:09:45 +01:00
Create ParticipantDisplayItem when creating the connections
The ParticipantDisplayItem for "video" was created when a participant joined the room, but the item for "screen" was created when the stream for the screen was connected. Due to this the item for the remote screen share just "popped up" once connected, but there was no hint of a connection being established, like done with the video streams. Now the ParticipantDisplayItems are created as soon as a PeerConnectionWrapper is created and then updated as needed (for example to set the user ID or the stream), which causes the item to immediately appear and a progress bar to be shown until the connection is established. Although the ParticipantDisplayItem may be created on a different thread (the main thread) than the PeerConnectionWrapper "runOnUiThread" executes the enqueued messages in order (and it also establishes a "happens-before" relation with further calls of "runOnUiThread" due to the internal use of synchronized blocks, although it is not explicitly documented), so the item will be already created when later updated. This also holds true when an offer is received even before the participant is seen as joined (a very rare case that can happen if the signaling message with the updated participant list is lost for any reason); the ParticipantDisplayItem is created when the offer is received and it is later updated with the user ID once a new signaling message with the updated participant list is received. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This commit is contained in:
parent
29d0574667
commit
6e222e7cd2
@ -1858,16 +1858,23 @@ public class CallActivity extends CallBaseActivity {
|
||||
getOrCreatePeerConnectionWrapperForSessionIdAndType(sessionId, VIDEO_STREAM_TYPE_VIDEO, false);
|
||||
|
||||
String userId = userIdsBySessionId.get(sessionId);
|
||||
|
||||
if (userId != null) {
|
||||
runOnUiThread(() -> {
|
||||
setupVideoStreamForLayout(
|
||||
null,
|
||||
sessionId,
|
||||
userId,
|
||||
false,
|
||||
VIDEO_STREAM_TYPE_VIDEO);
|
||||
boolean notifyDataSetChanged = false;
|
||||
if (participantDisplayItems.get(sessionId + "-video") != null) {
|
||||
participantDisplayItems.get(sessionId + "-video").setUserId(userId);
|
||||
notifyDataSetChanged = true;
|
||||
}
|
||||
if (participantDisplayItems.get(sessionId + "-screen") != null) {
|
||||
participantDisplayItems.get(sessionId + "-screen").setUserId(userId);
|
||||
notifyDataSetChanged = true;
|
||||
}
|
||||
if (notifyDataSetChanged) {
|
||||
participantsAdapter.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (newSessions.size() > 0 && currentCallStatus != CallStatus.IN_CONVERSATION) {
|
||||
setCallState(CallStatus.IN_CONVERSATION);
|
||||
@ -2024,6 +2031,18 @@ public class CallActivity extends CallBaseActivity {
|
||||
signalingMessageReceiver.addListener(offerAnswerNickProvider.getScreenWebRtcMessageListener(), sessionId, "screen");
|
||||
}
|
||||
|
||||
if (!publisher) {
|
||||
runOnUiThread(() -> {
|
||||
// userId is unknown here, but it will be got based on the session id, and the stream will be
|
||||
// updated once it is added to the connection.
|
||||
setupVideoStreamForLayout(
|
||||
null,
|
||||
sessionId,
|
||||
false,
|
||||
type);
|
||||
});
|
||||
}
|
||||
|
||||
if (publisher) {
|
||||
startSendingNick();
|
||||
}
|
||||
@ -2227,14 +2246,7 @@ public class CallActivity extends CallBaseActivity {
|
||||
public void onMessageEvent(MediaStreamEvent mediaStreamEvent) {
|
||||
String participantDisplayItemId = mediaStreamEvent.getSession() + "-" + mediaStreamEvent.getVideoStreamType();
|
||||
if (participantDisplayItems.get(participantDisplayItemId) == null) {
|
||||
// Initial setup, ignore media related properties as they will be set after it.
|
||||
// userId is unknown from the event, but it will be got based on the session id.
|
||||
setupVideoStreamForLayout(
|
||||
null,
|
||||
mediaStreamEvent.getSession(),
|
||||
null,
|
||||
false,
|
||||
mediaStreamEvent.getVideoStreamType());
|
||||
return;
|
||||
}
|
||||
|
||||
boolean hasAtLeastOneVideoStream = false;
|
||||
@ -2260,7 +2272,6 @@ public class CallActivity extends CallBaseActivity {
|
||||
|
||||
private void setupVideoStreamForLayout(@Nullable MediaStream mediaStream,
|
||||
String session,
|
||||
String userId,
|
||||
boolean videoStreamEnabled,
|
||||
String videoStreamType) {
|
||||
PeerConnectionWrapper peerConnectionWrapper = getPeerConnectionWrapperForSessionIdAndType(session,
|
||||
@ -2280,20 +2291,17 @@ public class CallActivity extends CallBaseActivity {
|
||||
nick = offerAnswerNickProviders.get(session) != null ? offerAnswerNickProviders.get(session).getNick() : "";
|
||||
}
|
||||
|
||||
String userId4Usage = userId;
|
||||
|
||||
if (userId4Usage == null) {
|
||||
String userId = null;
|
||||
if (hasMCU) {
|
||||
userId4Usage = webSocketClient.getUserIdForSession(session);
|
||||
userId = webSocketClient.getUserIdForSession(session);
|
||||
} else if (participantMap.get(session) != null && participantMap.get(session).getCalculatedActorType() == Participant.ActorType.USERS) {
|
||||
userId4Usage = participantMap.get(session).getCalculatedActorId();
|
||||
}
|
||||
userId = participantMap.get(session).getCalculatedActorId();
|
||||
}
|
||||
|
||||
String defaultGuestNick = getResources().getString(R.string.nc_nick_guest);
|
||||
|
||||
ParticipantDisplayItem participantDisplayItem = new ParticipantDisplayItem(baseUrl,
|
||||
userId4Usage,
|
||||
userId,
|
||||
session,
|
||||
connected,
|
||||
nick,
|
||||
|
Loading…
Reference in New Issue
Block a user