RTPSenderInfo.cc

Go to the documentation of this file.
00001 /***************************************************************************
00002                           RTPSenderInfo.cc  -  description
00003                              -------------------
00004     begin                : Wed Dec 5 2001
00005     copyright            : (C) 2001 by Matthias Oppitz
00006     email                : Matthias.Oppitz@gmx.de
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 
00023 #include "RTPSenderInfo.h"
00024 
00025 
00026 Register_Class(RTPSenderInfo);
00027 
00028 RTPSenderInfo::RTPSenderInfo(uint32 ssrc) : RTPParticipantInfo(ssrc)
00029 {
00030     _startTime = 0.0;
00031     _clockRate = 0;
00032     _timeStampBase = 0;
00033     _sequenceNumberBase = 0;
00034     _packetsSent = 0;
00035     _bytesSent = 0;
00036 }
00037 
00038 
00039 RTPSenderInfo::RTPSenderInfo(const RTPSenderInfo& senderInfo) : RTPParticipantInfo()
00040 {
00041     operator=(senderInfo);
00042 }
00043 
00044 
00045 RTPSenderInfo::~RTPSenderInfo()
00046 {
00047 
00048 }
00049 
00050 
00051 RTPSenderInfo& RTPSenderInfo::operator=(const RTPSenderInfo& senderInfo)
00052 {
00053     RTPParticipantInfo::operator=(senderInfo);
00054     _startTime = senderInfo._startTime;
00055     _clockRate = senderInfo._clockRate;
00056     _timeStampBase = senderInfo._timeStampBase;
00057     _sequenceNumberBase = senderInfo._sequenceNumberBase;
00058     _packetsSent = senderInfo._packetsSent;
00059     _bytesSent = senderInfo._bytesSent;
00060     return *this;
00061 }
00062 
00063 
00064 RTPSenderInfo *RTPSenderInfo::dup() const
00065 {
00066     return new RTPSenderInfo(*this);
00067 }
00068 
00069 
00070 void RTPSenderInfo::processRTPPacket(RTPPacket *packet, int id,  simtime_t arrivalTime)
00071 {
00072     _packetsSent++;
00073     _bytesSent = _bytesSent + packet->getPayloadLength();
00074 
00075     // call corresponding method of superclass
00076     // for setting _silentIntervals
00077     // it deletes the packet !!!
00078     RTPParticipantInfo::processRTPPacket(packet, id, arrivalTime);
00079 }
00080 
00081 
00082 void RTPSenderInfo::processReceptionReport(ReceptionReport *report, simtime_t arrivalTime)
00083 {
00084     delete report;
00085 }
00086 
00087 
00088 SenderReport *RTPSenderInfo::senderReport(simtime_t now)
00089 {
00090     if (isSender()) {
00091         SenderReport *senderReport = new SenderReport();
00092         // ntp time stamp is 64 bit integer
00093 
00094         uint64 ntpSeconds = (uint64)SIMTIME_DBL(now);
00095         uint64 ntpFraction = (uint64)( (SIMTIME_DBL(now) - ntpSeconds*65536.0) * 65536.0);
00096 
00097         senderReport->setNTPTimeStamp((uint64)(ntpSeconds << 32) + ntpFraction);
00098         senderReport->setRTPTimeStamp(SIMTIME_DBL(now - _startTime) * _clockRate);
00099         senderReport->setPacketCount(_packetsSent);
00100         senderReport->setByteCount(_bytesSent);
00101         return senderReport;
00102     }
00103     else {
00104         return NULL;
00105     }
00106 }
00107 
00108 
00109 void RTPSenderInfo::setStartTime(simtime_t startTime)
00110 {
00111     _startTime = startTime;
00112 }
00113 
00114 
00115 void RTPSenderInfo::setClockRate(int clockRate)
00116 {
00117     _clockRate = clockRate;
00118 }
00119 
00120 
00121 void RTPSenderInfo::setTimeStampBase(uint32 timeStampBase)
00122 {
00123     _timeStampBase = timeStampBase;
00124 }
00125 
00126 
00127 void RTPSenderInfo::setSequenceNumberBase(uint16 sequenceNumberBase)
00128 {
00129     _sequenceNumberBase = sequenceNumberBase;
00130 }
00131 
00132 
00133 bool RTPSenderInfo::toBeDeleted(simtime_t now)
00134 {
00135     return false;
00136 }