2021-05-27 10:59:22 -04:00
|
|
|
/*
|
|
|
|
receiver.h
|
|
|
|
|
|
|
|
Copyright (c) 2020 Kevin Matz (kevin.matz@gmail.com)
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in all
|
|
|
|
copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
SOFTWARE.
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2021-08-25 10:57:31 -04:00
|
|
|
#include "rlp/component.h"
|
2021-05-27 10:59:22 -04:00
|
|
|
#include "data.h"
|
2021-06-02 09:29:27 -04:00
|
|
|
#include "extended.h"
|
2021-08-28 15:28:52 -04:00
|
|
|
#include "arbitratinguniverse.h"
|
2021-08-15 23:36:29 -04:00
|
|
|
|
2021-05-27 10:59:22 -04:00
|
|
|
#include <unordered_map>
|
2021-09-04 17:38:55 -04:00
|
|
|
#include <set>
|
2021-06-02 09:29:27 -04:00
|
|
|
#include <vector>
|
2021-05-27 10:59:22 -04:00
|
|
|
|
2021-08-28 09:01:33 -04:00
|
|
|
namespace sACN {
|
2021-05-27 10:59:22 -04:00
|
|
|
|
2021-08-25 17:20:33 -04:00
|
|
|
/**
|
2021-08-28 09:01:33 -04:00
|
|
|
* @brief \cite sACN 3.6 Receiver: A receiver is the intended target of
|
|
|
|
* information from a source.
|
|
|
|
*
|
2021-08-28 11:24:01 -04:00
|
|
|
* > A receiver may listen on multiple universes.
|
|
|
|
*
|
|
|
|
* > \cite sACN 6.2.3.4 Requirements for Merging and Arbitrating
|
|
|
|
* > The ability of devices to merge or arbitrate between multiple sources at
|
|
|
|
* > highest active priority shall be declared in user documentation for the
|
|
|
|
* > device.
|
|
|
|
*
|
|
|
|
* sACN::Receiver has the ability to arbitrate between multiple source.
|
|
|
|
*
|
|
|
|
* > \cite sACN If merging or arbitration is implemented, the maximum number of
|
|
|
|
* > sources which can be correctly handled shall be declared in user
|
|
|
|
* > documentation for the device.
|
|
|
|
*
|
|
|
|
* sACN::Receiver has a merge limit maximum constrained by device memory, not
|
2021-08-28 15:28:52 -04:00
|
|
|
* to excede 18,446,744,073,709,551,615 (2^64) sources on most platforms.
|
2021-08-28 11:24:01 -04:00
|
|
|
*
|
|
|
|
* > \cite sACN If merging or arbitration is implemented the algorithm used
|
|
|
|
* > shall be declared in user documentation for the device.
|
|
|
|
*
|
|
|
|
* sACN::Receiver accepts the highest priority universe with an rxRate above
|
|
|
|
* DMX::E111_DATA_LOSS_TIMEOUT as the dominant universe.
|
|
|
|
*
|
2021-08-25 17:20:33 -04:00
|
|
|
*/
|
2021-05-27 10:59:22 -04:00
|
|
|
class Receiver
|
2021-08-25 10:57:31 -04:00
|
|
|
: public virtual ACN::RLP::Component
|
2021-05-27 10:59:22 -04:00
|
|
|
{
|
|
|
|
public:
|
2022-11-19 15:43:02 -05:00
|
|
|
Receiver(UUID::uuid = UUID::uuid(), std::string fctn = "OpenLCP sACN Receiver");
|
2021-08-02 10:09:14 -04:00
|
|
|
~Receiver();
|
|
|
|
|
2021-09-10 16:26:31 -04:00
|
|
|
void setHoldLastLook(const bool);
|
2022-11-19 15:45:31 -05:00
|
|
|
bool isEnabledHoldLastLook() const;
|
2021-09-10 16:26:31 -04:00
|
|
|
|
2021-05-27 10:59:22 -04:00
|
|
|
virtual void subscribe(const uint16_t);
|
|
|
|
virtual void unsubscribe(const uint16_t);
|
2022-11-19 12:26:07 -05:00
|
|
|
std::shared_ptr<Universe> universe(const uint16_t) const;
|
2021-05-27 10:59:22 -04:00
|
|
|
|
2022-11-19 16:43:41 -05:00
|
|
|
bool discoveryEnabled() const {return discovery_enabled_;} //!< @brief is discovery enabled @return
|
2021-06-02 09:29:27 -04:00
|
|
|
void discoveryStart();
|
|
|
|
void discoveryStop();
|
2021-08-29 11:44:27 -04:00
|
|
|
void onDiscovered(const std::function<void()>);
|
|
|
|
/// The listing of discovered universes.
|
2021-09-07 11:17:52 -04:00
|
|
|
std::set<std::shared_ptr<EXTENDED::DISCOVERY::discoveredUniverse>> discovered;
|
2021-06-02 09:29:27 -04:00
|
|
|
|
2021-05-27 10:59:22 -04:00
|
|
|
protected:
|
2021-07-28 10:43:43 -04:00
|
|
|
// 5 - E1.31 use of the ACN Root Layer Protocol
|
2021-08-25 10:33:53 -04:00
|
|
|
void dataReceiver(ACN::PDU::Message<ACN::RLP::Pdu>);
|
|
|
|
void extendedReceiver(ACN::PDU::Message<ACN::RLP::Pdu>);
|
2021-05-27 10:59:22 -04:00
|
|
|
|
2021-07-28 10:43:43 -04:00
|
|
|
// 6.2 E1.31 Data Packet Framing Layer
|
2021-08-25 10:33:53 -04:00
|
|
|
void dataFrameHandler(ACN::PDU::Message<DATA::Pdu>);
|
2021-07-28 10:43:43 -04:00
|
|
|
|
|
|
|
// 6.3 E1.31 Synchronization Packet Framing Layer
|
2021-08-25 10:33:53 -04:00
|
|
|
void syncFrameHandler(ACN::PDU::Message<EXTENDED::Pdu>);
|
2021-07-28 10:43:43 -04:00
|
|
|
|
|
|
|
// 6.4 E1.31 Universe Discovery Packet Framing Layer
|
2021-08-25 10:33:53 -04:00
|
|
|
void discoveryFrameHandler(ACN::PDU::Message<EXTENDED::Pdu>);
|
2021-07-28 10:43:43 -04:00
|
|
|
// 8 Universe Discovery Layer
|
2021-08-25 10:33:53 -04:00
|
|
|
void discoveryListHanlder(ACN::PDU::Message<EXTENDED::DISCOVERY::Pdu>);
|
2021-05-27 10:59:22 -04:00
|
|
|
|
|
|
|
private:
|
2021-09-10 09:55:34 -04:00
|
|
|
std::unordered_map<uint16_t, std::shared_ptr<ArbitratingUniverse>> universes_;
|
2021-08-29 11:44:27 -04:00
|
|
|
std::vector<std::function<void()>> discoveryCallbacks_;
|
2022-11-19 16:43:41 -05:00
|
|
|
bool discovery_enabled_;
|
2021-09-10 16:26:31 -04:00
|
|
|
bool HoldLastLook;
|
2021-05-27 10:59:22 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|