Open Lighting Architecture: libs/acn/E131Header.h Source File

| Open Lighting Architecture 0.10.9

Loading...
Searching...
No Matches
E131Header.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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
15 *
16 * E131Header.h
17 * The E1.31 Header
18 * Copyright (C) 2007 Simon Newton
19 */
20
21#ifndef LIBS_ACN_E131HEADER_H_
22#define LIBS_ACN_E131HEADER_H_
23
24#include <ola/base/Macro.h>
25
26#include <stdint.h>
27#include <string>
28
29namespace ola {
30namespace acn {
31
32/*
33 * Header for the E131 layer
34 */
35 class E131Header {
36 public:
37 E131Header()
38 : m_priority(0),
39 m_sequence(0),
40 m_universe(0),
41 m_is_preview(false),
42 m_has_terminated(false),
43 m_is_rev2(false) {
44 }
45 E131Header(const std::string &source,
46 uint8_t priority,
47 uint8_t sequence,
48 uint16_t universe,
49 bool is_preview = false,
50 bool has_terminated = false,
51 bool is_rev2 = false)
52 : m_source(source),
53 m_priority(priority),
54 m_sequence(sequence),
55 m_universe(universe),
56 m_is_preview(is_preview),
57 m_has_terminated(has_terminated),
58 m_is_rev2(is_rev2) {
59 }
60 ~E131Header() {}
61
62 const std::string Source() const { return m_source; }
63 uint8_t Priority() const { return m_priority; }
64 uint8_t Sequence() const { return m_sequence; }
65 uint16_t Universe() const { return m_universe; }
66 bool PreviewData() const { return m_is_preview; }
67 bool StreamTerminated() const { return m_has_terminated; }
68
69 bool UsingRev2() const { return m_is_rev2; }
70
71 bool operator==(const E131Header &other) const {
72 return m_source == other.m_source &&
73 m_priority == other.m_priority &&
74 m_sequence == other.m_sequence &&
75 m_universe == other.m_universe &&
76 m_is_preview == other.m_is_preview &&
77 m_has_terminated == other.m_has_terminated &&
78 m_is_rev2 == other.m_is_rev2;
79 }
80
81 enum { SOURCE_NAME_LEN = 64 };
82
83 PACK(
84 struct e131_pdu_header_s {
85 char source[SOURCE_NAME_LEN];
86 uint8_t priority;
87 uint16_t reserved;
88 uint8_t sequence;
89 uint8_t options;
90 uint16_t universe;
91 });
92 typedef struct e131_pdu_header_s e131_pdu_header;
93
94 static const uint8_t PREVIEW_DATA_MASK = 0x80;
95 static const uint8_t STREAM_TERMINATED_MASK = 0x40;
96
97 private:
98 std::string m_source;
99 uint8_t m_priority;
100 uint8_t m_sequence;
101 uint16_t m_universe;
102 bool m_is_preview;
103 bool m_has_terminated;
104 bool m_is_rev2;
105};
106
107
108 class E131Rev2Header: public E131Header {
109 public:
110 E131Rev2Header(const std::string &source,
111 uint8_t priority,
112 uint8_t sequence,
113 uint16_t universe,
114 bool is_preview = false,
115 bool has_terminated = false)
116 : E131Header(source, priority, sequence, universe, is_preview,
117 has_terminated, true) {
118 }
119
120 enum { REV2_SOURCE_NAME_LEN = 32 };
121
122 typedef struct {
123 char source[REV2_SOURCE_NAME_LEN];
124 uint8_t priority;
125 uint8_t sequence;
126 uint16_t universe;
127 } e131_rev2_pdu_header;
128};
129} // namespace acn
130} // namespace ola
131#endif // LIBS_ACN_E131HEADER_H_
Macro.h
Helper macros.
PACK
#define PACK(__Declaration__)
Pack structures.
Definition Macro.h:171
ola::acn
ACN related code.
ola
The namespace containing all OLA symbols.
Definition Credentials.cpp:44
ola::acn::E131Rev2Header::e131_rev2_pdu_header
Definition E131Header.h:122