Skip to content

Commit 1955638

Browse files
committed
Allow the RDMInflator to be used with both native E1.33 and LLRP RDM messages
1 parent 9583793 commit 1955638

File tree

2 files changed

+29
-8
lines changed

2 files changed

+29
-8
lines changed

libs/acn/RDMInflator.cpp

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,31 @@ using std::string;
3232
/**
3333
* Create a new RDM inflator
3434
*/
35-
RDMInflator::RDMInflator()
36-
: BaseInflator(PDU::ONE_BYTE) {
35+
RDMInflator::RDMInflator(unsigned int vector)
36+
: BaseInflator(PDU::ONE_BYTE),
37+
m_vector(vector) {
3738
}
3839

3940
/**
40-
* Set a RDMHandler to run when receiving a RDM message.
41-
* @param handler the callback to invoke when there is rdm data for this
41+
* Set an RDMMessageHandler to run when receiving a RDM message.
42+
* @param handler the callback to invoke when there is RDM data for this
4243
* universe.
4344
*/
4445
void RDMInflator::SetRDMHandler(RDMMessageHandler *handler) {
4546
m_rdm_handler.reset(handler);
4647
}
4748

4849

50+
/**
51+
* Set a GenericRDMHandler to run when receiving a RDM message.
52+
* @param handler the callback to invoke when there is RDM data for this
53+
* universe.
54+
*/
55+
void RDMInflator::SetGenericRDMHandler(GenericRDMMessageHandler *handler) {
56+
m_generic_rdm_handler.reset(handler);
57+
}
58+
59+
4960
/*
5061
* Decode the RDM 'header', which is 0 bytes in length.
5162
* @param headers the HeaderSet to add to
@@ -76,11 +87,13 @@ bool RDMInflator::HandlePDUData(uint32_t vector,
7687

7788
string rdm_message(reinterpret_cast<const char*>(&data[0]), pdu_len);
7889

79-
E133Header e133_header = headers.GetE133Header();
80-
8190
if (m_rdm_handler.get()) {
91+
E133Header e133_header = headers.GetE133Header();
92+
8293
m_rdm_handler->Run(&headers.GetTransportHeader(), &e133_header,
8394
rdm_message);
95+
} else if (m_generic_rdm_handler.get()) {
96+
m_generic_rdm_handler->Run(&headers, rdm_message);
8497
} else {
8598
OLA_WARN << "No RDM handler defined!";
8699
}

libs/acn/RDMInflator.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,18 @@ class RDMInflator: public BaseInflator {
4141
const std::string& // rdm data
4242
> RDMMessageHandler;
4343

44-
RDMInflator();
44+
typedef ola::Callback2<void,
45+
const HeaderSet*, // the HeaderSet
46+
const std::string& // rdm data
47+
> GenericRDMMessageHandler;
48+
49+
RDMInflator(unsigned int vector = ola::acn::VECTOR_FRAMING_RDMNET);
4550
~RDMInflator() {}
4651

47-
uint32_t Id() const { return ola::acn::VECTOR_FRAMING_RDMNET; }
52+
uint32_t Id() const { return m_vector; }
4853

4954
void SetRDMHandler(RDMMessageHandler *handler);
55+
void SetGenericRDMHandler(GenericRDMMessageHandler *handler);
5056

5157
static const unsigned int VECTOR_RDMNET_DATA = 0xcc;
5258

@@ -65,6 +71,8 @@ class RDMInflator: public BaseInflator {
6571

6672
private:
6773
std::auto_ptr<RDMMessageHandler> m_rdm_handler;
74+
std::auto_ptr<GenericRDMMessageHandler> m_generic_rdm_handler;
75+
unsigned int m_vector;
6876
};
6977
} // namespace acn
7078
} // namespace ola

0 commit comments

Comments
 (0)