queuebase.h
Go to the documentation of this file.
// Copyright (C) 2001,2002,2004 Federico Montesino Pouzols <fedemp@altern.org>.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
//
// This exception applies only to the code released under the name GNU
// ccRTP. If you copy code from other releases into a copy of GNU
// ccRTP, as the General Public License permits, the exception does
// not apply to the code that you add in this way. To avoid misleading
// anyone as to the status of such modified files, you must delete
// this exception notice from them.
//
// If you write modifications of your own for GNU ccRTP, it is your choice
// whether to permit this exception to apply to your modifications.
// If you do not wish that, delete this exception notice.
//
#ifndef CCXX_RTP_QUEUEBASE_H_
#define CCXX_RTP_QUEUEBASE_H_
#include <commoncpp/pointer.h>
#include <ccrtp/rtppkt.h>
#include <ccrtp/sources.h>
NAMESPACE_COMMONCPP
class __EXPORT AppDataUnit
{
public:
AppDataUnit(const IncomingRTPPkt& packet, const SyncSource& src);
inline ~AppDataUnit()
{ }
AppDataUnit(const AppDataUnit& src);
AppDataUnit&
operator=(const AppDataUnit& source);
inline PayloadType
getType() const
{ return datablock->getPayloadType(); }
inline const uint8* const
getData() const
{ return datablock->getPayload(); }
size_t
getSize() const
{ return datablock->getPayloadSize(); }
inline const SyncSource&
getSource() const
{ return *source; }
inline bool
isMarked() const
{ return datablock->isMarked(); }
inline uint16
getSeqNum() const
{ return datablock->getSeqNum(); }
inline uint8
getContributorsCount() const
{ return (uint8)datablock->getCSRCsCount(); }
inline const uint32*
getContributorsID() const
{ return datablock->getCSRCs(); }
private:
Pointer<const IncomingRTPPkt> datablock;
const SyncSource* source;
};
class __EXPORT RTPQueueBase
{
public:
inline bool
setPayloadFormat(const PayloadFormat& pf)
{
currentPayloadType = pf.getPayloadType();
currentRTPClockRate = pf.getRTPClockRate();
return true;
}
inline uint32 getLocalSSRC() const
{ return localSSRC; }
inline uint32 getCurrentRTPClockRate() const
{ return currentRTPClockRate; }
inline PayloadType getCurrentPayloadType() const
{ return currentPayloadType; }
inline timeval getInitialTime() const
{ return initialTime; }
protected:
RTPQueueBase(uint32 *ssrc = NULL);
inline void setLocalSSRC(uint32 ssrc)
{ localSSRC = ssrc; localSSRCNetwork = htonl(ssrc); }
inline uint32 getLocalSSRCNetwork() const
{ return localSSRCNetwork; }
virtual
~RTPQueueBase()
{ }
inline virtual size_t
dispatchBYE(const std::string&)
{ return 0; }
inline virtual void
renewLocalSSRC()
{ }
private:
// local SSRC 32-bit identifier
uint32 localSSRC;
// SSRC in network byte order
uint32 localSSRCNetwork;
// RTP clock rate for the current payload type.
uint32 currentRTPClockRate;
// Current payload type set for outgoing packets and expected
// from incoming packets.
PayloadType currentPayloadType;
// when the queue is created
timeval initialTime;
};
class __EXPORT OutgoingDataQueueBase:
public virtual RTPQueueBase
{
public:
inline size_t
getDefaultMaxSendSegmentSize()
{ return defaultMaxSendSegmentSize;}
inline void
setMaxSendSegmentSize(size_t size)
{ maxSendSegmentSize = size; }
inline size_t
getMaxSendSegmentSize()
{ return maxSendSegmentSize; }
protected:
OutgoingDataQueueBase();
inline virtual
~OutgoingDataQueueBase()
{ }
private:
static const size_t defaultMaxSendSegmentSize;
// maximum packet size before fragmenting sends.
size_t maxSendSegmentSize;
};
class __EXPORT IncomingDataQueueBase:
public virtual RTPQueueBase
{
public:
inline size_t getDefaultMaxRecvPacketSize() const
{ return defaultMaxRecvPacketSize; }
inline size_t
getMaxRecvPacketSize() const
{ return maxRecvPacketSize; }
inline void
setMaxRecvPacketSize(size_t maxsize)
{ maxRecvPacketSize = maxsize; }
protected:
IncomingDataQueueBase()
{ setMaxRecvPacketSize(getDefaultMaxRecvPacketSize()); }
inline virtual
~IncomingDataQueueBase()
{ }
private:
static const size_t defaultMaxRecvPacketSize;
// filter value for received packets length.
size_t maxRecvPacketSize;
};
// queuebase
END_NAMESPACE
#endif //CCXX_RTP_QUEUEBASE_H_
OutgoingDataQueueBase::getMaxSendSegmentSize
size_t getMaxSendSegmentSize()
Definition: queuebase.h:274
sources.h
Sources of synchronization and participants related clases.
RTPQueueBase
Definition: queuebase.h:167
OutgoingDataQueueBase::~OutgoingDataQueueBase
virtual ~OutgoingDataQueueBase()
Definition: queuebase.h:281
RTPQueueBase::getCurrentRTPClockRate
uint32 getCurrentRTPClockRate() const
Get the clock rate in RTP clock units (for instance, 8000 units per second for PCMU,...
Definition: queuebase.h:196
SyncSource
Synchronization source in an RTP session.
Definition: sources.h:194
RTPQueueBase::getInitialTime
timeval getInitialTime() const
Definition: queuebase.h:202
IncomingDataQueueBase::getMaxRecvPacketSize
size_t getMaxRecvPacketSize() const
Definition: queuebase.h:303
AppDataUnit::getType
PayloadType getType() const
Definition: queuebase.h:95
rtppkt.h
RTP packets handling.
IncomingDataQueueBase::IncomingDataQueueBase
IncomingDataQueueBase()
Definition: queuebase.h:321
RTPQueueBase::renewLocalSSRC
virtual void renewLocalSSRC()
Definition: queuebase.h:233
PayloadFormat::getRTPClockRate
uint32 getRTPClockRate() const
Get RTP clock rate for this payload format.
Definition: formats.h:149
AppDataUnit::getSource
const SyncSource & getSource() const
Definition: queuebase.h:120
RTPQueueBase::setPayloadFormat
bool setPayloadFormat(const PayloadFormat &pf)
Set the payload format in use, for timing and payload type identification purposes.
Definition: queuebase.h:178
PayloadType
uint8 PayloadType
RTP payload type numeric identifier.
Definition: formats.h:63
AppDataUnit::getData
const uint8 *const getData() const
Get data as it is received in RTP packets (i.e.
Definition: queuebase.h:106
IncomingDataQueueBase::~IncomingDataQueueBase
virtual ~IncomingDataQueueBase()
Definition: queuebase.h:325
PayloadFormat::getPayloadType
PayloadType getPayloadType() const
Get payload type numeric identifier carried in RTP packets.
Definition: formats.h:138
PayloadFormat
Base payload format class.
Definition: formats.h:130
AppDataUnit::isMarked
bool isMarked() const
Is this data unit marked?.
Definition: queuebase.h:129
RTPQueueBase::dispatchBYE
virtual size_t dispatchBYE(const std::string &)
A plugin point for posting of BYE messages.
Definition: queuebase.h:229
OutgoingDataQueueBase
Definition: queuebase.h:255
AppDataUnit::getContributorsCount
uint8 getContributorsCount() const
Get the number of contributing sources in the CSRC list.
Definition: queuebase.h:143
AppDataUnit::getSize
size_t getSize() const
Definition: queuebase.h:113
IncomingDataQueueBase
Definition: queuebase.h:295
IncomingDataQueueBase::getDefaultMaxRecvPacketSize
size_t getDefaultMaxRecvPacketSize() const
Definition: queuebase.h:299
OutgoingDataQueueBase::setMaxSendSegmentSize
void setMaxSendSegmentSize(size_t size)
Set maximum payload segment size before fragmenting sends.
Definition: queuebase.h:270
RTPQueueBase::getLocalSSRCNetwork
uint32 getLocalSSRCNetwork() const
Definition: queuebase.h:215
OutgoingDataQueueBase::getDefaultMaxSendSegmentSize
size_t getDefaultMaxSendSegmentSize()
Definition: queuebase.h:260
IncomingDataQueueBase::setMaxRecvPacketSize
void setMaxRecvPacketSize(size_t maxsize)
Definition: queuebase.h:317
AppDataUnit::getSeqNum
uint16 getSeqNum() const
Get data unit sequence number.
Definition: queuebase.h:136
AppDataUnit::getContributorsID
const uint32 * getContributorsID() const
Get the array of 32-bit CSRC identifiers.
Definition: queuebase.h:152
RTPQueueBase::getLocalSSRC
uint32 getLocalSSRC() const
Definition: queuebase.h:185
RTPQueueBase::getCurrentPayloadType
PayloadType getCurrentPayloadType() const
Definition: queuebase.h:199
IncomingRTPPkt
RTP packets received from other participants.
Definition: rtppkt.h:705
AppDataUnit::~AppDataUnit
~AppDataUnit()
Definition: queuebase.h:74
AppDataUnit
Interface (envelope) to data received over RTP packets.
Definition: queuebase.h:69
RTPQueueBase::setLocalSSRC
void setLocalSSRC(uint32 ssrc)
Definition: queuebase.h:212
RTPQueueBase::~RTPQueueBase
virtual ~RTPQueueBase()
Definition: queuebase.h:219