Merge pull request #667 from OpenVidu/forcecodec-preferred

ForcedVideoCodec default set to MEDIA_SERVER_PREFERRED
pull/685/head
Juan Navarro 2022-01-20 12:11:46 +01:00 committed by GitHub
commit 46c7516764
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 189 additions and 91 deletions

View File

@ -38,6 +38,7 @@ import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonSyntaxException;
@ -661,16 +662,17 @@ public class Session {
this.sessionId = responseJson.get("id").getAsString();
this.createdAt = responseJson.get("createdAt").getAsLong();
// forcedVideoCodec and allowTranscoding values are configured in OpenVidu
// Server via configuration or session
// Values that get filled by OpenVidu Server from its global or per-session configuration
VideoCodec forcedVideoCodec = VideoCodec.valueOf(responseJson.get("forcedVideoCodec").getAsString());
VideoCodec forcedVideoCodecResolved = VideoCodec
.valueOf(responseJson.get("forcedVideoCodecResolved").getAsString());
Boolean allowTranscoding = responseJson.get("allowTranscoding").getAsBoolean();
SessionProperties responseProperties = new SessionProperties.Builder()
.customSessionId(properties.customSessionId()).mediaMode(properties.mediaMode())
SessionProperties responseProperties = new SessionProperties.Builder().mediaMode(properties.mediaMode())
.recordingMode(properties.recordingMode())
.defaultRecordingProperties(properties.defaultRecordingProperties())
.mediaNode(properties.mediaNode()).forcedVideoCodec(forcedVideoCodec)
.customSessionId(properties.customSessionId()).mediaNode(properties.mediaNode())
.forcedVideoCodec(forcedVideoCodec).forcedVideoCodecResolved(forcedVideoCodecResolved)
.allowTranscoding(allowTranscoding).build();
this.properties = responseProperties;
@ -718,6 +720,9 @@ public class Session {
if (json.has("forcedVideoCodec")) {
builder.forcedVideoCodec(VideoCodec.valueOf(json.get("forcedVideoCodec").getAsString()));
}
if (json.has("forcedVideoCodecResolved")) {
builder.forcedVideoCodecResolved(VideoCodec.valueOf(json.get("forcedVideoCodecResolved").getAsString()));
}
if (json.has("allowTranscoding")) {
builder.allowTranscoding(json.get("allowTranscoding").getAsBoolean());
}
@ -756,19 +761,15 @@ public class Session {
JsonObject json = new JsonObject();
json.addProperty("sessionId", this.sessionId);
json.addProperty("createdAt", this.createdAt);
json.addProperty("customSessionId", this.properties.customSessionId());
json.addProperty("recording", this.recording);
json.addProperty("mediaMode", this.properties.mediaMode().name());
json.addProperty("recordingMode", this.properties.recordingMode().name());
if (this.properties.defaultRecordingProperties() != null) {
json.add("defaultRecordingProperties", this.properties.defaultRecordingProperties().toJson());
}
if (this.properties.forcedVideoCodec() != null) {
json.addProperty("forcedVideoCodec", this.properties.forcedVideoCodec().name());
}
if (this.properties.isTranscodingAllowed() != null) {
json.addProperty("allowTranscoding", this.properties.isTranscodingAllowed());
// Add keys from SessionProperties
JsonObject sessionPropertiesJson = this.properties.toJson();
for (Map.Entry<String, JsonElement> entry : sessionPropertiesJson.entrySet()) {
json.add(entry.getKey(), entry.getValue().deepCopy());
}
// Add "connections" object
JsonObject connections = new JsonObject();
connections.addProperty("numberOfElements", this.getConnections().size());
JsonArray jsonArrayConnections = new JsonArray();

View File

@ -30,6 +30,7 @@ public class SessionProperties {
private String customSessionId;
private String mediaNode;
private VideoCodec forcedVideoCodec;
private VideoCodec forcedVideoCodecResolved;
private Boolean allowTranscoding;
/**
@ -42,7 +43,8 @@ public class SessionProperties {
private RecordingProperties defaultRecordingProperties = new RecordingProperties.Builder().build();
private String customSessionId = "";
private String mediaNode;
private VideoCodec forcedVideoCodec = VideoCodec.VP8;
private VideoCodec forcedVideoCodec = VideoCodec.MEDIA_SERVER_PREFERRED;
private VideoCodec forcedVideoCodecResolved = VideoCodec.NONE;
private Boolean allowTranscoding = false;
/**
@ -51,7 +53,8 @@ public class SessionProperties {
*/
public SessionProperties build() {
return new SessionProperties(this.mediaMode, this.recordingMode, this.defaultRecordingProperties,
this.customSessionId, this.mediaNode, this.forcedVideoCodec, this.allowTranscoding);
this.customSessionId, this.mediaNode, this.forcedVideoCodec, this.forcedVideoCodecResolved,
this.allowTranscoding);
}
/**
@ -114,21 +117,37 @@ public class SessionProperties {
}
/**
* Call this method to define which video codec do you want to be forcibly used
* for this session. This allows browsers/clients to use the same codec avoiding
* transcoding in the media server. If the browser/client is not compatible with
* the specified codec and {@link #allowTranscoding(Boolean)} is
* <code>false</code> and exception will occur. If forcedVideoCodec is set to
* NONE, no codec will be forced.<br>
* Define which video codec will be forcibly used for this session.
* This forces all browsers/clients to use the same codec, which would
* avoid transcoding in the media server (Kurento only). If
* <code>forcedVideoCodec</code> is set to NONE, no codec will be forced.
*
* If the browser/client is not compatible with the specified codec, and
* {@link #allowTranscoding(Boolean)} is <code>false</code>, an
* exception will occur.
*
* If defined here, this parameter has prevalence over
* OPENVIDU_STREAMS_FORCED_VIDEO_CODEC. OPENVIDU_STREAMS_FORCED_VIDEO_CODEC
* default is {@link VideoCodec#VP8}
* OPENVIDU_STREAMS_FORCED_VIDEO_CODEC.
*
* Default is {@link VideoCodec#MEDIA_SERVER_PREFERRED}.
*/
public SessionProperties.Builder forcedVideoCodec(VideoCodec forcedVideoCodec) {
this.forcedVideoCodec = forcedVideoCodec;
return this;
}
/**
* Actual video codec that will be forcibly used for this session.
* This is the same as <code>forcedVideoCodec</code>, except when its
* value is {@link VideoCodec#MEDIA_SERVER_PREFERRED}: in that case,
* OpenVidu Server will fill this property with a resolved value,
* depending on what is the configured media server.
*/
public SessionProperties.Builder forcedVideoCodecResolved(VideoCodec forcedVideoCodec) {
this.forcedVideoCodecResolved = forcedVideoCodec;
return this;
}
/**
* Call this method to define if you want to allow transcoding in the media
* server or not when {@link #forcedVideoCodec(VideoCodec)} is not compatible
@ -154,13 +173,14 @@ public class SessionProperties {
private SessionProperties(MediaMode mediaMode, RecordingMode recordingMode,
RecordingProperties defaultRecordingProperties, String customSessionId, String mediaNode,
VideoCodec forcedVideoCodec, Boolean allowTranscoding) {
VideoCodec forcedVideoCodec, VideoCodec forcedVideoCodecResolved, Boolean allowTranscoding) {
this.mediaMode = mediaMode;
this.recordingMode = recordingMode;
this.defaultRecordingProperties = defaultRecordingProperties;
this.customSessionId = customSessionId;
this.mediaNode = mediaNode;
this.forcedVideoCodec = forcedVideoCodec;
this.forcedVideoCodecResolved = forcedVideoCodecResolved;
this.allowTranscoding = allowTranscoding;
}
@ -217,12 +237,24 @@ public class SessionProperties {
}
/**
* Defines which video codec is being forced to be used in the browser/client
* Defines which video codec is being forced to be used in the browser/client.
* This is the raw value that was configured. It might get resolved into a
* different one for actual usage in the server.
*/
public VideoCodec forcedVideoCodec() {
return this.forcedVideoCodec;
}
/**
* Defines which video codec is being forced to be used in the browser/client.
* This is the resolved value, for actual usage in the server.
*
* @hidden
*/
public VideoCodec forcedVideoCodecResolved() {
return this.forcedVideoCodecResolved;
}
/**
* Defines if transcoding is allowed or not when {@link #forcedVideoCodec} is
* not a compatible codec with the browser/client.
@ -231,22 +263,25 @@ public class SessionProperties {
return this.allowTranscoding;
}
protected JsonObject toJson() {
public JsonObject toJson() {
JsonObject json = new JsonObject();
json.addProperty("mediaMode", mediaMode().name());
json.addProperty("recordingMode", recordingMode().name());
json.addProperty("customSessionId", customSessionId());
json.add("defaultRecordingProperties", defaultRecordingProperties.toJson());
if (mediaNode() != null) {
json.addProperty("mediaMode", this.mediaMode.name());
json.addProperty("recordingMode", this.recordingMode.name());
json.add("defaultRecordingProperties", this.defaultRecordingProperties.toJson());
json.addProperty("customSessionId", this.customSessionId);
if (this.mediaNode != null && !this.mediaNode.isEmpty()) {
JsonObject mediaNodeJson = new JsonObject();
mediaNodeJson.addProperty("id", mediaNode());
mediaNodeJson.addProperty("id", this.mediaNode);
json.add("mediaNode", mediaNodeJson);
}
if (forcedVideoCodec() != null) {
json.addProperty("forcedVideoCodec", forcedVideoCodec().name());
if (this.forcedVideoCodec != null) {
json.addProperty("forcedVideoCodec", this.forcedVideoCodec.name());
}
if (isTranscodingAllowed() != null) {
json.addProperty("allowTranscoding", isTranscodingAllowed());
if (this.forcedVideoCodecResolved != null) {
json.addProperty("forcedVideoCodecResolved", this.forcedVideoCodecResolved.name());
}
if (this.allowTranscoding != null) {
json.addProperty("allowTranscoding", this.allowTranscoding);
}
return json;
}

View File

@ -22,5 +22,5 @@ package io.openvidu.java.client;
* {@link io.openvidu.java.client.SessionProperties.Builder#forcedVideoCodec(VideoCodec)}
*/
public enum VideoCodec {
VP8, VP9, H264, NONE
MEDIA_SERVER_PREFERRED, NONE, VP8, VP9, H264
}

View File

@ -490,6 +490,7 @@ export class Session {
this.properties.defaultRecordingProperties = res.data.defaultRecordingProperties;
this.properties.mediaNode = res.data.mediaNode;
this.properties.forcedVideoCodec = res.data.forcedVideoCodec;
this.properties.forcedVideoCodecResolved = res.data.forcedVideoCodecResolved;
this.properties.allowTranscoding = res.data.allowTranscoding;
this.sanitizeDefaultSessionProperties(this.properties);
resolve(this.sessionId);
@ -533,6 +534,7 @@ export class Session {
recordingMode: json.recordingMode,
defaultRecordingProperties: json.defaultRecordingProperties,
forcedVideoCodec: json.forcedVideoCodec,
forcedVideoCodecResolved: json.forcedVideoCodecResolved,
allowTranscoding: json.allowTranscoding
};
this.sanitizeDefaultSessionProperties(this.properties);
@ -548,6 +550,9 @@ export class Session {
if (json.forcedVideoCodec == null) {
delete this.properties.forcedVideoCodec;
}
if (json.forcedVideoCodecResolved == null) {
delete this.properties.forcedVideoCodecResolved;
}
if (json.allowTranscoding == null) {
delete this.properties.allowTranscoding;
}
@ -655,9 +660,12 @@ export class Session {
props.mediaMode = (props.mediaMode != null) ? props.mediaMode : MediaMode.ROUTED;
props.recordingMode = (props.recordingMode != null) ? props.recordingMode : RecordingMode.MANUAL;
props.customSessionId = (props.customSessionId != null) ? props.customSessionId : '';
props.mediaNode = (props.mediaNode != null) ? props.mediaNode : undefined;
props.forcedVideoCodec = props.forcedVideoCodec;
props.allowTranscoding = props.allowTranscoding;
// Remove null values: either set, or undefined
props.mediaNode = props.mediaNode ?? undefined;
props.forcedVideoCodec = props.forcedVideoCodec ?? undefined;
props.forcedVideoCodecResolved = props.forcedVideoCodecResolved ?? undefined;
props.allowTranscoding = props.allowTranscoding ?? undefined;
if (!props.defaultRecordingProperties) {
props.defaultRecordingProperties = {};

View File

@ -67,16 +67,32 @@ export interface SessionProperties {
}
/**
* It defines which video codec do you want to be forcibly used for this session.
* This allows browsers/clients to use the same codec avoiding transcoding in the media server.
* If the browser/client is not compatible with the specified codec and [[allowTranscoding]] is <code>false</code>
* and exception will occur. If forcedVideoCodec is set to [[VideoCodec.NONE]], no codec will be forced.
* Define which video codec will be forcibly used for this session.
* This forces all browsers/clients to use the same codec, which would
* avoid transcoding in the media server (Kurento only). If
* <code>forcedVideoCodec</code> is set to NONE, no codec will be forced.
*
* If defined here, this parameter has prevalence over OPENVIDU_STREAMS_FORCED_VIDEO_CODEC.
* OPENVIDU_STREAMS_FORCED_VIDEO_CODEC default is [[VideoCodec.VP8]]
* If the browser/client is not compatible with the specified codec, and
* [[allowTranscoding]] is <code>false</code>, an exception will occur.
*
* If defined here, this parameter has prevalence over
* OPENVIDU_STREAMS_FORCED_VIDEO_CODEC.
*
* Default is [[VideoCodec.MEDIA_SERVER_PREFERRED]].
*/
forcedVideoCodec?: VideoCodec;
/**
* Actual video codec that will be forcibly used for this session.
* This is the same as <code>forcedVideoCodec</code>, except when its value
* is [[VideoCodec.MEDIA_SERVER_PREFERRED]]: in that case, OpenVidu Server
* will fill this property with a resolved value, depending on what is the
* configured media server.
*
* @hidden
*/
forcedVideoCodecResolved?: VideoCodec;
/**
* It defines if you want to allow transcoding in the media server or not
* when [[forcedVideoCodec]] is not compatible with the browser/client.
@ -85,5 +101,4 @@ export interface SessionProperties {
* OPENVIDU_STREAMS_ALLOW_TRANSCODING default is 'false'
*/
allowTranscoding?: boolean;
}

View File

@ -2,10 +2,9 @@
* See [[SessionProperties.forcedVideoCodec]]
*/
export enum VideoCodec {
MEDIA_SERVER_PREFERRED = 'MEDIA_SERVER_PREFERRED',
NONE = 'NONE',
VP8 = 'VP8',
VP9 = 'VP9',
H264 = 'H264',
NONE = 'NONE'
}

View File

@ -128,9 +128,9 @@ OPENVIDU_STREAMS_VIDEO_MIN_SEND_BANDWIDTH=300
# All sessions of OpenVidu will try to force this codec. If OPENVIDU_STREAMS_ALLOW_TRANSCODING=true
# when a codec can not be forced, transcoding will be allowed
# Values: VP8, VP9, H264, NONE
# Default value is VP8
# OPENVIDU_STREAMS_FORCED_VIDEO_CODEC=VP8
# Values: MEDIA_SERVER_PREFERRED, NONE, VP8, VP9, H264
# Default value is MEDIA_SERVER_PREFERRED
# OPENVIDU_STREAMS_FORCED_VIDEO_CODEC=MEDIA_SERVER_PREFERRED
# Allow transcoding if codec specified in OPENVIDU_STREAMS_FORCED_VIDEO_CODEC can not be applied
# Values: true | false

View File

@ -259,9 +259,9 @@ OPENVIDU_STREAMS_VIDEO_MIN_SEND_BANDWIDTH=300
# All sessions of OpenVidu will try to force this codec. If OPENVIDU_STREAMS_ALLOW_TRANSCODING=true
# when a codec can not be forced, transcoding will be allowed
# Values: VP8, VP9, H264, NONE
# Default value is VP8
# OPENVIDU_STREAMS_FORCED_VIDEO_CODEC=VP8
# Values: MEDIA_SERVER_PREFERRED, NONE, VP8, VP9, H264
# Default value is MEDIA_SERVER_PREFERRED
# OPENVIDU_STREAMS_FORCED_VIDEO_CODEC=MEDIA_SERVER_PREFERRED
# Allow transcoding if codec specified in OPENVIDU_STREAMS_FORCED_VIDEO_CODEC can not be applied
# Values: true | false

View File

@ -246,9 +246,9 @@ OPENVIDU_STREAMS_VIDEO_MIN_SEND_BANDWIDTH=300
# All sessions of OpenVidu will try to force this codec. If OPENVIDU_STREAMS_ALLOW_TRANSCODING=true
# when a codec can not be forced, transcoding will be allowed
# Values: VP8, VP9, H264, NONE
# Default value is VP8
# OPENVIDU_STREAMS_FORCED_VIDEO_CODEC=VP8
# Values: MEDIA_SERVER_PREFERRED, NONE, VP8, VP9, H264
# Default value is MEDIA_SERVER_PREFERRED
# OPENVIDU_STREAMS_FORCED_VIDEO_CODEC=MEDIA_SERVER_PREFERRED
# Allow transcoding if codec specified in OPENVIDU_STREAMS_FORCED_VIDEO_CODEC can not be applied
# Values: true | false

View File

@ -19,6 +19,7 @@ package io.openvidu.server.core;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
@ -32,6 +33,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.stream.Collectors;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import io.openvidu.client.OpenViduException;
@ -234,22 +236,21 @@ public class Session implements SessionInterface {
json.addProperty("object", "session");
json.addProperty("sessionId", this.sessionId); // TODO: deprecated. Better use only "id"
json.addProperty("createdAt", this.startTime);
json.addProperty("mediaMode", this.sessionProperties.mediaMode().name());
json.addProperty("recordingMode", this.sessionProperties.recordingMode().name());
json.add("defaultRecordingProperties", this.sessionProperties.defaultRecordingProperties().toJson());
if (this.sessionProperties.customSessionId() != null) {
json.addProperty("customSessionId", this.sessionProperties.customSessionId());
json.addProperty("recording", this.recordingManager.sessionIsBeingRecorded(this.sessionId));
// Add keys from SessionProperties
JsonObject sessionPropertiesJson = sessionProperties.toJson();
for (Map.Entry<String, JsonElement> entry : sessionPropertiesJson.entrySet()) {
json.add(entry.getKey(), entry.getValue().deepCopy());
}
// Add "connections" object
JsonObject connections = new JsonObject();
JsonArray participants = this.getSnapshotOfConnectionsAsJsonArray(withPendingConnections, withWebrtcStats);
connections.addProperty("numberOfElements", participants.size());
connections.add("content", participants);
json.add("connections", connections);
json.addProperty("recording", this.recordingManager.sessionIsBeingRecorded(this.sessionId));
if (this.sessionProperties.forcedVideoCodec() != null) {
json.addProperty("forcedVideoCodec", this.sessionProperties.forcedVideoCodec().name());
}
json.addProperty("allowTranscoding", this.sessionProperties.isTranscodingAllowed());
return json;
}

View File

@ -380,7 +380,7 @@ public class KurentoSessionManager extends SessionManager {
KurentoParticipant kParticipant = (KurentoParticipant) participant;
KurentoSession kSession = kParticipant.getSession();
boolean isTranscodingAllowed = kSession.getSessionProperties().isTranscodingAllowed();
VideoCodec forcedVideoCodec = kSession.getSessionProperties().forcedVideoCodec();
VideoCodec forcedVideoCodec = kSession.getSessionProperties().forcedVideoCodecResolved();
final String streamId = kParticipant.generateStreamId(kurentoOptions);
@ -597,7 +597,7 @@ public class KurentoSessionManager extends SessionManager {
WebrtcDebugEventType.sdpOffer, sdpOffer));
boolean isTranscodingAllowed = session.getSessionProperties().isTranscodingAllowed();
VideoCodec forcedVideoCodec = session.getSessionProperties().forcedVideoCodec();
VideoCodec forcedVideoCodec = session.getSessionProperties().forcedVideoCodecResolved();
// Modify server's SDPOffer if forced codec is defined
if (forcedVideoCodec != VideoCodec.NONE && !participant.isIpcam()) {
@ -663,7 +663,7 @@ public class KurentoSessionManager extends SessionManager {
// Client initiated negotiation. sdpString is the SDP Offer of the client
boolean isTranscodingAllowed = session.getSessionProperties().isTranscodingAllowed();
VideoCodec forcedVideoCodec = session.getSessionProperties().forcedVideoCodec();
VideoCodec forcedVideoCodec = session.getSessionProperties().forcedVideoCodecResolved();
String sdpOffer = sdpString;
// Modify sdp if forced codec is defined
@ -1220,7 +1220,7 @@ public class KurentoSessionManager extends SessionManager {
private String mungeSdpOffer(Session kSession, Participant participant, String sdpOffer, boolean isPublisher) {
boolean isTranscodingAllowed = kSession.getSessionProperties().isTranscodingAllowed();
VideoCodec forcedVideoCodec = kSession.getSessionProperties().forcedVideoCodec();
VideoCodec forcedVideoCodec = kSession.getSessionProperties().forcedVideoCodecResolved();
// Modify sdp if forced codec is defined
if (forcedVideoCodec != VideoCodec.NONE && !participant.isIpcam()) {
return sdpMunging.forceCodec(sdpOffer, participant, isPublisher, true, isTranscodingAllowed,

View File

@ -726,20 +726,31 @@ public class SessionRestController {
if (params != null) {
// Obtain primitive values from the params map
String mediaModeString;
String recordingModeString;
String forcedVideoCodec;
String forcedVideoCodecStr;
Boolean allowTranscoding;
try {
mediaModeString = (String) params.get("mediaMode");
recordingModeString = (String) params.get("recordingMode");
customSessionId = (String) params.get("customSessionId");
forcedVideoCodec = (String) params.get("forcedVideoCodec");
forcedVideoCodecStr = (String) params.get("forcedVideoCodec");
allowTranscoding = (Boolean) params.get("allowTranscoding");
} catch (ClassCastException e) {
throw new Exception("Type error in some parameter: " + e.getMessage());
}
// Parse obtained values into actual types
VideoCodec forcedVideoCodec = null;
try {
forcedVideoCodec = VideoCodec.valueOf(forcedVideoCodecStr);
} catch (NullPointerException e) {
// Not an error: "forcedVideoCodec" was not provided in params.
} catch (IllegalArgumentException e) {
throw new Exception("Invalid value for parameter 'forcedVideoCodec': " + e.getMessage());
}
try {
// Safe parameter retrieval. Default values if not defined
if (recordingModeString != null) {
@ -761,11 +772,25 @@ public class SessionRestController {
}
builder = builder.customSessionId(customSessionId);
}
if (forcedVideoCodec != null) {
builder = builder.forcedVideoCodec(VideoCodec.valueOf(forcedVideoCodec));
} else {
builder = builder.forcedVideoCodec(openviduConfig.getOpenviduForcedCodec());
if (forcedVideoCodec == null) {
forcedVideoCodec = openviduConfig.getOpenviduForcedCodec();
}
builder = builder.forcedVideoCodec(forcedVideoCodec);
if (forcedVideoCodec == VideoCodec.MEDIA_SERVER_PREFERRED) {
switch (openviduConfig.getMediaServer()) {
case mediasoup:
builder = builder.forcedVideoCodecResolved(VideoCodec.NONE);
break;
case kurento:
default:
builder = builder.forcedVideoCodecResolved(VideoCodec.VP8);
break;
}
} else {
builder = builder.forcedVideoCodecResolved(forcedVideoCodec);
}
if (allowTranscoding != null) {
builder = builder.allowTranscoding(allowTranscoding);
} else {

View File

@ -187,7 +187,7 @@ public class SDPMunging {
return mungedSdpOffer;
} else {
throw new OpenViduException(Code.FORCED_CODEC_NOT_FOUND_IN_SDPOFFER,
"Codec not supported by Media Server");
"Codec not supported by Media Server: " + forcedVideoCodec);
}
} catch (OpenViduException e) {

View File

@ -157,7 +157,7 @@
"name": "OPENVIDU_STREAMS_FORCED_VIDEO_CODEC",
"type": "java.lang.String",
"description": "Defines which video codec is being forced to be used in the browser/client",
"defaultValue": "VP8"
"defaultValue": "MEDIA_SERVER_PREFERRED"
},
{
"name": "OPENVIDU_STREAMS_ALLOW_TRANSCODING",

View File

@ -43,7 +43,7 @@ OPENVIDU_STREAMS_VIDEO_MIN_RECV_BANDWIDTH=300
OPENVIDU_STREAMS_VIDEO_MAX_SEND_BANDWIDTH=1000
OPENVIDU_STREAMS_VIDEO_MIN_SEND_BANDWIDTH=300
OPENVIDU_STREAMS_VIDEO_SIMULCAST=true
OPENVIDU_STREAMS_FORCED_VIDEO_CODEC=VP8
OPENVIDU_STREAMS_FORCED_VIDEO_CODEC=MEDIA_SERVER_PREFERRED
OPENVIDU_STREAMS_ALLOW_TRANSCODING=false
OPENVIDU_SESSIONS_GARBAGE_INTERVAL=900

View File

@ -36,7 +36,7 @@ OPENVIDU_STREAMS_VIDEO_MAX_RECV_BANDWIDTH=1000
OPENVIDU_STREAMS_VIDEO_MIN_RECV_BANDWIDTH=300
OPENVIDU_STREAMS_VIDEO_MAX_SEND_BANDWIDTH=1000
OPENVIDU_STREAMS_VIDEO_MIN_SEND_BANDWIDTH=300
OPENVIDU_STREAMS_FORCED_VIDEO_CODEC=VP8
OPENVIDU_STREAMS_FORCED_VIDEO_CODEC=MEDIA_SERVER_PREFERRED
OPENVIDU_STREAMS_ALLOW_TRANSCODING=false
OPENVIDU_SESSIONS_GARBAGE_INTERVAL=900

View File

@ -67,7 +67,7 @@ public class OpenViduTestE2e {
final protected static String MEDIASOUP_IMAGE = "openvidu/mediasoup-controller";
protected static String MEDIA_SERVER_IMAGE = KURENTO_IMAGE + ":6.16.0";
final protected String DEFAULT_JSON_SESSION = "{'id':'STR','object':'session','sessionId':'STR','createdAt':0,'mediaMode':'STR','recordingMode':'STR','defaultRecordingProperties':{'hasVideo':true,'frameRate':25,'hasAudio':true,'shmSize':536870912,'name':'','outputMode':'COMPOSED','resolution':'1280x720','recordingLayout':'BEST_FIT'},'customSessionId':'STR','connections':{'numberOfElements':0,'content':[]},'recording':false,'forcedVideoCodec':'STR','allowTranscoding':false}";
final protected String DEFAULT_JSON_SESSION = "{'id':'STR','object':'session','sessionId':'STR','createdAt':0,'mediaMode':'STR','recordingMode':'STR','defaultRecordingProperties':{'hasVideo':true,'frameRate':25,'hasAudio':true,'shmSize':536870912,'name':'','outputMode':'COMPOSED','resolution':'1280x720','recordingLayout':'BEST_FIT'},'customSessionId':'STR','connections':{'numberOfElements':0,'content':[]},'recording':false,'forcedVideoCodec':'STR','forcedVideoCodecResolved':'STR','allowTranscoding':false}";
final protected String DEFAULT_JSON_PENDING_CONNECTION = "{'id':'STR','object':'connection','type':'WEBRTC','status':'pending','connectionId':'STR','sessionId':'STR','createdAt':0,'activeAt':null,'location':null,'ip':null,'platform':null,'token':'STR','serverData':'STR','record':true,'role':'STR','kurentoOptions':null,'rtspUri':null,'adaptativeBitrate':null,'onlyPlayWithSubscribers':null,'networkCache':null,'clientData':null,'publishers':null,'subscribers':null}";
final protected String DEFAULT_JSON_ACTIVE_CONNECTION = "{'id':'STR','object':'connection','type':'WEBRTC','status':'active','connectionId':'STR','sessionId':'STR','createdAt':0,'activeAt':0,'location':'STR','ip':'STR','platform':'STR','token':'STR','serverData':'STR','record':true,'role':'STR','kurentoOptions':null,'rtspUri':null,'adaptativeBitrate':null,'onlyPlayWithSubscribers':null,'networkCache':null,'clientData':'STR','publishers':[],'subscribers':[]}";
final protected String DEFAULT_JSON_IPCAM_CONNECTION = "{'id':'STR','object':'connection','type':'IPCAM','status':'active','connectionId':'STR','sessionId':'STR','createdAt':0,'activeAt':0,'location':'STR','ip':'STR','platform':'IPCAM','token':null,'serverData':'STR','record':true,'role':null,'kurentoOptions':null,'rtspUri':'STR','adaptativeBitrate':true,'onlyPlayWithSubscribers':true,'networkCache':2000,'clientData':null,'publishers':[],'subscribers':[]}";

View File

@ -3213,7 +3213,7 @@ public class OpenViduTestAppE2eTest extends AbstractOpenViduTestappE2eTest {
+ "'videoDimensions':'STR','filter':{}}}],'subscribers':[{'createdAt':0,'streamId':'STR','publisher':'STR'}]},{'connectionId':'STR','createdAt':0,'location':'STR','ip':'STR',"
+ "'platform':'STR','token':'STR','role':'STR','serverData':'STR','clientData':'STR','publishers':[{'createdAt':0,'streamId':'STR','mediaOptions':{'hasAudio':false,"
+ "'audioActive':false,'hasVideo':false,'videoActive':false,'typeOfVideo':'STR','frameRate':0,'videoDimensions':'STR','filter':{}}}],'subscribers':[{'createdAt':0,'streamId':'STR','publisher':'STR'}]}]},"
+ "'recording':false,'forcedVideoCodec':'STR','allowTranscoding':false}");
+ "'recording':false,'forcedVideoCodec':'STR','forcedVideoCodecResolved':'STR','allowTranscoding':false}");
String streamId = res.get("connections").getAsJsonObject().get("content").getAsJsonArray().get(0)
.getAsJsonObject().get("publishers").getAsJsonArray().get(0).getAsJsonObject().get("streamId")
.getAsString();
@ -4673,6 +4673,20 @@ public class OpenViduTestAppE2eTest extends AbstractOpenViduTestappE2eTest {
// Check browser codecs
VideoCodec codecToCheck = (codec != null) ? codec : defaultForcedVideoCodec;
// Validate the codec to check for special cases:
// * MEDIA_SERVER_PREFERRED means to use the codec that is preferred by the media server.
// * NONE means to use the codec that is preferred by the web browser.
// Because this test is always run only for Kurento and Chrome, we know what to select here.
if (codecToCheck == VideoCodec.MEDIA_SERVER_PREFERRED) {
// Kurento preferred video codec is VP8.
codecToCheck = VideoCodec.VP8;
}
else if (codecToCheck == VideoCodec.NONE) {
// Chrome preferred video codec is VP8.
codecToCheck = VideoCodec.VP8;
}
List<WebElement> statsButtons = user.getDriver().findElements(By.className("stats-button"));
for (WebElement statButton : statsButtons) {
statButton.click();