Skip to main content
Version: Dev (main)

Peer Management

Typedefs Index​

typedefvoid(* qar_peer_update_callback_t)(QarPeerSpec *handle, void *user_state)

Callback invoked when a peer spec changes. More...

Functions Index​

static QarResultqar_peer_spec_get_app_custom_peer_info (QarPeerSpec *handle, char *out_buffer, size_t buffer_size)

Get custom peer info string (application-defined). More...

static QarResultqar_peer_spec_get_app_state (QarPeerSpec *handle, QarAppState *out_state)

Get application state for this peer. More...

static QarResultqar_peer_spec_get_app_version (QarPeerSpec *handle, char *out_buffer, size_t buffer_size)

Get application version string. More...

static QarResultqar_peer_spec_get_category (QarPeerSpec *handle, QarDeviceCategory *out_category)

What kind of device the peer is: a headset, a Visualizer, a camera, a desktop PC, ... More...

static QarResultqar_peer_spec_get_device_family (QarPeerSpec *handle, char *out_buffer, size_t buffer_size)

The peer's device family: an open UTF-8 string ("MetaQuest", "HoloLens", "Metalens", "Headset", "Zed"), the fallback for a device id an application does not know. Empty when the peer has no family. More...

static QarResultqar_peer_spec_get_device_id (QarPeerSpec *handle, char *out_buffer, size_t buffer_size)

The peer's device id: an open UTF-8 string naming the exact device or app ("MetaQuest3", "HoloLens2", "Zed2i", "Visualizer", "DesktopWindows"). More...

static QarResultqar_peer_spec_get_device_name (QarPeerSpec *handle, char *out_buffer, size_t buffer_size)

The human name of the peer's device ("Meta Quest 3"), for showing it to a user. Empty when nothing better than the id is known. More...

static QarResultqar_peer_spec_get_display_name (QarPeerSpec *handle, char *out_buffer, size_t buffer_size)

Get display name string into provided buffer. More...

static QarResultqar_peer_spec_get_id (QarPeerSpec *handle, QarPeerId *out_id)

Get peer id from spec. More...

static QarResultqar_peer_spec_get_presence (QarPeerSpec *handle, QarPeerPresence *out_presence)

Whether this peer is here: the value to pick targets by. More...

static QarResultqar_peer_spec_get_role (QarPeerSpec *handle, QarPeerRole *out_role)

What the peer is in the streaming graph. More...

static QarResultqar_peer_spec_get_room_tag (QarPeerSpec *handle, char *out_buffer, size_t buffer_size)

Get current room tag string. More...

static QarResultqar_peer_spec_get_version_id (QarPeerSpec *handle, char *out_buffer, size_t buffer_size)

Get internal version id string. More...

static voidqar_peer_spec_handle_destroy (QarPeerSpec *handle)

Destroy a peer spec handle. More...

static boolqar_peer_spec_handle_is_valid (QarPeerSpec *handle)

Check if a peer spec handle is valid. More...

static QarResultqar_peer_spec_is_target_app (QarPeerSpec *handle, bool *out_is_target_app)

Whether this peer is a target app: a device or viewer that shows rendered content (a headset's serving app, a visualizer or camera receiver). The same as qar_peer_spec_get_role() returning QAR_PEER_ROLE_TARGET. More...

static QarResultqar_peer_subscribe_updates (QarSession *session, qar_peer_update_callback_t callback, void *user_state, QarCancelToken *token)

Subscribe for asynchronous peer spec updates. More...

static QarResultqar_peer_update_device_identity (QarSession *session, const QarPeerDeviceIdentity *identity)

Replace the device this application describes itself as, for example once a camera SDK has reported the exact model it opened. More...

static QarResultqar_peer_update_display_name (QarSession *session, const char *name)

Update current peer's display name. More...

static QarResultqar_query_peer_specs (QarSession *session, QarPeerSpec **out_handles, size_t handles_buffer_size, size_t *out_handles_written)

Enumerate peer specs into user-provided array. More...

static QarResultqar_query_peer_specs_count (QarSession *session, size_t *out_count)

Query number of known peer specs, retired peers excluded. More...

static QarResultqar_session_get_my_spec (const QarSession *session, QarPeerSpec **out_handle)

Get spec describing the current device/peer of a session. More...

Typedefs​

qar_peer_update_callback_t​

typedef void(* qar_peer_update_callback_t)(QarPeerSpec *handle, void *user_state)

Callback invoked when a peer spec changes.

Definition at line 4495 of file qar_streaming.h.

Functions​

qar_peer_spec_get_app_custom_peer_info()​

QarResult qar_peer_spec_get_app_custom_peer_info (QarPeerSpec * handle, char * out_buffer, size_t buffer_size)
inline static

Get custom peer info string (application-defined).

Definition at line 4272 of file qar_streaming.h.

qar_peer_spec_get_app_state()​

QarResult qar_peer_spec_get_app_state (QarPeerSpec * handle, QarAppState * out_state)
inline static

Get application state for this peer.

Deprecated

Use qar_peer_spec_get_presence(). Kept working: the value is computed from the presence. OFFLINE and LEAVING read as QAR_APP_STATE_SHUTTING_DOWN, RETIRED as QAR_APP_STATE_RETIRED, and an ONLINE or not yet reconciled peer reads as what it claimed, which every current peer claims as QAR_APP_STATE_RUNNING from the moment it joins. RUNNING therefore means "joined", never "finished configuring".

Definition at line 4286 of file qar_streaming.h.

qar_peer_spec_get_app_version()​

QarResult qar_peer_spec_get_app_version (QarPeerSpec * handle, char * out_buffer, size_t buffer_size)
inline static

Get application version string.

Definition at line 4268 of file qar_streaming.h.

qar_peer_spec_get_category()​

QarResult qar_peer_spec_get_category (QarPeerSpec * handle, QarDeviceCategory * out_category)
inline static

What kind of device the peer is: a headset, a Visualizer, a camera, a desktop PC, ...

The rendering fallback when an application does not know the peer's device id or family: pick an icon or a model by id, else by family, else by category.

 QarPeerRole role;
 QAR_CHECK(qar_peer_spec_get_role(peer, &role));
 if(role == QAR_PEER_ROLE_TARGET)
 {
  QarDeviceCategory category;
  char name[128], family[64];
  QAR_CHECK(qar_peer_spec_get_category(peer, &category));
  QAR_CHECK(qar_peer_spec_get_device_name(peer, name, sizeof name));
  QAR_CHECK(qar_peer_spec_get_device_family(peer, family, sizeof family));
  ShowTarget(name, IconFor(family, category)); // app's own icon table
 }
Parameters
handle

Peer spec handle.

out_category

Receives the category; treat a value this header does not name as QAR_DEVICE_CATEGORY_UNKNOWN.

Returns

Success, or QAR_STATUS_LOGIC_ERROR for an invalid handle or a null output.

Definition at line 4386 of file qar_streaming.h.

qar_peer_spec_get_device_family()​

QarResult qar_peer_spec_get_device_family (QarPeerSpec * handle, char * out_buffer, size_t buffer_size)
inline static

The peer's device family: an open UTF-8 string ("MetaQuest", "HoloLens", "Metalens", "Headset", "Zed"), the fallback for a device id an application does not know. Empty when the peer has no family.

Same buffer contract as qar_peer_spec_get_device_id().

Parameters
handle

Peer spec handle.

out_buffer

Receives the NUL-terminated family.

buffer_size

Size of out_buffer in bytes; must be > 0.

Returns

Success, or QAR_STATUS_LOGIC_ERROR for an invalid handle or buffer.

Definition at line 4421 of file qar_streaming.h.

qar_peer_spec_get_device_id()​

QarResult qar_peer_spec_get_device_id (QarPeerSpec * handle, char * out_buffer, size_t buffer_size)
inline static

The peer's device id: an open UTF-8 string naming the exact device or app ("MetaQuest3", "HoloLens2", "Zed2i", "Visualizer", "DesktopWindows").

Ids are not an enum: a new device model is a new id without a new API. The id can change while the peer runs (a serving app refines it once the device reports its model), so re-read it in the qar_peer_subscribe_updates() callback instead of caching it. Same buffer contract as qar_peer_spec_get_display_name(): NUL-terminated, truncated on a UTF-8 code point boundary.

Parameters
handle

Peer spec handle.

out_buffer

Receives the NUL-terminated id.

buffer_size

Size of out_buffer in bytes; must be > 0.

Returns

Success, or QAR_STATUS_LOGIC_ERROR for an invalid handle or buffer.

Definition at line 4406 of file qar_streaming.h.

qar_peer_spec_get_device_name()​

QarResult qar_peer_spec_get_device_name (QarPeerSpec * handle, char * out_buffer, size_t buffer_size)
inline static

The human name of the peer's device ("Meta Quest 3"), for showing it to a user. Empty when nothing better than the id is known.

Same buffer contract as qar_peer_spec_get_device_id(); the name can change while the peer runs.

Parameters
handle

Peer spec handle.

out_buffer

Receives the NUL-terminated name.

buffer_size

Size of out_buffer in bytes; must be > 0.

Returns

Success, or QAR_STATUS_LOGIC_ERROR for an invalid handle or buffer.

Definition at line 4436 of file qar_streaming.h.

qar_peer_spec_get_display_name()​

QarResult qar_peer_spec_get_display_name (QarPeerSpec * handle, char * out_buffer, size_t buffer_size)
inline static

Get display name string into provided buffer.

Definition at line 4263 of file qar_streaming.h.

qar_peer_spec_get_id()​

QarResult qar_peer_spec_get_id (QarPeerSpec * handle, QarPeerId * out_id)
inline static

Get peer id from spec.

Definition at line 4260 of file qar_streaming.h.

qar_peer_spec_get_presence()​

QarResult qar_peer_spec_get_presence (QarPeerSpec * handle, QarPeerPresence * out_presence)
inline static

Whether this peer is here: the value to pick targets by.

ONLINE while the hub sees the peer in the session. A peer the hub no longer sees reads as QAR_PEER_PRESENCE_OFFLINE (a killed process never announces its leave) and as ONLINE again once it is back, without the peer doing anything. A peer that announced its leave reads as QAR_PEER_PRESENCE_LEAVING, or QAR_PEER_PRESENCE_RETIRED when it never comes back under its id. QAR_PEER_PRESENCE_UNKNOWN is a peer the hub has not reconciled yet: an older hub that never reports presence, or one that has just started. Nothing says it is gone, so render for it like an ONLINE peer. A peer's readiness to receive a stream is negotiated by its render sender, not announced here.

 QarPeerPresence presence;
 QAR_CHECK(qar_peer_spec_get_presence(peer, &presence));
 if(presence == QAR_PEER_PRESENCE_ONLINE
  || presence == QAR_PEER_PRESENCE_UNKNOWN)
 {
  StartRenderingFor(peer);
 }
 else
 {
  StopRenderingFor(peer); // offline, leaving or retired
 }
Parameters
handle

Peer spec handle.

out_presence

Receives the presence; treat a value this header does not name as QAR_PEER_PRESENCE_UNKNOWN.

Returns

Success, or QAR_STATUS_LOGIC_ERROR for an invalid handle or a null output.

Definition at line 4321 of file qar_streaming.h.

qar_peer_spec_get_role()​

QarResult qar_peer_spec_get_role (QarPeerSpec * handle, QarPeerRole * out_role)
inline static

What the peer is in the streaming graph.

A source application renders for the peers whose role is QAR_PEER_ROLE_TARGET (a headset's serving app, a Visualizer receiver, a camera's receiver slot). See "Basic flow" at the top of this header. An application using this API is always QAR_PEER_ROLE_SOURCE.

Parameters
handle

Peer spec handle.

out_role

Receives the role.

Returns

Success, or QAR_STATUS_LOGIC_ERROR for an invalid handle or a null output.

Definition at line 4357 of file qar_streaming.h.

qar_peer_spec_get_room_tag()​

QarResult qar_peer_spec_get_room_tag (QarPeerSpec * handle, char * out_buffer, size_t buffer_size)
inline static

Get current room tag string.

Definition at line 4327 of file qar_streaming.h.

qar_peer_spec_get_version_id()​

QarResult qar_peer_spec_get_version_id (QarPeerSpec * handle, char * out_buffer, size_t buffer_size)
inline static

Get internal version id string.

Definition at line 4323 of file qar_streaming.h.

qar_peer_spec_handle_destroy()​

void qar_peer_spec_handle_destroy (QarPeerSpec * handle)
inline static

Destroy a peer spec handle.

Definition at line 4257 of file qar_streaming.h.

qar_peer_spec_handle_is_valid()​

bool qar_peer_spec_handle_is_valid (QarPeerSpec * handle)
inline static

Check if a peer spec handle is valid.

Definition at line 4255 of file qar_streaming.h.

qar_peer_spec_is_target_app()​

QarResult qar_peer_spec_is_target_app (QarPeerSpec * handle, bool * out_is_target_app)
inline static

Whether this peer is a target app: a device or viewer that shows rendered content (a headset's serving app, a visualizer or camera receiver). The same as qar_peer_spec_get_role() returning QAR_PEER_ROLE_TARGET.

Parameters
handle

Peer spec handle.

out_is_target_app

Receives true for a target app, false for anything else (a hub, a source application, pipeline infrastructure).

Returns

Success, or QAR_STATUS_LOGIC_ERROR for an invalid handle or a null output.

Definition at line 4342 of file qar_streaming.h.

qar_peer_subscribe_updates()​

QarResult qar_peer_subscribe_updates (QarSession * session, qar_peer_update_callback_t callback, void * user_state, QarCancelToken * token)
inline static

Subscribe for asynchronous peer spec updates.

The push form of qar_query_peer_specs(), and the way to learn that a peer invited with qar_session_invite_target_app() has joined: it is listed, and its qar_peer_spec_get_presence() is QAR_PEER_PRESENCE_ONLINE (or UNKNOWN on a hub that does not report presence).

Parameters
token

Required; cancelling or destroying it ends the subscription and waits for a running callback, see Ending a subscription.

Definition at line 4510 of file qar_streaming.h.

qar_peer_update_device_identity()​

QarResult qar_peer_update_device_identity (QarSession * session, const QarPeerDeviceIdentity * identity)
inline static

Replace the device this application describes itself as, for example once a camera SDK has reported the exact model it opened.

Published as a normal peer spec update. The role stays QAR_PEER_ROLE_SOURCE. To join with an identity from the start, chain the same struct on QarPeerPresentation::header.next of QarOnboardInit or QarRejoinInit.

 QarPeerDeviceIdentity refined = qar_peer_device_identity_default();
 refined.category = QAR_DEVICE_CATEGORY_CAMERA;
 refined.device_id = "LuxonisOakDPro";
 refined.device_family = "Luxonis";
 refined.device_name = "OAK-D Pro W";
 QAR_CHECK(qar_peer_update_device_identity(session, &refined));
Parameters
session

Active session handle.

identity

Required; see QarPeerDeviceIdentity.

Return Values
QAR_STATUS_PEER_DEVICE_CATEGORY_NOT_ALLOWED

the category is not DESKTOP_PC, SERVER or CAMERA. Nothing was changed.

QAR_STATUS_ARGUMENT_NOT_SUPPORTED

device_id is NULL or empty.

QAR_STATUS_LOGIC_ERROR

a NULL or wrongly typed struct, or an invalid session.

Definition at line 4491 of file qar_streaming.h.

qar_peer_update_display_name()​

QarResult qar_peer_update_display_name (QarSession * session, const char * name)
inline static

Update current peer's display name.

Definition at line 4464 of file qar_streaming.h.

qar_query_peer_specs()​

QarResult qar_query_peer_specs (QarSession * session, QarPeerSpec ** out_handles, size_t handles_buffer_size, size_t * out_handles_written)
inline static

Enumerate peer specs into user-provided array.

Size the array with qar_query_peer_specs_count(). Retired peers (QAR_PEER_PRESENCE_RETIRED) never come back and are not listed; an update subscription still reports a peer turning retired. The list also contains this process' own peer; qar_session_get_my_spec() identifies it. Match qar_peer_spec_get_id() against the id qar_session_invite_target_app() returned to find an invited peer, and read qar_peer_spec_get_presence() to see whether it has joined.

Definition at line 4456 of file qar_streaming.h.

qar_query_peer_specs_count()​

QarResult qar_query_peer_specs_count (QarSession * session, size_t * out_count)
inline static

Query number of known peer specs, retired peers excluded.

Definition at line 4444 of file qar_streaming.h.

qar_session_get_my_spec()​

QarResult qar_session_get_my_spec (const QarSession * session, QarPeerSpec ** out_handle)
inline static

Get spec describing the current device/peer of a session.

Definition at line 4441 of file qar_streaming.h.


Generated via doxygen2docusaurus 2.2.1 by Doxygen 1.9.8.