ccRTP
ext.h
Go to the documentation of this file.
1 // Copyright (C) 1999-2003 Open Source Telecom Corporation.
2 //
3 // This program is free software; you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation; either version 2 of the License, or
6 // (at your option) any later version.
7 //
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public License
14 // along with GNU ccRTP. If not, see <http://www.gnu.org/licenses/>.
15 //
16 // As a special exception, you may use this file as part of a free software
17 // library without restriction. Specifically, if other files instantiate
18 // templates or use macros or inline functions from this file, or you compile
19 // this file and link it with other files to produce an executable, this
20 // file does not by itself cause the resulting executable to be covered by
21 // the GNU General Public License. This exception does not however
22 // invalidate any other reasons why the executable file might be covered by
23 // the GNU General Public License.
24 //
25 // This exception applies only to the code released under the name GNU
26 // ccRTP. If you copy code from other releases into a copy of GNU
27 // ccRTP, as the General Public License permits, the exception does
28 // not apply to the code that you add in this way. To avoid misleading
29 // anyone as to the status of such modified files, you must delete
30 // this exception notice from them.
31 //
32 // If you write modifications of your own for GNU ccRTP, it is your choice
33 // whether to permit this exception to apply to your modifications.
34 // If you do not wish that, delete this exception notice.
35 //
36 
42 #ifndef CCXX_RTP_EXT_H
43 #define CCXX_RTP_EXT_H
44 
45 #ifndef COMMONCPP_SOCKET_H_
46 #include <commoncpp/socket.h>
47 #include <commoncpp/udp.h>
48 #endif
49 
50 #include <ccrtp/ioqueue.h>
51 #include <ccrtp/channel.h>
52 
53 NAMESPACE_COMMONCPP
54 
70 class __EXPORT RTPDuplex : public RTPDataQueue,
71  protected UDPReceive, public UDPTransmit
72 {
73 public:
79  RTPDuplex(const InetAddress &bind, tpport_t local, tpport_t remote);
80 
84  virtual
85  ~RTPDuplex();
86 
93  UDPTransmit::Error
94  connect(const InetHostAddress &host, tpport_t port = 0);
95 
96 protected:
97 
102  bool
104  { return isPendingReceive(timeout); }
105 
111  size_t
112  sendData(const unsigned char *const buffer, size_t len)
113  { return UDPTransmit::transmit((const char *)buffer, len); }
114 
122  size_t
123  recvData(unsigned char *buffer, size_t len,
124  InetHostAddress& na, tpport_t& tp)
125  { /* na = UDPReceive::getPeer(&tp); FIX name ambiguity */
126  return UDPReceive::receive(buffer, len); }
127 
132  inline void
133  setDataPeer(const InetAddress&, tpport_t)
134  { }
135 
140  inline void
141  setControlPeer(const InetAddress&, tpport_t)
142  { }
143 
144  inline size_t
146  {
147  // the const cast is a trick only needed for cc++2 <= 1.0.10
148  size_t len; ccioctl(const_cast<RTPDuplex*>(this)->UDPReceive::getReceiver(),FIONREAD,len); return len;
149  }
150 
154  SyncSource &getPeer();
155 
156 private:
157  tpport_t dataBasePort;
158 };
159  // rtpext
161 
162 END_NAMESPACE
163 
164 #endif //CCXX_RTP_EXT_H
165 
Generic RTP input/output queues.
size_t getNextDataPacketSize() const
Definition: ext.h:145
uint32 microtimeout_t
Time interval expressed in microseconds.
Definition: base.h:67
Synchronization source in an RTP session.
Definition: sources.h:192
Definition of socket classes for different underlying transport and/or network protocols that can be ...
bool isPendingData(microtimeout_t timeout)
Definition: ext.h:103
size_t recvData(unsigned char *buffer, size_t len, InetHostAddress &na, tpport_t &tp)
Definition: ext.h:123
void setDataPeer(const InetAddress &, tpport_t)
Definition: ext.h:133
size_t sendData(const unsigned char *const buffer, size_t len)
Definition: ext.h:112
size_t ccioctl(int so, int request, size_t &len)
Definition: channel.h:45
A packet queue handler for building different kinds of RTP protocol systems.
Definition: ioqueue.h:74
void setControlPeer(const InetAddress &, tpport_t)
Definition: ext.h:141
A peer associated RTP socket pair for physically connected peer hosts.
Definition: ext.h:70