Open Lighting Architecture
Main Page
Modules
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
plugins
e131
e131
UDPTransport.h
1
/*
2
* This program is free software; you can redistribute it and/or modify
3
* it under the terms of the GNU General Public License as published by
4
* the Free Software Foundation; either version 2 of the License, or
5
* (at your option) any later version.
6
*
7
* This program is distributed in the hope that it will be useful,
8
* but WITHOUT ANY WARRANTY; without even the implied warranty of
9
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
* GNU Library General Public License for more details.
11
*
12
* You should have received a copy of the GNU General Public License
13
* along with this program; if not, write to the Free Software
14
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15
*
16
* UDPTransport.h
17
* Interface for the UDPTransport class
18
* Copyright (C) 2007-2009 Simon Newton
19
*/
20
21
#ifndef PLUGINS_E131_E131_UDPTRANSPORT_H_
22
#define PLUGINS_E131_E131_UDPTRANSPORT_H_
23
24
#include "
ola/acn/ACNPort.h
"
25
#include "ola/network/IPV4Address.h"
26
#include "ola/network/Socket.h"
27
#include "plugins/e131/e131/PDU.h"
28
#include "plugins/e131/e131/PreamblePacker.h"
29
#include "plugins/e131/e131/Transport.h"
30
31
namespace
ola {
32
namespace
plugin {
33
namespace
e131 {
34
35
using
ola::network::IPV4Address
;
36
37
/*
38
* The OutgoingUDPTransport is a small shim that provides the options to
39
* UDPTransportImpl.
40
*/
41
class
OutgoingUDPTransport
:
public
OutgoingTransport
{
42
public
:
43
OutgoingUDPTransport
(
class
OutgoingUDPTransportImpl
*impl,
44
const
IPV4Address
&destination,
45
uint16_t port =
ola::acn::ACN_PORT
)
46
: m_impl(impl),
47
m_destination(destination),
48
m_port(port) {
49
}
50
~
OutgoingUDPTransport
() {}
51
52
bool
Send(
const
PDUBlock<PDU>
&pdu_block);
53
54
private
:
55
class
OutgoingUDPTransportImpl
*m_impl;
56
IPV4Address
m_destination;
57
uint16_t m_port;
58
59
OutgoingUDPTransport
(
const
OutgoingUDPTransport
&);
60
OutgoingUDPTransport
& operator=(
const
OutgoingUDPTransport
&);
61
};
62
63
67
class
OutgoingUDPTransportImpl
{
68
public
:
69
OutgoingUDPTransportImpl
(
ola::network::UDPSocket
*socket,
70
PreamblePacker
*packer = NULL)
71
: m_socket(socket),
72
m_packer(packer),
73
m_free_packer(
false
) {
74
if
(!m_packer) {
75
m_packer =
new
PreamblePacker
();
76
m_free_packer =
true
;
77
}
78
}
79
~
OutgoingUDPTransportImpl
() {
80
if
(m_free_packer)
81
delete
m_packer;
82
}
83
84
bool
Send(
const
PDUBlock<PDU>
&pdu_block,
85
const
IPV4Address
&destination,
86
uint16_t port);
87
88
private
:
89
ola::network::UDPSocket
*m_socket;
90
PreamblePacker
*m_packer;
91
bool
m_free_packer;
92
};
93
94
100
class
IncomingUDPTransport
{
101
public
:
102
IncomingUDPTransport
(
ola::network::UDPSocket
*socket,
103
class
BaseInflator
*inflator);
104
~
IncomingUDPTransport
() {
105
if
(m_recv_buffer)
106
delete
[] m_recv_buffer;
107
}
108
109
void
Receive();
110
111
private
:
112
ola::network::UDPSocket
*m_socket;
113
class
BaseInflator
*m_inflator;
114
uint8_t *m_recv_buffer;
115
};
116
}
// namespace e131
117
}
// namespace plugin
118
}
// namespace ola
119
#endif // PLUGINS_E131_E131_UDPTRANSPORT_H_
Generated on Fri Apr 4 2014 11:54:23 for Open Lighting Architecture by
1.8.1.2