mirror of https://github.com/OpenVidu/openvidu.git
openvidu-server: do not start automatic recording after manual stop if new only publisher
parent
147727bccd
commit
fe9d4605f7
|
@ -21,6 +21,7 @@ import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
@ -52,6 +53,8 @@ public class Session implements SessionInterface {
|
||||||
protected volatile boolean closed = false;
|
protected volatile boolean closed = false;
|
||||||
protected AtomicInteger activePublishers = new AtomicInteger(0);
|
protected AtomicInteger activePublishers = new AtomicInteger(0);
|
||||||
|
|
||||||
|
public final AtomicBoolean recordingManuallyStopped = new AtomicBoolean(false);
|
||||||
|
|
||||||
public Session(Session previousSession) {
|
public Session(Session previousSession) {
|
||||||
this.sessionId = previousSession.getSessionId();
|
this.sessionId = previousSession.getSessionId();
|
||||||
this.startTime = previousSession.getStartTime();
|
this.startTime = previousSession.getStartTime();
|
||||||
|
|
|
@ -250,7 +250,7 @@ public class KurentoSessionManager extends SessionManager {
|
||||||
participant.getParticipantPublicId());
|
participant.getParticipantPublicId());
|
||||||
|
|
||||||
SdpType sdpType = kurentoOptions.isOffer ? SdpType.OFFER : SdpType.ANSWER;
|
SdpType sdpType = kurentoOptions.isOffer ? SdpType.OFFER : SdpType.ANSWER;
|
||||||
KurentoSession session = kParticipant.getSession();
|
KurentoSession kSession = kParticipant.getSession();
|
||||||
|
|
||||||
kParticipant.createPublishingEndpoint(mediaOptions);
|
kParticipant.createPublishingEndpoint(mediaOptions);
|
||||||
|
|
||||||
|
@ -271,7 +271,7 @@ public class KurentoSessionManager extends SessionManager {
|
||||||
log.error("PARTICIPANT {}: Error applying filter. The token has no permissions to apply filter {}",
|
log.error("PARTICIPANT {}: Error applying filter. The token has no permissions to apply filter {}",
|
||||||
participant.getParticipantPublicId(), kurentoOptions.getFilter().getType(), e);
|
participant.getParticipantPublicId(), kurentoOptions.getFilter().getType(), e);
|
||||||
sessionEventsHandler.onPublishMedia(participant, null, kParticipant.getPublisher().createdAt(),
|
sessionEventsHandler.onPublishMedia(participant, null, kParticipant.getPublisher().createdAt(),
|
||||||
session.getSessionId(), mediaOptions, sdpAnswer, participants, transactionId, e);
|
kSession.getSessionId(), mediaOptions, sdpAnswer, participants, transactionId, e);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -284,44 +284,45 @@ public class KurentoSessionManager extends SessionManager {
|
||||||
"Error generating SDP response for publishing user " + participant.getParticipantPublicId());
|
"Error generating SDP response for publishing user " + participant.getParticipantPublicId());
|
||||||
log.error("PARTICIPANT {}: Error publishing media", participant.getParticipantPublicId(), e);
|
log.error("PARTICIPANT {}: Error publishing media", participant.getParticipantPublicId(), e);
|
||||||
sessionEventsHandler.onPublishMedia(participant, null, kParticipant.getPublisher().createdAt(),
|
sessionEventsHandler.onPublishMedia(participant, null, kParticipant.getPublisher().createdAt(),
|
||||||
session.getSessionId(), mediaOptions, sdpAnswer, participants, transactionId, e);
|
kSession.getSessionId(), mediaOptions, sdpAnswer, participants, transactionId, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.openviduConfig.isRecordingModuleEnabled()
|
if (this.openviduConfig.isRecordingModuleEnabled()
|
||||||
&& MediaMode.ROUTED.equals(session.getSessionProperties().mediaMode())
|
&& MediaMode.ROUTED.equals(kSession.getSessionProperties().mediaMode())
|
||||||
&& session.getActivePublishers() == 0) {
|
&& kSession.getActivePublishers() == 0) {
|
||||||
if (RecordingMode.ALWAYS.equals(session.getSessionProperties().recordingMode())
|
if (RecordingMode.ALWAYS.equals(kSession.getSessionProperties().recordingMode())
|
||||||
&& !recordingManager.sessionIsBeingRecorded(session.getSessionId())) {
|
&& !recordingManager.sessionIsBeingRecorded(kSession.getSessionId())
|
||||||
|
&& !kSession.recordingManuallyStopped.get()) {
|
||||||
// Start automatic recording for sessions configured with RecordingMode.ALWAYS
|
// Start automatic recording for sessions configured with RecordingMode.ALWAYS
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
recordingManager.startRecording(session,
|
recordingManager.startRecording(kSession,
|
||||||
new RecordingProperties.Builder().name("")
|
new RecordingProperties.Builder().name("")
|
||||||
.outputMode(session.getSessionProperties().defaultOutputMode())
|
.outputMode(kSession.getSessionProperties().defaultOutputMode())
|
||||||
.recordingLayout(session.getSessionProperties().defaultRecordingLayout())
|
.recordingLayout(kSession.getSessionProperties().defaultRecordingLayout())
|
||||||
.customLayout(session.getSessionProperties().defaultCustomLayout()).build());
|
.customLayout(kSession.getSessionProperties().defaultCustomLayout()).build());
|
||||||
}).start();
|
}).start();
|
||||||
} else if (RecordingMode.MANUAL.equals(session.getSessionProperties().recordingMode())
|
} else if (RecordingMode.MANUAL.equals(kSession.getSessionProperties().recordingMode())
|
||||||
&& recordingManager.sessionIsBeingRecorded(session.getSessionId())) {
|
&& recordingManager.sessionIsBeingRecorded(kSession.getSessionId())) {
|
||||||
// Abort automatic recording stop (user published before timeout)
|
// Abort automatic recording stop (user published before timeout)
|
||||||
log.info("Participant {} published before timeout finished. Aborting automatic recording stop",
|
log.info("Participant {} published before timeout finished. Aborting automatic recording stop",
|
||||||
participant.getParticipantPublicId());
|
participant.getParticipantPublicId());
|
||||||
boolean stopAborted = recordingManager.abortAutomaticRecordingStopThread(session);
|
boolean stopAborted = recordingManager.abortAutomaticRecordingStopThread(kSession);
|
||||||
if (stopAborted) {
|
if (stopAborted) {
|
||||||
log.info("Automatic recording stopped succesfully aborted");
|
log.info("Automatic recording stopped succesfully aborted");
|
||||||
} else {
|
} else {
|
||||||
log.info("Automatic recording stopped couldn't be aborted. Recording of session {} has stopped",
|
log.info("Automatic recording stopped couldn't be aborted. Recording of session {} has stopped",
|
||||||
session.getSessionId());
|
kSession.getSessionId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
session.newPublisher(participant);
|
kSession.newPublisher(participant);
|
||||||
|
|
||||||
participants = kParticipant.getSession().getParticipants();
|
participants = kParticipant.getSession().getParticipants();
|
||||||
|
|
||||||
if (sdpAnswer != null) {
|
if (sdpAnswer != null) {
|
||||||
sessionEventsHandler.onPublishMedia(participant, participant.getPublisherStreamId(),
|
sessionEventsHandler.onPublishMedia(participant, participant.getPublisherStreamId(),
|
||||||
kParticipant.getPublisher().createdAt(), session.getSessionId(), mediaOptions, sdpAnswer,
|
kParticipant.getPublisher().createdAt(), kSession.getSessionId(), mediaOptions, sdpAnswer,
|
||||||
participants, transactionId, null);
|
participants, transactionId, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -514,6 +514,8 @@ public class SessionRestController {
|
||||||
Recording stoppedRecording = this.recordingManager.stopRecording(session, recording.getId(),
|
Recording stoppedRecording = this.recordingManager.stopRecording(session, recording.getId(),
|
||||||
"recordingStoppedByServer");
|
"recordingStoppedByServer");
|
||||||
|
|
||||||
|
session.recordingManuallyStopped.set(true);
|
||||||
|
|
||||||
if (session != null && OutputMode.COMPOSED.equals(recording.getOutputMode()) && recording.hasVideo()) {
|
if (session != null && OutputMode.COMPOSED.equals(recording.getOutputMode()) && recording.hasVideo()) {
|
||||||
sessionManager.evictParticipant(
|
sessionManager.evictParticipant(
|
||||||
session.getParticipantByPublicId(ProtocolElements.RECORDER_PARTICIPANT_PUBLICID), null, null,
|
session.getParticipantByPublicId(ProtocolElements.RECORDER_PARTICIPANT_PUBLICID), null, null,
|
||||||
|
|
Loading…
Reference in New Issue