Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Show avatar for guests in call view
The avatar of guests is based on their display name/nick.

When the HPB is not used the nick is provided in the offer/answer
signaling messages, and later updated through data channel messages when
it changes. When the HPB is used the nick is periodically sent through
data channel messages. Therefore the avatar is based on the nick set in
the peer connection and reloaded when the nick changes (although it is
currently a bit hacky and brittle, as it is based on whether the nick
shown in the text view changed rather than whether the nick itself
changed, but it works nevertheless).

Note that currently it is required that the guest has a peer connection
to know its nick and, therefore, its avatar; some changes would be
needed in the clients to also send the nick when there is no peer
connection.

Signed-off-by: Daniel Calviño Sánchez <[email protected]>
  • Loading branch information
danxuliu committed Oct 2, 2020
commit ed8ac14d94b078584c94578f232f62e46ee9e3a6
Original file line number Diff line number Diff line change
Expand Up @@ -1914,23 +1914,35 @@ private void setupAvatarForSession(String session) {
SimpleDraweeView avatarImageView = relativeLayout.findViewById(R.id.avatarImageView);

String userId;
String displayName;

if (hasMCU) {
userId = webSocketClient.getUserIdForSession(session);
displayName = getPeerConnectionWrapperForSessionIdAndType(session, "video", false).getNick();
} else {
userId = participantMap.get(session).getUserId();
displayName = getPeerConnectionWrapperForSessionIdAndType(session, "video", false).getNick();
}

if (!TextUtils.isEmpty(userId)) {
if (!TextUtils.isEmpty(userId) || !TextUtils.isEmpty(displayName)) {

if (getActivity() != null) {
avatarImageView.setController(null);

String urlForAvatar;
if (!TextUtils.isEmpty(userId)) {
urlForAvatar = ApiUtils.getUrlForAvatarWithName(baseUrl,
userId,
R.dimen.avatar_size_big);
} else {
urlForAvatar = ApiUtils.getUrlForAvatarWithNameForGuests(baseUrl,
displayName,
R.dimen.avatar_size_big);
}

DraweeController draweeController = Fresco.newDraweeControllerBuilder()
.setOldController(avatarImageView.getController())
.setImageRequest(DisplayUtils.getImageRequestForUrl(ApiUtils.getUrlForAvatarWithName(baseUrl,
userId,
R.dimen.avatar_size_big), null))
.setImageRequest(DisplayUtils.getImageRequestForUrl(urlForAvatar, null))
.build();
avatarImageView.setController(draweeController);
}
Expand Down Expand Up @@ -2032,13 +2044,17 @@ private void setupNewPeerLayout(String session, String type) {
}

private void gotNick(String sessionId, String nick, String type) {
sessionId += "+" + type;
String remoteRendererTag = sessionId + "+" + type;

if (relativeLayout != null) {
RelativeLayout relativeLayout = remoteRenderersLayout.findViewWithTag(sessionId);
RelativeLayout relativeLayout = remoteRenderersLayout.findViewWithTag(remoteRendererTag);
TextView textView = relativeLayout.findViewById(R.id.peer_nick_text_view);
if (!textView.getText().equals(nick)) {
textView.setText(nick);

if (getActivity() != null && type.equals("video")) {
getActivity().runOnUiThread(() -> setupAvatarForSession(sessionId));
}
}
}
}
Expand Down