ccRTP
|
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 <cc++/pointer.h> 00048 #include <ccrtp/rtppkt.h> 00049 #include <ccrtp/sources.h> 00050 00051 #ifdef CCXX_NAMESPACES 00052 namespace ost { 00053 #endif 00054 00071 class __EXPORT AppDataUnit 00072 { 00073 public: 00074 AppDataUnit(const IncomingRTPPkt& packet, const SyncSource& src); 00075 00076 inline ~AppDataUnit() 00077 { } 00078 00082 AppDataUnit(const AppDataUnit& src); 00083 00090 AppDataUnit& 00091 operator=(const AppDataUnit& source); 00092 00096 inline PayloadType 00097 getType() const 00098 { return datablock->getPayloadType(); } 00099 00107 inline const uint8* const 00108 getData() const 00109 { return datablock->getPayload(); } 00110 00114 size_t 00115 getSize() const 00116 { return datablock->getPayloadSize(); } 00117 00121 inline const SyncSource& 00122 getSource() const 00123 { return *source; } 00124 00130 inline bool 00131 isMarked() const 00132 { return datablock->isMarked(); } 00133 00137 inline uint16 00138 getSeqNum() const 00139 { return datablock->getSeqNum(); } 00140 00144 inline uint8 00145 getContributorsCount() const 00146 { return (uint8)datablock->getCSRCsCount(); } 00147 00153 inline const uint32* 00154 getContributorsID() const 00155 { return datablock->getCSRCs(); } 00156 00157 private: 00158 Pointer<const IncomingRTPPkt> datablock; 00159 const SyncSource* source; 00160 }; 00161 00169 class __EXPORT RTPQueueBase 00170 { 00171 public: 00179 inline bool 00180 setPayloadFormat(const PayloadFormat& pf) 00181 { 00182 currentPayloadType = pf.getPayloadType(); 00183 currentRTPClockRate = pf.getRTPClockRate(); 00184 return true; 00185 } 00186 00187 inline uint32 getLocalSSRC() const 00188 { return localSSRC; } 00189 00198 inline uint32 getCurrentRTPClockRate() const 00199 { return currentRTPClockRate; } 00200 00201 inline PayloadType getCurrentPayloadType() const 00202 { return currentPayloadType; } 00203 00204 inline timeval getInitialTime() const 00205 { return initialTime; } 00206 00207 protected: 00212 RTPQueueBase(uint32 *ssrc = NULL); 00213 00214 inline void setLocalSSRC(uint32 ssrc) 00215 { localSSRC = ssrc; localSSRCNetwork = htonl(ssrc); } 00216 00217 inline uint32 getLocalSSRCNetwork() const 00218 { return localSSRCNetwork; } 00219 00220 virtual 00221 ~RTPQueueBase() 00222 { } 00223 00230 inline virtual size_t 00231 dispatchBYE(const std::string&) 00232 { return 0; } 00233 00234 inline virtual void 00235 renewLocalSSRC() 00236 { } 00237 00238 private: 00239 // local SSRC 32-bit identifier 00240 uint32 localSSRC; 00241 // SSRC in network byte order 00242 uint32 localSSRCNetwork; 00243 // RTP clock rate for the current payload type. 00244 uint32 currentRTPClockRate; 00245 // Current payload type set for outgoing packets and expected 00246 // from incoming packets. 00247 PayloadType currentPayloadType; 00248 // when the queue is created 00249 timeval initialTime; 00250 }; 00251 00257 class __EXPORT OutgoingDataQueueBase: 00258 public virtual RTPQueueBase 00259 { 00260 public: 00261 inline size_t 00262 getDefaultMaxSendSegmentSize() 00263 { return defaultMaxSendSegmentSize;} 00264 00271 inline void 00272 setMaxSendSegmentSize(size_t size) 00273 { maxSendSegmentSize = size; } 00274 00275 inline size_t 00276 getMaxSendSegmentSize() 00277 { return maxSendSegmentSize; } 00278 00279 protected: 00280 OutgoingDataQueueBase(); 00281 00282 inline virtual 00283 ~OutgoingDataQueueBase() 00284 { } 00285 00286 private: 00287 static const size_t defaultMaxSendSegmentSize; 00288 // maximum packet size before fragmenting sends. 00289 size_t maxSendSegmentSize; 00290 }; 00291 00297 class __EXPORT IncomingDataQueueBase: 00298 public virtual RTPQueueBase 00299 { 00300 public: 00301 inline size_t getDefaultMaxRecvPacketSize() const 00302 { return defaultMaxRecvPacketSize; } 00303 00304 inline size_t 00305 getMaxRecvPacketSize() const 00306 { return maxRecvPacketSize; } 00307 00318 inline void 00319 setMaxRecvPacketSize(size_t maxsize) 00320 { maxRecvPacketSize = maxsize; } 00321 00322 protected: 00323 IncomingDataQueueBase() 00324 { setMaxRecvPacketSize(getDefaultMaxRecvPacketSize()); } 00325 00326 inline virtual 00327 ~IncomingDataQueueBase() 00328 { } 00329 00330 private: 00331 static const size_t defaultMaxRecvPacketSize; 00332 // filter value for received packets length. 00333 size_t maxRecvPacketSize; 00334 }; 00335 // queuebase 00337 00338 #ifdef CCXX_NAMESPACES 00339 } 00340 #endif 00341 00342 #endif //CCXX_RTP_QUEUEBASE_H_ 00343