queuebase.h

Go to the documentation of this file.
00001 // Copyright (C) 2001,2002,2004 Federico Montesino Pouzols <fedemp@altern.org>.
00002 //
00003 // This program is free software; you can redistribute it and/or modify
00004 // it under the terms of the GNU General Public License as published by
00005 // the Free Software Foundation; either version 2 of the License, or
00006 // (at your option) any later version.
00007 //
00008 // This program is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011 // GNU General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU General Public License
00014 // along with this program; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00016 //
00017 // As a special exception, you may use this file as part of a free software
00018 // library without restriction.  Specifically, if other files instantiate
00019 // templates or use macros or inline functions from this file, or you compile
00020 // this file and link it with other files to produce an executable, this
00021 // file does not by itself cause the resulting executable to be covered by
00022 // the GNU General Public License.  This exception does not however
00023 // invalidate any other reasons why the executable file might be covered by
00024 // the GNU General Public License.
00025 //
00026 // This exception applies only to the code released under the name GNU
00027 // ccRTP.  If you copy code from other releases into a copy of GNU
00028 // ccRTP, as the General Public License permits, the exception does
00029 // not apply to the code that you add in this way.  To avoid misleading
00030 // anyone as to the status of such modified files, you must delete
00031 // this exception notice from them.
00032 //
00033 // If you write modifications of your own for GNU ccRTP, it is your choice
00034 // whether to permit this exception to apply to your modifications.
00035 // If you do not wish that, delete this exception notice.
00036 //
00037 
00044 #ifndef CCXX_RTP_QUEUEBASE_H_
00045 #define CCXX_RTP_QUEUEBASE_H_
00046 
00047 #include <commoncpp/pointer.h>
00048 #include <ccrtp/rtppkt.h>
00049 #include <ccrtp/sources.h>
00050 
00051 NAMESPACE_COMMONCPP
00052 
00069 class __EXPORT AppDataUnit
00070 {
00071 public:
00072     AppDataUnit(const IncomingRTPPkt& packet, const SyncSource& src);
00073 
00074     inline ~AppDataUnit()
00075     { }
00076 
00080     AppDataUnit(const AppDataUnit& src);
00081 
00088     AppDataUnit&
00089     operator=(const AppDataUnit& source);
00090 
00094     inline PayloadType
00095     getType() const
00096     { return datablock->getPayloadType(); }
00097 
00105     inline const uint8* const
00106     getData() const
00107     { return datablock->getPayload(); }
00108 
00112     size_t
00113     getSize() const
00114     { return datablock->getPayloadSize(); }
00115 
00119     inline const SyncSource&
00120     getSource() const
00121     { return *source; }
00122 
00128     inline bool
00129     isMarked() const
00130     { return datablock->isMarked(); }
00131 
00135     inline uint16
00136     getSeqNum() const
00137     { return datablock->getSeqNum(); }
00138 
00142     inline uint8
00143     getContributorsCount() const
00144     { return (uint8)datablock->getCSRCsCount(); }
00145 
00151     inline const uint32*
00152     getContributorsID() const
00153     { return datablock->getCSRCs(); }
00154 
00155 private:
00156     Pointer<const IncomingRTPPkt> datablock;
00157     const SyncSource* source;
00158 };
00159 
00167 class __EXPORT RTPQueueBase
00168 {
00169 public:
00177     inline bool
00178     setPayloadFormat(const PayloadFormat& pf)
00179     {
00180         currentPayloadType = pf.getPayloadType();
00181         currentRTPClockRate = pf.getRTPClockRate();
00182         return true;
00183     }
00184 
00185     inline uint32 getLocalSSRC() const
00186     { return localSSRC; }
00187 
00196     inline uint32 getCurrentRTPClockRate() const
00197     { return currentRTPClockRate; }
00198 
00199     inline PayloadType getCurrentPayloadType() const
00200     { return currentPayloadType; }
00201 
00202     inline timeval getInitialTime() const
00203     { return initialTime; }
00204 
00205 protected:
00210     RTPQueueBase(uint32 *ssrc = NULL);
00211 
00212     inline void setLocalSSRC(uint32 ssrc)
00213     { localSSRC = ssrc; localSSRCNetwork = htonl(ssrc); }
00214 
00215     inline uint32 getLocalSSRCNetwork() const
00216     { return localSSRCNetwork; }
00217 
00218     virtual
00219     ~RTPQueueBase()
00220     { }
00221 
00228     inline virtual size_t
00229     dispatchBYE(const std::string&)
00230     { return 0; }
00231 
00232     inline virtual void
00233     renewLocalSSRC()
00234     { }
00235 
00236 private:
00237     // local SSRC 32-bit identifier
00238     uint32 localSSRC;
00239     // SSRC in network byte order
00240     uint32 localSSRCNetwork;
00241     // RTP clock rate for the current payload type.
00242     uint32 currentRTPClockRate;
00243     // Current payload type set for outgoing packets and expected
00244     // from incoming packets.
00245     PayloadType currentPayloadType;
00246     // when the queue is created
00247     timeval initialTime;
00248 };
00249 
00255 class __EXPORT OutgoingDataQueueBase:
00256     public virtual RTPQueueBase
00257 {
00258 public:
00259     inline size_t
00260     getDefaultMaxSendSegmentSize()
00261     { return defaultMaxSendSegmentSize;}
00262 
00269     inline void
00270     setMaxSendSegmentSize(size_t size)
00271     { maxSendSegmentSize = size; }
00272 
00273     inline size_t
00274     getMaxSendSegmentSize()
00275     { return maxSendSegmentSize; }
00276 
00277 protected:
00278     OutgoingDataQueueBase();
00279 
00280     inline virtual
00281     ~OutgoingDataQueueBase()
00282     { }
00283 
00284 private:
00285     static const size_t defaultMaxSendSegmentSize;
00286     // maximum packet size before fragmenting sends.
00287     size_t maxSendSegmentSize;
00288 };
00289 
00295 class __EXPORT IncomingDataQueueBase:
00296     public virtual RTPQueueBase
00297 {
00298 public:
00299     inline size_t getDefaultMaxRecvPacketSize() const
00300     { return defaultMaxRecvPacketSize; }
00301 
00302     inline size_t
00303     getMaxRecvPacketSize() const
00304     { return maxRecvPacketSize; }
00305 
00316     inline void
00317     setMaxRecvPacketSize(size_t maxsize)
00318     { maxRecvPacketSize = maxsize; }
00319 
00320 protected:
00321     IncomingDataQueueBase()
00322     { setMaxRecvPacketSize(getDefaultMaxRecvPacketSize()); }
00323 
00324     inline virtual
00325     ~IncomingDataQueueBase()
00326     { }
00327 
00328 private:
00329     static const size_t defaultMaxRecvPacketSize;
00330     // filter value for received packets length.
00331     size_t maxRecvPacketSize;
00332 };
00333  // queuebase
00335 
00336 END_NAMESPACE
00337 
00338 #endif  //CCXX_RTP_QUEUEBASE_H_
00339 

Generated on 14 Aug 2013 for ccRTP by  doxygen 1.4.7