mirror of https://github.com/OpenVidu/openvidu.git
openvidu-browser: Filter interface to class
parent
e72a4a1f68
commit
b44839f95b
|
@ -130,7 +130,7 @@ export class Connection {
|
||||||
typeOfVideo: opts.typeOfVideo,
|
typeOfVideo: opts.typeOfVideo,
|
||||||
frameRate: opts.frameRate,
|
frameRate: opts.frameRate,
|
||||||
videoDimensions: !!opts.videoDimensions ? JSON.parse(opts.videoDimensions) : undefined,
|
videoDimensions: !!opts.videoDimensions ? JSON.parse(opts.videoDimensions) : undefined,
|
||||||
filter: !!opts.filter ? opts.filter : {}
|
filter: !!opts.filter ? opts.filter : undefined
|
||||||
};
|
};
|
||||||
const stream = new Stream(this.session, streamOptions);
|
const stream = new Stream(this.session, streamOptions);
|
||||||
|
|
||||||
|
|
|
@ -16,39 +16,48 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* **WARNING**: experimental option. This interface may change in the near future. See [[Stream.filter]]
|
* **WARNING**: experimental option. This interface may change in the near future
|
||||||
|
*
|
||||||
|
* Video/audio filter applied to a Stream. See [[Stream.applyFilter]]
|
||||||
*/
|
*/
|
||||||
export interface Filter {
|
export class Filter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type of filter applied. This is the name of the remote class identifying the filter to apply in Kurento Media Server.
|
* Type of filter applied. This is the name of the remote class identifying the filter to apply in Kurento Media Server.
|
||||||
* For example: `"FaceOverlayFilter"`, `"GStreamerFilter"`.
|
* For example: `"FaceOverlayFilter"`, `"GStreamerFilter"`.
|
||||||
*
|
*
|
||||||
* You can get this property in `*.kmd.json` files defining the Kurento filters: for GStreamerFilter that's
|
* You can get this property in `*.kmd.json` files defining the Kurento filters. For example, for GStreamerFilter that's
|
||||||
* [here](https://github.com/Kurento/kms-filters/blob/53a452fac71d61795952e3d2202156c6b00f6d65/src/server/interface/filters.GStreamerFilter.kmd.json#L4)
|
* [here](https://github.com/Kurento/kms-filters/blob/53a452fac71d61795952e3d2202156c6b00f6d65/src/server/interface/filters.GStreamerFilter.kmd.json#L4)
|
||||||
*/
|
*/
|
||||||
type?: string;
|
type: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parameters used to initialized the filter.
|
* Parameters used to initialize the filter.
|
||||||
* These correspond to the constructor parameters used in the filter in Kurento Media Server (except for `mediaPipeline` parameter, which is never needed).
|
* These correspond to the constructor parameters used in the filter in Kurento Media Server (except for `mediaPipeline` parameter, which is never needed).
|
||||||
*
|
*
|
||||||
* For example: for `filter.type = "GStreamerFilter"` could be `filter.options = {"command": "videobalance saturation=0.0"}`
|
* For example: for `filter.type = "GStreamerFilter"` could be `filter.options = {"command": "videobalance saturation=0.0"}`
|
||||||
*
|
*
|
||||||
* You can get this property in `*.kmd.json` files defining the Kurento filters: for GStreamerFilter that's
|
* You can get this property in `*.kmd.json` files defining the Kurento filters. For example, for GStreamerFilter that's
|
||||||
* [here](https://github.com/Kurento/kms-filters/blob/53a452fac71d61795952e3d2202156c6b00f6d65/src/server/interface/filters.GStreamerFilter.kmd.json#L13-L31)
|
* [here](https://github.com/Kurento/kms-filters/blob/53a452fac71d61795952e3d2202156c6b00f6d65/src/server/interface/filters.GStreamerFilter.kmd.json#L13-L31)
|
||||||
*/
|
*/
|
||||||
options?: Object;
|
options: Object;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Value passed the last time [[Session.execFilterMethod]] or [[Session.forceExecFilterMethod]] were called
|
* Value passed the last time [[Filter.execMethod]] was called. If `undefined` this method has not been called yet.
|
||||||
* for the Stream owning this filter. If `undefined` those methods have not been called yet.
|
|
||||||
*
|
*
|
||||||
* You can use this value to know the current status of any applied filter
|
* You can use this value to know the current status of any applied filter
|
||||||
*/
|
*/
|
||||||
lastExecMethod?: {
|
lastExecMethod?: {
|
||||||
method: string,
|
method: string, params: Object
|
||||||
params: Object
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @hidden
|
||||||
|
*/
|
||||||
|
constructor(type: string, options: Object) {
|
||||||
|
this.type = type;
|
||||||
|
this.options = options;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -16,6 +16,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Connection } from './Connection';
|
import { Connection } from './Connection';
|
||||||
|
import { Filter } from './Filter';
|
||||||
import { OpenVidu } from './OpenVidu';
|
import { OpenVidu } from './OpenVidu';
|
||||||
import { Publisher } from './Publisher';
|
import { Publisher } from './Publisher';
|
||||||
import { Stream } from './Stream';
|
import { Stream } from './Stream';
|
||||||
|
@ -513,8 +514,8 @@ export class Session implements EventDispatcher {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.info('Filter successfully applied on Stream ' + stream.streamId);
|
console.info('Filter successfully applied on Stream ' + stream.streamId);
|
||||||
const oldValue = JSON.parse(JSON.stringify(stream.filter));
|
const oldValue: Filter = stream.filter;
|
||||||
stream.filter = { type, options };
|
stream.filter = new Filter(type, options);
|
||||||
this.emitEvent('streamPropertyChanged', [new StreamPropertyChangedEvent(this, stream, 'filter', stream.filter, oldValue, 'applyFilter')]);
|
this.emitEvent('streamPropertyChanged', [new StreamPropertyChangedEvent(this, stream, 'filter', stream.filter, oldValue, 'applyFilter')]);
|
||||||
stream.streamManager.emitEvent('streamPropertyChanged', [new StreamPropertyChangedEvent(stream.streamManager, stream, 'filter', stream.filter, oldValue, 'applyFilter')]);
|
stream.streamManager.emitEvent('streamPropertyChanged', [new StreamPropertyChangedEvent(stream.streamManager, stream, 'filter', stream.filter, oldValue, 'applyFilter')]);
|
||||||
resolve();
|
resolve();
|
||||||
|
@ -580,7 +581,7 @@ export class Session implements EventDispatcher {
|
||||||
} else {
|
} else {
|
||||||
console.info('Filter successfully removed from Stream ' + stream.streamId);
|
console.info('Filter successfully removed from Stream ' + stream.streamId);
|
||||||
const oldValue = JSON.parse(JSON.stringify(stream.filter));
|
const oldValue = JSON.parse(JSON.stringify(stream.filter));
|
||||||
stream.filter = new Object();
|
delete stream.filter;
|
||||||
this.emitEvent('streamPropertyChanged', [new StreamPropertyChangedEvent(this, stream, 'filter', stream.filter, oldValue, 'applyFilter')]);
|
this.emitEvent('streamPropertyChanged', [new StreamPropertyChangedEvent(this, stream, 'filter', stream.filter, oldValue, 'applyFilter')]);
|
||||||
stream.streamManager.emitEvent('streamPropertyChanged', [new StreamPropertyChangedEvent(stream.streamManager, stream, 'filter', stream.filter, oldValue, 'applyFilter')]);
|
stream.streamManager.emitEvent('streamPropertyChanged', [new StreamPropertyChangedEvent(stream.streamManager, stream, 'filter', stream.filter, oldValue, 'applyFilter')]);
|
||||||
resolve();
|
resolve();
|
||||||
|
@ -937,6 +938,7 @@ export class Session implements EventDispatcher {
|
||||||
break;
|
break;
|
||||||
case 'filter':
|
case 'filter':
|
||||||
oldValue = stream.filter;
|
oldValue = stream.filter;
|
||||||
|
msg.newValue = (Object.keys(msg.newValue).length > 0) ? msg.newValue : undefined;
|
||||||
stream.filter = msg.newValue;
|
stream.filter = msg.newValue;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
import { Connection } from './Connection';
|
import { Connection } from './Connection';
|
||||||
import { Event } from '../OpenViduInternal/Events/Event';
|
import { Event } from '../OpenViduInternal/Events/Event';
|
||||||
|
import { Filter } from './Filter';
|
||||||
import { Session } from './Session';
|
import { Session } from './Session';
|
||||||
import { StreamManager } from './StreamManager';
|
import { StreamManager } from './StreamManager';
|
||||||
import { EventDispatcher } from '../OpenViduInternal/Interfaces/Public/EventDispatcher';
|
import { EventDispatcher } from '../OpenViduInternal/Interfaces/Public/EventDispatcher';
|
||||||
|
@ -109,13 +110,7 @@ export class Stream implements EventDispatcher {
|
||||||
* [[Session.execFilterMethod]] and remove it with [[Session.removeFilter]]. Be aware that the client calling this methods must have the
|
* [[Session.execFilterMethod]] and remove it with [[Session.removeFilter]]. Be aware that the client calling this methods must have the
|
||||||
* necessary permissions: the token owned by the client must have been initialized with the appropriated `allowedFilters` array.
|
* necessary permissions: the token owned by the client must have been initialized with the appropriated `allowedFilters` array.
|
||||||
*/
|
*/
|
||||||
filter: {
|
filter: Filter;
|
||||||
type?: string,
|
|
||||||
options?: Object,
|
|
||||||
lastExecMethod?: {
|
|
||||||
method: string, params: Object
|
|
||||||
}
|
|
||||||
} = {};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @hidden
|
* @hidden
|
||||||
|
@ -180,7 +175,7 @@ export class Stream implements EventDispatcher {
|
||||||
this.frameRate = (this.inboundStreamOpts.frameRate === -1) ? undefined : this.inboundStreamOpts.frameRate;
|
this.frameRate = (this.inboundStreamOpts.frameRate === -1) ? undefined : this.inboundStreamOpts.frameRate;
|
||||||
this.videoDimensions = this.inboundStreamOpts.videoDimensions;
|
this.videoDimensions = this.inboundStreamOpts.videoDimensions;
|
||||||
}
|
}
|
||||||
if (!!this.inboundStreamOpts.filter) {
|
if (!!this.inboundStreamOpts.filter && (Object.keys(this.inboundStreamOpts.filter).length > 0)) {
|
||||||
if (!!this.inboundStreamOpts.filter.lastExecMethod && Object.keys(this.inboundStreamOpts.filter.lastExecMethod).length === 0) {
|
if (!!this.inboundStreamOpts.filter.lastExecMethod && Object.keys(this.inboundStreamOpts.filter.lastExecMethod).length === 0) {
|
||||||
delete this.inboundStreamOpts.filter.lastExecMethod;
|
delete this.inboundStreamOpts.filter.lastExecMethod;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
import { Event } from './Event';
|
import { Event } from './Event';
|
||||||
import { Stream } from '../../OpenVidu/Stream';
|
import { Stream } from '../../OpenVidu/Stream';
|
||||||
import { Filter } from '../Interfaces/Public/Filter';
|
import { Filter } from '../../OpenVidu/Filter';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Connection } from '../../../OpenVidu/Connection';
|
import { Connection } from '../../../OpenVidu/Connection';
|
||||||
import { Filter } from '../Public/Filter';
|
import { Filter } from '../../../OpenVidu/Filter';
|
||||||
|
|
||||||
export interface InboundStreamOptions {
|
export interface InboundStreamOptions {
|
||||||
id: string;
|
id: string;
|
||||||
|
@ -28,5 +28,5 @@ export interface InboundStreamOptions {
|
||||||
typeOfVideo: string;
|
typeOfVideo: string;
|
||||||
frameRate: number;
|
frameRate: number;
|
||||||
videoDimensions: { width: number, height: number };
|
videoDimensions: { width: number, height: number };
|
||||||
filter: Filter;
|
filter?: Filter;
|
||||||
}
|
}
|
|
@ -15,7 +15,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Filter } from '../Public/Filter';
|
import { Filter } from '../../../OpenVidu/Filter';
|
||||||
|
|
||||||
export interface StreamOptionsServer {
|
export interface StreamOptionsServer {
|
||||||
id: string;
|
id: string;
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Filter } from './Filter';
|
import { Filter } from '../../../OpenVidu/Filter';
|
||||||
import { VideoInsertMode } from '../../Enums/VideoInsertMode';
|
import { VideoInsertMode } from '../../Enums/VideoInsertMode';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -6,6 +6,7 @@ export { StreamManager } from './OpenVidu/StreamManager';
|
||||||
export { Stream } from './OpenVidu/Stream';
|
export { Stream } from './OpenVidu/Stream';
|
||||||
export { Connection } from './OpenVidu/Connection';
|
export { Connection } from './OpenVidu/Connection';
|
||||||
export { LocalRecorder } from './OpenVidu/LocalRecorder';
|
export { LocalRecorder } from './OpenVidu/LocalRecorder';
|
||||||
|
export { Filter } from './OpenVidu/Filter';
|
||||||
|
|
||||||
export { LocalRecorderState } from './OpenViduInternal/Enums/LocalRecorderState';
|
export { LocalRecorderState } from './OpenViduInternal/Enums/LocalRecorderState';
|
||||||
export { OpenViduError } from './OpenViduInternal/Enums/OpenViduError';
|
export { OpenViduError } from './OpenViduInternal/Enums/OpenViduError';
|
||||||
|
@ -26,7 +27,6 @@ export { FilterEvent } from './OpenViduInternal/Events/FilterEvent';
|
||||||
export { Capabilities } from './OpenViduInternal/Interfaces/Public/Capabilities';
|
export { Capabilities } from './OpenViduInternal/Interfaces/Public/Capabilities';
|
||||||
export { Device } from './OpenViduInternal/Interfaces/Public/Device';
|
export { Device } from './OpenViduInternal/Interfaces/Public/Device';
|
||||||
export { EventDispatcher } from './OpenViduInternal/Interfaces/Public/EventDispatcher';
|
export { EventDispatcher } from './OpenViduInternal/Interfaces/Public/EventDispatcher';
|
||||||
export { Filter } from './OpenViduInternal/Interfaces/Public/Filter';
|
|
||||||
export { OpenViduAdvancedConfiguration } from './OpenViduInternal/Interfaces/Public/OpenViduAdvancedConfiguration';
|
export { OpenViduAdvancedConfiguration } from './OpenViduInternal/Interfaces/Public/OpenViduAdvancedConfiguration';
|
||||||
export { PublisherProperties } from './OpenViduInternal/Interfaces/Public/PublisherProperties';
|
export { PublisherProperties } from './OpenViduInternal/Interfaces/Public/PublisherProperties';
|
||||||
export { SignalOptions } from './OpenViduInternal/Interfaces/Public/SignalOptions';
|
export { SignalOptions } from './OpenViduInternal/Interfaces/Public/SignalOptions';
|
||||||
|
|
Loading…
Reference in New Issue