kurento-module-chroma
Version:
JavaScript Client API for Kurento Media Server
180 lines (145 loc) • 4.35 kB
JavaScript
/* Autogenerated with Kurento Idl */
/*
* (C) Copyright 2013-2015 Kurento (https://kurento.openvidu.io/)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var inherits = require('inherits');
var kurentoClient = require('kurento-client');
var disguise = kurentoClient.disguise;
var checkType = kurentoClient.checkType;
var ChecktypeError = checkType.ChecktypeError;
var Transaction = kurentoClient.TransactionsManager.Transaction;
var Filter = kurentoClient.register.abstracts.Filter;
function noop(error, result) {
if (error) console.trace(error);
return result
};
/**
* Create a {@link ChromaFilter}
*
* @classdesc
* ChromaFilter interface. This type of {@link Filter} makes transparent a
* colour
* range in the top layer, revealing another image behind
*
* @extends module:core/abstracts.Filter
*
* @constructor module:chroma.ChromaFilter
*/
function ChromaFilter(){
ChromaFilter.super_.call(this);
};
inherits(ChromaFilter, Filter);
//
// Public methods
//
/**
* Sets the image to show on the detected chroma surface.
*
* @alias module:chroma.ChromaFilter.setBackground
*
* @param {external:String} uri
* URI where the image is located
*
* @param {module:chroma.ChromaFilter~setBackgroundCallback} [callback]
*
* @return {external:Promise}
*/
ChromaFilter.prototype.setBackground = function(uri, callback){
var transaction = (arguments[0] instanceof Transaction)
? Array.prototype.shift.apply(arguments)
: undefined;
//
// checkType('String', 'uri', uri, {required: true});
//
var params = {
uri: uri
};
callback = (callback || noop).bind(this)
return disguise(this._invoke(transaction, 'setBackground', params, callback), this)
};
/**
* @callback module:chroma.ChromaFilter~setBackgroundCallback
* @param {external:Error} error
*/
/**
* Clears the image used to be shown behind the chroma surface.
*
* @alias module:chroma.ChromaFilter.unsetBackground
*
* @param {module:chroma.ChromaFilter~unsetBackgroundCallback} [callback]
*
* @return {external:Promise}
*/
ChromaFilter.prototype.unsetBackground = function(callback){
var transaction = (arguments[0] instanceof Transaction)
? Array.prototype.shift.apply(arguments)
: undefined;
var usePromise = false;
if (callback == undefined) {
usePromise = true;
}
if(!arguments.length) callback = undefined;
callback = (callback || noop).bind(this)
return disguise(this._invoke(transaction, 'unsetBackground', callback), this)
};
/**
* @callback module:chroma.ChromaFilter~unsetBackgroundCallback
* @param {external:Error} error
*/
/**
* @alias module:chroma.ChromaFilter.constructorParams
*
* @property {external:String} [backgroundImage]
* url of image to be used to replace the detected background
*
* @property {module:core.MediaPipeline} mediaPipeline
* the {@link MediaPipeline} to which the filter belongs
*
* @property {module:chroma/complexTypes.WindowParam} window
* Window of replacement for the {@link ChromaFilter}
*/
ChromaFilter.constructorParams = {
backgroundImage: {
type: 'String' },
mediaPipeline: {
type: 'kurento.MediaPipeline',
required: true
},
window: {
type: 'chroma.WindowParam',
required: true
}
};
/**
* @alias module:chroma.ChromaFilter.events
*
* @extends module:core/abstracts.Filter.events
*/
ChromaFilter.events = Filter.events;
/**
* Checker for {@link module:chroma.ChromaFilter}
*
* @memberof module:chroma
*
* @param {external:String} key
* @param {module:chroma.ChromaFilter} value
*/
function checkChromaFilter(key, value)
{
if(!(value instanceof ChromaFilter))
throw ChecktypeError(key, ChromaFilter, value);
};
module.exports = ChromaFilter;
ChromaFilter.check = checkChromaFilter;