mirror of https://github.com/OpenVidu/openvidu.git
openvidu-server: refactor kmsDisconnectionTime parameter
parent
baa7e37c2c
commit
0ae577ce6e
|
@ -194,7 +194,7 @@ public class KurentoParticipant extends Participant {
|
|||
return sdpResponse;
|
||||
}
|
||||
|
||||
public void unpublishMedia(EndReason reason, long kmsDisconnectionTime) {
|
||||
public void unpublishMedia(EndReason reason, Long kmsDisconnectionTime) {
|
||||
log.info("PARTICIPANT {}: unpublishing media stream from room {}", this.getParticipantPublicId(),
|
||||
this.session.getSessionId());
|
||||
final MediaOptions mediaOptions = this.getPublisher().getMediaOptions();
|
||||
|
@ -347,7 +347,7 @@ public class KurentoParticipant extends Participant {
|
|||
}
|
||||
}
|
||||
|
||||
public void close(EndReason reason, boolean definitelyClosed, long kmsDisconnectionTime) {
|
||||
public void close(EndReason reason, boolean definitelyClosed, Long kmsDisconnectionTime) {
|
||||
log.debug("PARTICIPANT {}: Closing user", this.getParticipantPublicId());
|
||||
if (isClosed()) {
|
||||
log.warn("PARTICIPANT {}: Already closed", this.getParticipantPublicId());
|
||||
|
@ -420,7 +420,7 @@ public class KurentoParticipant extends Participant {
|
|||
session.sendMediaError(this.getParticipantPrivateId(), desc);
|
||||
}
|
||||
|
||||
private void releasePublisherEndpoint(EndReason reason, long kmsDisconnectionTime) {
|
||||
private void releasePublisherEndpoint(EndReason reason, Long kmsDisconnectionTime) {
|
||||
if (publisher != null && publisher.getEndpoint() != null) {
|
||||
final ReadWriteLock closingLock = publisher.closingLock;
|
||||
try {
|
||||
|
@ -443,7 +443,7 @@ public class KurentoParticipant extends Participant {
|
|||
}
|
||||
}
|
||||
|
||||
private void releasePublisherEndpointAux(EndReason reason, long kmsDisconnectionTime) {
|
||||
private void releasePublisherEndpointAux(EndReason reason, Long kmsDisconnectionTime) {
|
||||
// Remove streamId from publisher's map
|
||||
this.session.publishedStreamIds.remove(this.getPublisherStreamId());
|
||||
|
||||
|
|
|
@ -122,7 +122,7 @@ public class KurentoSession extends Session {
|
|||
log.info("PARTICIPANT {}: Leaving session {}", participant.getParticipantPublicId(), this.sessionId);
|
||||
|
||||
this.removeParticipant(participant, reason);
|
||||
participant.close(reason, true, 0);
|
||||
participant.close(reason, true, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -133,7 +133,7 @@ public class KurentoSession extends Session {
|
|||
|
||||
for (Participant participant : participants.values()) {
|
||||
((KurentoParticipant) participant).releaseAllFilters();
|
||||
((KurentoParticipant) participant).close(reason, true, 0);
|
||||
((KurentoParticipant) participant).close(reason, true, null);
|
||||
}
|
||||
|
||||
participants.clear();
|
||||
|
@ -280,7 +280,7 @@ public class KurentoSession extends Session {
|
|||
return this.publishedStreamIds.get(streamId);
|
||||
}
|
||||
|
||||
public void restartStatusInKurento(long kmsDisconnectionTime) {
|
||||
public void restartStatusInKurento(Long kmsDisconnectionTime) {
|
||||
|
||||
log.info("Resetting process: resetting remote media objects for active session {}", this.sessionId);
|
||||
|
||||
|
|
|
@ -495,7 +495,7 @@ public class KurentoSessionManager extends SessionManager {
|
|||
throw new OpenViduException(Code.USER_NOT_STREAMING_ERROR_CODE,
|
||||
"Participant '" + participant.getParticipantPublicId() + "' is not streaming media");
|
||||
}
|
||||
kParticipant.unpublishMedia(reason, 0);
|
||||
kParticipant.unpublishMedia(reason, null);
|
||||
session.cancelPublisher(participant, reason);
|
||||
|
||||
Set<Participant> participants = session.getParticipants();
|
||||
|
|
|
@ -21,41 +21,34 @@ import org.kurento.client.RecorderEndpoint;
|
|||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import io.openvidu.server.kurento.core.KurentoParticipant;
|
||||
|
||||
public class RecorderEndpointWrapper {
|
||||
|
||||
private RecorderEndpoint recorder;
|
||||
private String connectionId;
|
||||
private KurentoParticipant kParticipant;
|
||||
private String recordingId;
|
||||
private String streamId;
|
||||
private String clientData;
|
||||
private String serverData;
|
||||
private boolean hasAudio;
|
||||
private boolean hasVideo;
|
||||
private String typeOfVideo;
|
||||
|
||||
private long startTime;
|
||||
private long endTime;
|
||||
private long size;
|
||||
|
||||
public RecorderEndpointWrapper(RecorderEndpoint recorder, String connectionId, String recordingId, String streamId,
|
||||
String clientData, String serverData, boolean hasAudio, boolean hasVideo, String typeOfVideo) {
|
||||
public RecorderEndpointWrapper(RecorderEndpoint recorder, KurentoParticipant kParticipant, String recordingId) {
|
||||
this.recorder = recorder;
|
||||
this.connectionId = connectionId;
|
||||
this.kParticipant = kParticipant;
|
||||
this.recordingId = recordingId;
|
||||
this.streamId = streamId;
|
||||
this.clientData = clientData;
|
||||
this.serverData = serverData;
|
||||
this.hasAudio = hasAudio;
|
||||
this.hasVideo = hasVideo;
|
||||
this.typeOfVideo = typeOfVideo;
|
||||
}
|
||||
|
||||
public RecorderEndpoint getRecorder() {
|
||||
return recorder;
|
||||
}
|
||||
|
||||
public KurentoParticipant getParticipant() {
|
||||
return this.kParticipant;
|
||||
}
|
||||
|
||||
public String getConnectionId() {
|
||||
return connectionId;
|
||||
return kParticipant.getParticipantPublicId();
|
||||
}
|
||||
|
||||
public String getRecordingId() {
|
||||
|
@ -63,15 +56,15 @@ public class RecorderEndpointWrapper {
|
|||
}
|
||||
|
||||
public String getStreamId() {
|
||||
return streamId;
|
||||
return kParticipant.getPublisherStreamId();
|
||||
}
|
||||
|
||||
public String getClientData() {
|
||||
return clientData;
|
||||
return kParticipant.getClientMetadata();
|
||||
}
|
||||
|
||||
public String getServerData() {
|
||||
return serverData;
|
||||
return kParticipant.getServerMetadata();
|
||||
}
|
||||
|
||||
public long getStartTime() {
|
||||
|
@ -99,31 +92,31 @@ public class RecorderEndpointWrapper {
|
|||
}
|
||||
|
||||
public boolean hasAudio() {
|
||||
return hasAudio;
|
||||
return kParticipant.getPublisher().getMediaOptions().hasAudio();
|
||||
}
|
||||
|
||||
public boolean hasVideo() {
|
||||
return hasVideo;
|
||||
return kParticipant.getPublisher().getMediaOptions().hasVideo();
|
||||
}
|
||||
|
||||
public String getTypeOfVideo() {
|
||||
return typeOfVideo;
|
||||
return kParticipant.getPublisher().getMediaOptions().getTypeOfVideo();
|
||||
}
|
||||
|
||||
public JsonObject toJson() {
|
||||
JsonObject json = new JsonObject();
|
||||
json.addProperty("connectionId", this.connectionId);
|
||||
json.addProperty("streamId", this.streamId);
|
||||
json.addProperty("clientData", this.clientData);
|
||||
json.addProperty("serverData", this.serverData);
|
||||
json.addProperty("startTime", this.startTime);
|
||||
json.addProperty("endTime", this.endTime);
|
||||
json.addProperty("duration", this.endTime - this.startTime);
|
||||
json.addProperty("size", this.size);
|
||||
json.addProperty("hasAudio", this.hasAudio);
|
||||
json.addProperty("hasVideo", this.hasVideo);
|
||||
if (this.hasVideo) {
|
||||
json.addProperty("typeOfVideo", this.typeOfVideo);
|
||||
json.addProperty("connectionId", this.getConnectionId());
|
||||
json.addProperty("streamId", this.getStreamId());
|
||||
json.addProperty("clientData", this.getClientData());
|
||||
json.addProperty("serverData", this.getServerData());
|
||||
json.addProperty("startTime", this.getStartTime());
|
||||
json.addProperty("endTime", this.getEndTime());
|
||||
json.addProperty("duration", this.getEndTime() - this.getStartTime());
|
||||
json.addProperty("size", this.getSize());
|
||||
json.addProperty("hasAudio", this.hasAudio());
|
||||
json.addProperty("hasVideo", this.hasVideo());
|
||||
if (this.hasVideo()) {
|
||||
json.addProperty("typeOfVideo", this.getTypeOfVideo());
|
||||
}
|
||||
return json;
|
||||
}
|
||||
|
|
|
@ -109,11 +109,11 @@ public class ComposedRecordingService extends RecordingService {
|
|||
if (recording.hasVideo()) {
|
||||
return this.stopRecordingWithVideo(session, recording, reason);
|
||||
} else {
|
||||
return this.stopRecordingAudioOnly(session, recording, reason, 0);
|
||||
return this.stopRecordingAudioOnly(session, recording, reason, null);
|
||||
}
|
||||
}
|
||||
|
||||
public Recording stopRecording(Session session, Recording recording, EndReason reason, long kmsDisconnectionTime) {
|
||||
public Recording stopRecording(Session session, Recording recording, EndReason reason, Long kmsDisconnectionTime) {
|
||||
if (recording.hasVideo()) {
|
||||
return this.stopRecordingWithVideo(session, recording, reason);
|
||||
} else {
|
||||
|
@ -322,7 +322,7 @@ public class ComposedRecordingService extends RecordingService {
|
|||
}
|
||||
|
||||
private Recording stopRecordingAudioOnly(Session session, Recording recording, EndReason reason,
|
||||
long kmsDisconnectionTime) {
|
||||
Long kmsDisconnectionTime) {
|
||||
|
||||
log.info("Stopping composed (audio-only) recording {} of session {}. Reason: {}", recording.getId(),
|
||||
recording.getSessionId(), reason);
|
||||
|
|
|
@ -67,7 +67,6 @@ import io.openvidu.server.core.Participant;
|
|||
import io.openvidu.server.core.Session;
|
||||
import io.openvidu.server.core.SessionEventsHandler;
|
||||
import io.openvidu.server.core.SessionManager;
|
||||
import io.openvidu.server.kurento.core.KurentoSession;
|
||||
import io.openvidu.server.kurento.kms.Kms;
|
||||
import io.openvidu.server.kurento.kms.KmsManager;
|
||||
import io.openvidu.server.recording.Recording;
|
||||
|
@ -351,7 +350,7 @@ public class RecordingManager {
|
|||
return recording;
|
||||
}
|
||||
|
||||
public Recording forceStopRecording(Session session, EndReason reason, long kmsDisconnectionTime) {
|
||||
public Recording forceStopRecording(Session session, EndReason reason, Long kmsDisconnectionTime) {
|
||||
Recording recording;
|
||||
recording = this.sessionsRecordings.get(session.getSessionId());
|
||||
switch (recording.getOutputMode()) {
|
||||
|
@ -409,8 +408,8 @@ public class RecordingManager {
|
|||
return;
|
||||
}
|
||||
|
||||
this.singleStreamRecordingService.startRecorderEndpointForPublisherEndpoint(session, recording.getId(),
|
||||
profile, participant, startedCountDown);
|
||||
this.singleStreamRecordingService.startRecorderEndpointForPublisherEndpoint(recording.getId(), profile,
|
||||
participant, startedCountDown);
|
||||
} else if (RecordingUtils.IS_COMPOSED(recording.getOutputMode()) && !recording.hasVideo()) {
|
||||
// Connect this stream to existing Composite recorder
|
||||
log.info("Joining PublisherEndpoint to existing Composite in session {} for new stream of participant {}",
|
||||
|
@ -419,7 +418,7 @@ public class RecordingManager {
|
|||
}
|
||||
}
|
||||
|
||||
public void stopOneIndividualStreamRecording(KurentoSession session, String streamId, long kmsDisconnectionTime) {
|
||||
public void stopOneIndividualStreamRecording(Session session, String streamId, Long kmsDisconnectionTime) {
|
||||
Recording recording = this.sessionsRecordings.get(session.getSessionId());
|
||||
if (recording == null) {
|
||||
recording = this.sessionsRecordingsStarting.get(session.getSessionId());
|
||||
|
|
|
@ -116,7 +116,7 @@ public class SingleStreamRecordingService extends RecordingService {
|
|||
recordingStartedCountdown.countDown();
|
||||
continue;
|
||||
}
|
||||
this.startRecorderEndpointForPublisherEndpoint(session, recording.getId(), profile, p,
|
||||
this.startRecorderEndpointForPublisherEndpoint(recording.getId(), profile, p,
|
||||
recordingStartedCountdown);
|
||||
}
|
||||
}
|
||||
|
@ -141,10 +141,10 @@ public class SingleStreamRecordingService extends RecordingService {
|
|||
|
||||
@Override
|
||||
public Recording stopRecording(Session session, Recording recording, EndReason reason) {
|
||||
return this.stopRecording(session, recording, reason, 0);
|
||||
return this.stopRecording(session, recording, reason, null);
|
||||
}
|
||||
|
||||
public Recording stopRecording(Session session, Recording recording, EndReason reason, long kmsDisconnectionTime) {
|
||||
public Recording stopRecording(Session session, Recording recording, EndReason reason, Long kmsDisconnectionTime) {
|
||||
log.info("Stopping individual ({}) recording {} of session {}. Reason: {}",
|
||||
recording.hasVideo() ? (recording.hasAudio() ? "video+audio" : "video-only") : "audioOnly",
|
||||
recording.getId(), recording.getSessionId(), reason);
|
||||
|
@ -205,18 +205,18 @@ public class SingleStreamRecordingService extends RecordingService {
|
|||
return finalRecordingArray[0];
|
||||
}
|
||||
|
||||
public void startRecorderEndpointForPublisherEndpoint(final Session session, final String recordingId,
|
||||
MediaProfileSpecType profile, final Participant participant, CountDownLatch globalStartLatch) {
|
||||
public void startRecorderEndpointForPublisherEndpoint(final String recordingId, MediaProfileSpecType profile,
|
||||
final Participant participant, CountDownLatch globalStartLatch) {
|
||||
|
||||
log.info("Starting single stream recorder for stream {} in session {}", participant.getPublisherStreamId(),
|
||||
session.getSessionId());
|
||||
participant.getSessionId());
|
||||
|
||||
try {
|
||||
if (participant.singleRecordingLock.tryLock(15, TimeUnit.SECONDS)) {
|
||||
try {
|
||||
if (this.activeRecorders.get(recordingId).containsKey(participant.getPublisherStreamId())) {
|
||||
log.warn("Concurrent initialization of RecorderEndpoint for stream {} of session {}. Returning",
|
||||
participant.getPublisherStreamId(), session.getSessionId());
|
||||
participant.getPublisherStreamId(), participant.getSessionId());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -244,13 +244,8 @@ public class SingleStreamRecordingService extends RecordingService {
|
|||
}
|
||||
});
|
||||
|
||||
RecorderEndpointWrapper wrapper = new RecorderEndpointWrapper(recorder,
|
||||
participant.getParticipantPublicId(), recordingId, participant.getPublisherStreamId(),
|
||||
participant.getClientMetadata(), participant.getServerMetadata(),
|
||||
kurentoParticipant.getPublisher().getMediaOptions().hasAudio(),
|
||||
kurentoParticipant.getPublisher().getMediaOptions().hasVideo(),
|
||||
kurentoParticipant.getPublisher().getMediaOptions().getTypeOfVideo());
|
||||
|
||||
RecorderEndpointWrapper wrapper = new RecorderEndpointWrapper(recorder, kurentoParticipant,
|
||||
recordingId);
|
||||
activeRecorders.get(recordingId).put(participant.getPublisherStreamId(), wrapper);
|
||||
storedRecorders.get(recordingId).put(participant.getPublisherStreamId(), wrapper);
|
||||
|
||||
|
@ -262,13 +257,13 @@ public class SingleStreamRecordingService extends RecordingService {
|
|||
}
|
||||
} else {
|
||||
log.error(
|
||||
"Timeout waiting for individual recording lock to be available for participant {} of session {}",
|
||||
participant.getParticipantPublicId(), session.getSessionId());
|
||||
"Timeout waiting for individual recording lock to be available to start stream recording for participant {} of session {}",
|
||||
participant.getParticipantPublicId(), participant.getSessionId());
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
log.error(
|
||||
"InterruptedException waiting for individual recording lock to be available for participant {} of session {}",
|
||||
participant.getParticipantPublicId(), session.getSessionId());
|
||||
"InterruptedException waiting for individual recording lock to be available to start stream recording for participant {} of session {}",
|
||||
participant.getParticipantPublicId(), participant.getSessionId());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue