|
|
// ########################################################################## // #### #### // #### RTP Audio Server Project #### // #### ============================ #### // #### #### // #### RTP Sender #### // #### #### // #### Version 1.00 -- September 17, 2000 #### // #### #### // #### Copyright (C) 1999 Thomas Dreibholz #### // #### 2000 Universität Bonn, Abt. IV #### // #### EMail: Dreibholz@bigfoot.com #### // #### WWW: http://www.bigfoot.com/~dreibholz #### // #### #### // ########################################################################## #ifndef RTPSENDER_H #define RTPSENDER_H #include "system.h" #include "timedthread.h" #include "socket.h" #include "rtppacket.h" #include "encoderinterface.h" #ifdef USE_TRANSPORTINFO #include "extendedtransportinfo.h" #else #include "abstractqosdescription.h" #include "bandwidthmanager.h" #endif namespace Coral { /** * This class implements an RTP sender based on TimedThread. * * @short RTP Sender * @author Thomas Dreibholz (Dreibholz@bigfoot.com) * @version 1.0 */ class RTPSender : #ifndef USE_TRANSPORTINFO virtual public ManagedStreamInterface, #endif public TimedThread { // ====== Constructor/Destructor ========================================= public: /** * Default constructor. * You have to initialize RTPSender by calling init(...) later! * * @see init */ RTPSender(); /** * Constructor for new RTPSender. The new sender's thread has to be started * by calling start()! * * @param ssrc Sender's SSRC (see RFC 1889). * @param encoder Encoder to get packets to send from. * @param senderSocket Socket to write packets to. * @param maxPacketSize Maximum packet size. * * @see Thread#start */ RTPSender(const card32 ssrc, EncoderInterface* encoder, Socket* senderSocket, const cardinal maxPacketSize = 1500 #ifndef USE_TRANSPORTINFO ,BandwidthManager* bwManager = NULL #endif ); /** * Destructor. */ ~RTPSender(); // ====== Initialize ===================================================== /** * Initialize new RTPSender. The new sender's thread has to be started * by calling start()! * * @param ssrc Sender's SSRC (see RFC 1889). * @param encoder Encoder to get packets to send from. * @param senderSocket Socket to write packets to. * @param maxPacketSize Maximum packet size. * @param bwManager Bandwidth manager. * * @see Thread#start */ void init(const card32 ssrc, EncoderInterface* encoder, Socket* senderSocket, const cardinal maxPacketSize = 1500 #ifndef USE_TRANSPORTINFO ,BandwidthManager* bwManager = NULL #endif ); // ====== Quality control ================================================ #ifdef USE_TRANSPORTINFO /** * Adapt quality. * * @param fractionLost Fraction of packets lost. * @param layer Layer number. */ void adaptQuality(const double fractionLost, const cardinal layer); // ====== Transport info ================================================= /** * Get TransportInfo for encoding. * * @param transportInfo Pointer to ExtendedTransportInfo. * @param calculateLevels true to calculate all level constants; false otherwise. */ void getTransportInfo(ExtendedTransportInfo& transportInfo, const bool calculateLevels = true); /** * Set TransportInfo for encoding. * * @param transportInfo Pointer to ExtendedTransportInfo. * @param calculateLevels true to calculate all level constants; false otherwise. */ void setTransportInfo(ExtendedTransportInfo& transportInfo, const bool calculateLevels = true); #else /** * Implementation of ManagedStreamInterface's getQoSDescription(). * * @see ManagedStreamInterface#getQoSDescription */ AbstractQoSDescription* getQoSDescription(const card64 offset); /** * Implementation of ManagedStreamInterface's updateQuality(). * * @see ManagedStreamInterface#updateQuality */ void updateQuality(const AbstractQoSDescription* aqd); /** * Implementation of ManagedStreamInterface's lock(). * * @see ManagedStreamInterface#lock */ void lock(); /** * Implementation of ManagedStreamInterface's unlock(). * * @see ManagedStreamInterface#unlock */ void unlock(); #endif // ====== Packet size ==================================================== /** * Get maximum packet size. * * @return Maximum packet size. */ inline cardinal getMaxPacketSize() const; /** * Set maximum packet size. * * @param size Maximum packet size. * @return Maximum packet size set. */ inline cardinal setMaxPacketSize(const cardinal size); // ====== Transmission control =========================================== /** * Check, if transmission is paused. * * @return true, if paused; false otherwise. */ inline bool paused() const; /** * Check, if transmission error has been detected (e.g. destination rejects * packets, no route etc.). * Note: The transmission error attribute will be resetted to false by * calling this method. */ inline bool transmissionErrorDetected(); /** * Set pause on or off. * * @param on true to set pause on; false to set pause off. */ inline void setPause(const bool on); /** * Get number of bytes sent. * * @return Bytes sent. */ inline card64 getBytesSent() const; /** * Get number of packets sent. * * @return Packets sent. */ inline card64 getPacketsSent() const; /** * Reset number of bytes sent. */ inline void resetBytesSent(); /** * Reset number of packets sent. */ inline void resetPacketsSent(); // ====== Private data =================================================== private: void timerEvent(); private: EncoderInterface* Encoder; Socket* SenderSocket; cardinal FramesPerSecond; cardinal RenewCounter; cardinal MaxPacketSize; card32 SSRC; card64 BytesSent; card64 PacketsSent; card64 TimeStamp; card32 PayloadBytesSent; card32 PayloadPacketsSent; bool Pause; bool TransmissionError; InternetFlow Flow[RTPConstants::RTPMaxQualityLayers]; card16 SequenceNumber[RTPConstants::RTPMaxQualityLayers]; #ifdef USE_TRANSPORTINFO void update(const TransportInfo& transportInfo); cardinal UnitBytesCheckCounter; card64 UnitBytesSent[RTPConstants::RTPMaxQualityLayers]; cardinal UnitPacketsSent[RTPConstants::RTPMaxQualityLayers]; cardinal PacketsPerSecond[RTPConstants::RTPMaxQualityLayers]; card64 BytesPerSecond[RTPConstants::RTPMaxQualityLayers]; #else void update(const AbstractQoSDescription* aqd); BandwidthManager* BandwidthMgr; #endif }; } #include "rtpsender.icc" #endif
Generated by: viper@odin on Mon Oct 16 11:49:26 2000, using kdoc 2.0a36. |