Source: rtpreceiver.h


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


#ifndef RTPRECEIVER_H
#define RTPRECEIVER_H


#include "system.h"
#include "thread.h"
#include "socket.h"
#include "rtppacket.h"
#include "decoderinterface.h"
#include "sourcestateinfo.h"
#include "internetflow.h"
#ifdef USE_TRANSPORTINFO
#include "transportinfo.h"
#endif


namespace Coral {


/**
  * This class implements an RTP receiver based on Thread.
  *
  * @short   RTP Receiver
  * @author  Thomas Dreibholz (Dreibholz@bigfoot.com)
  * @version 1.0
  */
class RTPReceiver : public Thread
{
   // ====== Constructor/Destructor =========================================
   public:
   /**
     * Default constructor.
     * You have to initialize RTPReceiver by calling init(...) later!
     *
     * @see init
     */
   RTPReceiver();

   /**
     * Constructor for new RTPSender. The new sender's thread has to be started
     * by calling start()!
     *
     * @param decoder Decoder to handle packets received.
     * @param receiverSocket Socket to receive data from.
     *
     * @see Thread#start
     */
   RTPReceiver(DecoderInterface* decoder,
               Socket*           receiverSocket);

   /**
     * Destructor.
     */
   ~RTPReceiver();


   // ====== Initialize =====================================================
   /**
     * Initialize RTPSender. The new receiver's thread has to be started
     * by calling start()!
     *
     * @param decoder Decoder to handle packets received.
     * @param receiverSocket Socket to receive data from.
     *
     * @see Thread#start
     */
   void init(DecoderInterface* decoder,
             Socket*           receiverSocket);


   // ====== Status functions ===============================================
#ifdef USE_TRANSPORTINFO
   /**
     * Get TransportInfo for current setting.
     * The access is synchronized with the receiver thread.
     *
     * @param calculateLevels true to calculate all level constants; false otherwise.
     * @param transportInfo Pointer to TransportInfo.
     */
   inline void getTransportInfo(TransportInfo& transportInfo,
                                const bool     calculateLevels) const;
#endif

   /**
     * Get position of the encoder.
     * The access is synchronized with the receiver thread.
     *
     * @return Position in nanoseconds.
     */
   inline card64 getPosition() const;

   /**
     * Get maximum position of the encoder.
     * The access is synchronized with the receiver thread.
     *
     * @return Maximum position in nanoseconds.
     */
   inline card64 getMaxPosition() const;

   /**
     * Get number of bytes received.
     *
     * @param layer Layer number or (cardinal)-1 to get sum of all layers.
     * @return Bytes received.
     */
   inline card64 getBytesReceived(const cardinal layer) const;
      
   /**
     * Get number of packets received.
     *
     * @param layer Layer number or (cardinal)-1 to get sum of all layers.
     * @return Packets received.
     */
   inline card64 getPacketsReceived(const cardinal layer) const;

   /**
     * Reset number of bytes received.
     *
     * @param layer Layer number.
     */
   inline void resetBytesReceived(const cardinal layer);
   
   /**
     * Reset number of packets received.
     *
     * @param layer Layer number.
     */
   inline void resetPacketsReceived(const cardinal layer);

   /**
     * Get number of layers of last transmission.
     *
     * @return Number of layers.
     */
   inline cardinal getLayers() const;
   
   /**
     * Get InternetFlow  of last transmission in a given layer.
     *
     * @param layer Layer number.
     * @return InternetFlow.
     */
   inline InternetFlow getInternetFlow(const cardinal layer = 0) const;

   /**
     * Get SourceStateInfo for given layer.
     */
   inline SourceStateInfo getSSI(const cardinal layer = 0) const;


   /**
     * RTCPSender is a friend class to enable efficient update of
     * SSI data.
     */
   friend class RTCPSender;


   // ====== Protected data =================================================
   protected:
   cardinal        Layers;
   InternetFlow    Flow[RTPConstants::RTPMaxQualityLayers];
   SourceStateInfo SSI[RTPConstants::RTPMaxQualityLayers];
   card64          BytesReceived[RTPConstants::RTPMaxQualityLayers];
   card64          PacketsReceived[RTPConstants::RTPMaxQualityLayers];


   // ====== Private data ===================================================
   private:
   void run();


   DecoderInterface* Decoder;
   Socket*           ReceiverSocket;
};


}


#include "rtpreceiver.icc"


#endif

Generated by: viper@odin on Sun Feb 4 18:54:51 2001, using kdoc 2.0a22.