00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00043 #ifndef CCXX_RTP_POOL_H
00044 #define CCXX_RTP_POOL_H
00045
00046 #include <list>
00047 #include <ccrtp/rtp.h>
00048
00049 #ifdef CCXX_NAMESPACES
00050 namespace ost {
00051 using std::list;
00052 #endif
00053
00054 typedef TRTPSessionBase<> RTPSessionBase;
00055
00056 class RTPSessionBaseHandler
00057 {
00058 public:
00059 size_t
00060 takeInDataPacket(RTPSessionBase& s)
00061 { return s.takeInDataPacket(); }
00062
00063 size_t
00064 dispatchDataPacket(RTPSessionBase& s)
00065 { return s.dispatchDataPacket(); }
00066
00067 void
00068 controlReceptionService(RTPSessionBase& s)
00069 { s.controlReceptionService(); }
00070
00071 void
00072 controlTransmissionService(RTPSessionBase& s)
00073 { s.controlTransmissionService(); }
00074
00075 inline SOCKET getDataRecvSocket(RTPSessionBase& s) const
00076 { return s.getDataRecvSocket(); }
00077
00078 inline SOCKET getControlRecvSocket(RTPSessionBase& s) const
00079 { return s.getControlRecvSocket(); }
00080 };
00081
00095 class __EXPORT RTPSessionPool: public RTPSessionBaseHandler
00096 {
00097 public:
00098 RTPSessionPool();
00099
00100 inline virtual ~RTPSessionPool()
00101 { }
00102
00103 bool
00104 addSession(RTPSessionBase& session);
00105
00106 bool
00107 removeSession(RTPSessionBase& session);
00108
00109 size_t
00110 getPoolLength() const;
00111
00112 virtual void startRunning() = 0;
00113
00114 inline bool isActive()
00115 { return poolActive; }
00116
00117 protected:
00118 inline void setActive()
00119 { poolActive = true; }
00120
00121 inline timeval getPoolTimeout()
00122 { return poolTimeout; }
00123
00124 inline void setPoolTimeout(int sec, int usec)
00125 { poolTimeout.tv_sec = sec; poolTimeout.tv_usec = usec; }
00126
00127 inline void setPoolTimeout(struct timeval to)
00128 { poolTimeout = to; }
00129
00130 std::list<RTPSessionBase*> sessionList;
00131 typedef std::list<RTPSessionBase*>::iterator PoolIterator;
00132
00133 #ifndef WIN32
00134 fd_set recvSocketSet;
00135 SOCKET highestSocket;
00136 #endif
00137
00138 private:
00139 mutable ThreadLock poolLock;
00140 timeval poolTimeout;
00141 mutable bool poolActive;
00142 };
00143
00144
00145 class __EXPORT SingleRTPSessionPool :
00146 public RTPSessionPool,
00147 public Thread
00148 {
00149 public:
00153 SingleRTPSessionPool(int pri = 0) :
00154 RTPSessionPool(),
00155 Thread(pri)
00156 { }
00157
00158 ~SingleRTPSessionPool()
00159 { }
00160
00161 void startRunning()
00162 { setActive(); Thread::start(); }
00163
00164 protected:
00169 void run();
00170 };
00171
00172 #ifdef CCXX_NAMESPACES
00173 }
00174 #endif
00175
00176 #endif //CCXX_RTP_POOL_H
00177