mirror of https://github.com/OpenVidu/openvidu.git
openvidu-server: uniqueSessionId
parent
c1984b5071
commit
4f1f50a2d5
|
@ -22,12 +22,14 @@ import com.google.gson.JsonObject;
|
|||
public class CDREvent {
|
||||
|
||||
protected String sessionId;
|
||||
protected String uniqueSessionId;
|
||||
protected Long timeStamp;
|
||||
protected CDREventName eventName;
|
||||
|
||||
public CDREvent(CDREventName eventName, String sessionId, Long timeStamp) {
|
||||
public CDREvent(CDREventName eventName, String sessionId, String uniqueSessionId, Long timeStamp) {
|
||||
this.eventName = eventName;
|
||||
this.sessionId = sessionId;
|
||||
this.uniqueSessionId = uniqueSessionId;
|
||||
this.timeStamp = timeStamp;
|
||||
}
|
||||
|
||||
|
@ -35,6 +37,10 @@ public class CDREvent {
|
|||
return this.sessionId;
|
||||
}
|
||||
|
||||
public String getUniqueSessionId() {
|
||||
return this.uniqueSessionId;
|
||||
}
|
||||
|
||||
public Long getTimestamp() {
|
||||
return this.timeStamp;
|
||||
}
|
||||
|
@ -48,6 +54,9 @@ public class CDREvent {
|
|||
if (sessionId != null) {
|
||||
json.addProperty("sessionId", this.sessionId);
|
||||
}
|
||||
if (uniqueSessionId != null) {
|
||||
json.addProperty("uniqueSessionId", this.uniqueSessionId);
|
||||
}
|
||||
json.addProperty("timestamp", this.timeStamp);
|
||||
return json;
|
||||
}
|
||||
|
|
|
@ -27,12 +27,13 @@ public class CDREventEnd extends CDREvent {
|
|||
protected Integer duration;
|
||||
protected EndReason reason;
|
||||
|
||||
public CDREventEnd(CDREventName eventName, String sessionId, Long timestamp) {
|
||||
super(eventName, sessionId, timestamp);
|
||||
public CDREventEnd(CDREventName eventName, String sessionId, String uniqueSessionId, Long timestamp) {
|
||||
super(eventName, sessionId, uniqueSessionId, timestamp);
|
||||
}
|
||||
|
||||
public CDREventEnd(CDREventName eventName, String sessionId, Long startTime, EndReason reason, Long timestamp) {
|
||||
super(eventName, sessionId, timestamp);
|
||||
public CDREventEnd(CDREventName eventName, String sessionId, String uniqueSessionId, Long startTime,
|
||||
EndReason reason, Long timestamp) {
|
||||
super(eventName, sessionId, uniqueSessionId, timestamp);
|
||||
this.startTime = startTime;
|
||||
this.duration = (int) ((this.timeStamp - this.startTime) / 1000);
|
||||
this.reason = reason;
|
||||
|
|
|
@ -12,9 +12,10 @@ public class CDREventFilterEvent extends CDREvent {
|
|||
private String streamId;
|
||||
private String filterType;
|
||||
|
||||
public CDREventFilterEvent(String sessionId, String connectionId, String streamId, String filterType,
|
||||
GenericMediaEvent event) {
|
||||
super(CDREventName.filterEventDispatched, sessionId, Long.parseLong(event.getTimestampMillis()));
|
||||
public CDREventFilterEvent(String sessionId, String uniqueSessionId, String connectionId, String streamId,
|
||||
String filterType, GenericMediaEvent event) {
|
||||
super(CDREventName.filterEventDispatched, sessionId, uniqueSessionId,
|
||||
Long.parseLong(event.getTimestampMillis()));
|
||||
this.event = event;
|
||||
this.connectionId = connectionId;
|
||||
this.streamId = streamId;
|
||||
|
|
|
@ -9,9 +9,8 @@ public class CDREventNodeCrashed extends CDREvent {
|
|||
private Kms kms;
|
||||
private String environmentId;
|
||||
|
||||
public CDREventNodeCrashed(CDREventName eventName, String sessionId, Long timeStamp, Kms kms,
|
||||
String environmentId) {
|
||||
super(eventName, sessionId, timeStamp);
|
||||
public CDREventNodeCrashed(CDREventName eventName, Long timeStamp, Kms kms, String environmentId) {
|
||||
super(eventName, null, null, timeStamp);
|
||||
this.kms = kms;
|
||||
this.environmentId = environmentId;
|
||||
}
|
||||
|
|
|
@ -28,13 +28,15 @@ public class CDREventParticipant extends CDREventEnd {
|
|||
|
||||
// participantJoined
|
||||
public CDREventParticipant(Participant participant) {
|
||||
super(CDREventName.participantJoined, participant.getSessionId(), participant.getActiveAt());
|
||||
super(CDREventName.participantJoined, participant.getSessionId(), participant.getUniqueSessionId(),
|
||||
participant.getActiveAt());
|
||||
this.participant = participant;
|
||||
}
|
||||
|
||||
// participantLeft
|
||||
public CDREventParticipant(CDREventParticipant event, EndReason reason, Long timestamp) {
|
||||
super(CDREventName.participantLeft, event.getSessionId(), event.getTimestamp(), reason, timestamp);
|
||||
super(CDREventName.participantLeft, event.getSessionId(), event.getUniqueSessionId(), event.getTimestamp(),
|
||||
reason, timestamp);
|
||||
this.participant = event.participant;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,13 +30,15 @@ public class CDREventRecording extends CDREventEnd {
|
|||
|
||||
// recordingStarted
|
||||
public CDREventRecording(Recording recording) {
|
||||
super(CDREventName.recordingStarted, recording.getSessionId(), recording.getCreatedAt());
|
||||
super(CDREventName.recordingStarted, recording.getSessionId(), recording.getUniqueSessionId(),
|
||||
recording.getCreatedAt());
|
||||
this.recording = recording;
|
||||
}
|
||||
|
||||
// recordingStopped
|
||||
public CDREventRecording(CDREventRecording event, Recording recording, EndReason reason, Long timestamp) {
|
||||
super(CDREventName.recordingStopped, event == null ? recording.getSessionId() : event.getSessionId(),
|
||||
event == null ? recording.getUniqueSessionId() : event.getUniqueSessionId(),
|
||||
event == null ? recording.getCreatedAt() : event.getTimestamp(), reason, timestamp);
|
||||
this.recording = recording;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,8 @@ public class CDREventRecordingStatus extends CDREventEnd {
|
|||
|
||||
public CDREventRecordingStatus(Recording recording, Long startTime, EndReason reason, Long timestamp,
|
||||
Status status) {
|
||||
super(CDREventName.recordingStatusChanged, recording.getSessionId(), startTime, reason, timestamp);
|
||||
super(CDREventName.recordingStatusChanged, recording.getSessionId(), recording.getUniqueSessionId(), startTime,
|
||||
reason, timestamp);
|
||||
this.recording = recording;
|
||||
this.status = status;
|
||||
}
|
||||
|
|
|
@ -26,13 +26,15 @@ public class CDREventSession extends CDREventEnd {
|
|||
|
||||
// sessionCreated
|
||||
public CDREventSession(Session session) {
|
||||
super(CDREventName.sessionCreated, session.getSessionId(), session.getStartTime());
|
||||
super(CDREventName.sessionCreated, session.getSessionId(), session.getUniqueSessionId(),
|
||||
session.getStartTime());
|
||||
this.session = session;
|
||||
}
|
||||
|
||||
// sessionDestroyed
|
||||
public CDREventSession(CDREventSession event, EndReason reason, Long timestamp) {
|
||||
super(CDREventName.sessionDestroyed, event.getSessionId(), event.getTimestamp(), reason, timestamp);
|
||||
super(CDREventName.sessionDestroyed, event.getSessionId(), event.getUniqueSessionId(), event.getTimestamp(),
|
||||
reason, timestamp);
|
||||
this.session = event.session;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,8 +27,9 @@ public class CDREventSignal extends CDREvent {
|
|||
private String type;
|
||||
private String data;
|
||||
|
||||
public CDREventSignal(String sessionId, String from, String[] to, String type, String data) {
|
||||
super(CDREventName.signalSent, sessionId, System.currentTimeMillis());
|
||||
public CDREventSignal(String sessionId, String uniqueSessionId, String from, String[] to, String type,
|
||||
String data) {
|
||||
super(CDREventName.signalSent, sessionId, uniqueSessionId, System.currentTimeMillis());
|
||||
this.from = from;
|
||||
this.to = to;
|
||||
this.type = type;
|
||||
|
|
|
@ -32,9 +32,9 @@ public class CDREventWebrtcConnection extends CDREventEnd implements Comparable<
|
|||
String receivingFrom;
|
||||
|
||||
// webrtcConnectionCreated
|
||||
public CDREventWebrtcConnection(String sessionId, String streamId, Participant participant,
|
||||
public CDREventWebrtcConnection(String sessionId, String uniqueSessionId, String streamId, Participant participant,
|
||||
MediaOptions mediaOptions, String receivingFrom, Long timestamp) {
|
||||
super(CDREventName.webrtcConnectionCreated, sessionId, timestamp);
|
||||
super(CDREventName.webrtcConnectionCreated, sessionId, uniqueSessionId, timestamp);
|
||||
this.streamId = streamId;
|
||||
this.participant = participant;
|
||||
this.mediaOptions = mediaOptions;
|
||||
|
@ -43,7 +43,8 @@ public class CDREventWebrtcConnection extends CDREventEnd implements Comparable<
|
|||
|
||||
// webrtcConnectionDestroyed
|
||||
public CDREventWebrtcConnection(CDREventWebrtcConnection event, EndReason reason, Long timestamp) {
|
||||
super(CDREventName.webrtcConnectionDestroyed, event.getSessionId(), event.getTimestamp(), reason, timestamp);
|
||||
super(CDREventName.webrtcConnectionDestroyed, event.getSessionId(), event.getUniqueSessionId(),
|
||||
event.getTimestamp(), reason, timestamp);
|
||||
this.streamId = event.streamId;
|
||||
this.participant = event.participant;
|
||||
this.mediaOptions = event.mediaOptions;
|
||||
|
@ -67,7 +68,7 @@ public class CDREventWebrtcConnection extends CDREventEnd implements Comparable<
|
|||
} else {
|
||||
json.addProperty("connection", "OUTBOUND");
|
||||
if (mediaOptions instanceof KurentoMediaOptions) {
|
||||
KurentoMediaOptions kMediaOptions = (KurentoMediaOptions)mediaOptions;
|
||||
KurentoMediaOptions kMediaOptions = (KurentoMediaOptions) mediaOptions;
|
||||
if (kMediaOptions.rtspUri != null) {
|
||||
json.addProperty("rtspUri", kMediaOptions.rtspUri);
|
||||
json.addProperty("adaptativeBitrate", kMediaOptions.adaptativeBitrate);
|
||||
|
|
|
@ -105,10 +105,10 @@ public class CallDetailRecord {
|
|||
sessionManager.getFinalUsers(sessionId).get(participant.getFinalUserId()).setConnection(eventParticipantEnd);
|
||||
}
|
||||
|
||||
public void recordNewPublisher(Participant participant, String sessionId, String streamId,
|
||||
MediaOptions mediaOptions, Long timestamp) {
|
||||
CDREventWebrtcConnection publisher = new CDREventWebrtcConnection(sessionId, streamId, participant,
|
||||
mediaOptions, null, timestamp);
|
||||
public void recordNewPublisher(Participant participant, String streamId, MediaOptions mediaOptions,
|
||||
Long timestamp) {
|
||||
CDREventWebrtcConnection publisher = new CDREventWebrtcConnection(participant.getSessionId(),
|
||||
participant.getUniqueSessionId(), streamId, participant, mediaOptions, null, timestamp);
|
||||
this.publications.put(participant.getParticipantPublicId(), publisher);
|
||||
this.log(publisher);
|
||||
}
|
||||
|
@ -126,11 +126,11 @@ public class CallDetailRecord {
|
|||
}
|
||||
}
|
||||
|
||||
public void recordNewSubscriber(Participant participant, String sessionId, String streamId, String senderPublicId,
|
||||
Long timestamp) {
|
||||
public void recordNewSubscriber(Participant participant, String streamId, String senderPublicId, Long timestamp) {
|
||||
CDREventWebrtcConnection publisher = this.publications.get(senderPublicId);
|
||||
CDREventWebrtcConnection subscriber = new CDREventWebrtcConnection(sessionId, streamId, participant,
|
||||
publisher.mediaOptions, senderPublicId, timestamp);
|
||||
CDREventWebrtcConnection subscriber = new CDREventWebrtcConnection(participant.getSessionId(),
|
||||
participant.getUniqueSessionId(), streamId, participant, publisher.mediaOptions, senderPublicId,
|
||||
timestamp);
|
||||
this.subscriptions.putIfAbsent(participant.getParticipantPublicId(), new ConcurrentSkipListSet<>());
|
||||
this.subscriptions.get(participant.getParticipantPublicId()).add(subscriber);
|
||||
this.log(subscriber);
|
||||
|
@ -180,16 +180,17 @@ public class CallDetailRecord {
|
|||
this.log(new CDREventRecordingStatus(recording, recording.getCreatedAt(), finalReason, timestamp, status));
|
||||
}
|
||||
|
||||
public void recordFilterEventDispatched(String sessionId, String connectionId, String streamId, String filterType,
|
||||
GenericMediaEvent event) {
|
||||
this.log(new CDREventFilterEvent(sessionId, connectionId, streamId, filterType, event));
|
||||
public void recordFilterEventDispatched(String sessionId, String uniqueSessionId, String connectionId,
|
||||
String streamId, String filterType, GenericMediaEvent event) {
|
||||
this.log(new CDREventFilterEvent(sessionId, uniqueSessionId, connectionId, streamId, filterType, event));
|
||||
}
|
||||
|
||||
public void recordSignalSent(String sessionId, String from, String[] to, String type, String data) {
|
||||
public void recordSignalSent(String sessionId, String uniqueSessionId, String from, String[] to, String type,
|
||||
String data) {
|
||||
if (from != null) {
|
||||
type = type.replaceFirst("^signal:", "");
|
||||
}
|
||||
this.log(new CDREventSignal(sessionId, from, to, type, data));
|
||||
this.log(new CDREventSignal(sessionId, uniqueSessionId, from, to, type, data));
|
||||
}
|
||||
|
||||
protected void log(CDREvent event) {
|
||||
|
@ -224,8 +225,7 @@ public class CallDetailRecord {
|
|||
}
|
||||
|
||||
public void recordNodeCrashed(Kms kms, String environmentId, long timeOfKurentoDisconnection) {
|
||||
CDREvent e = new CDREventNodeCrashed(CDREventName.nodeCrashed, null, timeOfKurentoDisconnection, kms,
|
||||
environmentId);
|
||||
CDREvent e = new CDREventNodeCrashed(CDREventName.nodeCrashed, timeOfKurentoDisconnection, kms, environmentId);
|
||||
this.log(e);
|
||||
}
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@ public class WebrtcDebugEvent {
|
|||
public JsonObject toJson() {
|
||||
JsonObject json = new JsonObject();
|
||||
json.addProperty("sessionId", participant.getSessionId());
|
||||
json.addProperty("uniqueSessionId", participant.getUniqueSessionId());
|
||||
json.addProperty("user", participant.getFinalUserId());
|
||||
json.addProperty("connectionId", participant.getParticipantPublicId());
|
||||
json.addProperty("endpoint", this.endpoint);
|
||||
|
|
|
@ -47,6 +47,7 @@ public class Participant {
|
|||
protected String participantPrivateId; // ID to identify the user on server (org.kurento.jsonrpc.Session.id)
|
||||
protected String participantPublicId; // ID to identify the user on clients
|
||||
protected String sessionId; // ID of the session to which the participant belongs
|
||||
protected String uniqueSessionId;
|
||||
protected ParticipantStatus status; // Status of the connection
|
||||
protected Long activeAt; // Timestamp when this connection entered status "active"
|
||||
protected String clientMetadata = ""; // Metadata provided on client side
|
||||
|
@ -76,12 +77,13 @@ public class Participant {
|
|||
public Lock singleRecordingLock = new ReentrantLock();
|
||||
|
||||
public Participant(String finalUserId, String participantPrivateId, String participantPublicId, String sessionId,
|
||||
Token token, String clientMetadata, GeoLocation location, String platform, EndpointType endpointType,
|
||||
Long activeAt) {
|
||||
String uniqueSessionId, Token token, String clientMetadata, GeoLocation location, String platform,
|
||||
EndpointType endpointType, Long activeAt) {
|
||||
this.finalUserId = finalUserId;
|
||||
this.participantPrivateId = participantPrivateId;
|
||||
this.participantPublicId = participantPublicId;
|
||||
this.sessionId = sessionId;
|
||||
this.uniqueSessionId = uniqueSessionId;
|
||||
this.status = ParticipantStatus.active;
|
||||
this.token = token;
|
||||
if (activeAt != null) {
|
||||
|
@ -121,6 +123,10 @@ public class Participant {
|
|||
return sessionId;
|
||||
}
|
||||
|
||||
public String getUniqueSessionId() {
|
||||
return uniqueSessionId;
|
||||
}
|
||||
|
||||
public Long getActiveAt() {
|
||||
return this.activeAt;
|
||||
}
|
||||
|
@ -210,7 +216,8 @@ public class Participant {
|
|||
}
|
||||
|
||||
public boolean isIpcam() {
|
||||
return this.platform != null && this.platform.equals("IPCAM") && this.participantPrivateId.startsWith(IdentifierPrefixes.IPCAM_ID);
|
||||
return this.platform != null && this.platform.equals("IPCAM")
|
||||
&& this.participantPrivateId.startsWith(IdentifierPrefixes.IPCAM_ID);
|
||||
}
|
||||
|
||||
public String getPublisherStreamId() {
|
||||
|
|
|
@ -56,6 +56,7 @@ public class Session implements SessionInterface {
|
|||
protected ConcurrentMap<String, Token> tokens = new ConcurrentHashMap<>();
|
||||
protected final ConcurrentMap<String, Participant> participants = new ConcurrentHashMap<>();
|
||||
protected String sessionId;
|
||||
protected String uniqueSessionId;
|
||||
protected SessionProperties sessionProperties;
|
||||
protected Long startTime;
|
||||
|
||||
|
@ -91,6 +92,7 @@ public class Session implements SessionInterface {
|
|||
public Session(Session previousSession) {
|
||||
this.sessionId = previousSession.getSessionId();
|
||||
this.startTime = previousSession.getStartTime();
|
||||
this.uniqueSessionId = previousSession.getUniqueSessionId();
|
||||
this.sessionProperties = previousSession.getSessionProperties();
|
||||
this.openviduConfig = previousSession.openviduConfig;
|
||||
this.recordingManager = previousSession.recordingManager;
|
||||
|
@ -101,6 +103,7 @@ public class Session implements SessionInterface {
|
|||
RecordingManager recordingManager) {
|
||||
this.sessionId = sessionId;
|
||||
this.startTime = System.currentTimeMillis();
|
||||
this.uniqueSessionId = sessionId + "_" + this.startTime;
|
||||
this.sessionProperties = sessionProperties;
|
||||
this.openviduConfig = openviduConfig;
|
||||
this.recordingManager = recordingManager;
|
||||
|
@ -110,6 +113,10 @@ public class Session implements SessionInterface {
|
|||
return this.sessionId;
|
||||
}
|
||||
|
||||
public String getUniqueSessionId() {
|
||||
return this.uniqueSessionId;
|
||||
}
|
||||
|
||||
public SessionProperties getSessionProperties() {
|
||||
return this.sessionProperties;
|
||||
}
|
||||
|
|
|
@ -322,7 +322,7 @@ public class SessionEventsHandler {
|
|||
}
|
||||
|
||||
public void onSendMessage(Participant participant, JsonObject message, Set<Participant> participants,
|
||||
String sessionId, Integer transactionId, OpenViduException error) {
|
||||
String sessionId, String uniqueSessionId, Integer transactionId, OpenViduException error) {
|
||||
|
||||
boolean isRpcCall = transactionId != null;
|
||||
if (isRpcCall) {
|
||||
|
@ -391,7 +391,7 @@ public class SessionEventsHandler {
|
|||
rpcNotificationService.sendResponse(participant.getParticipantPrivateId(), transactionId, new JsonObject());
|
||||
}
|
||||
|
||||
CDR.recordSignalSent(sessionId, from, toSet.toArray(new String[toSet.size()]), type, data);
|
||||
CDR.recordSignalSent(sessionId, uniqueSessionId, from, toSet.toArray(new String[toSet.size()]), type, data);
|
||||
}
|
||||
|
||||
public void onStreamPropertyChanged(Participant participant, Integer transactionId, Set<Participant> participants,
|
||||
|
@ -561,10 +561,10 @@ public class SessionEventsHandler {
|
|||
}
|
||||
}
|
||||
|
||||
public void onFilterEventDispatched(String sessionId, String connectionId, String streamId, String filterType,
|
||||
public void onFilterEventDispatched(String sessionId, String uniqueSessionId, String connectionId, String streamId, String filterType,
|
||||
GenericMediaEvent event, Set<Participant> participants, Set<String> subscribedParticipants) {
|
||||
|
||||
CDR.recordFilterEventDispatched(sessionId, connectionId, streamId, filterType, event);
|
||||
CDR.recordFilterEventDispatched(sessionId, uniqueSessionId, connectionId, streamId, filterType, event);
|
||||
|
||||
JsonObject params = new JsonObject();
|
||||
params.addProperty(ProtocolElements.FILTEREVENTLISTENER_CONNECTIONID_PARAM, connectionId);
|
||||
|
|
|
@ -113,10 +113,11 @@ public abstract class SessionManager {
|
|||
|
||||
public abstract void unsubscribe(Participant participant, String senderName, Integer transactionId);
|
||||
|
||||
public void sendMessage(String message, String sessionId) {
|
||||
public void sendMessage(String message, Session session) {
|
||||
try {
|
||||
JsonObject messageJson = JsonParser.parseString(message).getAsJsonObject();
|
||||
sessionEventsHandler.onSendMessage(null, messageJson, getParticipants(sessionId), sessionId, null, null);
|
||||
sessionEventsHandler.onSendMessage(null, messageJson, getParticipants(session.getSessionId()),
|
||||
session.getSessionId(), session.getUniqueSessionId(), null, null);
|
||||
} catch (JsonSyntaxException | IllegalStateException e) {
|
||||
throw new OpenViduException(Code.SIGNAL_FORMAT_INVALID_ERROR_CODE,
|
||||
"Provided signal object '" + message + "' has not a valid JSON format");
|
||||
|
@ -127,7 +128,7 @@ public abstract class SessionManager {
|
|||
try {
|
||||
JsonObject messageJson = JsonParser.parseString(message).getAsJsonObject();
|
||||
sessionEventsHandler.onSendMessage(participant, messageJson, getParticipants(participant.getSessionId()),
|
||||
participant.getSessionId(), transactionId, null);
|
||||
participant.getSessionId(), participant.getUniqueSessionId(), transactionId, null);
|
||||
} catch (JsonSyntaxException | IllegalStateException e) {
|
||||
throw new OpenViduException(Code.SIGNAL_FORMAT_INVALID_ERROR_CODE,
|
||||
"Provided signal object '" + message + "' has not a valid JSON format");
|
||||
|
@ -358,13 +359,15 @@ public abstract class SessionManager {
|
|||
this.insecureUsers.put(participantPrivateId, true);
|
||||
}
|
||||
|
||||
public Participant newParticipant(String sessionId, String participantPrivateId, Token token,
|
||||
String clientMetadata, GeoLocation location, String platform, String finalUserId) {
|
||||
public Participant newParticipant(Session session, String participantPrivateId, Token token, String clientMetadata,
|
||||
GeoLocation location, String platform, String finalUserId) {
|
||||
|
||||
String sessionId = session.getSessionId();
|
||||
if (this.sessionidParticipantpublicidParticipant.get(sessionId) != null) {
|
||||
|
||||
Participant p = new Participant(finalUserId, participantPrivateId, token.getConnectionId(), sessionId,
|
||||
token, clientMetadata, location, platform, EndpointType.WEBRTC_ENDPOINT, null);
|
||||
session.getUniqueSessionId(), token, clientMetadata, location, platform,
|
||||
EndpointType.WEBRTC_ENDPOINT, null);
|
||||
|
||||
this.sessionidParticipantpublicidParticipant.get(sessionId).put(p.getParticipantPublicId(), p);
|
||||
|
||||
|
@ -381,11 +384,13 @@ public abstract class SessionManager {
|
|||
}
|
||||
}
|
||||
|
||||
public Participant newRecorderParticipant(String sessionId, String participantPrivateId, Token token,
|
||||
public Participant newRecorderParticipant(Session session, String participantPrivateId, Token token,
|
||||
String clientMetadata) {
|
||||
String sessionId = session.getSessionId();
|
||||
if (this.sessionidParticipantpublicidParticipant.get(sessionId) != null) {
|
||||
Participant p = new Participant(null, participantPrivateId, ProtocolElements.RECORDER_PARTICIPANT_PUBLICID,
|
||||
sessionId, token, clientMetadata, null, null, EndpointType.WEBRTC_ENDPOINT, null);
|
||||
sessionId, session.getUniqueSessionId(), token, clientMetadata, null, null,
|
||||
EndpointType.WEBRTC_ENDPOINT, null);
|
||||
this.sessionidParticipantpublicidParticipant.get(sessionId)
|
||||
.put(ProtocolElements.RECORDER_PARTICIPANT_PUBLICID, p);
|
||||
return p;
|
||||
|
@ -394,11 +399,12 @@ public abstract class SessionManager {
|
|||
}
|
||||
}
|
||||
|
||||
public Participant newIpcamParticipant(String sessionId, String ipcamId, Token token, GeoLocation location,
|
||||
public Participant newIpcamParticipant(Session session, String ipcamId, Token token, GeoLocation location,
|
||||
String platform) {
|
||||
String sessionId = session.getSessionId();
|
||||
if (this.sessionidParticipantpublicidParticipant.get(sessionId) != null) {
|
||||
Participant p = new Participant(ipcamId, ipcamId, ipcamId, sessionId, token, null, location, platform,
|
||||
EndpointType.PLAYER_ENDPOINT, null);
|
||||
Participant p = new Participant(ipcamId, ipcamId, ipcamId, sessionId, session.getUniqueSessionId(), token,
|
||||
null, location, platform, EndpointType.PLAYER_ENDPOINT, null);
|
||||
this.sessionidParticipantpublicidParticipant.get(sessionId).put(ipcamId, p);
|
||||
return p;
|
||||
} else {
|
||||
|
|
|
@ -79,9 +79,9 @@ public class KurentoParticipant extends Participant {
|
|||
KurentoParticipantEndpointConfig endpointConfig, OpenviduConfig openviduConfig,
|
||||
RecordingManager recordingManager) {
|
||||
super(participant.getFinalUserId(), participant.getParticipantPrivateId(), participant.getParticipantPublicId(),
|
||||
kurentoSession.getSessionId(), participant.getToken(), participant.getClientMetadata(),
|
||||
participant.getLocation(), participant.getPlatform(), participant.getEndpointType(),
|
||||
participant.getActiveAt());
|
||||
kurentoSession.getSessionId(), kurentoSession.getUniqueSessionId(), participant.getToken(),
|
||||
participant.getClientMetadata(), participant.getLocation(), participant.getPlatform(),
|
||||
participant.getEndpointType(), participant.getActiveAt());
|
||||
this.endpointConfig = endpointConfig;
|
||||
this.openviduConfig = openviduConfig;
|
||||
this.recordingManager = recordingManager;
|
||||
|
@ -190,8 +190,8 @@ public class KurentoParticipant extends Participant {
|
|||
}
|
||||
|
||||
if (!silent) {
|
||||
endpointConfig.getCdr().recordNewPublisher(this, session.getSessionId(), publisher.getStreamId(),
|
||||
publisher.getMediaOptions(), publisher.createdAt());
|
||||
endpointConfig.getCdr().recordNewPublisher(this, publisher.getStreamId(), publisher.getMediaOptions(),
|
||||
publisher.createdAt());
|
||||
}
|
||||
|
||||
return sdpResponse;
|
||||
|
@ -278,8 +278,8 @@ public class KurentoParticipant extends Participant {
|
|||
|
||||
if (!silent
|
||||
&& !ProtocolElements.RECORDER_PARTICIPANT_PUBLICID.equals(this.getParticipantPublicId())) {
|
||||
endpointConfig.getCdr().recordNewSubscriber(this, this.session.getSessionId(),
|
||||
sender.getPublisherStreamId(), sender.getParticipantPublicId(), subscriber.createdAt());
|
||||
endpointConfig.getCdr().recordNewSubscriber(this, sender.getPublisherStreamId(),
|
||||
sender.getParticipantPublicId(), subscriber.createdAt());
|
||||
}
|
||||
|
||||
return sdpAnswer;
|
||||
|
|
|
@ -1089,7 +1089,7 @@ public class KurentoSessionManager extends SessionManager {
|
|||
this.newTokenForInsecureUser(session, token, connectionProperties);
|
||||
final Token tokenObj = session.consumeToken(token);
|
||||
|
||||
Participant ipcamParticipant = this.newIpcamParticipant(sessionId, rtspConnectionId, tokenObj, location,
|
||||
Participant ipcamParticipant = this.newIpcamParticipant(session, rtspConnectionId, tokenObj, location,
|
||||
mediaOptions.getTypeOfVideo());
|
||||
|
||||
// Store a "fake" final user for the IpCam connection
|
||||
|
@ -1246,13 +1246,14 @@ public class KurentoSessionManager extends SessionManager {
|
|||
PublisherEndpoint pub = kParticipant.getPublisher();
|
||||
if (!pub.isListenerAddedToFilterEvent(eventType)) {
|
||||
final String sessionId = kParticipant.getSessionId();
|
||||
final String uniqueSessionId = kParticipant.getUniqueSessionId();
|
||||
final String connectionId = kParticipant.getParticipantPublicId();
|
||||
final String streamId = kParticipant.getPublisherStreamId();
|
||||
final String filterType = kParticipant.getPublisherMediaOptions().getFilter().getType();
|
||||
try {
|
||||
ListenerSubscription listener = pub.getFilter().addEventListener(eventType, event -> {
|
||||
sessionEventsHandler.onFilterEventDispatched(sessionId, connectionId, streamId, filterType, event,
|
||||
kParticipant.getSession().getParticipants(),
|
||||
sessionEventsHandler.onFilterEventDispatched(sessionId, uniqueSessionId, connectionId, streamId,
|
||||
filterType, event, kParticipant.getSession().getParticipants(),
|
||||
kParticipant.getPublisher().getPartipantsListentingToFilterEvent(eventType));
|
||||
});
|
||||
pub.storeListener(eventType, listener);
|
||||
|
|
|
@ -48,6 +48,7 @@ public class KmsEvent {
|
|||
json.remove("timestampMillis");
|
||||
json.addProperty("timestamp", timestamp);
|
||||
json.addProperty("sessionId", participant.getSessionId());
|
||||
json.addProperty("uniqueSessionId", participant.getUniqueSessionId());
|
||||
json.addProperty("user", participant.getFinalUserId());
|
||||
// TODO: remove deprecated "connection" when possible
|
||||
json.addProperty("connection", participant.getParticipantPublicId());
|
||||
|
|
|
@ -31,6 +31,7 @@ public class Recording {
|
|||
|
||||
private String id;
|
||||
private String sessionId;
|
||||
private String uniqueSessionId;
|
||||
private long createdAt; // milliseconds (UNIX Epoch time)
|
||||
private long size = 0; // bytes
|
||||
private double duration = 0; // seconds
|
||||
|
@ -42,8 +43,9 @@ public class Recording {
|
|||
|
||||
public AtomicBoolean recordingNotificationSent = new AtomicBoolean(false);
|
||||
|
||||
public Recording(String sessionId, String id, RecordingProperties recordingProperties) {
|
||||
public Recording(String sessionId, String uniqueSessionId, String id, RecordingProperties recordingProperties) {
|
||||
this.sessionId = sessionId;
|
||||
this.uniqueSessionId = uniqueSessionId;
|
||||
this.createdAt = System.currentTimeMillis();
|
||||
this.id = id;
|
||||
this.status = io.openvidu.java.client.Recording.Status.started;
|
||||
|
@ -128,8 +130,8 @@ public class Recording {
|
|||
return sessionId;
|
||||
}
|
||||
|
||||
public void setSessionId(String sessionId) {
|
||||
this.sessionId = sessionId;
|
||||
public String getUniqueSessionId() {
|
||||
return uniqueSessionId;
|
||||
}
|
||||
|
||||
public long getCreatedAt() {
|
||||
|
|
|
@ -209,7 +209,7 @@ public class ComposedQuickStartRecordingService extends ComposedRecordingService
|
|||
private String runContainer(Session session, RecordingProperties properties) throws Exception {
|
||||
log.info("Starting COMPOSED_QUICK_START container for session id: {}", session.getSessionId());
|
||||
|
||||
Recording recording = new Recording(session.getSessionId(), null, properties);
|
||||
Recording recording = new Recording(session.getSessionId(), session.getUniqueSessionId(), null, properties);
|
||||
String layoutUrl = this.getLayoutUrl(recording);
|
||||
|
||||
List<String> envs = new ArrayList<>();
|
||||
|
|
|
@ -84,7 +84,8 @@ public class ComposedRecordingService extends RecordingService {
|
|||
throws OpenViduException {
|
||||
|
||||
// Instantiate and store recording object
|
||||
Recording recording = new Recording(session.getSessionId(), recordingId, properties);
|
||||
Recording recording = new Recording(session.getSessionId(), session.getUniqueSessionId(), recordingId,
|
||||
properties);
|
||||
this.recordingManager.recordingToStarting(recording);
|
||||
|
||||
if (properties.hasVideo()) {
|
||||
|
|
|
@ -92,7 +92,8 @@ public class SingleStreamRecordingService extends RecordingService {
|
|||
properties.hasVideo() ? (properties.hasAudio() ? "video+audio" : "video-only") : "audioOnly",
|
||||
recordingId, session.getSessionId());
|
||||
|
||||
Recording recording = new Recording(session.getSessionId(), recordingId, properties);
|
||||
Recording recording = new Recording(session.getSessionId(), session.getUniqueSessionId(), recordingId,
|
||||
properties);
|
||||
this.recordingManager.recordingToStarting(recording);
|
||||
|
||||
activeRecorders.put(recording.getId(), new ConcurrentHashMap<>());
|
||||
|
|
|
@ -638,7 +638,7 @@ public class SessionRestController {
|
|||
}
|
||||
|
||||
try {
|
||||
sessionManager.sendMessage(completeMessage.toString(), sessionId);
|
||||
sessionManager.sendMessage(completeMessage.toString(), session);
|
||||
} catch (OpenViduException e) {
|
||||
return this.generateErrorResponse("\"to\" array has no valid connection identifiers", "/signal",
|
||||
HttpStatus.NOT_ACCEPTABLE);
|
||||
|
|
|
@ -274,10 +274,10 @@ public class RpcHandler extends DefaultJsonRpcHandler<JsonObject> {
|
|||
}
|
||||
Participant participant;
|
||||
if (generateRecorderParticipant) {
|
||||
participant = sessionManager.newRecorderParticipant(sessionId, participantPrivateId,
|
||||
tokenObj, clientMetadata);
|
||||
participant = sessionManager.newRecorderParticipant(session, participantPrivateId, tokenObj,
|
||||
clientMetadata);
|
||||
} else {
|
||||
participant = sessionManager.newParticipant(sessionId, participantPrivateId, tokenObj,
|
||||
participant = sessionManager.newParticipant(session, participantPrivateId, tokenObj,
|
||||
clientMetadata, location, platform,
|
||||
httpSession.getId().substring(0, Math.min(16, httpSession.getId().length())));
|
||||
log.info("New Connection {} in Session {} with IP {} and platform {}",
|
||||
|
|
|
@ -46,6 +46,7 @@ public class SessionSummary {
|
|||
json.addProperty("createdAt", this.eventSessionEnd.getStartTime());
|
||||
json.addProperty("destroyedAt", this.eventSessionEnd.getTimestamp());
|
||||
json.addProperty("sessionId", this.eventSessionEnd.getSessionId());
|
||||
json.addProperty("uniqueSessionId", this.eventSessionEnd.getUniqueSessionId());
|
||||
json.addProperty("customSessionId", this.eventSessionEnd.getSession().getSessionProperties().customSessionId());
|
||||
json.addProperty("mediaMode", this.eventSessionEnd.getSession().getSessionProperties().mediaMode().name());
|
||||
json.addProperty("recordingMode",
|
||||
|
|
|
@ -37,6 +37,7 @@ import com.google.gson.JsonObject;
|
|||
|
||||
import io.openvidu.java.client.ConnectionProperties;
|
||||
import io.openvidu.server.core.Participant;
|
||||
import io.openvidu.server.core.Session;
|
||||
import io.openvidu.server.core.SessionManager;
|
||||
import io.openvidu.server.core.Token;
|
||||
import io.openvidu.server.kurento.kms.KmsManager;
|
||||
|
@ -71,7 +72,7 @@ public class SessionGarbageCollectorIntegrationTest {
|
|||
|
||||
JsonObject jsonResponse;
|
||||
|
||||
getSessionId();
|
||||
getSession();
|
||||
jsonResponse = listSessions();
|
||||
|
||||
Assert.assertEquals("Wrong number of sessions", 1, jsonResponse.get("numberOfElements").getAsInt());
|
||||
|
@ -81,14 +82,14 @@ public class SessionGarbageCollectorIntegrationTest {
|
|||
jsonResponse = listSessions();
|
||||
Assert.assertEquals("Wrong number of sessions", 0, jsonResponse.get("numberOfElements").getAsInt());
|
||||
|
||||
getSessionId();
|
||||
getSessionId();
|
||||
String sessionId = getSessionId();
|
||||
getSession();
|
||||
getSession();
|
||||
Session session = getSession();
|
||||
jsonResponse = listSessions();
|
||||
Assert.assertEquals("Wrong number of sessions", 3, jsonResponse.get("numberOfElements").getAsInt());
|
||||
|
||||
String token = getToken(sessionId);
|
||||
joinParticipant(sessionId, token);
|
||||
String token = getToken(session);
|
||||
joinParticipant(session, token);
|
||||
|
||||
Thread.sleep(2000);
|
||||
|
||||
|
@ -96,14 +97,16 @@ public class SessionGarbageCollectorIntegrationTest {
|
|||
Assert.assertEquals("Wrong number of sessions", 1, jsonResponse.get("numberOfElements").getAsInt());
|
||||
}
|
||||
|
||||
private String getSessionId() {
|
||||
private Session getSession() {
|
||||
String stringResponse = (String) sessionRestController.initializeSession(new HashMap<>()).getBody();
|
||||
return new Gson().fromJson(stringResponse, JsonObject.class).get("id").getAsString();
|
||||
JsonObject json = new Gson().fromJson(stringResponse, JsonObject.class);
|
||||
String sessionId = json.get("id").getAsString();
|
||||
return new Session(sessionId, null, null, null);
|
||||
}
|
||||
|
||||
private String getToken(String sessionId) {
|
||||
String stringResponse = (String) sessionRestController.initializeConnection(sessionId, new HashMap<>())
|
||||
.getBody();
|
||||
private String getToken(Session session) {
|
||||
String stringResponse = (String) sessionRestController
|
||||
.initializeConnection(session.getSessionId(), new HashMap<>()).getBody();
|
||||
return new Gson().fromJson(stringResponse, JsonObject.class).get("token").getAsString();
|
||||
}
|
||||
|
||||
|
@ -112,15 +115,15 @@ public class SessionGarbageCollectorIntegrationTest {
|
|||
return new Gson().fromJson(stringResponse, JsonObject.class);
|
||||
}
|
||||
|
||||
private void joinParticipant(String sessionId, String token) {
|
||||
private void joinParticipant(Session session, String token) {
|
||||
ConnectionProperties connectionProperties = new ConnectionProperties.Builder().data("SERVER_METADATA").build();
|
||||
Token t = new Token(token, sessionId, connectionProperties, null);
|
||||
Token t = new Token(token, session.getSessionId(), connectionProperties, null);
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
String participantPrivateId = "PARTICIPANT_PRIVATE_ID_" + uuid;
|
||||
String finalUserId = "FINAL_USER_ID_" + uuid;
|
||||
Participant participant = sessionManager.newParticipant(sessionId, participantPrivateId, t, "CLIENT_METADATA",
|
||||
Participant participant = sessionManager.newParticipant(session, participantPrivateId, t, "CLIENT_METADATA",
|
||||
null, "Chrome", finalUserId);
|
||||
sessionManager.joinRoom(participant, sessionId, null);
|
||||
sessionManager.joinRoom(participant, session.getSessionId(), null);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue