RTPPayloadSender Class Reference

#include <RTPPayloadSender.h>

Inheritance diagram for RTPPayloadSender:

RTPAVProfilePayload32Sender

List of all members.


Detailed Description

The class RTPPayloadSender is the base class for all modules creating rtp data packets. It provides functionality needed by every rtp data packet sender like opening and closing the data file and choosing sequence number and time stamp start values.

Public Types

enum  SenderStatus { STOPPED, PLAYING }

Public Member Functions

 RTPPayloadSender ()
virtual ~RTPPayloadSender ()
virtual void initialize ()
virtual void activity ()

Protected Member Functions

virtual void initializeSenderModule (RTPInnerPacket *)
virtual void openSourceFile (const char *fileName)
virtual void closeSourceFile ()
virtual void play ()
virtual void playUntilTime (simtime_t moment)
virtual void playUntilByte (int position)
virtual void pause ()
virtual void seekTime (simtime_t moment)
virtual void seekByte (int position)
virtual void stop ()
virtual void endOfFile ()
virtual bool sendPacket ()

Protected Attributes

std::ifstream _inputFileStream
int _mtu
uint32 _ssrc
int _payloadType
int _clockRate
uint32 _timeStampBase
uint32 _timeStamp
uint16 _sequenceNumberBase
uint16 _sequenceNumber
SenderStatus _status
cMessage * _reminderMessage

Member Enumeration Documentation

A sender module's transmission can be in different states.

Enumerator:
STOPPED 
PLAYING  Data is being sent.
00063                           {
00064             STOPPED, //< No transmission.
00065             PLAYING  
00066         };


Constructor & Destructor Documentation

RTPPayloadSender::RTPPayloadSender (  )  [inline]

Constructor, with activity() stack size.

00045 : cSimpleModule(32768) {}

RTPPayloadSender::~RTPPayloadSender (  )  [virtual]

Cleaning up. Calls closeSourceFile.

00029                                     {
00030     closeSourceFile();
00031 }


Member Function Documentation

void RTPPayloadSender::initialize (  )  [virtual]

Chooses sequence number and time stamp base values and reads the omnet parameter "mtu".

Reimplemented in RTPAVProfilePayload32Sender.

Referenced by RTPProfile::createSenderModule(), and RTPAVProfilePayload32Sender::initialize().

00034                                   {
00035     cSimpleModule::initialize();
00036     _mtu = 0;
00037     _ssrc = 0;
00038     _payloadType = 0;
00039     _clockRate = 0;
00040     _timeStampBase = intrand(65535);
00041     _timeStamp = _timeStampBase;
00042     _sequenceNumberBase = intrand(0x7fffffff);
00043     _sequenceNumber = _sequenceNumberBase;
00044 };

void RTPPayloadSender::activity (  )  [virtual]

00047                                 {
00048     const char *command;
00049     while (true) {
00050         cMessage *msg = receive();
00051         if (msg->getArrivalGateId() == findGate("fromProfile")) {
00052             RTPInnerPacket *rinpIn = (RTPInnerPacket *)msg;
00053             if (rinpIn->getType() == RTPInnerPacket::RTP_INP_INITIALIZE_SENDER_MODULE) {
00054                 initializeSenderModule(rinpIn);
00055             }
00056             else if (rinpIn->getType() == RTPInnerPacket::RTP_INP_SENDER_MODULE_CONTROL) {
00057                 RTPSenderControlMessage *rscm = (RTPSenderControlMessage *)(rinpIn->decapsulate());
00058                 delete rinpIn;
00059                 command = rscm->getCommand();
00060                 if (!opp_strcmp(command, "PLAY")) {
00061                     play();
00062                 }
00063                 else if (!opp_strcmp(command, "PLAY_UNTIL_TIME")) {
00064                     playUntilTime(rscm->getCommandParameter1());
00065                 }
00066                 else if (!opp_strcmp(command, "PLAY_UNTIL_BYTE")) {
00067                     playUntilByte(rscm->getCommandParameter1());
00068                 }
00069                 else if (!opp_strcmp(command, "PAUSE")) {
00070                     pause();
00071                 }
00072                 else if (!opp_strcmp(command, "STOP")) {
00073                     stop();
00074                 }
00075                 else if (!opp_strcmp(command, "SEEK_TIME")) {
00076                     seekTime(rscm->getCommandParameter1());
00077                 }
00078                 else if (!opp_strcmp(command, "SEEK_BYTE")) {
00079                     seekByte(rscm->getCommandParameter1());
00080                 }
00081                 else {
00082                     error("unknown sender control message");
00083                 };
00084                 delete rscm;
00085             }
00086         }
00087         else {
00088             if (!sendPacket()) {
00089                 endOfFile();
00090             }
00091             delete msg;
00092         }
00093     }
00094 };

void RTPPayloadSender::initializeSenderModule ( RTPInnerPacket rinpIn  )  [protected, virtual]

This method is called when a newly create sender module received its initialization message from profile module. It returns an RTP_INP_SENDER_MODULE_INITIALIZED message which

Reimplemented in RTPAVProfilePayload32Sender.

Referenced by activity(), and RTPAVProfilePayload32Sender::initializeSenderModule().

00097                                                                     {
00098     ev << "initializeSenderModule Enter" << endl;
00099     _mtu = rinpIn->getMTU();
00100     _ssrc = rinpIn->getSSRC();
00101     const char *fileName = rinpIn->getFileName();
00102     openSourceFile(fileName);
00103     delete rinpIn;
00104     RTPInnerPacket *rinpOut = new RTPInnerPacket("senderModuleInitialized()");
00105     rinpOut->senderModuleInitialized(_ssrc, _payloadType, _clockRate, _timeStampBase, _sequenceNumberBase);
00106     send(rinpOut, "toProfile");
00107     _status = STOPPED;
00108     ev << "initializeSenderModule Exit" << endl;
00109 };

void RTPPayloadSender::openSourceFile ( const char *  fileName  )  [protected, virtual]

This method is called by initializeSenderModule and opens the source data file as an inputFileStream stored in member variable _inputFileStream. Most data formats can use this method directly, but when using a library for a certain data format which offers an own open routine this method must be overwritten.

Referenced by initializeSenderModule().

00112                                                           {
00113     _inputFileStream.open(fileName);
00114     if (!_inputFileStream) {
00115         opp_error("sender module: error open data file");
00116     }
00117 };

void RTPPayloadSender::closeSourceFile (  )  [protected, virtual]

This method is called by the destructor and closes the data file.

Referenced by ~RTPPayloadSender().

00120                                        {
00121     _inputFileStream.close();
00122 };

void RTPPayloadSender::play (  )  [protected, virtual]

Starts data transmission. Every sender module must implement this method.

Referenced by activity().

00125                             {
00126     _status = PLAYING;
00127     RTPSenderStatusMessage *rssm = new RTPSenderStatusMessage("PLAYING");
00128     rssm->setStatus("PLAYING");
00129     rssm->setTimeStamp(_timeStamp);
00130     RTPInnerPacket *rinpOut = new RTPInnerPacket("senderModuleStatus(PLAYING)");
00131     rinpOut->senderModuleStatus(_ssrc, rssm);
00132     send(rinpOut, "toProfile");
00133 
00134     if (!sendPacket()) {
00135         endOfFile();
00136     }
00137 };

void RTPPayloadSender::playUntilTime ( simtime_t  moment  )  [protected, virtual]

Starts transmission from the current file position and plays until given time (relative to start of file) is reached. Implementation in sender modules is optional.

Referenced by activity().

00140                                                      {
00141     error("playUntilTime() not implemented");
00142 };

void RTPPayloadSender::playUntilByte ( int  position  )  [protected, virtual]

Starts transmission from the current file position and plays until given byte position (excluding file header) is reached. Implementation in sender modules is optional.

Referenced by activity().

00145                                                  {
00146     error("playUntilByte() not implemented");
00147 };

void RTPPayloadSender::pause (  )  [protected, virtual]

When data is being transmitted this methods suspends till a new PLAY command. Implementation in sender modules is optional.

Referenced by activity().

00150                              {
00151     cancelEvent(_reminderMessage);
00152     _status = STOPPED;
00153     RTPInnerPacket *rinpOut = new RTPInnerPacket("senderModuleStatus(PAUSED)");
00154     RTPSenderStatusMessage *rsim = new RTPSenderStatusMessage();
00155     rsim->setStatus("PAUSED");
00156     rinpOut->senderModuleStatus(_ssrc, rsim);
00157     send(rinpOut, "toProfile");
00158 };

void RTPPayloadSender::seekTime ( simtime_t  moment  )  [protected, virtual]

When the data transmission is paused the current position is changed to this time (relative to start of file). Implementation in sender modules is optional.

Referenced by activity().

00161                                                 {
00162     error("seekTime() not implemented");
00163 };

void RTPPayloadSender::seekByte ( int  position  )  [protected, virtual]

When the data transmission is paused the current position is changed to this byte position (excluding file header). Implementation in sender modules is optional.

Referenced by activity().

00166                                             {
00167     error("seekByte() not implemented");
00168 };

void RTPPayloadSender::stop (  )  [protected, virtual]

This method stop data transmission and resets the sender module so that a following PLAY command would start the transmission at the beginning again.

Referenced by activity().

00171                             {
00172     cancelEvent(_reminderMessage);
00173     _status = STOPPED;
00174     RTPSenderStatusMessage *rssm = new RTPSenderStatusMessage("STOPPED");
00175     rssm->setStatus("STOPPED");
00176     RTPInnerPacket *rinp = new RTPInnerPacket("senderModuleStatus(STOPPED)");
00177     rinp->senderModuleStatus(_ssrc, rssm);
00178     send(rinp, "toProfile");
00179 };

void RTPPayloadSender::endOfFile (  )  [protected, virtual]

This method gets called when the sender module reaches the end of file. For the transmission it has the same effect like stop().

Referenced by activity(), and play().

00182                                  {
00183     _status = STOPPED;
00184     RTPSenderStatusMessage *rssm = new RTPSenderStatusMessage();
00185     rssm->setStatus("FINISHED");
00186     RTPInnerPacket *rinpOut = new RTPInnerPacket("senderModuleStatus(FINISHED)");
00187     rinpOut->senderModuleStatus(_ssrc, rssm);
00188     send(rinpOut, "toProfile");
00189 };

bool RTPPayloadSender::sendPacket (  )  [protected, virtual]

This method gets called when one (or more) rtp data packets have to be sent. Subclasses must overwrite this method to do something useful. This implementation doesn't send packets it just returns

Reimplemented in RTPAVProfilePayload32Sender.

Referenced by activity(), and play().

00192                                   {
00193     error("sendPacket() not implemented");
00194     return false;
00195 };


Member Data Documentation

std::ifstream RTPPayloadSender::_inputFileStream [protected]

int RTPPayloadSender::_mtu [protected]

uint32 RTPPayloadSender::_ssrc [protected]

The ssrc identifier of this sender module.

Referenced by endOfFile(), initialize(), initializeSenderModule(), pause(), play(), RTPAVProfilePayload32Sender::sendPacket(), and stop().

The clock rate in ticks per second this sender uses.

Referenced by initialize(), RTPAVProfilePayload32Sender::initialize(), initializeSenderModule(), and RTPAVProfilePayload32Sender::sendPacket().

The first rtp time stamp used for created rtp data packets. The value is chosen randomly.

Referenced by initialize(), initializeSenderModule(), and RTPAVProfilePayload32Sender::sendPacket().

uint32 RTPPayloadSender::_timeStamp [protected]

The current rtp time stamp.

Referenced by initialize(), and play().

The first sequence number used for created rtp data packets. The value is chosen randomly.

Referenced by initialize(), and initializeSenderModule().

The current sequence number.

Referenced by initialize(), and RTPAVProfilePayload32Sender::sendPacket().

The current state of data transmission.

Referenced by endOfFile(), initializeSenderModule(), pause(), play(), and stop().

cMessage* RTPPayloadSender::_reminderMessage [protected]

A self message used as timer for the moment the next packet must be sent. It's a member variable because when playing gets paused or stopped the timer must be cancelled.

Referenced by pause(), RTPAVProfilePayload32Sender::sendPacket(), and stop().


The documentation for this class was generated from the following files:

Generated on Fri Mar 20 18:51:21 2009 for INET Framework for OMNeT++/OMNEST by  doxygen 1.5.5