Source: traceclient.h


Annotated List
Files
Globals
Hierarchy
Index
// ##########################################################################
// ####                                                                  ####
// ####                    Master Thesis Implementation                  ####
// ####  Management of Layered Variable Bitrate Multimedia Streams over  ####
// ####                  DiffServ with A Priori Knowledge                ####
// ####                                                                  ####
// #### ================================================================ ####
// ####                                                                  ####
// ####                                                                  ####
// #### Trace Client                                                     ####
// ####                                                                  ####
// #### Version 1.00  --  October 10, 2000                               ####
// ####                                                                  ####
// #### Copyright (C) 2000 Thomas Dreibholz                              ####
// #### University of Bonn, Department of Computer Science IV            ####
// #### EMail: Dreibholz@bigfoot.com                                     ####
// #### WWW:   http://www.bigfoot.com/~dreibholz/diplom/index.html       ####
// ####                                                                  ####
// ##########################################################################


#ifndef TRACECLIENT_H
#define TRACECLIENT_H


#include "tracedecoderinterface.h"
#include "tracedecoderrepository.h"
#include "mediainfo.h"
#include "rtcpsender.h"
#include "rtpreceiver.h"
#include "internetaddress.h"
#include "socket.h"
#include "strings.h"


#include "traceclientapppacket.h"


#include <multimap.h>
#include <algo.h>


namespace Coral {


/**
  * This class is a trace client.
  *
  * @short   Trace Client
  * @author  Thomas Dreibholz (Dreibholz@bigfoot.com)
  * @version 1.0
  */
class TraceClient
{
   // ====== Constructor/Destructor =========================================
   public:
   /**
     * Constructor for a new trace client.
     *
     * @param receiverName String with the receiver name or NULL for default.
     */
   TraceClient(const char* receiverName);

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


   // ====== Player functions ===============================================
   public:
   /**
     * Start playing given media from given server.
     *
     * @param server Server address (e.g. gaffel:7500).
     * @param mediaName Media name (e.g. ../TraceFiles/Test1.list)
     * @param sessionDescriptor Session descriptor.
     * @return true, if play request has been sent to server.
     */
   bool play(const char*  server,
             const char*  mediaName,
             const card32 sessionDescriptor = 0);

   /**
     * Change media of an established connection.
     *
     * @param mediaName New media name (e.g. ../TraceFiles/Test2.list)
     *
     * @see play
     */
   void change(const char* mediaName);

   /**
     * Stop playing.
     */
   void stop();


   // ====== Settings =======================================================
   /**
     * Get current media position. This will automatically the
     * RestartPosition value in the next TraceClientAppPacket. The server
     * will restart from the current position, if the server is restarted.
     *
     * @return Position in nanoseconds.
     */
   card64 getPosition();

   /**
     * Get maximum media position.
     *
     * @return Maximum position in nanoseconds.
     */
   inline card64 getMaxPosition() const;

   /**
     * Get MediaInfo.
     *
     * @return MediaInfo.
     */
   MediaInfo getMediaInfo() const;


   /**
     * Get error code.
     *
     * @return Error code.
     */
   inline card8 getErrorCode() const;

   /**
     * Get encoding name.
     *
     * @return Encoding name.
     */
   inline const char* getEncoding() const;

   /**
     * Get minimum wanted bandwidth.
     *
     * @return Minimum wanted bandwidth.
     */
   inline cardinal getMinWantedBandwidth() const;

   /**
     * Get maximum wanted bandwidth.
     *
     * @return Maximum wanted bandwidth.
     */
   inline cardinal getMaxWantedBandwidth() const;

   /**
     * Get maximum wanted delay.
     *
     * @return Maximum wanted delay.
     */
   inline double getMaxWantedDelay() const;

   /**
     * Get wanted utilization.
     *
     * @return Wanted utilization.
     */
   inline double getWantedUtilization() const;

   /**
     * Get stream priority.
     *
     * @return Stream priority;
     */
   inline int8 getStreamPriority() const;

   /**
     * Get session priority.
     *
     * @return Session priority;
     */
   inline int8 getSessionPriority() const;


   // ====== Transmission information =======================================
   /**
     * Get bandwidth range of last transmission.
     *
     * @return Bandwidth range.
     */
   inline Range<cardinal> getBandwidth() const;

   /**
     * Get frame rate of last transmission.
     *
     * @return Frame rate.
     */
   inline double getFrameRate() const;

   /**
     * Get utilization of last transmission.
     *
     * @return Utilization.
     */
   inline double getUtilization() const;

   /**
     * Get number of layers of last transmission.
     */
   inline cardinal getLayers() const;

   /**
     * Get IP version.
     *
     * @return IP Version.
     */
   card8 getIPVersion() const;

   /**
     * Check, if trace client is playing.
     *
     * @return true, if client is playing; false otherwise.
     */
   inline bool playing() const;

   /**
     * Get server address string.
     *
     * @param format Print format.
     * @return Server address.
     *
     * @see InternetAddress#PrintFormat
     */
   String getServerAddressString(InternetAddress::PrintFormat format = InternetAddress::PF_Address) const;

   /**
     * Get client address string.
     *
     * @param format Print format.
     * @return Client address.
     *
     * @see InternetAddress#PrintFormat
     */
   String getOurAddressString(InternetAddress::PrintFormat format = InternetAddress::PF_Address) const;

   /**
     * Get number of bytes received.
     *
     * @param layer Layer number or (cardinal)-1 for sum of all layers.
     * @return Number of bytes received
     */
   inline card64 getBytesReceived(const cardinal layer = 0) const;

   /**
     * Get number of packets received in given layer.
     *
     * @param layer Layer number or (cardinal)-1 for sum of all layers.
     * @return Number of packets received
     *
     * @see getLayers
     */
   inline card64 getPacketsReceived(const cardinal layer = 0) const;

   /**
     * Get InternetFlow of last received packet in given layer.
     *
     * @param layer Layer number.
     * @return InternetFlow.
     *
     * @see getLayers
     */
   inline InternetFlow getInternetFlow(const cardinal layer = 0) const;

   /**
     * Get flow label of last received packet in given layer.
     *
     * @param layer Layer number.
     * @return Flow label.
     *
     * @see getLayers
     */
   inline card32 getFlowLabel(const cardinal layer = 0) const;

   /**
     * Get traffic class of last received packet in given layer.
     *
     * @param layer Layer number.
     * @return Traffic class.
     *
     * @see getLayers
     */
   inline card8 getTrafficClass(const cardinal layer = 0) const;

   /**
     * Get server SSRC for given layer.
     *
     * @param layer Layer number.
     * @return Server SSRC.
     *
     * @see getLayers
     */
   card32 getServerSSRC(const cardinal layer = 0) const;

   /**
     * Get client SSRC.
     *
     * @return Client SSRC.
     */
   inline card32 getOurSSRC() const;

   /**
     * Get number of packets lost for given layer.
     *
     * @param layer Layer number.
     * @return Number of packets lost.
     *
     * @see getLayers
     */
   card64 getPacketsLost(const cardinal layer = 0) const;

   /**
     * Get fraction of packets lost for given layer.
     *
     * @param layer Layer number.
     * @return Fraction of packets lost.
     *
     * @see getLayers
     */
   double getFractionLost(const cardinal layer = 0) const;

   /**
     * Get jitter for given layer.
     *
     * @param layer Layer number.
     * @return Jitter.
     *
     * @see getLayers
     */
   double getJitter(const cardinal layer = 0) const;


   /**
     * Get encoding name for a given index of the client's decoder repository.
     *
     * @param index Repository index.
     * @return Encoding name or NULL, if index is too high.
     */
   const char* getEncodingName(const cardinal index);


   /**
     * Set media position.
     *
     * @param position New media position in nanoseconds.
     */
   inline void setPosition(const card64 position);

   /**
     * Set pause.
     *
     * @param on true for pause on; false for pause off.
     */
   void setPause(const bool on);

   /**
     * Set wanted utilization.
     *
     * @param utilization Wanted utilization.
     */
   inline void setWantedUtilization(const double utilization);

   /**
     * Set minimum wanted bandwidth.
     *
     * @param bandwidth Minimum wanted bandwidth.
     */
   inline void setMinWantedBandwidth(const cardinal bandwidth);

   /**
     * Set maximum wanted bandwidth.
     *
     * @param bandwidth Maximum wanted bandwidth.
     */
   inline void setMaxWantedBandwidth(const cardinal bandwidth);

   /**
     * Set maximum wanted delay.
     *
     * @param delay Maximum wanted delay in microseconds.
     */
   inline void setMaxWantedDelay(const double delay);

   /**
     * Set stream priority.
     *
     * @param priority Stream priority.
     */
   inline void setStreamPriority(const int8 priority);

   /**
     * Set session priority.
     *
     * @param priority Session priority.
     */
   inline void setSessionPriority(const int8 priority);

   /**
     * Set encoding by index in client's decoder repository.
     *
     * @param index Index in decoder repository.
     */
   void setEncoding(const cardinal index);


   // ====== Private data ===================================================
   private:
   void sendCommand(const bool updateRestartPosition = true);


   // Update of RestartPosition has to be delayed after change() call to
   // ensure that there are no more packets of the old file on the network
   // which change the restart position back to the old value.
   static const card64 RestartPositionUpdateDelay = 5000000;


   RTPReceiver*                                    Receiver;
   RTCPSender*                                     Sender;
   Socket                                          SenderSocket;
   Socket                                          ReceiverSocket;
   InternetFlow                                    Flow;
   InternetAddress                                 ServerAddress;
   InternetAddress                                 OurAddress;
   card32                                          OurSSRC;
   InternetAddress                                 ReceiverAddress;

   multimap<const cardinal,TraceDecoderInterface*> DecoderSet;
   TraceDecoderRepository                          Decoders;

   TraceClientAppPacket                            Status;
   card64                                          OldPosition;
   card64                                          ChangeTimeStamp;
   bool                                            IsPlaying;
};


}


#include "traceclient.icc"


#endif

Generated by: viper@odin on Mon Oct 16 11:49:26 2000, using kdoc 2.0a36.