mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 03:29:28 +01:00
Store actor data from signaling messages with participant updates
Starting with Talk 20 the signaling messages that provide updates to the participants ("participants->update" in the external signaling server, "usersInRoom" in the internal signaling server) now include "actorType" and "actorId" properties for each participant. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This commit is contained in:
parent
86b06488c3
commit
3b7c5e1d27
@ -2160,6 +2160,10 @@ class CallActivity : CallBaseActivity() {
|
|||||||
Log.d(TAG, " newSession joined: $sessionId")
|
Log.d(TAG, " newSession joined: $sessionId")
|
||||||
addCallParticipant(sessionId)
|
addCallParticipant(sessionId)
|
||||||
|
|
||||||
|
if (participant.actorType != null && participant.actorId != null) {
|
||||||
|
callParticipants[sessionId]!!.setActor(participant.actorType, participant.actorId)
|
||||||
|
}
|
||||||
|
|
||||||
val userId = participant.userId
|
val userId = participant.userId
|
||||||
if (userId != null) {
|
if (userId != null) {
|
||||||
callParticipants[sessionId]!!.setUserId(userId)
|
callParticipants[sessionId]!!.setUserId(userId)
|
||||||
|
@ -14,6 +14,7 @@ import android.text.TextUtils;
|
|||||||
|
|
||||||
import com.nextcloud.talk.call.CallParticipantModel;
|
import com.nextcloud.talk.call.CallParticipantModel;
|
||||||
import com.nextcloud.talk.call.RaisedHand;
|
import com.nextcloud.talk.call.RaisedHand;
|
||||||
|
import com.nextcloud.talk.models.json.participants.Participant;
|
||||||
import com.nextcloud.talk.utils.ApiUtils;
|
import com.nextcloud.talk.utils.ApiUtils;
|
||||||
|
|
||||||
import org.webrtc.EglBase;
|
import org.webrtc.EglBase;
|
||||||
@ -38,6 +39,8 @@ public class ParticipantDisplayItem {
|
|||||||
|
|
||||||
private final CallParticipantModel callParticipantModel;
|
private final CallParticipantModel callParticipantModel;
|
||||||
|
|
||||||
|
private Participant.ActorType actorType;
|
||||||
|
private String actorId;
|
||||||
private String userId;
|
private String userId;
|
||||||
private PeerConnection.IceConnectionState iceConnectionState;
|
private PeerConnection.IceConnectionState iceConnectionState;
|
||||||
private String nick;
|
private String nick;
|
||||||
@ -82,6 +85,8 @@ public class ParticipantDisplayItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateFromModel() {
|
private void updateFromModel() {
|
||||||
|
actorType = callParticipantModel.getActorType();
|
||||||
|
actorId = callParticipantModel.getActorId();
|
||||||
userId = callParticipantModel.getUserId();
|
userId = callParticipantModel.getUserId();
|
||||||
nick = callParticipantModel.getNick();
|
nick = callParticipantModel.getNick();
|
||||||
|
|
||||||
@ -166,6 +171,8 @@ public class ParticipantDisplayItem {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return "ParticipantSession{" +
|
return "ParticipantSession{" +
|
||||||
"userId='" + userId + '\'' +
|
"userId='" + userId + '\'' +
|
||||||
|
", actorType='" + actorType + '\'' +
|
||||||
|
", actorId='" + actorId + '\'' +
|
||||||
", session='" + session + '\'' +
|
", session='" + session + '\'' +
|
||||||
", nick='" + nick + '\'' +
|
", nick='" + nick + '\'' +
|
||||||
", urlForAvatar='" + urlForAvatar + '\'' +
|
", urlForAvatar='" + urlForAvatar + '\'' +
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.nextcloud.talk.call;
|
package com.nextcloud.talk.call;
|
||||||
|
|
||||||
|
import com.nextcloud.talk.models.json.participants.Participant;
|
||||||
import com.nextcloud.talk.signaling.SignalingMessageReceiver;
|
import com.nextcloud.talk.signaling.SignalingMessageReceiver;
|
||||||
import com.nextcloud.talk.webrtc.PeerConnectionWrapper;
|
import com.nextcloud.talk.webrtc.PeerConnectionWrapper;
|
||||||
|
|
||||||
@ -132,6 +133,10 @@ public class CallParticipant {
|
|||||||
return callParticipantModel;
|
return callParticipantModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setActor(Participant.ActorType actorType, String actorId) {
|
||||||
|
callParticipantModel.setActor(actorType, actorId);
|
||||||
|
}
|
||||||
|
|
||||||
public void setUserId(String userId) {
|
public void setUserId(String userId) {
|
||||||
callParticipantModel.setUserId(userId);
|
callParticipantModel.setUserId(userId);
|
||||||
}
|
}
|
||||||
|
@ -122,6 +122,8 @@ public class CallParticipantList {
|
|||||||
|
|
||||||
private Participant copyParticipant(Participant participant) {
|
private Participant copyParticipant(Participant participant) {
|
||||||
Participant copiedParticipant = new Participant();
|
Participant copiedParticipant = new Participant();
|
||||||
|
copiedParticipant.setActorId(participant.getActorId());
|
||||||
|
copiedParticipant.setActorType(participant.getActorType());
|
||||||
copiedParticipant.setInCall(participant.getInCall());
|
copiedParticipant.setInCall(participant.getInCall());
|
||||||
copiedParticipant.setInternal(participant.getInternal());
|
copiedParticipant.setInternal(participant.getInternal());
|
||||||
copiedParticipant.setLastPing(participant.getLastPing());
|
copiedParticipant.setLastPing(participant.getLastPing());
|
||||||
|
@ -8,6 +8,8 @@ package com.nextcloud.talk.call;
|
|||||||
|
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
|
||||||
|
import com.nextcloud.talk.models.json.participants.Participant;
|
||||||
|
|
||||||
import org.webrtc.MediaStream;
|
import org.webrtc.MediaStream;
|
||||||
import org.webrtc.PeerConnection;
|
import org.webrtc.PeerConnection;
|
||||||
|
|
||||||
@ -25,6 +27,8 @@ import java.util.Objects;
|
|||||||
*
|
*
|
||||||
* Audio and video in screen shares, on the other hand, are always seen as available.
|
* Audio and video in screen shares, on the other hand, are always seen as available.
|
||||||
*
|
*
|
||||||
|
* Actor type and actor id will be set only in Talk >= 20.
|
||||||
|
*
|
||||||
* Clients of the model can observe it with CallParticipantModel.Observer to be notified when any value changes.
|
* Clients of the model can observe it with CallParticipantModel.Observer to be notified when any value changes.
|
||||||
* Getters called after receiving a notification are guaranteed to provide at least the value that triggered the
|
* Getters called after receiving a notification are guaranteed to provide at least the value that triggered the
|
||||||
* notification, but it may return even a more up to date one (so getting the value again on the following
|
* notification, but it may return even a more up to date one (so getting the value again on the following
|
||||||
@ -39,6 +43,8 @@ public class CallParticipantModel {
|
|||||||
|
|
||||||
protected final String sessionId;
|
protected final String sessionId;
|
||||||
|
|
||||||
|
protected Data<Participant.ActorType> actorType;
|
||||||
|
protected Data<String> actorId;
|
||||||
protected Data<String> userId;
|
protected Data<String> userId;
|
||||||
protected Data<String> nick;
|
protected Data<String> nick;
|
||||||
|
|
||||||
@ -81,6 +87,8 @@ public class CallParticipantModel {
|
|||||||
public CallParticipantModel(String sessionId) {
|
public CallParticipantModel(String sessionId) {
|
||||||
this.sessionId = sessionId;
|
this.sessionId = sessionId;
|
||||||
|
|
||||||
|
this.actorType = new Data<>();
|
||||||
|
this.actorId = new Data<>();
|
||||||
this.userId = new Data<>();
|
this.userId = new Data<>();
|
||||||
this.nick = new Data<>();
|
this.nick = new Data<>();
|
||||||
|
|
||||||
@ -101,6 +109,14 @@ public class CallParticipantModel {
|
|||||||
return sessionId;
|
return sessionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Participant.ActorType getActorType() {
|
||||||
|
return actorType.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getActorId() {
|
||||||
|
return actorId.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
public String getUserId() {
|
public String getUserId() {
|
||||||
return userId.getValue();
|
return userId.getValue();
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
*/
|
*/
|
||||||
package com.nextcloud.talk.call;
|
package com.nextcloud.talk.call;
|
||||||
|
|
||||||
|
import com.nextcloud.talk.models.json.participants.Participant;
|
||||||
|
|
||||||
import org.webrtc.MediaStream;
|
import org.webrtc.MediaStream;
|
||||||
import org.webrtc.PeerConnection;
|
import org.webrtc.PeerConnection;
|
||||||
|
|
||||||
@ -20,6 +22,11 @@ public class MutableCallParticipantModel extends CallParticipantModel {
|
|||||||
super(sessionId);
|
super(sessionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setActor(Participant.ActorType actorType, String actorId) {
|
||||||
|
this.actorType.setValue(actorType);
|
||||||
|
this.actorId.setValue(actorId);
|
||||||
|
}
|
||||||
|
|
||||||
public void setUserId(String userId) {
|
public void setUserId(String userId) {
|
||||||
this.userId.setValue(userId);
|
this.userId.setValue(userId);
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.nextcloud.talk.signaling;
|
package com.nextcloud.talk.signaling;
|
||||||
|
|
||||||
|
import com.nextcloud.talk.models.json.converters.EnumActorTypeConverter;
|
||||||
import com.nextcloud.talk.models.json.converters.EnumParticipantTypeConverter;
|
import com.nextcloud.talk.models.json.converters.EnumParticipantTypeConverter;
|
||||||
import com.nextcloud.talk.models.json.participants.Participant;
|
import com.nextcloud.talk.models.json.participants.Participant;
|
||||||
import com.nextcloud.talk.models.json.signaling.NCIceCandidate;
|
import com.nextcloud.talk.models.json.signaling.NCIceCandidate;
|
||||||
@ -38,6 +39,8 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
public abstract class SignalingMessageReceiver {
|
public abstract class SignalingMessageReceiver {
|
||||||
|
|
||||||
|
private final EnumActorTypeConverter enumActorTypeConverter = new EnumActorTypeConverter();
|
||||||
|
|
||||||
private final ParticipantListMessageNotifier participantListMessageNotifier = new ParticipantListMessageNotifier();
|
private final ParticipantListMessageNotifier participantListMessageNotifier = new ParticipantListMessageNotifier();
|
||||||
|
|
||||||
private final LocalParticipantMessageNotifier localParticipantMessageNotifier = new LocalParticipantMessageNotifier();
|
private final LocalParticipantMessageNotifier localParticipantMessageNotifier = new LocalParticipantMessageNotifier();
|
||||||
@ -398,6 +401,8 @@ public abstract class SignalingMessageReceiver {
|
|||||||
// "nextcloudSessionId": #STRING#, // Optional
|
// "nextcloudSessionId": #STRING#, // Optional
|
||||||
// "internal": #BOOLEAN#, // Optional
|
// "internal": #BOOLEAN#, // Optional
|
||||||
// "participantPermissions": #INTEGER#, // Talk >= 13
|
// "participantPermissions": #INTEGER#, // Talk >= 13
|
||||||
|
// "actorType": #STRING#, // Talk >= 20
|
||||||
|
// "actorId": #STRING#, // Talk >= 20
|
||||||
// },
|
// },
|
||||||
// ...
|
// ...
|
||||||
// ],
|
// ],
|
||||||
@ -447,6 +452,8 @@ public abstract class SignalingMessageReceiver {
|
|||||||
// "sessionId": #STRING#,
|
// "sessionId": #STRING#,
|
||||||
// "userId": #STRING#, // Always included, although it can be empty
|
// "userId": #STRING#, // Always included, although it can be empty
|
||||||
// "participantPermissions": #INTEGER#, // Talk >= 13
|
// "participantPermissions": #INTEGER#, // Talk >= 13
|
||||||
|
// "actorType": #STRING#, // Talk >= 20
|
||||||
|
// "actorId": #STRING#, // Talk >= 20
|
||||||
// },
|
// },
|
||||||
// ...
|
// ...
|
||||||
// ],
|
// ],
|
||||||
@ -492,6 +499,14 @@ public abstract class SignalingMessageReceiver {
|
|||||||
participant.setInternal(Boolean.TRUE);
|
participant.setInternal(Boolean.TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (participantMap.get("actorType") != null && !participantMap.get("actorType").toString().isEmpty()) {
|
||||||
|
participant.setActorType(enumActorTypeConverter.getFromString(participantMap.get("actorType").toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (participantMap.get("actorId") != null && !participantMap.get("actorId").toString().isEmpty()) {
|
||||||
|
participant.setActorId(participantMap.get("actorId").toString());
|
||||||
|
}
|
||||||
|
|
||||||
// Only in external signaling messages
|
// Only in external signaling messages
|
||||||
if (participantMap.get("participantType") != null) {
|
if (participantMap.get("participantType") != null) {
|
||||||
int participantTypeInt = Integer.parseInt(participantMap.get("participantType").toString());
|
int participantTypeInt = Integer.parseInt(participantMap.get("participantType").toString());
|
||||||
|
@ -71,6 +71,8 @@ public class CallParticipantListExternalSignalingTest {
|
|||||||
participant.setSessionId(sessionId);
|
participant.setSessionId(sessionId);
|
||||||
participant.setType(type);
|
participant.setType(type);
|
||||||
participant.setUserId(userId);
|
participant.setUserId(userId);
|
||||||
|
participant.setActorType(Participant.ActorType.USERS);
|
||||||
|
participant.setActorId(userId);
|
||||||
|
|
||||||
return participant;
|
return participant;
|
||||||
}
|
}
|
||||||
@ -81,6 +83,8 @@ public class CallParticipantListExternalSignalingTest {
|
|||||||
participant.setLastPing(lastPing);
|
participant.setLastPing(lastPing);
|
||||||
participant.setSessionId(sessionId);
|
participant.setSessionId(sessionId);
|
||||||
participant.setType(type);
|
participant.setType(type);
|
||||||
|
participant.setActorType(Participant.ActorType.GUESTS);
|
||||||
|
participant.setActorId("sha1-" + sessionId);
|
||||||
|
|
||||||
return participant;
|
return participant;
|
||||||
}
|
}
|
||||||
|
@ -61,6 +61,8 @@ public class CallParticipantListInternalSignalingTest {
|
|||||||
participant.setLastPing(lastPing);
|
participant.setLastPing(lastPing);
|
||||||
participant.setSessionId(sessionId);
|
participant.setSessionId(sessionId);
|
||||||
participant.setUserId(userId);
|
participant.setUserId(userId);
|
||||||
|
participant.setActorType(Participant.ActorType.USERS);
|
||||||
|
participant.setActorId(userId);
|
||||||
|
|
||||||
return participant;
|
return participant;
|
||||||
}
|
}
|
||||||
@ -70,6 +72,8 @@ public class CallParticipantListInternalSignalingTest {
|
|||||||
participant.setInCall(inCall);
|
participant.setInCall(inCall);
|
||||||
participant.setLastPing(lastPing);
|
participant.setLastPing(lastPing);
|
||||||
participant.setSessionId(sessionId);
|
participant.setSessionId(sessionId);
|
||||||
|
participant.setActorType(Participant.ActorType.GUESTS);
|
||||||
|
participant.setActorId("sha1-" + sessionId);
|
||||||
|
|
||||||
return participant;
|
return participant;
|
||||||
}
|
}
|
||||||
|
@ -58,10 +58,12 @@ public class SignalingMessageReceiverParticipantListTest {
|
|||||||
user1.put("roomId", 108);
|
user1.put("roomId", 108);
|
||||||
user1.put("sessionId", "theSessionId1");
|
user1.put("sessionId", "theSessionId1");
|
||||||
user1.put("userId", "theUserId");
|
user1.put("userId", "theUserId");
|
||||||
// If "participantPermissions" is set in any of the participants all the other participants in the message
|
// If any of the following properties is set in any of the participants all the other participants in the
|
||||||
// would have it too. But for test simplicity, and as it is not relevant for the processing, in this test it
|
// message would have it too. But for test simplicity, and as it is not relevant for the processing, in this
|
||||||
// is included only in one of the participants.
|
// test they are included only in one of the participants.
|
||||||
user1.put("participantPermissions", 42);
|
user1.put("participantPermissions", 42);
|
||||||
|
user1.put("actorType", "federated_users");
|
||||||
|
user1.put("actorId", "theActorId");
|
||||||
users.add(user1);
|
users.add(user1);
|
||||||
Map<String, Object> user2 = new HashMap<>();
|
Map<String, Object> user2 = new HashMap<>();
|
||||||
user2.put("inCall", 0);
|
user2.put("inCall", 0);
|
||||||
@ -78,6 +80,8 @@ public class SignalingMessageReceiverParticipantListTest {
|
|||||||
expectedParticipant1.setLastPing(4815);
|
expectedParticipant1.setLastPing(4815);
|
||||||
expectedParticipant1.setSessionId("theSessionId1");
|
expectedParticipant1.setSessionId("theSessionId1");
|
||||||
expectedParticipant1.setUserId("theUserId");
|
expectedParticipant1.setUserId("theUserId");
|
||||||
|
expectedParticipant1.setActorType(Participant.ActorType.FEDERATED);
|
||||||
|
expectedParticipant1.setActorId("theActorId");
|
||||||
expectedParticipantList.add(expectedParticipant1);
|
expectedParticipantList.add(expectedParticipant1);
|
||||||
|
|
||||||
Participant expectedParticipant2 = new Participant();
|
Participant expectedParticipant2 = new Participant();
|
||||||
@ -266,11 +270,13 @@ public class SignalingMessageReceiverParticipantListTest {
|
|||||||
user1.put("sessionId", "theSessionId1");
|
user1.put("sessionId", "theSessionId1");
|
||||||
user1.put("participantType", 3);
|
user1.put("participantType", 3);
|
||||||
user1.put("userId", "theUserId");
|
user1.put("userId", "theUserId");
|
||||||
// If "nextcloudSessionId" or "participantPermissions" is set in any of the participants all the other
|
// If any of the following properties is set in any of the participants all the other participants in the
|
||||||
// participants in the message would have them too. But for test simplicity, and as it is not relevant for
|
// message would have it too. But for test simplicity, and as it is not relevant for the processing, in this
|
||||||
// the processing, in this test they are included only in one of the participants.
|
// test they are included only in one of the participants.
|
||||||
user1.put("nextcloudSessionId", "theNextcloudSessionId");
|
user1.put("nextcloudSessionId", "theNextcloudSessionId");
|
||||||
user1.put("participantPermissions", 42);
|
user1.put("participantPermissions", 42);
|
||||||
|
user1.put("actorType", "federated_users");
|
||||||
|
user1.put("actorId", "theActorId");
|
||||||
users.add(user1);
|
users.add(user1);
|
||||||
Map<String, Object> user2 = new HashMap<>();
|
Map<String, Object> user2 = new HashMap<>();
|
||||||
user2.put("inCall", 0);
|
user2.put("inCall", 0);
|
||||||
@ -289,6 +295,8 @@ public class SignalingMessageReceiverParticipantListTest {
|
|||||||
expectedParticipant1.setSessionId("theSessionId1");
|
expectedParticipant1.setSessionId("theSessionId1");
|
||||||
expectedParticipant1.setType(Participant.ParticipantType.USER);
|
expectedParticipant1.setType(Participant.ParticipantType.USER);
|
||||||
expectedParticipant1.setUserId("theUserId");
|
expectedParticipant1.setUserId("theUserId");
|
||||||
|
expectedParticipant1.setActorType(Participant.ActorType.FEDERATED);
|
||||||
|
expectedParticipant1.setActorId("theActorId");
|
||||||
expectedParticipantList.add(expectedParticipant1);
|
expectedParticipantList.add(expectedParticipant1);
|
||||||
|
|
||||||
Participant expectedParticipant2 = new Participant();
|
Participant expectedParticipant2 = new Participant();
|
||||||
|
Loading…
Reference in New Issue
Block a user