Public Member Functions | Protected Attributes

RTPApplication Class Reference

#include <RTPApplication.h>

List of all members.

Public Member Functions

 RTPApplication ()
virtual void initialize ()
virtual void activity ()

Protected Attributes

const char * _commonName
const char * _profileName
int _bandwidth
IPAddress _destinationAddress
int _port
const char * _fileName
int _payloadType
simtime_t _sessionEnterDelay
simtime_t _transmissionStartDelay
simtime_t _transmissionStopDelay
simtime_t _sessionLeaveDelay

Detailed Description

The class RTPApplication is just a very simple sample for an application which uses RTP. It acts as a sender if the omnet parameter fileName is set, and as a receiver if the parameter is empty.

Definition at line 27 of file RTPApplication.h.


Constructor & Destructor Documentation

RTPApplication::RTPApplication (  )  [inline]

Constructor, with activity() stack size.

Definition at line 33 of file RTPApplication.h.

: cSimpleModule(32768) {}


Member Function Documentation

void RTPApplication::activity (  )  [virtual]

RTPApplication uses activity for message handling. The behaviour is controlled by omnet parameters.

Definition at line 68 of file RTPApplication.cc.

{


    bool sessionEntered = false;
    bool transmissionStarted = false;
    bool transmissionFinished = false;
    bool sessionLeft = false;

    cMessage *msg1 = new cMessage("enterSession");
    scheduleAt(simTime() + _sessionEnterDelay, msg1);

    uint32 ssrc = 0;

    while (!sessionLeft) {

        cMessage *msgIn = receive();
        if (msgIn->isSelfMessage()) {
            if (!opp_strcmp(msgIn->getName(), "enterSession")) {
                ev << "enterSession"<<endl;
                // create an RTPInterfacePacket to enter the session
                RTPInterfacePacket *rifpOut1 = new RTPInterfacePacket("enterSession()");
                rifpOut1->enterSession(opp_strdup(_commonName), opp_strdup(_profileName), _bandwidth, _destinationAddress, _port);
                // and send it to the rtp layer
                send(rifpOut1, "rtpOut");
            }
            else if (!opp_strcmp(msgIn->getName(), "startTransmission")) {
                ev << "startTransmission"<<endl;
                RTPSenderControlMessage *rscm = new RTPSenderControlMessage();
                rscm->setCommand("PLAY");
                RTPInterfacePacket *rifpOut = new RTPInterfacePacket("senderModuleControl(PLAY)");
                rifpOut->senderModuleControl(ssrc, rscm);
                send(rifpOut, "rtpOut");
                transmissionStarted = true;

                cMessage *msg4 = new cMessage("stopTransmission");
                scheduleAt(simTime() + _transmissionStopDelay, msg4);
            }
            else if (!opp_strcmp(msgIn->getName(), "stopTransmission")) {
                ev << "stopTransmission"<<endl;
                RTPSenderControlMessage *rscm = new RTPSenderControlMessage();
                rscm->setCommand("STOP");
                RTPInterfacePacket *rifpOut = new RTPInterfacePacket("senderModuleControl(STOP)");
                rifpOut->senderModuleControl(ssrc, rscm);
                send(rifpOut, "rtpOut");
            }
            else if (!opp_strcmp(msgIn->getName(), "leaveSession")) {
                ev<< "leaveSession"<<endl;
                RTPInterfacePacket *rifpOut = new RTPInterfacePacket("leaveSession()");
                rifpOut->leaveSession();
                send(rifpOut, "rtpOut");
            }
        }
        else {
            RTPInterfacePacket *rifpIn = check_and_cast<RTPInterfacePacket *>(msgIn);

            if (rifpIn->getType() == RTPInterfacePacket::RTP_IFP_SESSION_ENTERED) {
                ev << "Session Entered"<<endl;
                ssrc = rifpIn->getSSRC();
                sessionEntered = true;
                if (opp_strcmp(_fileName, "")) {
                    RTPInterfacePacket *rifpOut = new RTPInterfacePacket("createSenderModule()");
                    rifpOut->createSenderModule(ssrc, _payloadType, opp_strdup(_fileName));
                    ev << "CreateSenderModule"<<endl;
                    send(rifpOut, "rtpOut");
                }
                else {
                    cMessage *msg2 = new cMessage("leaveSession");
                    ev << "Receiver Module : leaveSession"<<endl;
                    scheduleAt(simTime() + _sessionLeaveDelay, msg2);
                }
            }
            else if (rifpIn->getType() == RTPInterfacePacket::RTP_IFP_SENDER_MODULE_CREATED) {
                cMessage *msg3 = new cMessage("startTransmission");
                ev << "Sender Module Created"<<endl;
                scheduleAt(simTime() + _transmissionStartDelay, msg3);
            }
            else if (rifpIn->getType() == RTPInterfacePacket::RTP_IFP_SENDER_STATUS) {
                RTPSenderStatusMessage *rsim = (RTPSenderStatusMessage *)(rifpIn->decapsulate());
                if (!opp_strcmp(rsim->getStatus(), "PLAYING")) {
                    ev << "PLAYING"<<endl;
                }
                else if (!opp_strcmp(rsim->getStatus(), "FINISHED")) {
                    transmissionFinished = true;
                    ev << "FINISHED"<<endl;
                    cMessage *msg5 = new cMessage("leaveSession");
                    scheduleAt(simTime() + _sessionLeaveDelay, msg5);
                }
                else if (!opp_strcmp(rsim->getStatus(), "STOPPED")) {
                    transmissionFinished = true;
                    ev << "FINISHED"<<endl;
                    cMessage *msg6 = new cMessage("leaveSession");
                    scheduleAt(simTime() + _sessionLeaveDelay, msg6);
                }
                else {
                    delete rifpIn;
                }
                cancelAndDelete(rsim);
            }
            else if (rifpIn->getType() == RTPInterfacePacket::RTP_IFP_SESSION_LEFT) {
                sessionLeft = true;
            }
        }
        delete msgIn;

    }
}

virtual void RTPApplication::initialize (  )  [virtual]

Reads the OMNeT++ parameters.


Member Data Documentation

int RTPApplication::_bandwidth [protected]

The reserved bandwidth for rtp/rtcp in bytes/second.

Definition at line 61 of file RTPApplication.h.

Referenced by activity().

const char* RTPApplication::_commonName [protected]

The CNAME of this participant.

Definition at line 51 of file RTPApplication.h.

Referenced by activity().

The address of the unicast peer or of the multicast group.

Definition at line 66 of file RTPApplication.h.

Referenced by activity().

const char* RTPApplication::_fileName [protected]

The name of the file to be transmitted.

Definition at line 76 of file RTPApplication.h.

Referenced by activity().

The payload type of the data in the file.

Definition at line 81 of file RTPApplication.h.

Referenced by activity().

int RTPApplication::_port [protected]

One of the udp port used.

Definition at line 71 of file RTPApplication.h.

Referenced by activity().

const char* RTPApplication::_profileName [protected]

The name of the used profile.

Definition at line 56 of file RTPApplication.h.

Referenced by activity().

simtime_t RTPApplication::_sessionEnterDelay [protected]

The delay after the application enters the session,

Definition at line 86 of file RTPApplication.h.

Referenced by activity().

simtime_t RTPApplication::_sessionLeaveDelay [protected]

The delay after the application leaves the session.

Definition at line 101 of file RTPApplication.h.

Referenced by activity().

The delay after the application starts the transmission.

Definition at line 91 of file RTPApplication.h.

Referenced by activity().

The delay after the application stops the transmission.

Definition at line 96 of file RTPApplication.h.

Referenced by activity().


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