/* Autogenerated with Kurento Idl */
/*
* (C) Copyright 2013-2015 Kurento (http://kurento.org/)
*
* 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 SdpEndpoint = require('./SdpEndpoint');
function noop(error, result) {
if (error) console.trace(error);
return result
};
/**
* @classdesc
* This class extends from the SdpEndpoint, and handles RTP communications. All
* <ul style='list-style-type:circle'>
* <li>
* ConnectionStateChangedEvent: This event is raised when the
* connection between two peers changes. It can have two values
* <ul>
* <li>CONNECTED</li>
* <li>DISCONNECTED</li>
* </ul>
* </li>
* <li>
* MediaStateChangedEvent: Based on RTCP packet flow, this event
* provides more reliable information about the state of media flow.
* Since RTCP packets are not flowing at a constant rate (minimizing
* a browser with an RTCPeerConnection might affect this interval,
* for instance), there is a guard period of about 5s. This traduces
* in a period where there might be no media flowing, but the event
* hasn't been fired yet. Nevertheless, this is the most reliable and
* <ul>
* <li>CONNECTED: There is an RTCP packet flow between peers.</li>
* <li>DISCONNECTED: No RTCP packets have been received, or at
* least 5s have passed since the last packet arrived.</li>
* </ul>
* </li>
* </ul>
* Part of the bandwidth control of the video component of the media
* session is done here. The values of the properties described are in
* kbps.
* <ul style='list-style-type:circle'>
* <li>
* Input bandwidth control mechanism: Configuration interval used to
* inform remote peer the range of bitrates that can be pushed into
* this BaseRtpEndpoint object.
* <ul>
* <li>
* setMinVideoRecvBandwidth: sets min bitrate limits expected for
* </li>
* </ul>
* Max values are announced in the SDP, while min values are set to
* limit the lower value of REMB packages. It follows that min values
* </li>
* <li>
* Output bandwidth control mechanism: Configuration interval used to
* <ul>
* <li>
* setMinVideoSendBandwidth: sets the minimum bitrate for video
* to be sent to remote peer. 0 is considered unconstrained.
* </li>
* <li>
* setMaxVideoSendBandwidth: sets maximum bitrate limits for
* video sent to remote peer. 0 is considered unconstrained.
* </li>
* </ul>
* </li>
* </ul>
* All bandwidth control parameters must be changed before the SDP
* negotiation takes place, and can't be changed afterwards.
* </p>
*
* @abstract
* @extends module:core/abstracts.SdpEndpoint
*
* @constructor module:core/abstracts.BaseRtpEndpoint
*
* @fires {@link module:core#event:ConnectionStateChanged ConnectionStateChanged}
* @fires {@link module:core#event:MediaStateChanged MediaStateChanged}
*/
function BaseRtpEndpoint(){
BaseRtpEndpoint.super_.call(this);
};
inherits(BaseRtpEndpoint, SdpEndpoint);
//
// Public properties
//
/**
* Connection state. Possible values are
* <ul>
* <li>CONNECTED</li>
* <li>DISCONNECTED</li>
* </ul>
*
* @alias module:core/abstracts.BaseRtpEndpoint#getConnectionState
*
* @param {module:core/abstracts.BaseRtpEndpoint~getConnectionStateCallback} [callback]
*
* @return {external:Promise}
*/
BaseRtpEndpoint.prototype.getConnectionState = 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, 'getConnectionState', callback), this)
};
/**
* @callback module:core/abstracts.BaseRtpEndpoint~getConnectionStateCallback
* @param {external:Error} error
* @param {module:core/complexTypes.ConnectionState} result
*/
/**
* Maximum bandwidth for video transmission, in kbps. The default value is 500
* kbps. 0 is considered unconstrained.
*
* @alias module:core/abstracts.BaseRtpEndpoint#getMaxVideoSendBandwidth
*
* @param {module:core/abstracts.BaseRtpEndpoint~getMaxVideoSendBandwidthCallback} [callback]
*
* @return {external:Promise}
*/
BaseRtpEndpoint.prototype.getMaxVideoSendBandwidth = 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, 'getMaxVideoSendBandwidth', callback), this)
};
/**
* @callback module:core/abstracts.BaseRtpEndpoint~getMaxVideoSendBandwidthCallback
* @param {external:Error} error
* @param {external:Integer} result
*/
/**
* Maximum bandwidth for video transmission, in kbps. The default value is 500
* kbps. 0 is considered unconstrained.
*
* @alias module:core/abstracts.BaseRtpEndpoint#setMaxVideoSendBandwidth
*
* @param {external:Integer} maxVideoSendBandwidth
* @param {module:core/abstracts.BaseRtpEndpoint~setMaxVideoSendBandwidthCallback} [callback]
*
* @return {external:Promise}
*/
BaseRtpEndpoint.prototype.setMaxVideoSendBandwidth = function(maxVideoSendBandwidth, callback){
var transaction = (arguments[0] instanceof Transaction)
? Array.prototype.shift.apply(arguments)
: undefined;
//
// checkType('int', 'maxVideoSendBandwidth', maxVideoSendBandwidth, {required: true});
//
var params = {
maxVideoSendBandwidth: maxVideoSendBandwidth
};
callback = (callback || noop).bind(this)
return disguise(this._invoke(transaction, 'setMaxVideoSendBandwidth', params, callback), this)
};
/**
* @callback module:core/abstracts.BaseRtpEndpoint~setMaxVideoSendBandwidthCallback
* @param {external:Error} error
*/
/**
* Media flow state. Possible values are
* <ul>
* <li>CONNECTED: There is an RTCP flow.</li>
* <li>DISCONNECTED: No RTCP packets have been received for at least
* </ul>
*
* @alias module:core/abstracts.BaseRtpEndpoint#getMediaState
*
* @param {module:core/abstracts.BaseRtpEndpoint~getMediaStateCallback} [callback]
*
* @return {external:Promise}
*/
BaseRtpEndpoint.prototype.getMediaState = 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, 'getMediaState', callback), this)
};
/**
* @callback module:core/abstracts.BaseRtpEndpoint~getMediaStateCallback
* @param {external:Error} error
* @param {module:core/complexTypes.MediaState} result
*/
/**
* Minimum bandwidth announced for video reception, in kbps. The default and
* absolute minimum value is 30 kbps, even if a lower value is set.
*
* @alias module:core/abstracts.BaseRtpEndpoint#getMinVideoRecvBandwidth
*
* @param {module:core/abstracts.BaseRtpEndpoint~getMinVideoRecvBandwidthCallback} [callback]
*
* @return {external:Promise}
*/
BaseRtpEndpoint.prototype.getMinVideoRecvBandwidth = 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, 'getMinVideoRecvBandwidth', callback), this)
};
/**
* @callback module:core/abstracts.BaseRtpEndpoint~getMinVideoRecvBandwidthCallback
* @param {external:Error} error
* @param {external:Integer} result
*/
/**
* Minimum bandwidth announced for video reception, in kbps. The default and
* absolute minimum value is 30 kbps, even if a lower value is set.
*
* @alias module:core/abstracts.BaseRtpEndpoint#setMinVideoRecvBandwidth
*
* @param {external:Integer} minVideoRecvBandwidth
* @param {module:core/abstracts.BaseRtpEndpoint~setMinVideoRecvBandwidthCallback} [callback]
*
* @return {external:Promise}
*/
BaseRtpEndpoint.prototype.setMinVideoRecvBandwidth = function(minVideoRecvBandwidth, callback){
var transaction = (arguments[0] instanceof Transaction)
? Array.prototype.shift.apply(arguments)
: undefined;
//
// checkType('int', 'minVideoRecvBandwidth', minVideoRecvBandwidth, {required: true});
//
var params = {
minVideoRecvBandwidth: minVideoRecvBandwidth
};
callback = (callback || noop).bind(this)
return disguise(this._invoke(transaction, 'setMinVideoRecvBandwidth', params, callback), this)
};
/**
* @callback module:core/abstracts.BaseRtpEndpoint~setMinVideoRecvBandwidthCallback
* @param {external:Error} error
*/
/**
* Minimum bandwidth for video transmission, in kbps. The default value is 100
* kbps. 0 is considered unconstrained.
*
* @alias module:core/abstracts.BaseRtpEndpoint#getMinVideoSendBandwidth
*
* @param {module:core/abstracts.BaseRtpEndpoint~getMinVideoSendBandwidthCallback} [callback]
*
* @return {external:Promise}
*/
BaseRtpEndpoint.prototype.getMinVideoSendBandwidth = 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, 'getMinVideoSendBandwidth', callback), this)
};
/**
* @callback module:core/abstracts.BaseRtpEndpoint~getMinVideoSendBandwidthCallback
* @param {external:Error} error
* @param {external:Integer} result
*/
/**
* Minimum bandwidth for video transmission, in kbps. The default value is 100
* kbps. 0 is considered unconstrained.
*
* @alias module:core/abstracts.BaseRtpEndpoint#setMinVideoSendBandwidth
*
* @param {external:Integer} minVideoSendBandwidth
* @param {module:core/abstracts.BaseRtpEndpoint~setMinVideoSendBandwidthCallback} [callback]
*
* @return {external:Promise}
*/
BaseRtpEndpoint.prototype.setMinVideoSendBandwidth = function(minVideoSendBandwidth, callback){
var transaction = (arguments[0] instanceof Transaction)
? Array.prototype.shift.apply(arguments)
: undefined;
//
// checkType('int', 'minVideoSendBandwidth', minVideoSendBandwidth, {required: true});
//
var params = {
minVideoSendBandwidth: minVideoSendBandwidth
};
callback = (callback || noop).bind(this)
return disguise(this._invoke(transaction, 'setMinVideoSendBandwidth', params, callback), this)
};
/**
* @callback module:core/abstracts.BaseRtpEndpoint~setMinVideoSendBandwidthCallback
* @param {external:Error} error
*/
/**
* Advanced parameters to configure the congestion control algorithm.
*
* @alias module:core/abstracts.BaseRtpEndpoint#getRembParams
*
* @param {module:core/abstracts.BaseRtpEndpoint~getRembParamsCallback} [callback]
*
* @return {external:Promise}
*/
BaseRtpEndpoint.prototype.getRembParams = 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, 'getRembParams', callback), this)
};
/**
* @callback module:core/abstracts.BaseRtpEndpoint~getRembParamsCallback
* @param {external:Error} error
* @param {module:core/complexTypes.RembParams} result
*/
/**
* Advanced parameters to configure the congestion control algorithm.
*
* @alias module:core/abstracts.BaseRtpEndpoint#setRembParams
*
* @param {module:core/complexTypes.RembParams} rembParams
* @param {module:core/abstracts.BaseRtpEndpoint~setRembParamsCallback} [callback]
*
* @return {external:Promise}
*/
BaseRtpEndpoint.prototype.setRembParams = function(rembParams, callback){
var transaction = (arguments[0] instanceof Transaction)
? Array.prototype.shift.apply(arguments)
: undefined;
//
// checkType('RembParams', 'rembParams', rembParams, {required: true});
//
var params = {
rembParams: rembParams
};
callback = (callback || noop).bind(this)
return disguise(this._invoke(transaction, 'setRembParams', params, callback), this)
};
/**
* @callback module:core/abstracts.BaseRtpEndpoint~setRembParamsCallback
* @param {external:Error} error
*/
/**
* @alias module:core/abstracts.BaseRtpEndpoint.constructorParams
*/
BaseRtpEndpoint.constructorParams = {
};
/**
* @alias module:core/abstracts.BaseRtpEndpoint.events
*
* @extends module:core/abstracts.SdpEndpoint.events
*/
BaseRtpEndpoint.events = SdpEndpoint.events.concat(['ConnectionStateChanged', 'MediaStateChanged']);
/**
* Checker for {@link module:core/abstracts.BaseRtpEndpoint}
*
* @memberof module:core/abstracts
*
* @param {external:String} key
* @param {module:core/abstracts.BaseRtpEndpoint} value
*/
function checkBaseRtpEndpoint(key, value)
{
if(!(value instanceof BaseRtpEndpoint))
throw ChecktypeError(key, BaseRtpEndpoint, value);
};
module.exports = BaseRtpEndpoint;
BaseRtpEndpoint.check = checkBaseRtpEndpoint;