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 General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16 //
17 // As a special exception, you may use this file as part of a free software
18 // library without restriction. Specifically, if other files instantiate
19 // templates or use macros or inline functions from this file, or you compile
20 // this file and link it with other files to produce an executable, this
21 // file does not by itself cause the resulting executable to be covered by
22 // the GNU General Public License. This exception does not however
23 // invalidate any other reasons why the executable file might be covered by
24 // the GNU General Public License.
25 //
26 // This exception applies only to the code released under the name GNU
27 // ccRTP. If you copy code from other releases into a copy of GNU
28 // ccRTP, as the General Public License permits, the exception does
29 // not apply to the code that you add in this way. To avoid misleading
30 // anyone as to the status of such modified files, you must delete
31 // this exception notice from them.
32 //
33 // If you write modifications of your own for GNU ccRTP, it is your choice
34 // whether to permit this exception to apply to your modifications.
35 // If you do not wish that, delete this exception notice.
36 //
37 
43 #ifndef CCXX_RTP_EXT_H
44 #define CCXX_RTP_EXT_H
45 
46 #ifndef COMMONCPP_SOCKET_H_
47 #include <commoncpp/socket.h>
48 #include <commoncpp/udp.h>
49 #endif
50 
51 #include <ccrtp/ioqueue.h>
52 #include <ccrtp/channel.h>
53 
54 NAMESPACE_COMMONCPP
55 
71 class __EXPORT RTPDuplex : public RTPDataQueue,
72  protected UDPReceive, public UDPTransmit
73 {
74 public:
80  RTPDuplex(const InetAddress &bind, tpport_t local, tpport_t remote);
81 
85  virtual
86  ~RTPDuplex();
87 
94  UDPTransmit::Error
95  connect(const InetHostAddress &host, tpport_t port = 0);
96 
97 protected:
98 
103  bool
105  { return isPendingReceive(timeout); }
106 
112  size_t
113  sendData(const unsigned char *const buffer, size_t len)
114  { return UDPTransmit::transmit((const char *)buffer, len); }
115 
123  size_t
124  recvData(unsigned char *buffer, size_t len,
125  InetHostAddress& na, tpport_t& tp)
126  { /* na = UDPReceive::getPeer(&tp); FIX name ambiguity */
127  return UDPReceive::receive(buffer, len); }
128 
133  inline void
134  setDataPeer(const InetAddress&, tpport_t)
135  { }
136 
141  inline void
142  setControlPeer(const InetAddress&, tpport_t)
143  { }
144 
145  inline size_t
147  {
148  // the const cast is a trick only needed for cc++2 <= 1.0.10
149  size_t len; ccioctl(const_cast<RTPDuplex*>(this)->UDPReceive::getReceiver(),FIONREAD,len); return len;
150  }
151 
155  SyncSource &getPeer();
156 
157 private:
158  tpport_t dataBasePort;
159 };
160  // rtpext
162 
163 END_NAMESPACE
164 
165 #endif //CCXX_RTP_EXT_H
166 
Generic RTP input/output queues.
uint32 microtimeout_t
Time interval expressed in microseconds.
Definition: base.h:68
size_t getNextDataPacketSize() const
Definition: ext.h:146
Synchronization source in an RTP session.
Definition: sources.h:194
Definition of socket classes for different underlying transport and/or network protocols that can be ...
bool isPendingData(microtimeout_t timeout)
Definition: ext.h:104
size_t recvData(unsigned char *buffer, size_t len, InetHostAddress &na, tpport_t &tp)
Definition: ext.h:124
void setDataPeer(const InetAddress &, tpport_t)
Definition: ext.h:134
size_t sendData(const unsigned char *const buffer, size_t len)
Definition: ext.h:113
size_t ccioctl(int so, int request, size_t &len)
Definition: channel.h:46
A packet queue handler for building different kinds of RTP protocol systems.
Definition: ioqueue.h:75
void setControlPeer(const InetAddress &, tpport_t)
Definition: ext.h:142
A peer associated RTP socket pair for physically connected peer hosts.
Definition: ext.h:71