ccRTP
ioqueue.h
Go to the documentation of this file.
00001 // Copyright (C) 2001-2015 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 Lesser General Public License
00014 // along with GNU ccRTP.  If not, see <http://www.gnu.org/licenses/>.
00015 //
00016 // As a special exception, you may use this file as part of a free software
00017 // library without restriction.  Specifically, if other files instantiate
00018 // templates or use macros or inline functions from this file, or you compile
00019 // this file and link it with other files to produce an executable, this
00020 // file does not by itself cause the resulting executable to be covered by
00021 // the GNU General Public License.  This exception does not however
00022 // invalidate any other reasons why the executable file might be covered by
00023 // the GNU General Public License.
00024 //
00025 // This exception applies only to the code released under the name GNU
00026 // ccRTP.  If you copy code from other releases into a copy of GNU
00027 // ccRTP, as the General Public License permits, the exception does
00028 // not apply to the code that you add in this way.  To avoid misleading
00029 // anyone as to the status of such modified files, you must delete
00030 // this exception notice from them.
00031 //
00032 // If you write modifications of your own for GNU ccRTP, it is your choice
00033 // whether to permit this exception to apply to your modifications.
00034 // If you do not wish that, delete this exception notice.
00035 //
00036 
00043 #ifndef CCXX_RTP_IOQUEUE_H_
00044 #define CCXX_RTP_IOQUEUE_H_
00045 
00046 #include <ccrtp/iqueue.h>
00047 #include <ccrtp/oqueue.h>
00048 
00049 NAMESPACE_COMMONCPP
00050 
00074 class __EXPORT RTPDataQueue :
00075     public IncomingDataQueue,
00076     public OutgoingDataQueue
00077 {
00078 public:
00098     typedef enum {
00099         tosBestEffort,      
00100         tosEnhanced         
00101     }       Tos;
00102 
00115     inline void
00116     setTypeOfService(Tos tos)
00117     { typeOfService = tos; }
00118 
00123     inline void enableStack()
00124     { dataServiceActive = true; }
00125 
00129         inline void disableStack()
00130         { dataServiceActive = false; }
00131 
00137     inline bool
00138     isActive() const
00139     { return dataServiceActive; }
00140 
00200     uint32
00201     getCurrentTimestamp() const;
00202 
00210     void
00211     setSessionBandwidth(uint32 bw)
00212     { sessionBw = bw; }
00213 
00214     uint32
00215     getDefaultSessionBandwidth() const
00216     { return defaultSessionBw; }
00217 
00218     uint32
00219     getSessionBandwidth() const
00220     { return sessionBw; }
00221 
00225     inline void
00226     setTimeclock()
00227     { timeclock.setTimer(); }
00228 
00234     inline timeout_t
00235     getTimeclock() const
00236     { return timeclock.getElapsed(); }
00237 
00238 protected:
00239 
00247     RTPDataQueue(uint32 size = defaultMembersHashSize);
00248 
00264     RTPDataQueue(uint32* ssrc, uint32 size = defaultMembersHashSize);
00265 
00270     inline virtual
00271     ~RTPDataQueue()
00272     { endQueue(); }
00273 
00277         inline virtual void
00278     timerTick()
00279     { return; }
00280 
00281     void renewLocalSSRC()
00282         {IncomingDataQueue::renewLocalSSRC();}
00283 
00284 private:
00285     RTPDataQueue(const RTPDataQueue &o);
00286 
00287     RTPDataQueue&
00288     operator=(const RTPDataQueue &o);
00289 
00295     void
00296     initQueue();
00297 
00298 protected:
00302     void
00303     endQueue();
00304 
00312     virtual bool
00313     isPendingData(microtimeout_t timeout) = 0;
00314 
00315 private:
00316     // true if connection "active"
00317     volatile bool dataServiceActive;
00318     Tos typeOfService;
00319     TimerPort timeclock;
00320     /* RTP session bandwidth control */
00321     static const uint32 defaultSessionBw;
00322     uint32 sessionBw;
00323 
00324 
00325 };
00326  // ioqueue
00328 
00329 END_NAMESPACE
00330 
00331 #endif  //CCXX_RTP_IOQUEUE_H_
00332