ccRTP 2.1.2
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
duplex.cpp
Go to the documentation of this file.
1 // Copyright (C) 1999-2005 Open Source Telecom Corporation.
2 // Copyright (C) 2006-2014 David Sugar, Tycho Softworks.
3 // Copyright (C) 2015 Cherokees of Idaho.
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 //
19 // As a special exception, you may use this file as part of a free software
20 // library without restriction. Specifically, if other files instantiate
21 // templates or use macros or inline functions from this file, or you compile
22 // this file and link it with other files to produce an executable, this
23 // file does not by itself cause the resulting executable to be covered by
24 // the GNU General Public License. This exception does not however
25 // invalidate any other reasons why the executable file might be covered by
26 // the GNU General Public License.
27 //
28 // This exception applies only to the code released under the name GNU
29 // ccRTP. If you copy code from other releases into a copy of GNU
30 // ccRTP, as the General Public License permits, the exception does
31 // not apply to the code that you add in this way. To avoid misleading
32 // anyone as to the status of such modified files, you must delete
33 // this exception notice from them.
34 //
35 // If you write modifications of your own for GNU ccRTP, it is your choice
36 // whether to permit this exception to apply to your modifications.
37 // If you do not wish that, delete this exception notice.
38 //
39 // RTPDuplex class implementation
40 //
41 
42 #include "private.h"
43 #include <ccrtp/ext.h>
44 
45 NAMESPACE_COMMONCPP
46 
47 RTPDuplex::RTPDuplex(const InetAddress &ia, tpport_t local, tpport_t remote) :
48 RTPDataQueue(), UDPReceive(ia, local), UDPTransmit(ia, remote)
49 {
50  dataBasePort = local;
51 }
52 
54 {
55  // Terminate both sockets.
56  endTransmitter();
57  endReceiver();
58 }
59 
60 UDPSocket::Error RTPDuplex::connect(const InetHostAddress &ia, tpport_t port)
61 {
62  UDPTransmit::Error rtn;
63 
64  if(!port)
65  port = dataBasePort;
66 
67  rtn = UDPTransmit::connect(ia, port);
68 
69  if(!rtn)
70  rtn = UDPReceive::connect(ia, port + 1);
71  if(rtn)
72  return rtn;
73 
74  enableStack();
75 
76  return UDPTransmit::errSuccess;
77 }
78 
79 END_NAMESPACE
80 
ccRTP Stack extensions.
tpport_t dataBasePort
Definition: ext.h:159
Declaration of ccRTP internal stuff.
virtual ~RTPDuplex()
Definition: duplex.cpp:53
RTPDuplex(const InetAddress &bind, tpport_t local, tpport_t remote)
Definition: duplex.cpp:47
void enableStack()
Enable packet queue processing in the stack.
Definition: ioqueue.h:123
UDPTransmit::Error connect(const InetHostAddress &host, tpport_t port=0)
Definition: duplex.cpp:60
A packet queue handler for building different kinds of RTP protocol systems.
Definition: ioqueue.h:74