UNPKG

kurento-client-core

Version:

JavaScript Client API for Kurento Media Server

418 lines (341 loc) 11 kB
/* 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 MediaObject = require('./MediaObject'); function noop(error, result) { if (error) console.trace(error); return result }; /** * @classdesc * This is a standalone object for managing the MediaServer * * @abstract * @extends module:core/abstracts.MediaObject * * @constructor module:core/abstracts.ServerManager * * @fires {@link module:core#event:ObjectCreated ObjectCreated} * @fires {@link module:core#event:ObjectDestroyed ObjectDestroyed} */ function ServerManager(){ ServerManager.super_.call(this); }; inherits(ServerManager, MediaObject); // // Public properties // /** * Server information, version, modules, factories, etc * * @alias module:core/abstracts.ServerManager#getInfo * * @param {module:core/abstracts.ServerManager~getInfoCallback} [callback] * * @return {external:Promise} */ ServerManager.prototype.getInfo = 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, 'getInfo', callback), this) }; /** * @callback module:core/abstracts.ServerManager~getInfoCallback * @param {external:Error} error * @param {module:core/complexTypes.ServerInfo} result */ /** * Metadata stored in the server * * @alias module:core/abstracts.ServerManager#getMetadata * * @param {module:core/abstracts.ServerManager~getMetadataCallback} [callback] * * @return {external:Promise} */ ServerManager.prototype.getMetadata = 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, 'getMetadata', callback), this) }; /** * @callback module:core/abstracts.ServerManager~getMetadataCallback * @param {external:Error} error * @param {external:String} result */ /** * All the pipelines available in the server * * @alias module:core/abstracts.ServerManager#getPipelines * * @param {module:core/abstracts.ServerManager~getPipelinesCallback} [callback] * * @return {external:Promise} */ ServerManager.prototype.getPipelines = 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) if (usePromise) { var self = this; var promise = new Promise(function(resolve, reject) { function callback2(error, values) { resolve(values) } self._invoke(transaction, 'getPipelines', function(error, result) { if (error) return callback(error); self.emit('_describe', result, callback2); }) }); return promise; } else { return disguise(this._invoke(transaction, 'getPipelines', function(error, result) { if (error) return callback(error); this.emit('_describe', result, callback); }), this) } }; /** * @callback module:core/abstracts.ServerManager~getPipelinesCallback * @param {external:Error} error * @param {module:core.MediaPipeline} result */ /** * All active sessions in the server * * @alias module:core/abstracts.ServerManager#getSessions * * @param {module:core/abstracts.ServerManager~getSessionsCallback} [callback] * * @return {external:Promise} */ ServerManager.prototype.getSessions = 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, 'getSessions', callback), this) }; /** * @callback module:core/abstracts.ServerManager~getSessionsCallback * @param {external:Error} error * @param {external:String} result */ // // Public methods // /** * Number of CPU cores that the media server can use. * <p> * Linux processes can be configured to use only a subset of the cores that * are * available in the system, via the process affinity settings * (<strong>sched_setaffinity(2)</strong>). With this method it is possible to * know the number of cores that the media server can use in the machine where * is running. * </p> * <p> * For example, it's possible to limit the core affinity inside a Docker * container by running with a command such as * <em>docker run --cpuset-cpus='0,1'</em>. * </p> * <p> * Note that the return value represents the number of * <em>logical</em> processing units available, i.e. CPU cores including * Hyper-Threading. * </p> * * @alias module:core/abstracts.ServerManager.getCpuCount * * @param {module:core/abstracts.ServerManager~getCpuCountCallback} [callback] * * @return {external:Promise} */ ServerManager.prototype.getCpuCount = 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, 'getCpuCount', callback), this) }; /** * @callback module:core/abstracts.ServerManager~getCpuCountCallback * @param {external:Error} error * @param {external:Integer} result * Number of CPU cores available for the media server. */ /** * Returns the kmd associated to a module * * @alias module:core/abstracts.ServerManager.getKmd * * @param {external:String} moduleName * Name of the module to get its kmd file * * @param {module:core/abstracts.ServerManager~getKmdCallback} [callback] * * @return {external:Promise} */ ServerManager.prototype.getKmd = function(moduleName, callback){ var transaction = (arguments[0] instanceof Transaction) ? Array.prototype.shift.apply(arguments) : undefined; // // checkType('String', 'moduleName', moduleName, {required: true}); // var params = { moduleName: moduleName }; callback = (callback || noop).bind(this) return disguise(this._invoke(transaction, 'getKmd', params, callback), this) }; /** * @callback module:core/abstracts.ServerManager~getKmdCallback * @param {external:Error} error * @param {external:String} result * The kmd file. */ /** * Average CPU usage of the server. * <p> * This method measures the average CPU usage of the media server during the * requested interval. Normally you will want to choose an interval between * 1000 * and 10000 ms. * </p> * <p> * The returned value represents the global system CPU usage of the media * server, * as an average across all processing units (CPU cores). * </p> * * @alias module:core/abstracts.ServerManager.getUsedCpu * * @param {external:Integer} interval * Time to measure the average CPU usage, in milliseconds. * * @param {module:core/abstracts.ServerManager~getUsedCpuCallback} [callback] * * @return {external:Promise} */ ServerManager.prototype.getUsedCpu = function(interval, callback){ var transaction = (arguments[0] instanceof Transaction) ? Array.prototype.shift.apply(arguments) : undefined; // // checkType('int', 'interval', interval, {required: true}); // var params = { interval: interval }; callback = (callback || noop).bind(this) return disguise(this._invoke(transaction, 'getUsedCpu', params, callback), this) }; /** * @callback module:core/abstracts.ServerManager~getUsedCpuCallback * @param {external:Error} error * @param {external:Number} result * CPU usage %. */ /** * Returns the amount of memory that the server is using, in KiB * * @alias module:core/abstracts.ServerManager.getUsedMemory * * @param {module:core/abstracts.ServerManager~getUsedMemoryCallback} [callback] * * @return {external:Promise} */ ServerManager.prototype.getUsedMemory = 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, 'getUsedMemory', callback), this) }; /** * @callback module:core/abstracts.ServerManager~getUsedMemoryCallback * @param {external:Error} error * @param {external:int64} result * Used memory, in KiB. */ /** * @alias module:core/abstracts.ServerManager.constructorParams */ ServerManager.constructorParams = { }; /** * @alias module:core/abstracts.ServerManager.events * * @extends module:core/abstracts.MediaObject.events */ ServerManager.events = MediaObject.events.concat(['ObjectCreated', 'ObjectDestroyed']); /** * Checker for {@link module:core/abstracts.ServerManager} * * @memberof module:core/abstracts * * @param {external:String} key * @param {module:core/abstracts.ServerManager} value */ function checkServerManager(key, value) { if(!(value instanceof ServerManager)) throw ChecktypeError(key, ServerManager, value); }; module.exports = ServerManager; ServerManager.check = checkServerManager;