mirror of https://github.com/OpenVidu/openvidu.git
openvidu-server: configuration parameters for max and min video send and recv (kbps)
parent
2571a8a33c
commit
e615ff7ec4
|
@ -44,19 +44,28 @@ public class OpenviduConfig {
|
|||
private String openviduRecordingPath;
|
||||
|
||||
@Value("${openvidu.recording.public-access}")
|
||||
boolean openviduRecordingPublicAccess;
|
||||
private boolean openviduRecordingPublicAccess;
|
||||
|
||||
@Value("${openvidu.recording.notification}")
|
||||
String openviduRecordingNotification;
|
||||
private String openviduRecordingNotification;
|
||||
|
||||
@Value("${openvidu.recording.custom-layout}")
|
||||
String openviduRecordingCustomLayout;
|
||||
private String openviduRecordingCustomLayout;
|
||||
|
||||
@Value("${openvidu.recording.version}")
|
||||
String openviduRecordingVersion;
|
||||
private String openviduRecordingVersion;
|
||||
|
||||
@Value("#{'${spring.profiles.active:}'.length() > 0 ? '${spring.profiles.active:}'.split(',') : \"default\"}")
|
||||
private String springProfile;
|
||||
@Value("${openvidu.streams.video.max-recv-bandwidth}")
|
||||
private int openviduStreamsVideoMaxRecvBandwidth;
|
||||
|
||||
@Value("${openvidu.streams.video.min-recv-bandwidth}")
|
||||
private int openviduStreamsVideoMinRecvBandwidth;
|
||||
|
||||
@Value("${openvidu.streams.video.max-send-bandwidth}")
|
||||
private int openviduStreamsVideoMaxSendBandwidth;
|
||||
|
||||
@Value("${openvidu.streams.video.min-send-bandwidth}")
|
||||
private int openviduStreamsVideoMinSendBandwidth;
|
||||
|
||||
@Value("${coturn.redis.ip}")
|
||||
private String coturnRedisIp;
|
||||
|
@ -70,6 +79,9 @@ public class OpenviduConfig {
|
|||
@Value("${coturn.redis.connect-timeout}")
|
||||
private String coturnRedisConnectTimeout;
|
||||
|
||||
@Value("#{'${spring.profiles.active:}'.length() > 0 ? '${spring.profiles.active:}'.split(',') : \"default\"}")
|
||||
private String springProfile;
|
||||
|
||||
private String finalUrl;
|
||||
|
||||
public String getOpenViduPublicUrl() {
|
||||
|
@ -132,6 +144,22 @@ public class OpenviduConfig {
|
|||
return springProfile;
|
||||
}
|
||||
|
||||
public int getVideoMaxRecvBandwidth() {
|
||||
return this.openviduStreamsVideoMaxRecvBandwidth;
|
||||
}
|
||||
|
||||
public int getVideoMinRecvBandwidth() {
|
||||
return this.openviduStreamsVideoMinRecvBandwidth;
|
||||
}
|
||||
|
||||
public int getVideoMaxSendBandwidth() {
|
||||
return this.openviduStreamsVideoMaxSendBandwidth;
|
||||
}
|
||||
|
||||
public int getVideoMinSendBandwidth() {
|
||||
return this.openviduStreamsVideoMinSendBandwidth;
|
||||
}
|
||||
|
||||
public String getCoturnDatabaseString() {
|
||||
return "\"ip=" + this.coturnRedisIp + " dbname=" + this.coturnRedisDbname + " password="
|
||||
+ this.coturnRedisPassword + " connect_timeout=" + this.coturnRedisConnectTimeout + "\"";
|
||||
|
|
|
@ -39,7 +39,6 @@ import org.kurento.client.SdpEndpoint;
|
|||
import org.kurento.client.internal.server.KurentoServerException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import io.openvidu.client.OpenViduException;
|
||||
import io.openvidu.client.OpenViduException.Code;
|
||||
|
@ -60,8 +59,7 @@ public class KurentoParticipant extends Participant {
|
|||
|
||||
private static final Logger log = LoggerFactory.getLogger(KurentoParticipant.class);
|
||||
|
||||
@Autowired
|
||||
protected OpenviduConfig openviduConfig;
|
||||
private OpenviduConfig openviduConfig;
|
||||
|
||||
private InfoHandler infoHandler;
|
||||
private CallDetailRecord CDR;
|
||||
|
@ -78,12 +76,14 @@ public class KurentoParticipant extends Participant {
|
|||
private final ConcurrentMap<String, SubscriberEndpoint> subscribers = new ConcurrentHashMap<String, SubscriberEndpoint>();
|
||||
|
||||
public KurentoParticipant(Participant participant, KurentoSession kurentoSession, MediaPipeline pipeline,
|
||||
InfoHandler infoHandler, CallDetailRecord CDR) {
|
||||
InfoHandler infoHandler, CallDetailRecord CDR, OpenviduConfig openviduConfig) {
|
||||
super(participant.getParticipantPrivateId(), participant.getParticipantPublicId(), participant.getToken(),
|
||||
participant.getClientMetadata());
|
||||
this.openviduConfig = openviduConfig;
|
||||
this.session = kurentoSession;
|
||||
this.pipeline = pipeline;
|
||||
this.publisher = new PublisherEndpoint(webParticipant, this, participant.getParticipantPublicId(), pipeline);
|
||||
this.publisher = new PublisherEndpoint(webParticipant, this, participant.getParticipantPublicId(), pipeline,
|
||||
this.openviduConfig);
|
||||
|
||||
for (Participant other : session.getParticipants()) {
|
||||
if (!other.getParticipantPublicId().equals(this.getParticipantPublicId())) {
|
||||
|
@ -250,7 +250,8 @@ public class KurentoParticipant extends Participant {
|
|||
log.info("PARTICIPANT {}: unpublishing media stream from room {}", this.getParticipantPublicId(),
|
||||
this.session.getSessionId());
|
||||
releasePublisherEndpoint(reason);
|
||||
this.publisher = new PublisherEndpoint(webParticipant, this, this.getParticipantPublicId(), pipeline);
|
||||
this.publisher = new PublisherEndpoint(webParticipant, this, this.getParticipantPublicId(), pipeline,
|
||||
this.openviduConfig);
|
||||
log.info("PARTICIPANT {}: released publisher endpoint and left it initialized (ready for future streaming)",
|
||||
this.getParticipantPublicId());
|
||||
}
|
||||
|
@ -394,7 +395,8 @@ public class KurentoParticipant extends Participant {
|
|||
*/
|
||||
public SubscriberEndpoint getNewOrExistingSubscriber(String senderPublicId) {
|
||||
|
||||
SubscriberEndpoint sendingEndpoint = new SubscriberEndpoint(webParticipant, this, senderPublicId, pipeline);
|
||||
SubscriberEndpoint sendingEndpoint = new SubscriberEndpoint(webParticipant, this, senderPublicId, pipeline,
|
||||
this.openviduConfig);
|
||||
|
||||
SubscriberEndpoint existingSendingEndpoint = this.subscribers.putIfAbsent(senderPublicId, sendingEndpoint);
|
||||
if (existingSendingEndpoint != null) {
|
||||
|
|
|
@ -42,6 +42,7 @@ import io.openvidu.client.OpenViduException.Code;
|
|||
import io.openvidu.client.internal.ProtocolElements;
|
||||
import io.openvidu.java.client.SessionProperties;
|
||||
import io.openvidu.server.cdr.CallDetailRecord;
|
||||
import io.openvidu.server.config.OpenviduConfig;
|
||||
import io.openvidu.server.core.Participant;
|
||||
import io.openvidu.server.core.Session;
|
||||
|
||||
|
@ -53,6 +54,8 @@ public class KurentoSession implements Session {
|
|||
private final static Logger log = LoggerFactory.getLogger(Session.class);
|
||||
public static final int ASYNC_LATCH_TIMEOUT = 30;
|
||||
|
||||
private OpenviduConfig openviduConfig;
|
||||
|
||||
private final ConcurrentMap<String, KurentoParticipant> participants = new ConcurrentHashMap<>();
|
||||
private String sessionId;
|
||||
private SessionProperties sessionProperties;
|
||||
|
@ -78,13 +81,15 @@ public class KurentoSession implements Session {
|
|||
public final ConcurrentHashMap<String, String> publishedStreamIds = new ConcurrentHashMap<>();
|
||||
|
||||
public KurentoSession(String sessionId, SessionProperties sessionProperties, KurentoClient kurentoClient,
|
||||
KurentoSessionEventsHandler kurentoSessionHandler, boolean destroyKurentoClient, CallDetailRecord CDR) {
|
||||
KurentoSessionEventsHandler kurentoSessionHandler, boolean destroyKurentoClient, CallDetailRecord CDR,
|
||||
OpenviduConfig openviduConfig) {
|
||||
this.sessionId = sessionId;
|
||||
this.sessionProperties = sessionProperties;
|
||||
this.kurentoClient = kurentoClient;
|
||||
this.destroyKurentoClient = destroyKurentoClient;
|
||||
this.kurentoSessionHandler = kurentoSessionHandler;
|
||||
this.CDR = CDR;
|
||||
this.openviduConfig = openviduConfig;
|
||||
log.debug("New SESSION instance with id '{}'", sessionId);
|
||||
}
|
||||
|
||||
|
@ -104,7 +109,7 @@ public class KurentoSession implements Session {
|
|||
createPipeline();
|
||||
|
||||
KurentoParticipant kurentoParticipant = new KurentoParticipant(participant, this, getPipeline(),
|
||||
kurentoSessionHandler.getInfoHandler(), this.CDR);
|
||||
kurentoSessionHandler.getInfoHandler(), this.CDR, this.openviduConfig);
|
||||
participants.put(participant.getParticipantPrivateId(), kurentoParticipant);
|
||||
|
||||
filterStates.forEach((filterId, state) -> {
|
||||
|
|
|
@ -441,7 +441,7 @@ public class KurentoSessionManager extends SessionManager {
|
|||
}
|
||||
KurentoClient kurentoClient = kcProvider.getKurentoClient(kcSessionInfo);
|
||||
session = new KurentoSession(sessionId, sessionProperties, kurentoClient, kurentoSessionEventsHandler,
|
||||
kcProvider.destroyWhenUnused(), this.CDR);
|
||||
kcProvider.destroyWhenUnused(), this.CDR, this.openviduConfig);
|
||||
|
||||
KurentoSession oldSession = (KurentoSession) sessions.putIfAbsent(sessionId, session);
|
||||
if (oldSession != null) {
|
||||
|
|
|
@ -44,6 +44,7 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import io.openvidu.client.OpenViduException;
|
||||
import io.openvidu.client.OpenViduException.Code;
|
||||
import io.openvidu.server.config.OpenviduConfig;
|
||||
import io.openvidu.server.core.Participant;
|
||||
import io.openvidu.server.kurento.core.KurentoParticipant;
|
||||
|
||||
|
@ -57,12 +58,18 @@ import io.openvidu.server.kurento.core.KurentoParticipant;
|
|||
*/
|
||||
public abstract class MediaEndpoint {
|
||||
private static Logger log;
|
||||
private OpenviduConfig openviduConfig;
|
||||
|
||||
private boolean web = false;
|
||||
|
||||
private WebRtcEndpoint webEndpoint = null;
|
||||
private RtpEndpoint endpoint = null;
|
||||
|
||||
private final int maxRecvKbps;
|
||||
private final int minRecvKbps;
|
||||
private final int maxSendKbps;
|
||||
private final int minSendKbps;
|
||||
|
||||
private KurentoParticipant owner;
|
||||
private String endpointName;
|
||||
|
||||
|
@ -89,7 +96,7 @@ public abstract class MediaEndpoint {
|
|||
* @param log
|
||||
*/
|
||||
public MediaEndpoint(boolean web, KurentoParticipant owner, String endpointName, MediaPipeline pipeline,
|
||||
Logger log) {
|
||||
OpenviduConfig openviduConfig, Logger log) {
|
||||
if (log == null) {
|
||||
MediaEndpoint.log = LoggerFactory.getLogger(MediaEndpoint.class);
|
||||
} else {
|
||||
|
@ -99,6 +106,12 @@ public abstract class MediaEndpoint {
|
|||
this.owner = owner;
|
||||
this.setEndpointName(endpointName);
|
||||
this.setMediaPipeline(pipeline);
|
||||
|
||||
this.openviduConfig = openviduConfig;
|
||||
this.maxRecvKbps = this.openviduConfig.getVideoMaxRecvBandwidth();
|
||||
this.minRecvKbps = this.openviduConfig.getVideoMinRecvBandwidth();
|
||||
this.maxSendKbps = this.openviduConfig.getVideoMaxSendBandwidth();
|
||||
this.minSendKbps = this.openviduConfig.getVideoMinSendBandwidth();
|
||||
}
|
||||
|
||||
public boolean isWeb() {
|
||||
|
@ -218,10 +231,10 @@ public abstract class MediaEndpoint {
|
|||
public void onSuccess(WebRtcEndpoint result) throws Exception {
|
||||
webEndpoint = result;
|
||||
|
||||
webEndpoint.setMaxVideoRecvBandwidth(600);
|
||||
webEndpoint.setMinVideoRecvBandwidth(300);
|
||||
webEndpoint.setMaxVideoSendBandwidth(600);
|
||||
webEndpoint.setMinVideoSendBandwidth(300);
|
||||
webEndpoint.setMaxVideoRecvBandwidth(maxRecvKbps);
|
||||
webEndpoint.setMinVideoRecvBandwidth(minRecvKbps);
|
||||
webEndpoint.setMaxVideoSendBandwidth(maxSendKbps);
|
||||
webEndpoint.setMinVideoSendBandwidth(minSendKbps);
|
||||
|
||||
endpointLatch.countDown();
|
||||
log.trace("EP {}: Created a new WebRtcEndpoint", endpointName);
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import io.openvidu.client.OpenViduException;
|
||||
import io.openvidu.client.OpenViduException.Code;
|
||||
import io.openvidu.server.config.OpenviduConfig;
|
||||
import io.openvidu.server.core.MediaOptions;
|
||||
import io.openvidu.server.kurento.TrackType;
|
||||
import io.openvidu.server.kurento.core.KurentoParticipant;
|
||||
|
@ -60,8 +61,8 @@ public class PublisherEndpoint extends MediaEndpoint {
|
|||
|
||||
private Map<String, ListenerSubscription> elementsErrorSubscriptions = new HashMap<String, ListenerSubscription>();
|
||||
|
||||
public PublisherEndpoint(boolean web, KurentoParticipant owner, String endpointName, MediaPipeline pipeline) {
|
||||
super(web, owner, endpointName, pipeline, log);
|
||||
public PublisherEndpoint(boolean web, KurentoParticipant owner, String endpointName, MediaPipeline pipeline, OpenviduConfig openviduConfig) {
|
||||
super(web, owner, endpointName, pipeline, openviduConfig, log);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.kurento.client.MediaPipeline;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import io.openvidu.server.config.OpenviduConfig;
|
||||
import io.openvidu.server.kurento.core.KurentoParticipant;
|
||||
|
||||
/**
|
||||
|
@ -36,8 +37,8 @@ public class SubscriberEndpoint extends MediaEndpoint {
|
|||
|
||||
private PublisherEndpoint publisher = null;
|
||||
|
||||
public SubscriberEndpoint(boolean web, KurentoParticipant owner, String endpointName, MediaPipeline pipeline) {
|
||||
super(web, owner, endpointName, pipeline, log);
|
||||
public SubscriberEndpoint(boolean web, KurentoParticipant owner, String endpointName, MediaPipeline pipeline, OpenviduConfig openviduConfig) {
|
||||
super(web, owner, endpointName, pipeline, openviduConfig, log);
|
||||
}
|
||||
|
||||
public synchronized String subscribe(String sdpOffer, PublisherEndpoint publisher) {
|
||||
|
|
|
@ -64,6 +64,54 @@
|
|||
"type": "java.lang.String",
|
||||
"description": "Path to COTURN sqlite database to add and remove TURN user credentials",
|
||||
"defaultValue": "/opt/openvidu/coturn/turndb"
|
||||
},
|
||||
{
|
||||
"name": "openvidu.streams.video.max-recv-bandwidth",
|
||||
"type": "java.lang.Integer",
|
||||
"description": "Maximum video bandwith sent from clients to OpenVidu Server, in kbps. 0 means unconstrained",
|
||||
"defaultValue": 600
|
||||
},
|
||||
{
|
||||
"name": "openvidu.streams.video.min-recv-bandwidth",
|
||||
"type": "java.lang.Integer",
|
||||
"description": "Minimum video bandwith sent from clients to OpenVidu Server, in kbps. 0 means unconstrained",
|
||||
"defaultValue": 300
|
||||
},
|
||||
{
|
||||
"name": "openvidu.streams.video.max-send-bandwidth",
|
||||
"type": "java.lang.Integer",
|
||||
"description": "Maximum video bandwith sent from OpenVidu Server to clients, in kbps. 0 means unconstrained",
|
||||
"defaultValue": 600
|
||||
},
|
||||
{
|
||||
"name": "openvidu.streams.video.min-send-bandwidth",
|
||||
"type": "java.lang.Integer",
|
||||
"description": "Minimum video bandwith sent from OpenVidu Server to clients, in kbps. 0 means unconstrained",
|
||||
"defaultValue": 300
|
||||
},
|
||||
{
|
||||
"name": "coturn.redis.ip",
|
||||
"type": "java.lang.String",
|
||||
"description": "Redis IP where OpenVidu Server should connect to store TURN credentials",
|
||||
"defaultValue": "127.0.0.1"
|
||||
},
|
||||
{
|
||||
"name": "coturn.redis.dbname",
|
||||
"type": "java.lang.String",
|
||||
"description": "Redis database where to store TURN credentials",
|
||||
"defaultValue": "0"
|
||||
},
|
||||
{
|
||||
"name": "coturn.redis.password",
|
||||
"type": "java.lang.String",
|
||||
"description": "Password to connect OpenVidu Server to Redis database to store TURN credentials",
|
||||
"defaultValue": "turn"
|
||||
},
|
||||
{
|
||||
"name": "coturn.redis.connect-timeout",
|
||||
"type": "java.lang.Integer",
|
||||
"description": "Timeout in seconds when OpenVidu Server is connecting to Redis database to store TURN credentials",
|
||||
"defaultValue": 30
|
||||
}
|
||||
]
|
||||
}
|
|
@ -13,15 +13,21 @@ server.ssl.key-alias: openvidu-selfsigned
|
|||
openvidu.secret: MY_SECRET
|
||||
openvidu.publicurl: local
|
||||
openvidu.cdr: false
|
||||
|
||||
openvidu.recording: false
|
||||
openvidu.recording.path: /opt/openvidu/recordings
|
||||
openvidu.recording.public-access: false
|
||||
openvidu.recording.notification: publisher_moderator
|
||||
openvidu.recording.custom-layout: /opt/openvidu/custom-layout
|
||||
|
||||
kms.uris=[\"ws://localhost:8888/kurento\"]
|
||||
openvidu.streams.video.max-recv-bandwidth: 600
|
||||
openvidu.streams.video.min-recv-bandwidth: 300
|
||||
openvidu.streams.video.max-send-bandwidth: 600
|
||||
openvidu.streams.video.min-send-bandwidth: 300
|
||||
|
||||
coturn.redis.ip=127.0.0.1
|
||||
coturn.redis.dbname=0
|
||||
coturn.redis.password=turn
|
||||
coturn.redis.connect-timeout=30
|
||||
kms.uris: [\"ws://localhost:8888/kurento\"]
|
||||
|
||||
coturn.redis.ip: 127.0.0.1
|
||||
coturn.redis.dbname: 0
|
||||
coturn.redis.password: turn
|
||||
coturn.redis.connect-timeout: 30
|
||||
|
|
Loading…
Reference in New Issue