Expand description
C ABI for mx_remote.
The whole of this crate is one translation: it holds every unsafe in the
workspace, and adds no protocol logic of its own. Anything a caller can do
here is something the core crate already does; if a rule is not enforced in
mx_remote, it is not enforced at all.
Three conventions run through the header, and knowing them is most of knowing the API:
- A device is addressed by value. There is no handle for a device or a
bay: a device is a
mxr_uid_t, a bay is amxr_bay_uid_t, and state is read by passing one in and having a struct filled out. Nothing hands back a pointer into state that a lock protects. - Every call returns, whatever happens. An unwind across the boundary
is undefined behaviour, so each entry point catches: a panic becomes
mxr_result_t::MXR_ERR_PANICrather than a corrupted stack. - A borrowed pointer lives for one call. Strings and arrays handed to a callback point into memory the library owns and reuses. A caller that needs one afterwards copies it.
Every failure code is negative and mxr_result_t::MXR_OK is zero, so
if (rc < 0) is a complete test, and a code added later cannot turn a
failure into a success.
§From C
#include <mx_remote.h>
/* The client cannot be its own userdata: it does not exist when the table
* is handed over, so it reaches the callbacks through a struct that does. */
struct app { mxr_remote_t *remote; };
static void on_device_update(void *userdata, mxr_uid_t device) {
mxr_device_info_t info;
if (mxr_device(((struct app *)userdata)->remote, device, &info) == MXR_OK)
printf("%s %s\n", info.model, info.name);
}
int main(void) {
struct app app = {0};
mxr_callbacks_t cb = {0};
cb.on_device_update = on_device_update;
/* Zeroing a config asks for every default; NULL does the same. */
app.remote = mxr_remote_new(NULL, &cb, &app);
mxr_remote_start(app.remote);
/* ... */
mxr_remote_free(app.remote);
return 0;
}include/mx_remote.h is generated from this source by cbindgen and checked
into the repository. include/mx_remote.hpp is a hand-written header-only
C++ layer over it, with a move-only mxr::Remote that closes and joins in
its destructor and an mxr::Handler base class carrying a virtual method
per event.
Structs§
- mxr_
action_ transmit_ request_ t - Asks one device to perform a remote-control action.
- mxr_
amp_ zone_ settings_ t - A ProAmp8 zone’s gain, delay, tone and power settings.
- mxr_
audio_ change_ source_ t - Which source endpoint an audio sink endpoint was switched to.
- mxr_
audio_ endpoint_ t - One node of a device’s audio tree.
- mxr_
audio_ format_ t - A stream’s sample rate and channel count.
- mxr_
bay_ info_ t - What a bay is, and what is connected to it.
- mxr_
bay_ name_ change_ t - Asks a device to rename one of its bays.
- mxr_
bay_ uid_ t - A single bay: the device it is on, and its port number there.
- mxr_
blacklist_ change_ t - Registers or unregisters a device on the source blacklist.
- mxr_
cable_ status_ t - The diagnostic result for one UTP cable pair.
- mxr_
callbacks_ t - What to call when something happens.
- mxr_
config_ t - How a client finds the network.
- mxr_
device_ info_ t - What a device is, and what it is doing.
- mxr_
dolby_ settings_ t - A ProAmp8’s Dolby settings.
- mxr_
edid_ profile_ change_ t - Asks a device to switch its input EDID profile.
- mxr_
edid_ record_ t - One EDID block from a device’s reply.
- mxr_
edid_ request_ t - Asks one device for its EDID.
- mxr_
factory_ reset_ request_ t - Asks peers to factory-reset.
- mxr_
firmware_ version_ t - One firmware component a device reports.
- mxr_
ir_ capture_ t - Raw IR captured on a bay of the sending device.
- mxr_
ir_ meta_ t - The metadata shared by the raw-IR capture and transmit frames.
- mxr_
ir_ transmit_ request_ t - Asks one device to blast raw IR on one of its local bays.
- mxr_
key_ transmit_ request_ t - Asks one device to send a remote-control key on a bay.
- mxr_
multiviewer_ command_ t - A command addressed to a multiviewer.
- mxr_
multiviewer_ status_ t - What a multiviewer reports about itself.
- mxr_
network_ port_ t - The link state and diagnostics of one network port.
- mxr_
pdu_ state_ t - The electrical state a PDU reports.
- mxr_
power_ save_ request_ t - Asks a sink to enter or leave power save.
- mxr_
rc_ settings_ t - The remote-control configuration of a source bay.
- mxr_
remote_ t - A running client. Opaque: everything about it is reached through the functions below.
- mxr_
set_ route_ request_ t - Asks a device, addressed by serial, to switch a sink.
- mxr_
signal_ details_ t - The signal a bay measures, beyond the description in
mxr_bay_info_t::signal_type. - mxr_
stream_ source_ t - One multicast stream address.
- mxr_
stream_ sources_ t - The streams one V2IP source advertises.
- mxr_
tiling_ config_ t - The window a sink is currently told to show.
- mxr_
topology_ entry_ t - One device in a topology report.
- mxr_
uid_ t - The 16-byte identifier of a device on the network.
- mxr_
v2ip_ details_ t - A V2IP device’s own encoder configuration.
- mxr_
v2ip_ rx_ stats_ t - Receiver stream statistics.
- mxr_
v2ip_ sink_ t - The streams a V2IP sink is subscribed to.
- mxr_
v2ip_ stats_ t - A device’s V2IP statistics, cumulative and over the last minute.
- mxr_
v2ip_ tx_ stats_ t - Transmitter stream statistics.
- mxr_
video_ wall_ command_ t - Asks one sink to crop its source to a wall window.
Enums§
- mxr_
arc_ status_ t - The audio return channel a bay is carrying.
- mxr_
device_ status_ t - The high-level state of a device on the network.
- mxr_
power_ status_ t - The CEC power state of whatever is connected to a bay.
- mxr_
result_ t - How a call ended.
- mxr_
stream_ kind_ t - Which of a V2IP device’s streams an address describes.
- mxr_
tribool_ t - A flag a device may not have reported.
Constants§
- MXR_
AMP_ EQ_ BANDS - Number of EQ bands an amplifier zone carries.
- MXR_
IP_ STRING_ LEN - Bytes an IPv4 address needs when written as text, the terminator included.
- MXR_
MESSAGE_ LEN - Bytes a device’s system-status message needs, the terminator included.
- MXR_
MODEL_ LEN - Bytes a model name needs, the terminator included.
- MXR_
MULTIVIEWER_ INPUTS - How many inputs a multiviewer has.
- MXR_
NAME_ LEN - Bytes a device, bay or port name needs, the terminator included.
- MXR_
PDU_ OUTLETS - How many outlets a PDU reports.
- MXR_
SCALING_ FLAG_ AUTO_ SCALING - Set when the output scales automatically.
- MXR_
SCALING_ FLAG_ MODE_ VALID - Set when the frame carries a scaling mode and refresh rate.
- MXR_
SCALING_ FLAG_ OPTIONS_ VALID - Set when the frame carries the scaling options.
- MXR_
SERIAL_ LEN - Bytes a serial number needs, the terminator included.
- MXR_
SIGNAL_ TYPE_ LEN - Bytes a signal description such as
1080p60 444 8needs, the terminator included. - MXR_
UID_ STRING_ LEN - Bytes a
mxr_uid_tneeds when written as text, the terminator included. - MXR_
UTP_ PAIRS - How many pairs a UTP cable diagnostic covers.
- MXR_
VERSION_ LEN - Bytes a firmware version string needs, the terminator included.
Functions§
- mxr_
audio_ ⚠endpoint_ children - Writes the endpoints hanging off one audio endpoint, and returns how many there are.
- mxr_
audio_ ⚠endpoints - Writes a device’s audio endpoints, in the order it reported them, and returns how many there are.
- mxr_bay⚠
- Fills
outwith what is known about a bay. - mxr_
bay_ ⚠amp_ settings - Fills
outwith an amplifier zone’s settings. - mxr_
bay_ ⚠by_ name - Finds a bay on a device by the name the device gives its port.
- mxr_
bay_ ⚠by_ stream_ ip - Finds the source bay advertising a multicast group.
- mxr_
bay_ ⚠filtered - Writes the devices whose signals a bay refuses, and returns how many there are.
- mxr_
bay_ ⚠signal_ details - Fills
outwith the signal a bay measures. - mxr_
device ⚠ - Fills
outwith what is known about a device. - mxr_
device_ ⚠bays - Writes a device’s bays in port order, and returns how many there are.
- mxr_
device_ ⚠by_ serial - Finds a device by its serial number.
- mxr_
device_ ⚠firmware - Writes the firmware versions a device reports, and returns how many there are.
- mxr_
device_ ⚠temperatures - Writes the temperatures a device reports, in its own order, in degrees Celsius, and returns how many there are.
- mxr_
devices ⚠ - Writes every device heard from, and returns how many there are.
- mxr_
discover ⚠ - Asks every device on the network to announce itself.
- mxr_
dolby_ ⚠settings - Fills
outwith a ProAmp8’s Dolby settings. - mxr_
last_ error - Why the last call on this thread failed, or an empty string.
- mxr_
multiviewer_ ⚠auto_ route - Asks a multiviewer to map its inputs to the sources it can see.
- mxr_
multiviewer_ ⚠status - Fills
outwith what a multiviewer reports about itself. - mxr_
network_ ⚠status - Writes a device’s network ports, and returns how many there are.
- mxr_
pdu_ ⚠state - Fills
outwith the electrical state a PDU reports. - mxr_
power_ ⚠off - Powers off what is attached to a bay.
- mxr_
power_ ⚠on - Powers on what is attached to a bay.
- mxr_
rc_ ⚠settings - Fills
outwith a source bay’s remote-control configuration. - mxr_
reboot ⚠ - Reboots a device.
- mxr_
remote_ ⚠close - Stops the threads and closes the socket. Idempotent.
- mxr_
remote_ ⚠free - Closes the client and releases it. Null is ignored.
- mxr_
remote_ ⚠name - Writes the name this client advertises.
- mxr_
remote_ ⚠new - Creates a client, without opening a socket yet.
- mxr_
remote_ ⚠start - Opens the socket and starts the receive and timer threads.
- mxr_
remote_ ⚠target - Writes the address this client sends to.
- mxr_
remote_ ⚠uid - Writes this client’s own identifier.
- mxr_
remote_ ⚠update_ config - Reopens the socket on a different interface, or in the other mode.
- mxr_
resolve_ ⚠device - Finds a device by serial number, name or identifier, in that order.
- mxr_
select_ ⚠audio_ endpoint_ input - Points one device’s audio endpoint at another device’s.
- mxr_
select_ ⚠audio_ source - Routes a V2IP sink’s audio to the stream a source port advertises, leaving its video where it is.
- mxr_
select_ ⚠audio_ source_ addr - Routes a V2IP sink’s audio to a multicast group directly, for a source this client has not heard advertise it.
- mxr_
select_ ⚠audio_ source_ by_ name - Routes a V2IP sink’s audio to the source bay with this user-assigned name.
- mxr_
select_ ⚠edid_ profile - Switches an input bay’s EDID profile.
- mxr_
select_ ⚠video_ source - Routes a V2IP sink’s video to the stream a source port advertises.
- mxr_
select_ ⚠video_ source_ by_ name - Routes a V2IP sink’s video to the source bay with this user-assigned name.
- mxr_
send_ ⚠action - Sends a remote-control action to whatever is attached to a bay.
- mxr_
send_ ⚠monitoring_ pulse - Sends the monitoring pulse that tells devices this client is watching.
- mxr_
set_ ⚠amp_ zone_ settings - Writes an amplifier zone’s gain, delay, tone and power settings.
- mxr_
set_ ⚠audio_ endpoint_ muted - Mutes or unmutes one of a device’s audio endpoints.
- mxr_
set_ ⚠audio_ endpoint_ trigger - Activates or clears an audio endpoint’s trigger.
- mxr_
set_ ⚠audio_ endpoint_ volume - Sets an audio endpoint’s volume.
- mxr_
set_ ⚠bay_ hidden - Hides a bay from the installation’s user interface, or shows it again.
- mxr_
set_ ⚠bay_ name - Renames a bay. The device stores the first 16 bytes.
- mxr_
set_ ⚠multiviewer_ aspect_ ratio - Sets how a multiviewer fits a source into its window.
- mxr_
set_ ⚠multiviewer_ audio_ source - Chooses which window a multiviewer takes its audio from.
- mxr_
set_ ⚠multiviewer_ audio_ volume - Sets a multiviewer’s output volume and mute state.
- mxr_
set_ ⚠multiviewer_ auto_ switch - Turns a multiviewer’s automatic source switching on or off.
- mxr_
set_ ⚠multiviewer_ edid_ template - Switches the EDID a multiviewer presents to its sources.
- mxr_
set_ ⚠multiviewer_ hdcp_ mode - Switches a multiviewer’s HDCP mode.
- mxr_
set_ ⚠multiviewer_ input_ source - Maps one of a multiviewer’s inputs to a source device.
- mxr_
set_ ⚠multiviewer_ output_ itc - Sets a multiviewer’s IT content flag.
- mxr_
set_ ⚠multiviewer_ output_ mode - Switches a multiviewer’s output resolution.
- mxr_
set_ ⚠multiviewer_ pip_ position - Sets which corner a multiviewer’s picture-in-picture window sits in.
- mxr_
set_ ⚠multiviewer_ pip_ size - Sets the size of a multiviewer’s picture-in-picture window.
- mxr_
set_ ⚠multiviewer_ remote_ control - Chooses which window a multiviewer forwards remote control to.
- mxr_
set_ ⚠multiviewer_ video_ source - Puts a source in one of a multiviewer’s windows.
- mxr_
set_ ⚠multiviewer_ view_ mode - Switches a multiviewer’s window layout.
- mxr_
set_ ⚠muted - Mutes or unmutes a bay, leaving its volume alone.
- mxr_
set_ ⚠volume - Sets a bay’s volume percentage, and its mute state when
mutedis notMXR_UNKNOWN. - mxr_
subscribe_ ⚠v2ip_ stats - Subscribes to, or unsubscribes from, a device’s V2IP statistics.
- mxr_
topology ⚠ - Writes a device’s view of the mesh topology, and returns how many entries there are.
- mxr_
uid_ ⚠from_ string - Reads the dotted-hex form
mxr_uid_to_string()writes. - mxr_
uid_ is_ zero - Reports whether
uidis the empty identifier. - mxr_
uid_ ⚠to_ string - Writes
uidas dotted hex intoout, which needsMXR_UID_STRING_LENbytes. - mxr_
v2ip_ ⚠details - Fills
outwith a V2IP device’s own encoder configuration. - mxr_
v2ip_ ⚠sink - Fills
outwith the streams a V2IP sink is subscribed to. - mxr_
v2ip_ ⚠sources - Writes the streams a device’s source bays advertise, and returns how many there are.
- mxr_
v2ip_ ⚠stats - Fills
outwith a device’s V2IP statistics. - mxr_
v2ip_ ⚠tiling - Fills
outwith the window a sink is told to show. - mxr_
version - This library’s version, as
MAJOR.MINOR.PATCH. - mxr_
volume_ ⚠down - Asks a bay to step its volume down.
- mxr_
volume_ ⚠up - Asks a bay to step its volume up.
Type Aliases§
- mxr_
action_ transmit_ cb - Carries a request to perform a remote-control action.
- mxr_
arc_ cb - Names a bay and its audio return channel.
- mxr_
audio_ select_ cb - Carries an audio input selection.
- mxr_
bay_ bay_ cb - Names a bay and another bay, the zero device standing for none.
- mxr_
bay_ bool_ cb - Names a bay and a flag.
- mxr_
bay_ cb - Names only the bay the event concerns.
- mxr_
bay_ linked_ cb - Names a bay and the link that was made to it.
- mxr_
bay_ name_ change_ cb - Carries a request to rename a bay.
- mxr_
bay_ str_ cb - Names a bay and a string, borrowed for the call.
- mxr_
bay_ u8_ cb - Names a bay and an 8-bit value.
- mxr_
bay_ u16_ cb - Names a bay and a 16-bit value.
- mxr_
bay_ unlinked_ cb - Names a bay and the link that was removed from it.
- mxr_
blacklist_ cb - Carries a blacklist change.
- mxr_
device_ bool_ cb - Names a device and a flag.
- mxr_
device_ cb - Names only the device the event concerns.
- mxr_
device_ u16_ cb - Names a device and a 16-bit value.
- mxr_
device_ uid_ cb - Names a device and a second device.
- mxr_
edid_ profile_ change_ cb - Carries a request to switch an EDID profile.
- mxr_
edid_ record_ cb - Carries one EDID block a device replied with.
- mxr_
edid_ request_ cb - Carries a request for a device’s EDID.
- mxr_
endpoint_ bool_ cb - Names a device, one of its audio endpoints, and a flag.
- mxr_
endpoint_ u32_ cb - Names a device, one of its audio endpoints, and a 32-bit value.
- mxr_
factory_ reset_ cb - Carries a factory-reset request.
- mxr_
ir_ capture_ cb - Carries raw infrared captured on a bay.
- mxr_
ir_ transmit_ cb - Carries a request to blast raw infrared.
- mxr_
key_ transmit_ cb - Carries a request to send a remote-control key.
- mxr_
multiviewer_ command_ cb - Carries a multiviewer command.
- mxr_
power_ cb - Names a bay and the power state of what is connected to it.
- mxr_
power_ save_ cb - Carries a power-save request.
- mxr_
set_ route_ cb - Carries a request addressed to a device.
- mxr_
system_ status_ cb - Names a device, a status code and a message.
- mxr_
video_ wall_ cb - Carries a video wall command.
- mxr_
volume_ cb - Names a bay, its combined volume percentage and its mute state.