From 65c886930f603cbb8bb734df94ee8552b6ff5068 Mon Sep 17 00:00:00 2001 From: pabloFuente Date: Wed, 1 Aug 2018 15:10:46 +0200 Subject: [PATCH] Minor updates for Kurento filters support --- openvidu-browser/src/OpenVidu/Session.ts | 6 ++++- .../Interfaces/Public/Filter.ts | 2 +- .../io/openvidu/client/OpenViduException.java | 9 ++++--- .../client/internal/ProtocolElements.java | 27 ++++++++++++++++--- .../java/io/openvidu/java/client/Session.java | 2 +- openvidu-node-client/src/Session.ts | 2 +- openvidu-node-client/src/TokenOptions.ts | 2 ++ 7 files changed, 39 insertions(+), 11 deletions(-) diff --git a/openvidu-browser/src/OpenVidu/Session.ts b/openvidu-browser/src/OpenVidu/Session.ts index b6fa1d6e..73080fc3 100644 --- a/openvidu-browser/src/OpenVidu/Session.ts +++ b/openvidu-browser/src/OpenVidu/Session.ts @@ -492,9 +492,13 @@ export class Session implements EventDispatcher { }); } - applyFilter(stream: Stream, type: string, options: string): Promise { + applyFilter(stream: Stream, type: string, options: Object): Promise { return new Promise((resolve, reject) => { console.info('Applying filter to stream ' + stream.streamId); + options = !!options ? options : {}; + if (typeof options !== 'string') { + options = JSON.stringify(options); + } this.openvidu.sendRequest( 'applyFilter', { streamId: stream.streamId, type, options }, diff --git a/openvidu-browser/src/OpenViduInternal/Interfaces/Public/Filter.ts b/openvidu-browser/src/OpenViduInternal/Interfaces/Public/Filter.ts index df1c7be7..81d23171 100644 --- a/openvidu-browser/src/OpenViduInternal/Interfaces/Public/Filter.ts +++ b/openvidu-browser/src/OpenViduInternal/Interfaces/Public/Filter.ts @@ -29,7 +29,7 @@ export interface Filter { /** * Parameters used to initialized the filter. * These correspond to the constructor parameters used in the filter in Kurento Media Server. - * For example: for `filter.type = "GStreamerFilter"` could be `filter.options = "pitch pitch=0.8 tempo=1.0"` + * For example: for `filter.type = "GStreamerFilter"` could be `filter.options = {"command": "pitch pitch=0.8 tempo=1.0"}` */ options?: Object; diff --git a/openvidu-client/src/main/java/io/openvidu/client/OpenViduException.java b/openvidu-client/src/main/java/io/openvidu/client/OpenViduException.java index 5b3fc16e..55d4f0c8 100644 --- a/openvidu-client/src/main/java/io/openvidu/client/OpenViduException.java +++ b/openvidu-client/src/main/java/io/openvidu/client/OpenViduException.java @@ -35,18 +35,19 @@ public class OpenViduException extends JsonRpcErrorException { 202), ROOM_GENERIC_ERROR_CODE(201), USER_NOT_STREAMING_ERROR_CODE(105), EXISTING_USER_IN_ROOM_ERROR_CODE(104), USER_CLOSED_ERROR_CODE( - 103), USER_NOT_FOUND_ERROR_CODE(102), USER_GENERIC_ERROR_CODE(101), + 103), USER_NOT_FOUND_ERROR_CODE(102), USER_GENERIC_ERROR_CODE(10), USER_UNAUTHORIZED_ERROR_CODE(401), ROLE_NOT_FOUND_ERROR_CODE(402), SESSIONID_CANNOT_BE_CREATED_ERROR_CODE( - 403), TOKEN_CANNOT_BE_CREATED_ERROR_CODE(404), + 403), TOKEN_CANNOT_BE_CREATED_ERROR_CODE(404), EXISTING_FILTER_ALREADY_APPLIED_ERROR_CODE(405), + FILTER_NOT_APPLIED_ERROR_CODE(406), USER_METADATA_FORMAT_INVALID_ERROR_CODE(500), SIGNAL_FORMAT_INVALID_ERROR_CODE(600), SIGNAL_TO_INVALID_ERROR_CODE(601), SIGNAL_MESSAGE_INVALID_ERROR_CODE( 602), - RECORDING_PATH_NOT_VALID(708), RECORDING_FILE_EMPTY_ERROR(707), RECORDING_DELETE_ERROR_CODE(706), RECORDING_LIST_ERROR_CODE( - 705), RECORDING_STOP_ERROR_CODE(704), RECORDING_START_ERROR_CODE( + RECORDING_PATH_NOT_VALID(708), RECORDING_FILE_EMPTY_ERROR(707), RECORDING_DELETE_ERROR_CODE( + 706), RECORDING_LIST_ERROR_CODE(705), RECORDING_STOP_ERROR_CODE(704), RECORDING_START_ERROR_CODE( 703), RECORDING_REPORT_ERROR_CODE(702), RECORDING_COMPLETION_ERROR_CODE(701); private int value; diff --git a/openvidu-client/src/main/java/io/openvidu/client/internal/ProtocolElements.java b/openvidu-client/src/main/java/io/openvidu/client/internal/ProtocolElements.java index f2cc5846..194cab39 100644 --- a/openvidu-client/src/main/java/io/openvidu/client/internal/ProtocolElements.java +++ b/openvidu-client/src/main/java/io/openvidu/client/internal/ProtocolElements.java @@ -49,6 +49,7 @@ public class ProtocolElements { public static final String JOINROOM_PEERSTREAMTYPEOFVIDEO_PARAM = "typeOfVideo"; public static final String JOINROOM_PEERSTREAMFRAMERATE_PARAM = "frameRate"; public static final String JOINROOM_PEERSTREAMVIDEODIMENSIONS_PARAM = "videoDimensions"; + public static final String JOINROOM_PEERSTREAMFILTER_PARAM = "filter"; public static final String PUBLISHVIDEO_METHOD = "publishVideo"; public static final String PUBLISHVIDEO_SDPOFFER_PARAM = "sdpOffer"; @@ -62,6 +63,7 @@ public class ProtocolElements { public static final String PUBLISHVIDEO_TYPEOFVIDEO_PARAM = "typeOfVideo"; public static final String PUBLISHVIDEO_FRAMERATE_PARAM = "frameRate"; public static final String PUBLISHVIDEO_VIDEODIMENSIONS_PARAM = "videoDimensions"; + public static final String PUBLISHVIDEO_KURENTOFILTER_PARAM = "filter"; public static final String UNPUBLISHVIDEO_METHOD = "unpublishVideo"; @@ -87,13 +89,31 @@ public class ProtocolElements { public static final String STREAMPROPERTYCHANGED_PROPERTY_PARAM = "property"; public static final String STREAMPROPERTYCHANGED_NEWVALUE_PARAM = "newValue"; public static final String STREAMPROPERTYCHANGED_REASON_PARAM = "reason"; - + public static final String FORCEDISCONNECT_METHOD = "forceDisconnect"; public static final String FORCEDISCONNECT_CONNECTIONID_PARAM = "connectionId"; - + public static final String FORCEUNPUBLISH_METHOD = "forceUnpublish"; public static final String FORCEUNPUBLISH_STREAMID_PARAM = "streamId"; - + + public static final String APPLYFILTER_METHOD = "applyFilter"; + public static final String FILTER_STREAMID_PARAM = "streamId"; + public static final String FILTER_TYPE_PARAM = "type"; + public static final String FILTER_OPTIONS_PARAM = "options"; + public static final String FILTER_METHOD_PARAM = "method"; + public static final String FILTER_PARAMS_PARAM = "params"; + + public static final String EXECFILTERMETHOD_METHOD = "execFilterMethod"; + public static final String EXECFILTERMETHOD_LASTEXECMETHOD_PARAM = "lastExecMethod"; + + public static final String REMOVEFILTER_METHOD = "removeFilter"; + + public static final String FORCEAPPLYFILTER_METHOD = "forceApplyFilter"; + + public static final String FORCEEXECFILTERMETHOD_METHOD = "forceExecFilterMethod"; + + public static final String FORCEREMOVEFILTER_METHOD = "forceRemoveFilter"; + // ---------------------------- SERVER RESPONSES & EVENTS ----------------- public static final String PARTICIPANTJOINED_METHOD = "participantJoined"; @@ -119,6 +139,7 @@ public class ProtocolElements { public static final String PARTICIPANTPUBLISHED_TYPEOFVIDEO_PARAM = "typeOfVideo"; public static final String PARTICIPANTPUBLISHED_FRAMERATE_PARAM = "frameRate"; public static final String PARTICIPANTPUBLISHED_VIDEODIMENSIONS_PARAM = "videoDimensions"; + public static final String PARTICIPANTPUBLISHED_FILTER_PARAM = "filter"; public static final String PARTICIPANTUNPUBLISHED_METHOD = "participantUnpublished"; public static final String PARTICIPANTUNPUBLISHED_NAME_PARAM = "connectionId"; diff --git a/openvidu-java-client/src/main/java/io/openvidu/java/client/Session.java b/openvidu-java-client/src/main/java/io/openvidu/java/client/Session.java index 7e1afc37..59adca5d 100644 --- a/openvidu-java-client/src/main/java/io/openvidu/java/client/Session.java +++ b/openvidu-java-client/src/main/java/io/openvidu/java/client/Session.java @@ -133,7 +133,7 @@ public class Session { } kurentoOptions.put("allowedFilters", allowedFilters); } - json.put("kurentoConfiguration", kurentoOptions); + json.put("kurentoOptions", kurentoOptions); } StringEntity params; try { diff --git a/openvidu-node-client/src/Session.ts b/openvidu-node-client/src/Session.ts index 9936423a..12cd7e01 100644 --- a/openvidu-node-client/src/Session.ts +++ b/openvidu-node-client/src/Session.ts @@ -97,7 +97,7 @@ export class Session { session: this.sessionId, role: (!!tokenOptions && !!tokenOptions.role) ? tokenOptions.role : OpenViduRole.PUBLISHER, data: (!!tokenOptions && !!tokenOptions.data) ? tokenOptions.data : '', - kurentoConfiguration: (!!tokenOptions && !!tokenOptions.kurentoOptions) ? tokenOptions.kurentoOptions : {}, + kurentoOptions: (!!tokenOptions && !!tokenOptions.kurentoOptions) ? tokenOptions.kurentoOptions : {}, }); axios.post( diff --git a/openvidu-node-client/src/TokenOptions.ts b/openvidu-node-client/src/TokenOptions.ts index b4ed6e27..25ed2b14 100644 --- a/openvidu-node-client/src/TokenOptions.ts +++ b/openvidu-node-client/src/TokenOptions.ts @@ -36,6 +36,8 @@ export interface TokenOptions { role?: OpenViduRole; /** + * **WARNING**: experimental option. This interface may change in the near future + * * Some advanced properties setting the configuration that the WebRTC streams of the user owning the token will have in Kurento Media Server. * You can adjust: * - `videoMaxRecvBandwidth`: maximum number of Kbps that the client owning the token will be able to receive from Kurento Media Server. 0 means unconstrained. Giving a value to this property will override