Remove improper usages of SessionProperties.forcedVideoCodecResolved (#737)

forcedVideoCodecResolved is a property that gets automatically assigned
by the server and only used by it; clients don't need to know about its
existence and don't need to use it. Similarly, SessionProperties itself
should not serialize this field.
pull/739/head
Juan Navarro 2022-06-09 15:29:23 +02:00 committed by GitHub
parent a18b15146f
commit ac5700cd95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 12 additions and 30 deletions

View File

@ -665,15 +665,13 @@ public class Session {
// Values that get filled by OpenVidu Server from its global or per-session // Values that get filled by OpenVidu Server from its global or per-session
// configuration // configuration
VideoCodec forcedVideoCodec = VideoCodec.valueOf(responseJson.get("forcedVideoCodec").getAsString()); VideoCodec forcedVideoCodec = VideoCodec.valueOf(responseJson.get("forcedVideoCodec").getAsString());
VideoCodec forcedVideoCodecResolved = VideoCodec
.valueOf(responseJson.get("forcedVideoCodecResolved").getAsString());
Boolean allowTranscoding = responseJson.get("allowTranscoding").getAsBoolean(); Boolean allowTranscoding = responseJson.get("allowTranscoding").getAsBoolean();
SessionProperties responseProperties = new SessionProperties.Builder().mediaMode(properties.mediaMode()) SessionProperties responseProperties = new SessionProperties.Builder().mediaMode(properties.mediaMode())
.recordingMode(properties.recordingMode()) .recordingMode(properties.recordingMode())
.defaultRecordingProperties(properties.defaultRecordingProperties()) .defaultRecordingProperties(properties.defaultRecordingProperties())
.customSessionId(properties.customSessionId()).mediaNode(properties.mediaNode()) .customSessionId(properties.customSessionId()).mediaNode(properties.mediaNode())
.forcedVideoCodec(forcedVideoCodec).forcedVideoCodecResolved(forcedVideoCodecResolved) .forcedVideoCodec(forcedVideoCodec)
.allowTranscoding(allowTranscoding).build(); .allowTranscoding(allowTranscoding).build();
this.properties = responseProperties; this.properties = responseProperties;
@ -727,9 +725,6 @@ public class Session {
if (json.has("forcedVideoCodec")) { if (json.has("forcedVideoCodec")) {
builder.forcedVideoCodec(VideoCodec.valueOf(json.get("forcedVideoCodec").getAsString())); builder.forcedVideoCodec(VideoCodec.valueOf(json.get("forcedVideoCodec").getAsString()));
} }
if (json.has("forcedVideoCodecResolved")) {
builder.forcedVideoCodecResolved(VideoCodec.valueOf(json.get("forcedVideoCodecResolved").getAsString()));
}
if (json.has("allowTranscoding")) { if (json.has("allowTranscoding")) {
builder.allowTranscoding(json.get("allowTranscoding").getAsBoolean()); builder.allowTranscoding(json.get("allowTranscoding").getAsBoolean());
} }

View File

@ -249,6 +249,13 @@ 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 resolved value, for actual usage in the server. * This is the resolved value, for actual usage in the server.
* *
* This is a server-only property, and as such, it doesn't need to be transmitted
* over the wire between server and client. Thus it doesn't get serialized in
* the `toJson()` method.
*
* If more server-only properties start to appear here, maybe a good idea
* would be to refactor them all into a server-specific Properties class.
*
* @hidden * @hidden
*/ */
public VideoCodec forcedVideoCodecResolved() { public VideoCodec forcedVideoCodecResolved() {
@ -277,9 +284,6 @@ public class SessionProperties {
if (this.forcedVideoCodec != null) { if (this.forcedVideoCodec != null) {
json.addProperty("forcedVideoCodec", this.forcedVideoCodec.name()); json.addProperty("forcedVideoCodec", this.forcedVideoCodec.name());
} }
if (this.forcedVideoCodecResolved != null) {
json.addProperty("forcedVideoCodecResolved", this.forcedVideoCodecResolved.name());
}
if (this.allowTranscoding != null) { if (this.allowTranscoding != null) {
json.addProperty("allowTranscoding", this.allowTranscoding); json.addProperty("allowTranscoding", this.allowTranscoding);
} }

View File

@ -491,7 +491,6 @@ export class Session {
this.properties.defaultRecordingProperties = res.data.defaultRecordingProperties; this.properties.defaultRecordingProperties = res.data.defaultRecordingProperties;
this.properties.mediaNode = res.data.mediaNode; this.properties.mediaNode = res.data.mediaNode;
this.properties.forcedVideoCodec = res.data.forcedVideoCodec; this.properties.forcedVideoCodec = res.data.forcedVideoCodec;
this.properties.forcedVideoCodecResolved = res.data.forcedVideoCodecResolved;
this.properties.allowTranscoding = res.data.allowTranscoding; this.properties.allowTranscoding = res.data.allowTranscoding;
this.sanitizeDefaultSessionProperties(this.properties); this.sanitizeDefaultSessionProperties(this.properties);
resolve(this.sessionId); resolve(this.sessionId);
@ -524,7 +523,6 @@ export class Session {
recordingMode: json.recordingMode, recordingMode: json.recordingMode,
defaultRecordingProperties: json.defaultRecordingProperties, defaultRecordingProperties: json.defaultRecordingProperties,
forcedVideoCodec: json.forcedVideoCodec, forcedVideoCodec: json.forcedVideoCodec,
forcedVideoCodecResolved: json.forcedVideoCodecResolved,
allowTranscoding: json.allowTranscoding allowTranscoding: json.allowTranscoding
}; };
this.sanitizeDefaultSessionProperties(this.properties); this.sanitizeDefaultSessionProperties(this.properties);
@ -540,9 +538,6 @@ export class Session {
if (json.forcedVideoCodec == null) { if (json.forcedVideoCodec == null) {
delete this.properties.forcedVideoCodec; delete this.properties.forcedVideoCodec;
} }
if (json.forcedVideoCodecResolved == null) {
delete this.properties.forcedVideoCodecResolved;
}
if (json.allowTranscoding == null) { if (json.allowTranscoding == null) {
delete this.properties.allowTranscoding; delete this.properties.allowTranscoding;
} }
@ -645,7 +640,6 @@ export class Session {
// Remove null values: either set, or undefined // Remove null values: either set, or undefined
props.mediaNode = props.mediaNode ?? undefined; props.mediaNode = props.mediaNode ?? undefined;
props.forcedVideoCodec = props.forcedVideoCodec ?? undefined; props.forcedVideoCodec = props.forcedVideoCodec ?? undefined;
props.forcedVideoCodecResolved = props.forcedVideoCodecResolved ?? undefined;
props.allowTranscoding = props.allowTranscoding ?? undefined; props.allowTranscoding = props.allowTranscoding ?? undefined;
if (!props.defaultRecordingProperties) { if (!props.defaultRecordingProperties) {

View File

@ -82,17 +82,6 @@ export interface SessionProperties {
*/ */
forcedVideoCodec?: VideoCodec; 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 * It defines if you want to allow transcoding in the media server or not
* when [[forcedVideoCodec]] is not compatible with the browser/client. * when [[forcedVideoCodec]] is not compatible with the browser/client.

View File

@ -67,7 +67,7 @@ public class OpenViduTestE2e {
final protected static String MEDIASOUP_IMAGE = "openvidu/mediasoup-controller"; final protected static String MEDIASOUP_IMAGE = "openvidu/mediasoup-controller";
protected static String MEDIA_SERVER_IMAGE = KURENTO_IMAGE + ":6.16.0"; 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','forcedVideoCodecResolved':'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','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, 'customIceServers':[]}"; 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, 'customIceServers':[]}";
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':[], 'customIceServers':[]}"; 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':[], 'customIceServers':[]}";
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':[], 'customIceServers':[]}"; 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':[], 'customIceServers':[]}";

View File

@ -3304,7 +3304,7 @@ public class OpenViduTestAppE2eTest extends AbstractOpenViduTestappE2eTest {
+ "'videoDimensions':'STR','filter':{}}}],'subscribers':[{'createdAt':0,'streamId':'STR','publisher':'STR'}]},{'connectionId':'STR','createdAt':0,'location':'STR','ip':'STR'," + "'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," + "'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'}]}]}," + "'audioActive':false,'hasVideo':false,'videoActive':false,'typeOfVideo':'STR','frameRate':0,'videoDimensions':'STR','filter':{}}}],'subscribers':[{'createdAt':0,'streamId':'STR','publisher':'STR'}]}]},"
+ "'recording':false,'forcedVideoCodec':'STR','forcedVideoCodecResolved':'STR','allowTranscoding':false}"); + "'recording':false,'forcedVideoCodec':'STR','allowTranscoding':false}");
String streamId = res.get("connections").getAsJsonObject().get("content").getAsJsonArray().get(0) String streamId = res.get("connections").getAsJsonObject().get("content").getAsJsonArray().get(0)
.getAsJsonObject().get("publishers").getAsJsonArray().get(0).getAsJsonObject().get("streamId") .getAsJsonObject().get("publishers").getAsJsonArray().get(0).getAsJsonObject().get("streamId")
.getAsString(); .getAsString();
@ -4901,7 +4901,7 @@ public class OpenViduTestAppE2eTest extends AbstractOpenViduTestappE2eTest {
/** /**
* Test to force specified codec and allowTranscoding * Test to force specified codec and allowTranscoding
* *
* @param codec codec to force. If null, default value in openvidu * @param codec codec to force. If null, default value in openvidu
* config will be used. * config will be used.
* @param allowTranscoding If true, allow transcoding. If null, default value in * @param allowTranscoding If true, allow transcoding. If null, default value in
@ -5010,7 +5010,7 @@ public class OpenViduTestAppE2eTest extends AbstractOpenViduTestappE2eTest {
/** /**
* Force codec not allowed by opened browser * Force codec not allowed by opened browser
* *
* @throws Exception * @throws Exception
*/ */
private void forceNotSupportedCodec(OpenViduTestappUser user, VideoCodec codec, boolean allowTranscoding) private void forceNotSupportedCodec(OpenViduTestappUser user, VideoCodec codec, boolean allowTranscoding)