mirror of https://github.com/OpenVidu/openvidu.git
Add broadcasting property to Session entity
parent
fa91a529bc
commit
f841886b52
|
@ -54,6 +54,7 @@ public class Session {
|
|||
private SessionProperties properties;
|
||||
private Map<String, Connection> connections = new ConcurrentHashMap<>();
|
||||
private boolean recording = false;
|
||||
private boolean broadcasting = false;
|
||||
|
||||
protected Session(OpenVidu openVidu) throws OpenViduJavaClientException, OpenViduHttpException {
|
||||
this.openVidu = openVidu;
|
||||
|
@ -633,6 +634,13 @@ public class Session {
|
|||
return this.recording;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the session is being broadcasted or not.
|
||||
*/
|
||||
public boolean isBeingBroadcasted() {
|
||||
return this.broadcasting;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the properties defining the session.
|
||||
*/
|
||||
|
@ -705,10 +713,15 @@ public class Session {
|
|||
this.recording = recording;
|
||||
}
|
||||
|
||||
protected void setIsBeingBroadcasted(boolean broadcasting) {
|
||||
this.broadcasting = broadcasting;
|
||||
}
|
||||
|
||||
protected Session resetWithJson(JsonObject json) {
|
||||
this.sessionId = json.get("sessionId").getAsString();
|
||||
this.createdAt = json.get("createdAt").getAsLong();
|
||||
this.recording = json.get("recording").getAsBoolean();
|
||||
this.broadcasting = json.get("broadcasting").getAsBoolean();
|
||||
SessionProperties.Builder builder = new SessionProperties.Builder()
|
||||
.mediaMode(MediaMode.valueOf(json.get("mediaMode").getAsString()))
|
||||
.recordingMode(RecordingMode.valueOf(json.get("recordingMode").getAsString()));
|
||||
|
@ -764,6 +777,7 @@ public class Session {
|
|||
json.addProperty("sessionId", this.sessionId);
|
||||
json.addProperty("createdAt", this.createdAt);
|
||||
json.addProperty("recording", this.recording);
|
||||
json.addProperty("broadcasting", this.broadcasting);
|
||||
|
||||
// Add keys from SessionProperties
|
||||
JsonObject sessionPropertiesJson = this.properties.toJson();
|
||||
|
|
|
@ -75,6 +75,11 @@ export class Session {
|
|||
*/
|
||||
recording = false;
|
||||
|
||||
/**
|
||||
* Whether the session is being broadcasted or not
|
||||
*/
|
||||
broadcasting = false;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
|
@ -526,6 +531,7 @@ export class Session {
|
|||
this.sessionId = json.sessionId;
|
||||
this.createdAt = json.createdAt;
|
||||
this.recording = json.recording;
|
||||
this.broadcasting = json.broadcasting;
|
||||
this.properties = {
|
||||
customSessionId: json.customSessionId,
|
||||
mediaMode: json.mediaMode,
|
||||
|
@ -599,6 +605,7 @@ export class Session {
|
|||
this.sessionId === other.sessionId &&
|
||||
this.createdAt === other.createdAt &&
|
||||
this.recording === other.recording &&
|
||||
this.broadcasting === other.broadcasting &&
|
||||
this.connections.length === other.connections.length &&
|
||||
JSON.stringify(this.properties) === JSON.stringify(other.properties)
|
||||
);
|
||||
|
|
|
@ -42,6 +42,8 @@ import org.springframework.context.annotation.DependsOn;
|
|||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.context.event.EventListener;
|
||||
|
||||
import io.openvidu.server.broadcast.BroadcastManager;
|
||||
import io.openvidu.server.broadcast.BroadcastManagerDummy;
|
||||
import io.openvidu.server.cdr.CDRLogger;
|
||||
import io.openvidu.server.cdr.CDRLoggerFile;
|
||||
import io.openvidu.server.cdr.CallDetailRecord;
|
||||
|
@ -237,6 +239,12 @@ public class OpenViduServer implements JsonRpcConfigurer {
|
|||
return new MediaNodeManagerDummy();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public BroadcastManager broadcastManager() {
|
||||
return new BroadcastManagerDummy();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
@ConditionalOnProperty(name = "SUPPORT_DEPRECATED_API", havingValue = "true")
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
package io.openvidu.server.broadcast;
|
||||
|
||||
public interface BroadcastManager {
|
||||
|
||||
boolean sessionIsBeingBroadcasted(String sessionId);
|
||||
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package io.openvidu.server.broadcast;
|
||||
|
||||
public class BroadcastManagerDummy implements BroadcastManager {
|
||||
|
||||
@Override
|
||||
public boolean sessionIsBeingBroadcasted(String sessionId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -39,6 +39,7 @@ import com.google.gson.JsonObject;
|
|||
import io.openvidu.client.OpenViduException;
|
||||
import io.openvidu.client.OpenViduException.Code;
|
||||
import io.openvidu.java.client.SessionProperties;
|
||||
import io.openvidu.server.broadcast.BroadcastManager;
|
||||
import io.openvidu.server.config.OpenviduConfig;
|
||||
import io.openvidu.server.recording.service.RecordingManager;
|
||||
|
||||
|
@ -46,6 +47,7 @@ public class Session implements SessionInterface {
|
|||
|
||||
protected OpenviduConfig openviduConfig;
|
||||
protected RecordingManager recordingManager;
|
||||
protected BroadcastManager broadcastManager;
|
||||
|
||||
protected ConcurrentMap<String, Token> tokens = new ConcurrentHashMap<>();
|
||||
protected final ConcurrentMap<String, Participant> participants = new ConcurrentHashMap<>();
|
||||
|
@ -90,17 +92,19 @@ public class Session implements SessionInterface {
|
|||
this.sessionProperties = previousSession.getSessionProperties();
|
||||
this.openviduConfig = previousSession.openviduConfig;
|
||||
this.recordingManager = previousSession.recordingManager;
|
||||
this.broadcastManager = previousSession.broadcastManager;
|
||||
this.tokens = previousSession.tokens;
|
||||
}
|
||||
|
||||
public Session(String sessionId, SessionProperties sessionProperties, OpenviduConfig openviduConfig,
|
||||
RecordingManager recordingManager) {
|
||||
RecordingManager recordingManager, BroadcastManager broadcastManager) {
|
||||
this.sessionId = sessionId;
|
||||
this.startTime = System.currentTimeMillis();
|
||||
this.uniqueSessionId = sessionId + "_" + this.startTime;
|
||||
this.sessionProperties = sessionProperties;
|
||||
this.openviduConfig = openviduConfig;
|
||||
this.recordingManager = recordingManager;
|
||||
this.broadcastManager = broadcastManager;
|
||||
}
|
||||
|
||||
public String getSessionId() {
|
||||
|
@ -243,6 +247,7 @@ public class Session implements SessionInterface {
|
|||
json.addProperty("sessionId", this.sessionId); // TODO: deprecated. Better use only "id"
|
||||
json.addProperty("createdAt", this.startTime);
|
||||
json.addProperty("recording", this.recordingManager.sessionIsBeingRecorded(this.sessionId));
|
||||
json.addProperty("broadcasting", this.broadcastManager.sessionIsBeingBroadcasted(this.sessionId));
|
||||
|
||||
// Add keys from SessionProperties
|
||||
JsonObject sessionPropertiesJson = sessionProperties.toJson();
|
||||
|
|
|
@ -53,6 +53,7 @@ import io.openvidu.java.client.KurentoOptions;
|
|||
import io.openvidu.java.client.OpenViduRole;
|
||||
import io.openvidu.java.client.Recording;
|
||||
import io.openvidu.java.client.SessionProperties;
|
||||
import io.openvidu.server.broadcast.BroadcastManager;
|
||||
import io.openvidu.server.cdr.CDREventRecordingStatusChanged;
|
||||
import io.openvidu.server.config.OpenviduConfig;
|
||||
import io.openvidu.server.coturn.CoturnCredentialsService;
|
||||
|
@ -74,6 +75,9 @@ public abstract class SessionManager {
|
|||
@Autowired
|
||||
protected RecordingManager recordingManager;
|
||||
|
||||
@Autowired
|
||||
protected BroadcastManager broadcastManager;
|
||||
|
||||
@Autowired
|
||||
protected OpenviduConfig openviduConfig;
|
||||
|
||||
|
@ -315,8 +319,8 @@ public abstract class SessionManager {
|
|||
* @return null if concurrent storing of session
|
||||
*/
|
||||
public Session storeSessionNotActive(String sessionId, SessionProperties sessionProperties) {
|
||||
Session sessionNotActive = this
|
||||
.storeSessionNotActive(new Session(sessionId, sessionProperties, openviduConfig, recordingManager));
|
||||
Session sessionNotActive = this.storeSessionNotActive(
|
||||
new Session(sessionId, sessionProperties, openviduConfig, recordingManager, broadcastManager));
|
||||
if (sessionNotActive == null) {
|
||||
return null;
|
||||
} else {
|
||||
|
|
|
@ -114,7 +114,8 @@ public class KurentoSessionManager extends SessionManager {
|
|||
// Insecure user directly call joinRoom RPC method, without REST API use
|
||||
SessionProperties.Builder builder = new SessionProperties.Builder().mediaMode(MediaMode.ROUTED)
|
||||
.recordingMode(RecordingMode.ALWAYS);
|
||||
sessionNotActive = new Session(sessionId, builder.build(), openviduConfig, recordingManager);
|
||||
sessionNotActive = new Session(sessionId, builder.build(), openviduConfig, recordingManager,
|
||||
broadcastManager);
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
|
@ -101,7 +101,7 @@ public class SessionGarbageCollectorIntegrationTest {
|
|||
String stringResponse = (String) sessionRestController.initializeSession(new HashMap<>()).getBody();
|
||||
JsonObject json = new Gson().fromJson(stringResponse, JsonObject.class);
|
||||
String sessionId = json.get("id").getAsString();
|
||||
return new Session(sessionId, null, null, null);
|
||||
return new Session(sessionId, null, null, null, null);
|
||||
}
|
||||
|
||||
private String getToken(Session session) {
|
||||
|
|
|
@ -844,7 +844,7 @@ public class OpenViduTestE2e {
|
|||
}
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
log.error("Waiting for OpenVidu Server...");
|
||||
log.warn("Waiting for OpenVidu Server...");
|
||||
Thread.sleep(msInterval);
|
||||
} catch (InterruptedException e1) {
|
||||
log.error("Sleep interrupted");
|
||||
|
|
Loading…
Reference in New Issue