Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

RTPAVProfilePayload32Receiver Class Reference

#include <RTPAVProfilePayload32Receiver.h>

Inheritance diagram for RTPAVProfilePayload32Receiver:

RTPPayloadReceiver List of all members.

Detailed Description

This module is used to receive data (mpeg video) of payload 32 for rtp endsystems working under the rtp av profile. It expects data in the format defined in rfc 2250. Its corresponding sender module is RTPAVProfilePayload32Sender. This implementation doesn't work with real mpeg data, so it doesn't write an mpeg file but a sim file, which can be played with a modified mpeg player.


Protected Member Functions

virtual ~RTPAVProfilePayload32Receiver ()
virtual void initialize ()
virtual void processPacket (RTPPacket *packet)

Protected Attributes

cQueue * _queue
u_int32 _lowestAllowedTimeStamp


Constructor & Destructor Documentation

RTPAVProfilePayload32Receiver::~RTPAVProfilePayload32Receiver  )  [protected, virtual]
 

Destructor.

00034                                                               {
00035     delete _queue;
00036 };


Member Function Documentation

void RTPAVProfilePayload32Receiver::initialize  )  [protected, virtual]
 

Calls the method of the superclass RTPPayloadReceiver and sets the payload type to 32.

Reimplemented from RTPPayloadReceiver.

00039                                                {
00040     RTPPayloadReceiver::initialize();
00041     _payloadType = 32;
00042     _queue = new cQueue("IncomingQueue", &(RTPPacket::compareFunction));
00043     _lowestAllowedTimeStamp = 0;
00044 };

void RTPAVProfilePayload32Receiver::processPacket RTPPacket packet  )  [protected, virtual]
 

Writes information about received frames into the output file. The only error correction provided is reordering packets of one frame if needed.

Reimplemented from RTPPayloadReceiver.

00047                                                                       {
00048     // the first packet sets the lowest allowed time stamp
00049     if (_lowestAllowedTimeStamp == 0) {
00050         _lowestAllowedTimeStamp = rtpPacket->timeStamp();
00051     };
00052 
00053     if (rtpPacket->timeStamp() < _lowestAllowedTimeStamp) {
00054         delete rtpPacket;
00055     }
00056     else {
00057         // is this packet from the next frame ?
00058         // this can happen when the marked packet has been
00059         // lost or arrives late
00060         bool nextTimeStamp = rtpPacket->timeStamp() > _lowestAllowedTimeStamp;
00061 
00062         // is this packet marked, which means that it's
00063         // the last packet of this frame
00064         bool marked = rtpPacket->marker();
00065 
00066         // test if end of frame reached
00067 
00068         // check if we received the last (= marked)
00069         // packet of the frame or
00070         // we received a packet of the next frame
00071 
00072         if (nextTimeStamp || marked) {
00073 
00074             // a marked packet belongs to this frame
00075             if (marked && !nextTimeStamp) {
00076                 _queue->insert(rtpPacket);
00077             }
00078 
00079             int pictureType = 0;
00080             int frameSize = 0;
00081 
00082             // the queue contains all packets for this frame
00083             // we have received
00084             while (!_queue->empty()) {
00085                 RTPPacket *readPacket = (RTPPacket *)(_queue->head());
00086                 _queue->remove(readPacket);
00087                 RTPMpegPacket *mpegPacket = (RTPMpegPacket *)(readPacket->decapsulate());
00088                 if (pictureType == 0)
00089                     pictureType = mpegPacket->pictureType();
00090                 frameSize = frameSize + mpegPacket->payloadLength();
00091 
00092                 delete mpegPacket;
00093                 delete readPacket;
00094             };
00095 
00096             // we start the next frame
00097             // set the allowed time stamp
00098             if (nextTimeStamp) {
00099                 _lowestAllowedTimeStamp = rtpPacket->timeStamp();
00100                 _queue->insert(rtpPacket);
00101             };
00102 
00103             // we have calculated a frame
00104             if (frameSize > 0) {
00105                 char line[100];
00106                 // what picture type is it
00107                 char picture = ' ';
00108                 if (pictureType == 1)
00109                     picture = 'I';
00110                 else if (pictureType == 2)
00111                     picture = 'P';
00112                 else if (pictureType == 3)
00113                     picture = 'B';
00114                 else if (pictureType == 4)
00115                     picture = 'D';
00116 
00117                 // create sim line
00118                 sprintf(line, "%f %i %c-Frame", simTime(), frameSize * 8, picture);
00119                 // and write it to the file
00120                 _outputFileStream << line << endl;
00121             }
00122         }
00123         // we are not at the end of the frame
00124         // so just insert this packet
00125         else {
00126             _queue->insert(rtpPacket);
00127         }
00128     }
00129 };


Member Data Documentation

u_int32 RTPAVProfilePayload32Receiver::_lowestAllowedTimeStamp [protected]
 

Stores the lowest allowed time stamp of rtp data packets. The value is used to throw away packets from mpeg frames already stored in the data file.

cQueue* RTPAVProfilePayload32Receiver::_queue [protected]
 

A reordering queue for incoming packets.


The documentation for this class was generated from the following files:
Generated on Thu Oct 19 18:22:29 2006 for INET Framework for OMNeT++/OMNEST by  doxygen 1.4.0