20#ifndef SACN_CPP_RECEIVER_H_
21#define SACN_CPP_RECEIVER_H_
124 ETCPAL_UNUSED_ARG(
handle);
125 ETCPAL_UNUSED_ARG(universe);
140 ETCPAL_UNUSED_ARG(
handle);
141 ETCPAL_UNUSED_ARG(universe);
152 ETCPAL_UNUSED_ARG(
handle);
153 ETCPAL_UNUSED_ARG(universe);
154 ETCPAL_UNUSED_ARG(source);
165 ETCPAL_UNUSED_ARG(
handle);
166 ETCPAL_UNUSED_ARG(universe);
270 if (source_addr && source_info && universe_data && context)
273 *source_info, *universe_data);
277extern "C" inline void ReceiverCbSourcesLost(
sacn_receiver_t handle, uint16_t universe,
278 const SacnLostSource* lost_sources,
size_t num_lost_sources,
void* context)
280 if (context && lost_sources && (num_lost_sources > 0))
283 static_cast<Receiver::NotifyHandler*
>(context)->HandleSourcesLost(Receiver::Handle(handle), universe, lost_vec);
287extern "C" inline void ReceiverCbSamplingPeriodStarted(
sacn_receiver_t handle, uint16_t universe,
void* context)
291 static_cast<Receiver::NotifyHandler*
>(context)->HandleSamplingPeriodStarted(Receiver::Handle(handle), universe);
295extern "C" inline void ReceiverCbSamplingPeriodEnded(
sacn_receiver_t handle, uint16_t universe,
void* context)
299 static_cast<Receiver::NotifyHandler*
>(context)->HandleSamplingPeriodEnded(Receiver::Handle(handle), universe);
306 if (context && source)
308 static_cast<Receiver::NotifyHandler*
>(context)->HandleSourcePapLost(Receiver::Handle(handle), universe, *source);
312extern "C" inline void ReceiverCbSourceLimitExceeded(
sacn_receiver_t handle, uint16_t universe,
void* context)
316 static_cast<Receiver::NotifyHandler*
>(context)->HandleSourceLimitExceeded(Receiver::Handle(handle), universe);
340 return (universe_id > 0) && (footprint.start_address >= 1) && (footprint.start_address <=
DMX_ADDRESS_COUNT) &&
341 (footprint.address_count >= 1) &&
351 McastMode mcast_mode = McastMode::kEnabledOnAllInterfaces)
352 :
handle(receiver_handle), no_netints(mcast_mode ==
McastMode::kDisabledOnAllInterfaces)
364 :
handle(receiver_handle), netints(network_interfaces)
393 McastMode mcast_mode = McastMode::kEnabledOnAllInterfaces)
398 if (mcast_mode == McastMode::kDisabledOnAllInterfaces)
568 size_t size_guess = 4u;
569 size_t num_netints = 0u;
573 netints.
resize(size_guess);
575 size_guess = num_netints + 4u;
576 }
while (num_netints > netints.
size());
578 netints.
resize(num_netints);
637 if (mcast_mode == McastMode::kDisabledOnAllInterfaces)
668 if (sys_netints.
empty())
710 netint_lists_c.
reserve(per_receiver_netint_lists.
size());
715 SacnReceiverNetintList c_list = {
727 sys_netint_config.netints = sys_netints.data();
728 sys_netint_config.num_netints = sys_netints.size();
743inline SacnReceiverConfig Receiver::TranslateConfig(
const Settings& settings, NotifyHandler& notify_handler)
749 internal::ReceiverCbUniverseData,
750 internal::ReceiverCbSourcesLost,
751 internal::ReceiverCbSamplingPeriodStarted,
752 internal::ReceiverCbSamplingPeriodEnded,
753 internal::ReceiverCbPapLost,
754 internal::ReceiverCbSourceLimitExceeded,
758 settings.source_count_max,
760 settings.ip_supported
T back_inserter(T... args)
ETCPAL_CONSTEXPR_14 void Clear()
ETCPAL_CONSTEXPR_14 void SetValue(const ValueType &new_value)
constexpr ValueType value() const
A base class for a class that receives notification callbacks from a sACN receiver.
Definition receiver.h:72
virtual void HandleUniverseData(Handle receiver_handle, const etcpal::SockAddr &source_addr, const SacnRemoteSource &source_info, const SacnRecvUniverseData &universe_data)=0
Notify that new universe data within the configured footprint has been received.
virtual void HandleSamplingPeriodStarted(Handle handle, uint16_t universe)
Notify that a receiver's sampling period has begun.
Definition receiver.h:122
virtual void HandleSourceLimitExceeded(Handle handle, uint16_t universe)
Notify that more than the configured maximum number of sources are currently sending on the universe ...
Definition receiver.h:163
virtual void HandleSourcesLost(Handle handle, uint16_t universe, const std::vector< SacnLostSource > &lost_sources)=0
Notify that one or more sources have entered a source loss state.
virtual void HandleSamplingPeriodEnded(Handle handle, uint16_t universe)
Notify that a receiver's sampling period has ended.
Definition receiver.h:138
virtual void HandleSourcePapLost(Handle handle, uint16_t universe, const SacnRemoteSource &source)
Notify that a source has stopped transmission of per-address priority packets.
Definition receiver.h:150
An instance of sACN Receiver functionality; see Using the sACN Receiver API.
Definition receiver.h:62
static uint32_t GetExpiredWait()
Get the current value of the expired notification wait time.
Definition receiver.h:605
static void SetExpiredWait(uint32_t wait_ms)
Set the expired notification wait time.
Definition receiver.h:591
etcpal::Error Startup(const Settings &settings, NotifyHandler ¬ify_handler, McastMode mcast_mode)
Start listening for sACN data on a universe.
Definition receiver.h:392
std::vector< EtcPalMcastNetintId > GetNetworkInterfaces()
Obtain a vector of this receiver's network interfaces.
Definition receiver.h:564
etcpal::Expected< uint16_t > GetUniverse() const
Get the universe this receiver is listening to.
Definition receiver.h:478
Receiver & operator=(Receiver &&other)=default
etcpal::Error ChangeFootprint(const SacnRecvUniverseSubrange &new_footprint)
Change the footprint within the universe this receiver is listening to. TODO: Not yet implemented.
Definition receiver.h:537
Receiver(Receiver &&other)=default
etcpal::Error ChangeUniverse(uint16_t new_universe_id)
Change the universe this receiver is listening to.
Definition receiver.h:522
etcpal::Expected< SacnRecvUniverseSubrange > GetFootprint() const
Get the footprint within the universe this receiver is listening to.
Definition receiver.h:495
static etcpal::Error ResetNetworking(McastMode mcast_mode)
Resets the underlying network sockets and packet receipt state for all sACN receivers.
Definition receiver.h:634
etcpal::Error ChangeUniverseAndFootprint(uint16_t new_universe_id, const SacnRecvUniverseSubrange &new_footprint)
Change the universe and footprint this receiver is listening to. TODO: Not yet implemented.
Definition receiver.h:553
void Shutdown()
Stop listening for sACN data on a universe.
Definition receiver.h:467
constexpr Handle handle() const
Get the current handle to the underlying C receiver.
Definition receiver.h:738
C++ wrapper for the sACN init/deinit functions.
sacn_ip_support_t
Definition common.h:71
#define DMX_ADDRESS_COUNT
Definition common.h:55
@ kSacnIpV4AndIpV6
Definition common.h:77
etcpal_error_t sacn_receiver_reset_networking_per_receiver(const SacnNetintConfig *sys_netint_config, const SacnReceiverNetintList *per_receiver_netint_lists, size_t num_per_receiver_netint_lists)
Resets underlying network sockets and packet receipt state, determines network interfaces for each re...
Definition receiver.c:424
etcpal_error_t sacn_receiver_get_footprint(sacn_receiver_t handle, SacnRecvUniverseSubrange *footprint)
Get the footprint within the universe on which a sACN receiver is currently listening.
Definition receiver.c:219
etcpal_error_t sacn_receiver_destroy(sacn_receiver_t handle)
Destroy a sACN receiver instance.
Definition receiver.c:140
etcpal_error_t sacn_receiver_reset_networking(const SacnNetintConfig *sys_netint_config)
Resets underlying network sockets and packet receipt state, determines network interfaces for all rec...
Definition receiver.c:348
size_t sacn_receiver_get_network_interfaces(sacn_receiver_t handle, EtcPalMcastNetintId *netints, size_t netints_size)
Obtain a list of a receiver's network interfaces.
Definition receiver.c:522
#define SACN_RECEIVER_INVALID
Definition receiver.h:60
etcpal_error_t sacn_receiver_change_footprint(sacn_receiver_t handle, const SacnRecvUniverseSubrange *new_footprint)
Change the footprint within the universe on which an sACN receiver is listening. TODO: Not yet implem...
Definition receiver.c:294
etcpal_error_t sacn_receiver_change_universe(sacn_receiver_t handle, uint16_t new_universe_id)
Change the universe on which an sACN receiver is listening.
Definition receiver.c:258
uint32_t sacn_receiver_get_expired_wait()
Get the current value of the expired notification wait time.
Definition receiver.c:568
void sacn_receiver_set_expired_wait(uint32_t wait_ms)
Set the expired notification wait time.
Definition receiver.c:547
etcpal_error_t sacn_receiver_create(const SacnReceiverConfig *config, sacn_receiver_t *handle, const SacnNetintConfig *netint_config)
Create a new sACN receiver to listen for sACN data on a universe.
Definition receiver.c:92
#define SACN_RECEIVER_INFINITE_SOURCES
Constant for "infinite" when listening or merging sACN universes.
Definition receiver.h:68
etcpal_error_t sacn_receiver_get_universe(sacn_receiver_t handle, uint16_t *universe_id)
Get the universe on which a sACN receiver is currently listening.
Definition receiver.c:176
etcpal_error_t sacn_receiver_change_universe_and_footprint(sacn_receiver_t handle, uint16_t new_universe_id, const SacnRecvUniverseSubrange *new_footprint)
Change the universe and footprint on which an sACN receiver is listening. TODO: Not yet implemented.
Definition receiver.c:314
int sacn_receiver_t
Definition receiver.h:58
A namespace which contains all C++ language definitions in the sACN library.
Definition common.h:50
McastMode
Definition common.h:53
sACN Receiver API definitions
Definition receiver.h:138
bool no_netints
Definition common.h:110
size_t num_netints
Definition common.h:107
SacnMcastInterface * netints
Definition common.h:105
Definition receiver.h:288
uint16_t universe_id
Definition receiver.h:292
Definition receiver.h:127
A set of network interfaces for a particular receiver.
Definition receiver.h:209
sacn_receiver_t handle
Definition receiver.h:211
std::vector< SacnMcastInterface > netints
Definition receiver.h:215
bool no_netints
Definition receiver.h:218
A set of configuration settings that a receiver needs to initialize.
Definition receiver.h:175
SacnRecvUniverseSubrange footprint
Definition receiver.h:183
uint16_t universe_id
Definition receiver.h:178
int source_count_max
Definition receiver.h:188
sacn_ip_support_t ip_supported
Definition receiver.h:191
bool IsValid() const
Definition receiver.h:338
unsigned int flags
Definition receiver.h:189