Source: node_modules/kurento-client-core/lib/abstracts/BaseRtpEndpoint.js

/* 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
 *  Handles RTP communications.
 *  <p>
 *    All endpoints that rely on the RTP protocol, like the
 *    <strong>RtpEndpoint</strong> or the <strong>WebRtcEndpoint</strong>, 
 *    inherit
 *    from this class. The endpoint provides information about the connection 
 *    state
 *    and the media state, which can be consulted at any time through the
 *    {@link module:core/abstracts.BaseRtpEndpoint#mediaState} and the {@link 
 *    module:core/abstracts.BaseRtpEndpoint#connectionState} properties. It is
 *    also possible subscribe to events fired when these properties change.
 *  </p>
 *  <ul>
 *    <li>
 *      <strong>ConnectionStateChangedEvent</strong>: 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>
 *      <strong>MediaStateChangedEvent</strong>: This event provides information
 *      about the state of the underlying RTP session.
 *      <p>
 *        The standard definition of RTP (<a
 *          href='https://tools.ietf.org/html/rfc3550'
 *          target='_blank'
 *          >RFC 3550</a
 *        >) describes a session as active whenever there is a maintained flow 
 *        of
 *        RTCP control packets, regardless of whether there is actual media 
 *        flowing
 *        through RTP data packets or not. The reasoning behind this is that, at
 *        given moment, a participant of an RTP session might temporarily stop
 *        sending RTP data packets, but this wouldn't necessarily mean that the 
 *        RTP
 *        session as a whole is finished; it maybe just means that the 
 *        participant
 *        has some temporary issues but it will soon resume sending data. For 
 *        this
 *        reason, that an RTP session has really finished is something that is
 *        considered only by the prolonged absence of RTCP control packets 
 *        between
 *        participants.
 *      </p>
 *      <p>
 *        Since RTCP packets do not flow at a constant rate (for instance,
 *        minimizing a browser window with a WebRTC's
 *        <code>RTCPeerConnection</code> object might affect the sending 
 *        interval),
 *        it is not possible to immediately detect their absence and assume that
 *        RTP session has finished. Instead, there is a guard period of
 *        approximately <strong>5 seconds</strong> of missing RTCP packets 
 *        before
 *        considering that the underlying RTP session is effectively finished, 
 *        thus
 *        triggering a <code>MediaStateChangedEvent = DISCONNECTED</code> event.
 *      </p>
 *      <p>
 *        In other words, there is always a period during which there might be 
 *        no
 *        media flowing, but this event hasn't been fired yet. Nevertheless, 
 *        this is
 *        the most reliable and useful way of knowing what is the long-term, 
 *        steady
 *        state of RTP media exchange.
 *      </p>
 *      <p>
 *        The <code>ConnectionStateChangedEvent</code> comes in contrast with 
 *        more
 *        instantaneous events such as MediaElement's
 *        {@link module:core/abstracts.BaseRtpEndpoint#MediaFlowInStateChange} 
 *        and
 *        {@link module:core/abstracts.BaseRtpEndpoint#MediaFlowOutStateChange},
 *        immediately after the RTP data packets stop flowing between RTP 
 *        session
 *        participants. This makes the <em>MediaFlow</em> events a good way to
 *        know if participants are suffering from short-term intermittent
 *        connectivity issues, but they are not enough to know if the 
 *        connectivity
 *        issues are just spurious network hiccups or are part of a more 
 *        long-term
 *        disconnection problem.
 *      </p>
 *      <p>
 *        Possible values are:
 *      </p>
 *      <ul>
 *        <li>CONNECTED: There is an RTCP packet flow between peers.</li>
 *        <li>
 *          DISCONNECTED: Either no RTCP packets have been received yet, or the
 *          remote peer has ended the RTP session with a <code>BYE</code> 
 *          message,
 *          or at least 5 seconds have elapsed since the last RTCP packet was
 *          received.
 *        </li>
 *      </ul>
 *    </li>
 *  </ul>
 *  <p>
 *    Part of the bandwidth control for the video component of the media session
 *    done here:
 *  </p>
 *  <ul>
 *    <li>
 *      Input bandwidth: Values used to inform remote peers about the bitrate 
 *      that
 *      can be sent to this endpoint.
 *      <ul>
 *        <li>
 *          <strong>MinVideoRecvBandwidth</strong>: Minimum input bitrate, 
 *          requested
 *          from WebRTC senders with REMB (Default: 30 Kbps).
 *        </li>
 *        <li>
 *          <strong>MaxAudioRecvBandwidth</strong> and
 *          <strong>MaxVideoRecvBandwidth</strong>: Maximum input bitrate, 
 *          signaled
 *          in SDP Offers to WebRTC and RTP senders (Default: unlimited).
 *        </li>
 *      </ul>
 *    </li>
 *    <li>
 *      Output bandwidth: Values used to control bitrate of the video streams 
 *      sent
 *      to remote peers. It is important to keep in mind that pushed bitrate 
 *      depends
 *      on network and remote peer capabilities. Remote peers can also announce
 *      bandwidth limitation in their SDPs (through the
 *      <code>b={modifier}:{value}</code> attribute). Kurento will always 
 *      enforce
 *      bitrate limitations specified by the remote peer over internal
 *      configurations.
 *      <ul>
 *        <li>
 *          <strong>MinVideoSendBandwidth</strong>: REMB override of minimum 
 *          bitrate
 *          sent to WebRTC receivers (Default: 100 Kbps).
 *        </li>
 *        <li>
 *          <strong>MaxVideoSendBandwidth</strong>: REMB override of maximum 
 *          bitrate
 *          sent to WebRTC receivers (Default: 500 Kbps).
 *        </li>
 *        <li>
 *          <strong>RembParams.rembOnConnect</strong>: Initial local REMB 
 *          bandwidth
 *          estimation that gets propagated when a new endpoint is connected.
 *        </li>
 *      </ul>
 *    </li>
 *  </ul>
 *  <p>
 *    <strong>
 *      All bandwidth control parameters must be changed before the SDP 
 *      negotiation
 *      takes place, and can't be changed afterwards.
 *    </strong>
 *  </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.
 * <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
 */

/**
 * REMB override of maximum bitrate sent to WebRTC receivers.
 * <p>
 *   With this parameter you can control the maximum video quality that will be
 *   sent when reacting to good network conditions. Setting this parameter to a
 *   high value permits the video quality to raise when the network conditions 
 *   get
 *   better.
 * </p>
 * <p>
 *   This parameter provides a way to limit the bitrate requested by remote REMB
 *   bandwidth estimations: the bitrate sent will be always equal or less than 
 *   this
 *   parameter, even if the remote peer requests higher bitrates.
 * </p>
 * <p>
 *   Note that the default value of <strong>500 kbps</strong> is a VERY
 *   conservative one, and leads to a low maximum video quality. Most 
 *   applications
 *   will probably want to increase this to higher values such as 2000 kbps (2
 *   mbps).
 * </p>
 * <p>
 *   The REMB congestion control algorithm works by gradually increasing the 
 *   output
 *   video bitrate, until the available bandwidth is fully used or the maximum 
 *   send
 *   bitrate has been reached. This is a slow, progressive change, which starts 
 *   at
 *   300 kbps by default. You can change the default starting point of REMB
 *   estimations, by setting <code>RembParams.rembOnConnect</code>.
 * </p>
 * <ul>
 *   <li>Unit: kbps (kilobits per second).</li>
 *   <li>Default: 500.</li>
 *   <li>
 *     0 = unlimited: the video bitrate will grow until all the available 
 *     network
 *     bandwidth is used by the stream.<br />
 *     Note that this might have a bad effect if more than one stream is running
 *     (as all of them would try to raise the video bitrate indefinitely, until 
 *     the
 *     network gets saturated).
 *   </li>
 * </ul>
 *
 * @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
 */

/**
 * REMB override of maximum bitrate sent to WebRTC receivers.
 * <p>
 *   With this parameter you can control the maximum video quality that will be
 *   sent when reacting to good network conditions. Setting this parameter to a
 *   high value permits the video quality to raise when the network conditions 
 *   get
 *   better.
 * </p>
 * <p>
 *   This parameter provides a way to limit the bitrate requested by remote REMB
 *   bandwidth estimations: the bitrate sent will be always equal or less than 
 *   this
 *   parameter, even if the remote peer requests higher bitrates.
 * </p>
 * <p>
 *   Note that the default value of <strong>500 kbps</strong> is a VERY
 *   conservative one, and leads to a low maximum video quality. Most 
 *   applications
 *   will probably want to increase this to higher values such as 2000 kbps (2
 *   mbps).
 * </p>
 * <p>
 *   The REMB congestion control algorithm works by gradually increasing the 
 *   output
 *   video bitrate, until the available bandwidth is fully used or the maximum 
 *   send
 *   bitrate has been reached. This is a slow, progressive change, which starts 
 *   at
 *   300 kbps by default. You can change the default starting point of REMB
 *   estimations, by setting <code>RembParams.rembOnConnect</code>.
 * </p>
 * <ul>
 *   <li>Unit: kbps (kilobits per second).</li>
 *   <li>Default: 500.</li>
 *   <li>
 *     0 = unlimited: the video bitrate will grow until all the available 
 *     network
 *     bandwidth is used by the stream.<br />
 *     Note that this might have a bad effect if more than one stream is running
 *     (as all of them would try to raise the video bitrate indefinitely, until 
 *     the
 *     network gets saturated).
 *   </li>
 * </ul>
 *
 * @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.
 * <ul>
 *   <li>CONNECTED: There is an RTCP flow.</li>
 *   <li>DISCONNECTED: No RTCP packets have been received for at least 5 
 *   sec.</li>
 * </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 input bitrate, requested from WebRTC senders with REMB.
 * <p>
 *   This is used to set a minimum value of local REMB during bandwidth 
 *   estimation,
 *   if supported by the implementing class. The REMB estimation will then be 
 *   sent
 *   to remote peers, requesting them to send at least the indicated video 
 *   bitrate.
 *   It follows that min values will only have effect in remote peers that 
 *   support
 *   this congestion control mechanism, such as Chrome.
 * </p>
 * <ul>
 *   <li>Unit: kbps (kilobits per second).</li>
 *   <li>Default: 0.</li>
 *   <li>
 *     Note: The absolute minimum REMB value is 30 kbps, even if a lower value 
 *     is
 *     set here.
 *   </li>
 * </ul>
 *
 * @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 input bitrate, requested from WebRTC senders with REMB.
 * <p>
 *   This is used to set a minimum value of local REMB during bandwidth 
 *   estimation,
 *   if supported by the implementing class. The REMB estimation will then be 
 *   sent
 *   to remote peers, requesting them to send at least the indicated video 
 *   bitrate.
 *   It follows that min values will only have effect in remote peers that 
 *   support
 *   this congestion control mechanism, such as Chrome.
 * </p>
 * <ul>
 *   <li>Unit: kbps (kilobits per second).</li>
 *   <li>Default: 0.</li>
 *   <li>
 *     Note: The absolute minimum REMB value is 30 kbps, even if a lower value 
 *     is
 *     set here.
 *   </li>
 * </ul>
 *
 * @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
 */

/**
 * REMB override of minimum bitrate sent to WebRTC receivers.
 * <p>
 *   With this parameter you can control the minimum video quality that will be
 *   sent when reacting to bad network conditions. Setting this parameter to a 
 *   low
 *   value permits the video quality to drop when the network conditions get 
 *   worse.
 * </p>
 * <p>
 *   This parameter provides a way to override the bitrate requested by remote 
 *   REMB
 *   bandwidth estimations: the bitrate sent will be always equal or greater 
 *   than
 *   this parameter, even if the remote peer requests even lower bitrates.
 * </p>
 * <p>
 *   Note that if you set this parameter too high (trying to avoid bad video
 *   quality altogether), you would be limiting the adaptation ability of the
 *   congestion control algorithm, and your stream might be unable to ever 
 *   recover
 *   from adverse network conditions.
 * </p>
 * <ul>
 *   <li>Unit: kbps (kilobits per second).</li>
 *   <li>Default: 100.</li>
 *   <li>
 *     0 = unlimited: the video bitrate will drop as needed, even to the lowest
 *     possible quality, which might make the video completely blurry and
 *     pixelated.
 *   </li>
 * </ul>
 *
 * @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
 */

/**
 * REMB override of minimum bitrate sent to WebRTC receivers.
 * <p>
 *   With this parameter you can control the minimum video quality that will be
 *   sent when reacting to bad network conditions. Setting this parameter to a 
 *   low
 *   value permits the video quality to drop when the network conditions get 
 *   worse.
 * </p>
 * <p>
 *   This parameter provides a way to override the bitrate requested by remote 
 *   REMB
 *   bandwidth estimations: the bitrate sent will be always equal or greater 
 *   than
 *   this parameter, even if the remote peer requests even lower bitrates.
 * </p>
 * <p>
 *   Note that if you set this parameter too high (trying to avoid bad video
 *   quality altogether), you would be limiting the adaptation ability of the
 *   congestion control algorithm, and your stream might be unable to ever 
 *   recover
 *   from adverse network conditions.
 * </p>
 * <ul>
 *   <li>Unit: kbps (kilobits per second).</li>
 *   <li>Default: 100.</li>
 *   <li>
 *     0 = unlimited: the video bitrate will drop as needed, even to the lowest
 *     possible quality, which might make the video completely blurry and
 *     pixelated.
 *   </li>
 * </ul>
 *
 * @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
 */

/**
 * Maximum Transmission Unit (MTU) used for RTP.
 * <p>
 *   This setting affects the maximum size that will be used by RTP payloads. 
 *   You
 *   can change it from the default, if you think that a different value would 
 *   be
 *   beneficial for the typical network settings of your application.
 * </p>
 * <p>
 *   The default value is 1200 Bytes. This is the same as in <b>libwebrtc</b> 
 *   (from
 *   webrtc.org), as used by
 *   <a
 *     href='https://dxr.mozilla.org/mozilla-central/rev/b5c5ba07d3dbd0d07b66fa42a103f4df2c27d3a2/media/webrtc/trunk/webrtc/media/engine/constants.cc#16'
 *     >Firefox</a
 *   >
 *   or
 *   <a
 *     href='https://codesearch.chromium.org/chromium/src/third_party/webrtc/media/engine/constants.cc?l=15&rcl=6dd488b2e55125644263e4837f1abd950d5e410d'
 *     >Chrome</a
 *   >
 *   . You can read more about this value in
 *   <a
 *     href='https://groups.google.com/d/topic/discuss-webrtc/gH5ysR3SoZI/discussion'
 *     >Why RTP max packet size is 1200 in WebRTC?</a
 *   >
 *   .
 * </p>
 * <p>
 *   <b>WARNING</b>: Change this value ONLY if you really know what you are 
 *   doing
 *   and you have strong reasons to do so. Do NOT change this parameter just
 *   because it <i>seems</i> to work better for some reduced scope tests. The
 *   default value is a consensus chosen by people who have deep knowledge about
 *   network optimization.
 * </p>
 * <ul>
 *   <li>Unit: Bytes.</li>
 *   <li>Default: 1200.</li>
 * </ul>
 *
 * @alias module:core/abstracts.BaseRtpEndpoint#getMtu
 *
 * @param {module:core/abstracts.BaseRtpEndpoint~getMtuCallback} [callback]
 *
 * @return {external:Promise}
 */
BaseRtpEndpoint.prototype.getMtu = 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, 'getMtu', callback), this)
};
/**
 * @callback module:core/abstracts.BaseRtpEndpoint~getMtuCallback
 * @param {external:Error} error
 * @param {external:Integer} result
 */

/**
 * Maximum Transmission Unit (MTU) used for RTP.
 * <p>
 *   This setting affects the maximum size that will be used by RTP payloads. 
 *   You
 *   can change it from the default, if you think that a different value would 
 *   be
 *   beneficial for the typical network settings of your application.
 * </p>
 * <p>
 *   The default value is 1200 Bytes. This is the same as in <b>libwebrtc</b> 
 *   (from
 *   webrtc.org), as used by
 *   <a
 *     href='https://dxr.mozilla.org/mozilla-central/rev/b5c5ba07d3dbd0d07b66fa42a103f4df2c27d3a2/media/webrtc/trunk/webrtc/media/engine/constants.cc#16'
 *     >Firefox</a
 *   >
 *   or
 *   <a
 *     href='https://codesearch.chromium.org/chromium/src/third_party/webrtc/media/engine/constants.cc?l=15&rcl=6dd488b2e55125644263e4837f1abd950d5e410d'
 *     >Chrome</a
 *   >
 *   . You can read more about this value in
 *   <a
 *     href='https://groups.google.com/d/topic/discuss-webrtc/gH5ysR3SoZI/discussion'
 *     >Why RTP max packet size is 1200 in WebRTC?</a
 *   >
 *   .
 * </p>
 * <p>
 *   <b>WARNING</b>: Change this value ONLY if you really know what you are 
 *   doing
 *   and you have strong reasons to do so. Do NOT change this parameter just
 *   because it <i>seems</i> to work better for some reduced scope tests. The
 *   default value is a consensus chosen by people who have deep knowledge about
 *   network optimization.
 * </p>
 * <ul>
 *   <li>Unit: Bytes.</li>
 *   <li>Default: 1200.</li>
 * </ul>
 *
 * @alias module:core/abstracts.BaseRtpEndpoint#setMtu
 *
 * @param {external:Integer} mtu
 * @param {module:core/abstracts.BaseRtpEndpoint~setMtuCallback} [callback]
 *
 * @return {external:Promise}
 */
BaseRtpEndpoint.prototype.setMtu = function(mtu, callback){
  var transaction = (arguments[0] instanceof Transaction)
                  ? Array.prototype.shift.apply(arguments)
                  : undefined;

  //  
  // checkType('int', 'mtu', mtu, {required: true});
  //  

  var params = {
    mtu: mtu
  };

  callback = (callback || noop).bind(this)

  return disguise(this._invoke(transaction, 'setMtu', params, callback), this)
};
/**
 * @callback module:core/abstracts.BaseRtpEndpoint~setMtuCallback
 * @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;