Source: transportinfo.h


Annotated List
Files
Globals
Hierarchy
Index
// ##########################################################################
// ####                                                                  ####
// ####                      RTP Audio Server Project                    ####
// ####                    ============================                  ####
// ####                                                                  ####
// #### Transport Info                                                   ####
// ####                                                                  ####
// #### Version 1.00  --  February 23, 2001                              ####
// ####                                                                  ####
// #### Copyright (C) 1999  Thomas Dreibholz                             ####
// ####               2000  Universität Bonn, Abt. IV                    ####
// ####               2001  EMail: Dreibholz@bigfoot.com                 ####
// ####                     WWW:   http://www.bigfoot.com/~dreibholz     ####
// ####                                                                  ####
// ##########################################################################


#ifndef TRANSPORTINFO_H
#define TRANSPORTINFO_H


#include "system.h"
#include "range.h"


namespace Coral {


// ##########################################################################
// #### TransportInfoLayer                                               ####
// ##########################################################################


/**
  * This class keeps information on a quality level's layers.
  *
  * @short   TransportInfo Layer
  * @author  Thomas Dreibholz (Dreibholz@bigfoot.com)
  * @version 1.0
  *
  * @see TransportInfo
  */
class TransportInfoLayer
{
   // ====== Constructor ====================================================
   public:
   /**
     * Constructor.
     */
   TransportInfoLayer();

   // ====== Byte order translation =========================================
   /**
     * Translate byte order.
     */
   void translate();

   // ====== Reset ==========================================================
   /**
     * Reset.
     */
   void reset();


   // ====== Comparision operators ==========================================
   /**
     * == operator.
     */
   inline int operator==(const TransportInfoLayer& layer) const;

   /**
     * != operator.
     */
   inline int operator!=(const TransportInfoLayer& layer) const;


   // ====== Layer's values =================================================
   /**
     * Layer's bytes per second at StartFramesPerSecond * FramesPerSecondScale
     * frames per second.
     */
   card64 BytesPerSecond;

   /**
     * Layer's packets per second at StartFramesPerSecond * FramesPerSecondScale
     * frames per second.
     */
   card32 PacketsPerSecond;

   /**
     * Layer's frame size.
     */
   card32 FrameSize;

   /**
     * Layer's maximum acceptable loss rate in fraction of 255.
     */
   card8 MaxLossRate;

   card8 pad;

   /**
     * Layer's flags.
     */
   card16 Flags;

   /**
     * TransportInfoLayer flags enumeration.
     */
   enum TransportInfoFlags {
      TILF_Static  = 0,                    // Static quality settings.
      TILF_Dynamic = (1 << 0)              // Dynamic quality settings.
   };


   // ##### Insert additional QoS/RSVP/... information here! #####
   /* ------------------------------------------------------------
      IMPORTANT: Changes here require Update of translate(),
                 reset() and operator<<() implementation!
                 Do not forget to update Java TransportInfo... and
                 JNI JavaAudioClient.getTransportInfo(), too!!!
      ------------------------------------------------------------
   */
};


/**
  * << operator.
  */
ostream& operator<<(ostream& os, const TransportInfoLayer& ti);


// ##########################################################################
// #### TransportInfoLevel                                               ####
// ##########################################################################



/**
  * This class keeps information on a quality level.
  *
  * @short   TransportInfo Level
  * @author  Thomas Dreibholz (Dreibholz@bigfoot.com)
  * @version 1.0
  *
  * @see TransportInfo
  */
class TransportInfoLevel
{
   // ====== Constructor ====================================================
   public:
   /**
     * Constructor.
     */
   TransportInfoLevel();

   // ====== Byte order translation =========================================
   /**
     * Translate byte order.
     */
   void translate();

   // ====== Reset ==========================================================
   /**
     * Reset.
     */
   void reset();


   // ====== Comparision operators ==========================================
   /**
     * == operator.
     */
   int operator==(const TransportInfoLevel& level) const;

   /**
     * != operator.
     */
   inline int operator!=(const TransportInfoLevel& level) const;


   // ====== Constants ======================================================
   /**
     * Constant for maximum number of quality layers.
     */
   const static cardinal MaxQualityLayers = 4;


   // ====== Level's values =================================================
   /**
     * Level's bytes per second scale factor multiplied with 65536.
     */
   card32 BytesPerSecondScale;

   /**
     * Level's packets per second scale factor multiplied with 65536.
     */
   card32 PacketsPerSecondScale;

   /**
     * Level's frames per second: StartFramesPerSecond * FramesPerSecondScale.
     */
   card32 FramesPerSecond;

   /**
     * Layer's frames per second scale factor multiplied with 65536.
     */
   card32 FramesPerSecondScale;

   /**
     * Level's maximum transfer delay for base data in 1/16 milliseonds.
     */
   card32 MaxTransferDelay;

   /**
     * Level's quality in fraction of 255.
     */
   card8 Quality;

   /**
     * Next higher quality level's number.
     */
   card8 LevelUp;

   /**
     * Next lower quality level's number.
     */
   card8 LevelDown;

   /**
     * Number of layers in the following array.
     */
   card8 QualityLayers;


   // ====== Level's layers =================================================
   /**
     * Array of layer descriptions.
     */
   TransportInfoLayer QualityLayer[MaxQualityLayers];


   // ====== Calculation methods ============================================
   /**
     * Calculate of sum of all layers' BytesPerSecond value.
     *
     * @return Total bytes per second.
     */
   inline card64 getTotalBytesPerSecond() const;

   /**
     * Calculate of sum of all layers' PacketsPerSecond value.
     *
     * @return Total packets per second.
     */
   inline card32 getTotalPacketsPerSecond() const;
};


/**
  * << operator.
  */
ostream& operator<<(ostream& os, const TransportInfoLevel& ti);



// ##########################################################################
// #### TransportInfo                                                    ####
// ##########################################################################



/**
  * This class keeps information on an encoding's transport of data:
  * Quality levels and layers, required bandwidth, etc.
  *
  * @short   Transport Information
  * @author  Thomas Dreibholz (Dreibholz@bigfoot.com)
  * @version 1.0
  *
  * @see EncoderInterface
  * @see DecoderInterface
  */
class TransportInfo
{
   // ====== Constructor ====================================================
   public:
   /**
     * Constructor.
     */
   TransportInfo();

   // ====== Byte order translation =========================================
   /**
     * Translate byte order.
     */
   void translate();

   // ====== Reset ==========================================================
   /**
     * Reset.
     */
   void reset();


   // ====== Comparision operators ==========================================
   /**
     * == operator.
     */
   int operator==(const TransportInfo& ti) const;

   /**
     * != operator.
     */
   inline int operator!=(const TransportInfo& ti) const;


   // ====== Constants ======================================================
   /**
     * Constant for maximum number of quality levels.
     */
   const static cardinal MaxQualityLevels = 24;


   // ====== Wanted values ==================================================
   /**
     * Bytes per second: Minimum, maximum and current quality setting's value
     * for each layer.
     */
   Range<card64> WantedBytesPerSecond[TransportInfoLevel::MaxQualityLayers];

   /**
     * Packets per second: Minimum, maximum and current quality setting's value
     * for each layer.
     */
   Range<card32> WantedPacketsPerSecond[TransportInfoLevel::MaxQualityLayers];

   /**
     * Frames per second: Minimum, maximum and current quality setting's value.
     */
   Range<card32> WantedFramesPerSecond;

   /**
     * Wanted maximum transfer delay in 1/16 milliseconds for base data.
     */
   card32 WantedMaxTransferDelay;

   /**
     * Wanted maximum loss rate in fraction of 255 for each layer.
     */
   card8 WantedMaxLossRate[TransportInfoLevel::MaxQualityLayers];


   // ====== Global limits ==================================================
   /**
     * Total bytes per second limit.
     */
   card64 TotalBytesPerSecondLimit;


   /**
     * Total packets per second limit.
     */
   card32 TotalPacketsPerSecondLimit;


   /**
     * Total frames per second limit.
     */
   card32 TotalFramesPerSecondLimit;


   // ====== Flags and number of quality levels =============================
   /**
     * TransportInfo flags.
     * This is a constant set by the encoding.
     */
   card16 Flags;

   /**
     * TransportInfo flags enumeration.
     */
   enum TransportInfoFlags {
      TIF_None       = 0,
      TIF_HasDynamic = (1 << 0)
   };


   // ====== Quality levels =================================================
   /**
     * Number of quality levels stored in QualityLevel array.
     * This is a constant set by the encoding.
     */
   card8 QualityLevels;

   /**
     * Maximum number of quality layers within in a level. It is used to limit
     * the range of valid Wanted values.
     * This is a constant set by the encoding.
     */
   card8 QualityLayers;

   /**
     * Start frames per second.
     * This is a constant set by the encoding.
     */
   card32 StartFramesPerSecond;

   /**
     * Quality level transport information array.
     * All values are *constants* of the encoding.
     */
   TransportInfoLevel QualityLevel[MaxQualityLevels];


   // ====== Current quality setting ========================================
   /**
     * Current setting's transport information.
     * The encoding will store current setting here.
     */
   TransportInfoLevel CurrentSetting;


   // ====== Calculation methods ============================================
   /**
     * Calculate of sum of all layers' WantedBytesPerSecond[].getValue() value.
     *
     * @return Total wanted bytes per second.
     */
   inline card64 getTotalWantedBytesPerSecond() const;

   /**
     * Calculate of sum of all layers' WantedBytesPerSecond[].getMin() value.
     *
     * @return Total minimum wanted bytes per second.
     */
   inline card64 getTotalMinWantedBytesPerSecond() const;

   /**
     * Calculate of sum of all layers' WantedBytesPerSecond[].getMax() value.
     *
     * @return Total maximum wanted bytes per second.
     */
   inline card64 getTotalMaxWantedBytesPerSecond() const;


   /**
     * Calculate of sum of all layers' WantedPacketsPerSecond[].getValue() value.
     *
     * @return Total wanted packets per second.
     */
   inline card32 getTotalWantedPacketsPerSecond() const;

   /**
     * Calculate of sum of all layers' WantedPacketsPerSecond[].getMin() value.
     *
     * @return Total minimum wanted packets per second.
     */
   inline card32 getTotalMinWantedPacketsPerSecond() const;

   /**
     * Calculate of sum of all layers' WantedPacketsPerSecond[].getMax() value.
     *
     * @return Total maximum wanted packets per second.
     */
   inline card32 getTotalMaxWantedPacketsPerSecond() const;
};


/**
  * << operator.
  */
ostream& operator<<(ostream& os, const TransportInfo& ti);


}


#include "transportinfo.icc"


#endif

Generated by: viper@odin on Fri Feb 23 12:41:26 2001, using kdoc 2.0a36.