mirror of https://github.com/OpenVidu/openvidu.git
openvidu-server: deprecated recordingStarted/recordingStopped CDR events removed
parent
8e418bfd16
commit
edb5dd36ff
|
@ -20,7 +20,7 @@ package io.openvidu.server.cdr;
|
||||||
public enum CDREventName {
|
public enum CDREventName {
|
||||||
|
|
||||||
sessionCreated, sessionDestroyed, participantJoined, participantLeft, webrtcConnectionCreated,
|
sessionCreated, sessionDestroyed, participantJoined, participantLeft, webrtcConnectionCreated,
|
||||||
webrtcConnectionDestroyed, recordingStarted, recordingStopped, recordingStatusChanged, filterEventDispatched,
|
webrtcConnectionDestroyed, recordingStatusChanged, filterEventDispatched,
|
||||||
signalSent, mediaNodeStatusChanged, autoscaling, nodeCrashed
|
signalSent, mediaNodeStatusChanged, autoscaling, nodeCrashed
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,75 +0,0 @@
|
||||||
/*
|
|
||||||
* (C) Copyright 2017-2020 OpenVidu (https://openvidu.io)
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
package io.openvidu.server.cdr;
|
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
|
|
||||||
import io.openvidu.java.client.RecordingLayout;
|
|
||||||
import io.openvidu.server.core.EndReason;
|
|
||||||
import io.openvidu.server.recording.Recording;
|
|
||||||
import io.openvidu.server.utils.RecordingUtils;
|
|
||||||
|
|
||||||
public class CDREventRecording extends CDREventEnd {
|
|
||||||
|
|
||||||
protected Recording recording;
|
|
||||||
|
|
||||||
// recordingStarted
|
|
||||||
public CDREventRecording(Recording recording) {
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public JsonObject toJson() {
|
|
||||||
JsonObject json = super.toJson();
|
|
||||||
json.addProperty("id", this.recording.getId());
|
|
||||||
json.addProperty("name", this.recording.getName());
|
|
||||||
json.addProperty("outputMode", this.recording.getOutputMode().name());
|
|
||||||
if (RecordingUtils.IS_COMPOSED(this.recording.getOutputMode()) && this.recording.hasVideo()) {
|
|
||||||
json.addProperty("resolution", this.recording.getResolution());
|
|
||||||
json.addProperty("frameRate", this.recording.getFrameRate());
|
|
||||||
json.addProperty("recordingLayout", this.recording.getRecordingLayout().name());
|
|
||||||
if (RecordingLayout.CUSTOM.equals(this.recording.getRecordingLayout())
|
|
||||||
&& this.recording.getCustomLayout() != null && !this.recording.getCustomLayout().isEmpty()) {
|
|
||||||
json.addProperty("customLayout", this.recording.getCustomLayout());
|
|
||||||
}
|
|
||||||
if (this.recording.getRecordingProperties().mediaNode() != null) {
|
|
||||||
json.addProperty("media_node_id", this.recording.getRecordingProperties().mediaNode());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
json.addProperty("hasAudio", this.recording.hasAudio());
|
|
||||||
json.addProperty("hasVideo", this.recording.hasVideo());
|
|
||||||
json.addProperty("size", this.recording.getSize());
|
|
||||||
json.addProperty("duration", this.recording.getDuration());
|
|
||||||
return json;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Recording getRecording() {
|
|
||||||
return this.recording;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -25,12 +25,12 @@ import io.openvidu.server.core.EndReason;
|
||||||
import io.openvidu.server.recording.Recording;
|
import io.openvidu.server.recording.Recording;
|
||||||
import io.openvidu.server.utils.RecordingUtils;
|
import io.openvidu.server.utils.RecordingUtils;
|
||||||
|
|
||||||
public class CDREventRecordingStatus extends CDREventEnd {
|
public class CDREventRecordingStatusChanged extends CDREventEnd {
|
||||||
|
|
||||||
private Recording recording;
|
private Recording recording;
|
||||||
private Status status;
|
private Status status;
|
||||||
|
|
||||||
public CDREventRecordingStatus(Recording recording, Long startTime, EndReason reason, Long timestamp,
|
public CDREventRecordingStatusChanged(Recording recording, Long startTime, EndReason reason, Long timestamp,
|
||||||
Status status) {
|
Status status) {
|
||||||
super(CDREventName.recordingStatusChanged, recording.getSessionId(), recording.getUniqueSessionId(), startTime,
|
super(CDREventName.recordingStatusChanged, recording.getSessionId(), recording.getUniqueSessionId(), startTime,
|
||||||
reason, timestamp);
|
reason, timestamp);
|
|
@ -39,7 +39,6 @@ import io.openvidu.server.kurento.endpoint.KmsEvent;
|
||||||
import io.openvidu.server.recording.Recording;
|
import io.openvidu.server.recording.Recording;
|
||||||
import io.openvidu.server.recording.service.RecordingManager;
|
import io.openvidu.server.recording.service.RecordingManager;
|
||||||
import io.openvidu.server.summary.SessionSummary;
|
import io.openvidu.server.summary.SessionSummary;
|
||||||
import io.openvidu.server.webhook.CDRLoggerWebhook;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CDR logger to register all information of a Session. Enabled by property
|
* CDR logger to register all information of a Session. Enabled by property
|
||||||
|
@ -60,7 +59,6 @@ public class CallDetailRecord {
|
||||||
private Map<String, CDREventParticipant> participants = new ConcurrentHashMap<>();
|
private Map<String, CDREventParticipant> participants = new ConcurrentHashMap<>();
|
||||||
private Map<String, CDREventWebrtcConnection> publications = new ConcurrentHashMap<>();
|
private Map<String, CDREventWebrtcConnection> publications = new ConcurrentHashMap<>();
|
||||||
private Map<String, Set<CDREventWebrtcConnection>> subscriptions = new ConcurrentHashMap<>();
|
private Map<String, Set<CDREventWebrtcConnection>> subscriptions = new ConcurrentHashMap<>();
|
||||||
private Map<String, CDREventRecording> recordings = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
public CallDetailRecord(Collection<CDRLogger> loggers) {
|
public CallDetailRecord(Collection<CDRLogger> loggers) {
|
||||||
this.loggers = loggers;
|
this.loggers = loggers;
|
||||||
|
@ -158,25 +156,15 @@ public class CallDetailRecord {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void recordRecordingStarted(Recording recording) {
|
|
||||||
CDREventRecording recordingStartedEvent = new CDREventRecording(recording);
|
|
||||||
this.recordings.putIfAbsent(recording.getId(), recordingStartedEvent);
|
|
||||||
this.log(recordingStartedEvent);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void recordRecordingStopped(Recording recording, EndReason reason, long timestamp) {
|
|
||||||
CDREventRecording recordingStartedEvent = this.recordings.remove(recording.getId());
|
|
||||||
CDREventRecording recordingStoppedEvent = new CDREventRecording(recordingStartedEvent, recording,
|
|
||||||
RecordingManager.finalReason(reason), timestamp);
|
|
||||||
this.log(recordingStoppedEvent);
|
|
||||||
|
|
||||||
// Summary: update ended recording
|
|
||||||
sessionManager.getAccumulatedRecordings(recording.getSessionId()).add(recordingStoppedEvent);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void recordRecordingStatusChanged(Recording recording, EndReason finalReason, long timestamp,
|
public void recordRecordingStatusChanged(Recording recording, EndReason finalReason, long timestamp,
|
||||||
Status status) {
|
Status status) {
|
||||||
this.log(new CDREventRecordingStatus(recording, recording.getCreatedAt(), finalReason, timestamp, status));
|
CDREventRecordingStatusChanged event = new CDREventRecordingStatusChanged(recording, recording.getCreatedAt(),
|
||||||
|
finalReason, timestamp, status);
|
||||||
|
if (Status.stopped.equals(status)) {
|
||||||
|
// Summary: update ended recording
|
||||||
|
sessionManager.accumulateNewRecording(event);
|
||||||
|
}
|
||||||
|
this.log(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void recordFilterEventDispatched(String sessionId, String uniqueSessionId, String connectionId,
|
public void recordFilterEventDispatched(String sessionId, String uniqueSessionId, String connectionId,
|
||||||
|
@ -194,14 +182,7 @@ public class CallDetailRecord {
|
||||||
|
|
||||||
protected void log(CDREvent event) {
|
protected void log(CDREvent event) {
|
||||||
this.loggers.forEach(logger -> {
|
this.loggers.forEach(logger -> {
|
||||||
|
logger.log(event);
|
||||||
// TEMP FIX: AVOID SENDING recordingStarted AND recordingStopped EVENTS TO
|
|
||||||
// WEBHOOK. ONLY recordingStatusChanged
|
|
||||||
if (!(logger instanceof CDRLoggerWebhook && (CDREventName.recordingStarted.equals(event.getEventName())
|
|
||||||
|| CDREventName.recordingStopped.equals(event.getEventName())))) {
|
|
||||||
logger.log(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ import io.openvidu.java.client.KurentoOptions;
|
||||||
import io.openvidu.java.client.OpenViduRole;
|
import io.openvidu.java.client.OpenViduRole;
|
||||||
import io.openvidu.java.client.Recording;
|
import io.openvidu.java.client.Recording;
|
||||||
import io.openvidu.java.client.SessionProperties;
|
import io.openvidu.java.client.SessionProperties;
|
||||||
import io.openvidu.server.cdr.CDREventRecording;
|
import io.openvidu.server.cdr.CDREventRecordingStatusChanged;
|
||||||
import io.openvidu.server.config.OpenviduConfig;
|
import io.openvidu.server.config.OpenviduConfig;
|
||||||
import io.openvidu.server.coturn.CoturnCredentialsService;
|
import io.openvidu.server.coturn.CoturnCredentialsService;
|
||||||
import io.openvidu.server.kurento.endpoint.EndpointType;
|
import io.openvidu.server.kurento.endpoint.EndpointType;
|
||||||
|
@ -99,7 +99,7 @@ public abstract class SessionManager {
|
||||||
final protected ConcurrentMap<String, Session> sessionsNotActive = new ConcurrentHashMap<>();
|
final protected ConcurrentMap<String, Session> sessionsNotActive = new ConcurrentHashMap<>();
|
||||||
protected ConcurrentMap<String, ConcurrentHashMap<String, Participant>> sessionidParticipantpublicidParticipant = new ConcurrentHashMap<>();
|
protected ConcurrentMap<String, ConcurrentHashMap<String, Participant>> sessionidParticipantpublicidParticipant = new ConcurrentHashMap<>();
|
||||||
protected ConcurrentMap<String, ConcurrentHashMap<String, FinalUser>> sessionidFinalUsers = new ConcurrentHashMap<>();
|
protected ConcurrentMap<String, ConcurrentHashMap<String, FinalUser>> sessionidFinalUsers = new ConcurrentHashMap<>();
|
||||||
protected ConcurrentMap<String, ConcurrentLinkedQueue<CDREventRecording>> sessionidAccumulatedRecordings = new ConcurrentHashMap<>();
|
protected ConcurrentMap<String, ConcurrentLinkedQueue<CDREventRecordingStatusChanged>> sessionidAccumulatedRecordings = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
protected ConcurrentMap<String, Boolean> insecureUsers = new ConcurrentHashMap<>();
|
protected ConcurrentMap<String, Boolean> insecureUsers = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
@ -292,11 +292,11 @@ public abstract class SessionManager {
|
||||||
return this.sessionidFinalUsers.remove(sessionId);
|
return this.sessionidFinalUsers.remove(sessionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<CDREventRecording> getAccumulatedRecordings(String sessionId) {
|
public void accumulateNewRecording(CDREventRecordingStatusChanged event) {
|
||||||
return this.sessionidAccumulatedRecordings.get(sessionId);
|
this.sessionidAccumulatedRecordings.get(event.getSessionId()).add(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<CDREventRecording> removeAccumulatedRecordings(String sessionId) {
|
public Collection<CDREventRecordingStatusChanged> removeAccumulatedRecordings(String sessionId) {
|
||||||
return this.sessionidAccumulatedRecordings.remove(sessionId);
|
return this.sessionidAccumulatedRecordings.remove(sessionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -221,7 +221,8 @@ public class RecordingManager {
|
||||||
log.info("Recording module required: Downloading openvidu/openvidu-recording:"
|
log.info("Recording module required: Downloading openvidu/openvidu-recording:"
|
||||||
+ openviduConfig.getOpenViduRecordingVersion() + " Docker image (350MB aprox)");
|
+ openviduConfig.getOpenViduRecordingVersion() + " Docker image (350MB aprox)");
|
||||||
|
|
||||||
if (dockMng.dockerImageExistsLocally(openviduConfig.getOpenviduRecordingImageRepo() + ":" + openviduConfig.getOpenViduRecordingVersion())) {
|
if (dockMng.dockerImageExistsLocally(
|
||||||
|
openviduConfig.getOpenviduRecordingImageRepo() + ":" + openviduConfig.getOpenViduRecordingVersion())) {
|
||||||
log.info("Docker image already exists locally");
|
log.info("Docker image already exists locally");
|
||||||
} else {
|
} else {
|
||||||
Thread t = new Thread(() -> {
|
Thread t = new Thread(() -> {
|
||||||
|
@ -239,7 +240,8 @@ public class RecordingManager {
|
||||||
});
|
});
|
||||||
t.start();
|
t.start();
|
||||||
try {
|
try {
|
||||||
dockMng.downloadDockerImage(openviduConfig.getOpenviduRecordingImageRepo() + ":" + openviduConfig.getOpenViduRecordingVersion(), 600);
|
dockMng.downloadDockerImage(openviduConfig.getOpenviduRecordingImageRepo() + ":"
|
||||||
|
+ openviduConfig.getOpenViduRecordingVersion(), 600);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Error downloading docker image {}:{}", openviduConfig.getOpenviduRecordingImageRepo(),
|
log.error("Error downloading docker image {}:{}", openviduConfig.getOpenviduRecordingImageRepo(),
|
||||||
openviduConfig.getOpenViduRecordingVersion());
|
openviduConfig.getOpenViduRecordingVersion());
|
||||||
|
@ -302,8 +304,6 @@ public class RecordingManager {
|
||||||
|
|
||||||
this.cdr.recordRecordingStatusChanged(recording, null, recording.getCreatedAt(),
|
this.cdr.recordRecordingStatusChanged(recording, null, recording.getCreatedAt(),
|
||||||
Status.started);
|
Status.started);
|
||||||
// TODO: remove deprecated "recordingStarted" event
|
|
||||||
this.cdr.recordRecordingStarted(recording);
|
|
||||||
|
|
||||||
if (!(OutputMode.COMPOSED.equals(properties.outputMode()) && properties.hasVideo())) {
|
if (!(OutputMode.COMPOSED.equals(properties.outputMode()) && properties.hasVideo())) {
|
||||||
// Directly send recording started notification for all cases except for
|
// Directly send recording started notification for all cases except for
|
||||||
|
@ -365,8 +365,6 @@ public class RecordingManager {
|
||||||
|
|
||||||
final long timestamp = System.currentTimeMillis();
|
final long timestamp = System.currentTimeMillis();
|
||||||
this.cdr.recordRecordingStatusChanged(recording, reason, timestamp, Status.stopped);
|
this.cdr.recordRecordingStatusChanged(recording, reason, timestamp, Status.stopped);
|
||||||
// TODO: remove deprecated "recordingStopped" event
|
|
||||||
this.cdr.recordRecordingStopped(recording, reason, timestamp);
|
|
||||||
|
|
||||||
switch (recording.getOutputMode()) {
|
switch (recording.getOutputMode()) {
|
||||||
case COMPOSED:
|
case COMPOSED:
|
||||||
|
|
|
@ -24,7 +24,7 @@ import java.util.Map;
|
||||||
import com.google.gson.JsonArray;
|
import com.google.gson.JsonArray;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
import io.openvidu.server.cdr.CDREventRecording;
|
import io.openvidu.server.cdr.CDREventRecordingStatusChanged;
|
||||||
import io.openvidu.server.cdr.CDREventSession;
|
import io.openvidu.server.cdr.CDREventSession;
|
||||||
import io.openvidu.server.core.FinalUser;
|
import io.openvidu.server.core.FinalUser;
|
||||||
|
|
||||||
|
@ -32,10 +32,10 @@ public class SessionSummary {
|
||||||
|
|
||||||
private CDREventSession eventSessionEnd;
|
private CDREventSession eventSessionEnd;
|
||||||
private Map<String, FinalUser> users;
|
private Map<String, FinalUser> users;
|
||||||
private Collection<CDREventRecording> recordings;
|
private Collection<CDREventRecordingStatusChanged> recordings;
|
||||||
|
|
||||||
public SessionSummary(CDREventSession event, Map<String, FinalUser> users,
|
public SessionSummary(CDREventSession event, Map<String, FinalUser> users,
|
||||||
Collection<CDREventRecording> recordings) {
|
Collection<CDREventRecordingStatusChanged> recordings) {
|
||||||
this.eventSessionEnd = event;
|
this.eventSessionEnd = event;
|
||||||
this.users = users;
|
this.users = users;
|
||||||
this.recordings = recordings == null ? new LinkedList<>() : recordings;
|
this.recordings = recordings == null ? new LinkedList<>() : recordings;
|
||||||
|
|
Loading…
Reference in New Issue