20#ifndef SACN_CPP_RECEIVER_H_
21#define SACN_CPP_RECEIVER_H_
141 const std::vector<SacnLostSource>& lost_sources) = 0;
154 ETCPAL_UNUSED_ARG(
handle);
155 ETCPAL_UNUSED_ARG(universe);
170 ETCPAL_UNUSED_ARG(
handle);
171 ETCPAL_UNUSED_ARG(universe);
182 ETCPAL_UNUSED_ARG(
handle);
183 ETCPAL_UNUSED_ARG(universe);
184 ETCPAL_UNUSED_ARG(source);
195 ETCPAL_UNUSED_ARG(
handle);
196 ETCPAL_UNUSED_ARG(universe);
267 std::vector<SacnMcastInterface>& netints);
283 std::vector<NetintList>& netint_lists);
299extern "C" inline void ReceiverCbUniverseData(
sacn_receiver_t receiver_handle,
305 if (source_addr && source_info && universe_data && context)
308 *source_info, *universe_data);
315 size_t num_lost_sources,
318 if (context && lost_sources && (num_lost_sources > 0))
320 std::vector<SacnLostSource> lost_vec(lost_sources, lost_sources + num_lost_sources);
321 static_cast<Receiver::NotifyHandler*
>(context)->HandleSourcesLost(Receiver::Handle(handle), universe, lost_vec);
325extern "C" inline void ReceiverCbSamplingPeriodStarted(
sacn_receiver_t handle, uint16_t universe,
void* context)
329 static_cast<Receiver::NotifyHandler*
>(context)->HandleSamplingPeriodStarted(Receiver::Handle(handle), universe);
333extern "C" inline void ReceiverCbSamplingPeriodEnded(
sacn_receiver_t handle, uint16_t universe,
void* context)
337 static_cast<Receiver::NotifyHandler*
>(context)->HandleSamplingPeriodEnded(Receiver::Handle(handle), universe);
346 if (context && source)
348 static_cast<Receiver::NotifyHandler*
>(context)->HandleSourcePapLost(Receiver::Handle(handle), universe, *source);
352extern "C" inline void ReceiverCbSourceLimitExceeded(
sacn_receiver_t handle, uint16_t universe,
void* context)
356 static_cast<Receiver::NotifyHandler*
>(context)->HandleSourceLimitExceeded(Receiver::Handle(handle), universe);
380 return (universe_id > 0) && (footprint.start_address >= 1) && (footprint.start_address <=
kSacnDmxAddressCount) &&
381 (footprint.address_count >= 1) &&
391 McastMode mcast_mode = McastMode::kEnabledOnAllInterfaces)
392 :
handle(receiver_handle), no_netints(mcast_mode ==
McastMode::kDisabledOnAllInterfaces)
403 const std::vector<SacnMcastInterface>& network_interfaces)
404 :
handle(receiver_handle), netints(network_interfaces)
435 McastMode mcast_mode = McastMode::kEnabledOnAllInterfaces)
440 if (mcast_mode == McastMode::kDisabledOnAllInterfaces)
480 std::vector<SacnMcastInterface>& netints)
494 netint_config.
netints = netints.data();
615 size_t size_guess = 4u;
616 std::vector<EtcPalMcastNetintId> netints(size_guess);
619 while (num_netints > netints.size())
621 size_guess = num_netints + 4u;
622 netints.resize(size_guess);
626 netints.resize(num_netints);
685 if (mcast_mode == McastMode::kDisabledOnAllInterfaces)
716 if (sys_netints.empty())
720 netint_config.
netints = sys_netints.data();
755 std::vector<NetintList>& per_receiver_netint_lists)
757 std::vector<SacnReceiverNetintList> netint_lists_c;
758 netint_lists_c.reserve(per_receiver_netint_lists.size());
759 std::transform(per_receiver_netint_lists.begin(), per_receiver_netint_lists.end(), std::back_inserter(netint_lists_c),
762 SacnReceiverNetintList c_list = {
774 sys_netint_config.
netints = sys_netints.data();
775 sys_netint_config.num_netints = sys_netints.size();
796 internal::ReceiverCbUniverseData,
797 internal::ReceiverCbSourcesLost,
798 internal::ReceiverCbSamplingPeriodStarted,
799 internal::ReceiverCbSamplingPeriodEnded,
800 internal::ReceiverCbPapLost,
801 internal::ReceiverCbSourceLimitExceeded,
805 settings.source_count_max,
807 settings.ip_supported
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 common notification callbacks from sACN.
Definition common.h:73
A base class for a class that receives notification callbacks from a sACN receiver.
Definition receiver.h:72
virtual void HandleSamplingPeriodEnded(Handle handle, uint16_t universe)
Notify that a receiver's sampling period has ended.
Definition receiver.h:168
NotifyHandler(NotifyHandler &&other)=default
Defaulted move constructor.
virtual void HandleSamplingPeriodStarted(Handle handle, uint16_t universe)
Notify that a receiver's sampling period has begun.
Definition receiver.h:152
NotifyHandler & operator=(NotifyHandler &&other)=default
Defaulted move assignment operator.
NotifyHandler(const NotifyHandler &other)=default
Defaulted copy constructor.
NotifyHandler & operator=(const NotifyHandler &other)=default
Defaulted copy assignment operator.
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 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:193
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:180
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.
An instance of sACN Receiver functionality; see Using the sACN Receiver API.
Definition receiver.h:62
Receiver & operator=(Receiver &&other)=default
Move a receiver instance.
etcpal::Expected< uint16_t > GetUniverse() const
Get the universe this receiver is listening to.
Definition receiver.h:526
etcpal::Error ChangeFootprint(const SacnRecvUniverseSubrange &new_footprint)
Change the footprint within the universe this receiver is listening to.
Definition receiver.h:585
static uint32_t GetExpiredWait()
Get the current value of the expired notification wait time.
Definition receiver.h:653
void Shutdown()
Stop listening for sACN data on a universe.
Definition receiver.h:515
constexpr Handle handle() const
Get the current handle to the underlying C receiver.
Definition receiver.h:785
static etcpal::Error ResetNetworking(McastMode mcast_mode)
Resets the underlying network sockets and packet receipt state for all sACN receivers.
Definition receiver.h:682
static void SetExpiredWait(uint32_t wait_ms)
Set the expired notification wait time.
Definition receiver.h:639
Receiver(Receiver &&other)=default
Move a receiver instance.
etcpal::Error ChangeUniverseAndFootprint(uint16_t new_universe_id, const SacnRecvUniverseSubrange &new_footprint)
Change the universe and footprint this receiver is listening to.
Definition receiver.h:601
std::vector< EtcPalMcastNetintId > GetNetworkInterfaces()
Obtain a vector of this receiver's network interfaces.
Definition receiver.h:612
etcpal::Error ChangeUniverse(uint16_t new_universe_id)
Change the universe this receiver is listening to.
Definition receiver.h:570
etcpal::Expected< SacnRecvUniverseSubrange > GetFootprint() const
Get the footprint within the universe this receiver is listening to.
Definition receiver.h:543
etcpal::Error Startup(const Settings &settings, NotifyHandler ¬ify_handler, McastMode mcast_mode)
Start listening for sACN data on a universe.
Definition receiver.h:433
C++ wrapper for the sACN init/deinit functions.
sacn_ip_support_t
This enum defines how the API module will use IPv4 and IPv6 networking.
Definition common.h:75
#define SACN_NETINT_CONFIG_DEFAULT_INIT
Initializes the members of a SacnNetintConfig to defaults.
Definition common.h:187
@ kSacnIpV4AndIpV6
Use both IPv4 and IPv6.
Definition common.h:81
@ kSacnDmxAddressCount
The number of addresses in a DMX universe.
Definition common.h:60
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:439
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:233
etcpal_error_t sacn_receiver_destroy(sacn_receiver_t handle)
Destroy a sACN receiver instance.
Definition receiver.c:145
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:363
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:537
static const sacn_receiver_t kSacnReceiverInvalid
An invalid sACN receiver handle value.
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.
Definition receiver.c:308
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:272
uint32_t sacn_receiver_get_expired_wait()
Get the current value of the expired notification wait time.
Definition receiver.c:583
void sacn_receiver_set_expired_wait(uint32_t wait_ms)
Set the expired notification wait time.
Definition receiver.c:562
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
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:190
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.
Definition receiver.c:328
int sacn_receiver_t
A handle to an sACN receiver.
Definition receiver.h:58
@ kSacnReceiverInfiniteSources
Constant for "infinite" when listening or merging sACN universes.
Definition receiver.h:70
A namespace which contains all C++ language definitions in the sACN library.
Definition common.h:50
McastMode
Determines whether multicast traffic is allowed through all interfaces or none.
Definition common.h:53
sACN Receiver API definitions
Information about a sACN source that was lost.
Definition receiver.h:153
Network interface configuration information to give the sACN library.
Definition common.h:114
SacnMcastInterface * netints
An array of network interface IDs to which to restrict multicast traffic.
Definition common.h:117
size_t num_netints
Size of netints array.
Definition common.h:119
bool no_netints
If this is true, no network interfaces will be used for multicast.
Definition common.h:122
A set of configuration information for an sACN receiver.
Definition receiver.h:313
uint16_t universe_id
Universe number on which to listen for sACN.
Definition receiver.h:317
A complete description of newly received universe data within the configured footprint.
Definition receiver.h:92
Defines a range of addresses within a sACN universe.
Definition receiver.h:83
Information about a remote sACN source being tracked by a receiver.
Definition receiver.h:142
A set of network interfaces for a particular receiver.
Definition receiver.h:239
bool no_netints
If this is true, this receiver will not use any network interfaces for multicast traffic.
Definition receiver.h:248
NetintList()=default
Create an empty, invalid data structure by default.
sacn_receiver_t handle
The receiver's handle.
Definition receiver.h:241
std::vector< SacnMcastInterface > netints
If !empty, this is the list of interfaces the application wants to use, and the status codes are fill...
Definition receiver.h:245
A set of configuration settings that a receiver needs to initialize.
Definition receiver.h:205
int source_count_max
The maximum number of sources this universe will listen to.
Definition receiver.h:218
SacnRecvUniverseSubrange footprint
The footprint within the universe to monitor.
Definition receiver.h:213
Settings()=default
Create an empty, invalid data structure by default.
bool IsValid() const
Determine whether a Reciever Settings instance contains valid data for sACN operation.
Definition receiver.h:378
sacn_ip_support_t ip_supported
What IP networking the receiver will support.
Definition receiver.h:221
uint16_t universe_id
The sACN universe number the receiver is listening to.
Definition receiver.h:208
unsigned int flags
A set of option flags.
Definition receiver.h:219