Skip to main content
Version: Dev (main)

Render Sender

Typedefs Index​

typedefvoid(* qar_render_sender_begin_frame_callback_t)(QarResult status, QarRenderFrameInfo *frame_info, void *user_state)
typedefvoid(* qar_render_sender_create_callback_t)(QarResult status, QarRenderSender *out_stream, void *user_state)

Functions Index​

static QarResultqar_render_frame_info_get_view_fov (QarRenderFrameInfo *handle, size_t view_index, QarFov *out_fov)

The field of view of one view, in view space, in radians. A view of eye QAR_VIDEO_FRAME_VIEW_EYE_NONE gets the left eye's. More...

static QarResultqar_render_frame_info_get_view_pose (QarRenderFrameInfo *handle, size_t view_index, QarPose *out_pose)

The pose to render one view with, in the bound app volume's app content space. More...

static voidqar_render_frame_info_handle_destroy (QarRenderFrameInfo *handle)
static boolqar_render_frame_info_handle_is_valid (QarRenderFrameInfo *handle)
static QarResultqar_render_request_get_stream_id (QarRenderStreamRequest *request, QarStreamId *out_stream_id)

Get the stream id from a render request. More...

static QarResultqar_render_request_get_target_peer_id (QarRenderStreamRequest *request, QarPeerId *out_peer_id)

Get the target peer id from a render request. More...

static voidqar_render_request_handle_destroy (QarRenderStreamRequest *request)

Destroy a render stream request handle. More...

static boolqar_render_request_handle_is_valid (QarRenderStreamRequest *request)

Check if a render stream request handle is valid. More...

static QarResultqar_render_sender_begin_frame (QarRenderSender *stream, QarCancelToken *token, QarRenderFrameInfo **out_frame_info)

Begin producing a new frame. More...

static QarResultqar_render_sender_begin_frame_async (QarRenderSender *stream, qar_render_sender_begin_frame_callback_t callback, void *user_state, QarCancelToken *token)

Async version of begin_frame. Same poses, same space, same failures and the same wait through a paused stream as qar_render_sender_begin_frame(). The callback fires exactly once, see Async calls. More...

static QarResultqar_render_sender_change_layout (QarRenderSender *stream, const QarVideoFrameLayout *layout)

Request a layout change for subsequent frames. More...

static QarResultqar_render_sender_create (QarSession *session, QarRenderSenderInit *init, QarCancelToken *cancel, QarRenderSender **out_stream)

Create a rendering stream sender bound to a session. More...

static QarResultqar_render_sender_create_async (QarSession *session, QarRenderSenderInit *init, qar_render_sender_create_callback_t callback, void *user_state, QarCancelToken *token)

Async variant of qar_render_sender_create. The callback fires exactly once, see Async calls; out_stream is the app's only on success. On a session created with QarGraphicsDeviceDisabledExt it returns QAR_STATUS_GRAPHICS_DEVICE_NOT_INITIALIZED and never calls the callback. More...

static QarResultqar_render_sender_frame_cpu (QarRenderSender *stream, QarVideoFrameCpu *out_frame)

Get CPU-backed frame access. More...

static QarResultqar_render_sender_frame_d3d11 (QarRenderSender *stream, QarVideoFrameD3D11 *out_frame)

Get D3D11-backed frame access. Readable before the first begin-frame; writable only inside a frame cycle. More...

static QarResultqar_render_sender_get_stream_state (QarRenderSender *stream, QarRenderSenderStreamState *out_state)

Reads what a render sender's stream is doing right now. Never blocks. More...

static QarResultqar_render_sender_is_ready_for_next_frame (QarRenderSender *stream, bool *out_ready)

For a sender declared QAR_RENDER_LOOP_FREE_RUNNING: whether a frame rendered now can be sent without waiting. Never blocks. More...

static QarResultqar_render_sender_last_hands (QarRenderSender *stream, QarDeviceHandsWithJoints *out_hands)

Query the newest hands data the device sent since the previous call. More...

static QarResultqar_render_sender_layout (QarRenderSender *stream, QarVideoFrameLayout *out_layout)

Retrieve the negotiated video frame layout. More...

static QarResultqar_render_sender_next_render_pose (QarRenderSender *stream, size_t view_count, QarPose *out_view_poses, QarFov *out_view_fovs)

For a sender declared QAR_RENDER_LOOP_FREE_RUNNING: the poses and fields of view to render the next frame with, taken before begin-frame. More...

static QarResultqar_render_sender_show_frame (QarRenderSender *stream, const QarRenderFrameShow *frame_show)

Submit the rendered frame for presentation/streaming. More...

static QarResultqar_render_sender_subscribe_requests (QarSession *session, qar_render_sender_request_callback_t callback, void *user_state, QarCancelToken *token)

Subscribe to render stream requests for this application's content. More...

static QarResultqar_render_sender_try_begin_frame (QarRenderSender *stream, QarRenderFrameInfo **out_frame_info, bool *out_ready)

Non-blocking attempt to begin producing a new frame. More...

static voidqar_render_stream_handle_destroy (QarRenderSender *handle)

Destroy a render stream sender handle. More...

Typedefs​

qar_render_sender_begin_frame_callback_t​

typedef void(* qar_render_sender_begin_frame_callback_t)(QarResult status, QarRenderFrameInfo *frame_info, void *user_state)

Definition at line 4749 of file qar_streaming.h.

qar_render_sender_create_callback_t​

typedef void(* qar_render_sender_create_callback_t)(QarResult status, QarRenderSender *out_stream, void *user_state)

Definition at line 4614 of file qar_streaming.h.

Functions​

qar_render_frame_info_get_view_fov()​

QarResult qar_render_frame_info_get_view_fov (QarRenderFrameInfo * handle, size_t view_index, QarFov * out_fov)
inline static

The field of view of one view, in view space, in radians. A view of eye QAR_VIDEO_FRAME_VIEW_EYE_NONE gets the left eye's.

Definition at line 4814 of file qar_streaming.h.

qar_render_frame_info_get_view_pose()​

QarResult qar_render_frame_info_get_view_pose (QarRenderFrameInfo * handle, size_t view_index, QarPose * out_pose)
inline static

The pose to render one view with, in the bound app volume's app content space.

The sender has already taken the viewer's room-space pose through the volume's pose, app pose and app scale, so the application renders its scene in its own coordinates. A view of eye QAR_VIDEO_FRAME_VIEW_EYE_NONE gets the head pose.

Definition at line 4807 of file qar_streaming.h.

qar_render_frame_info_handle_destroy()​

void qar_render_frame_info_handle_destroy (QarRenderFrameInfo * handle)
inline static

Definition at line 4797 of file qar_streaming.h.

qar_render_frame_info_handle_is_valid()​

bool qar_render_frame_info_handle_is_valid (QarRenderFrameInfo * handle)
inline static

Definition at line 9038 of file qar_streaming.h.

qar_render_request_get_stream_id()​

QarResult qar_render_request_get_stream_id (QarRenderStreamRequest * request, QarStreamId * out_stream_id)
inline static

Get the stream id from a render request.

Definition at line 4580 of file qar_streaming.h.

qar_render_request_get_target_peer_id()​

QarResult qar_render_request_get_target_peer_id (QarRenderStreamRequest * request, QarPeerId * out_peer_id)
inline static

Get the target peer id from a render request.

Definition at line 4576 of file qar_streaming.h.

qar_render_request_handle_destroy()​

void qar_render_request_handle_destroy (QarRenderStreamRequest * request)
inline static

Destroy a render stream request handle.

Definition at line 4574 of file qar_streaming.h.

qar_render_request_handle_is_valid()​

bool qar_render_request_handle_is_valid (QarRenderStreamRequest * request)
inline static

Check if a render stream request handle is valid.

Definition at line 9044 of file qar_streaming.h.

qar_render_sender_begin_frame()​

QarResult qar_render_sender_begin_frame (QarRenderSender * stream, QarCancelToken * token, QarRenderFrameInfo ** out_frame_info)
inline static

Begin producing a new frame.

Returns per-frame information such as per-eye pose/FOV to render with. The poses are in the bound app volume's app content space.

Fails with QAR_STATUS_RENDERING_PRODUCER_APP_VOLUME_UNRESOLVED, without beginning a frame, while the app volume does not resolve: app content space is undefined then, and no room-space pose is handed out in its place. The failure is recoverable - keep calling, a frame begins once the volume resolves. The call is held about 16 ms first, so a retrying loop does not spin.

Waits, rather than fails, while the receiver has paused the stream (for example, its display is not visible): the sender and its stream stay up and the frame begins as soon as the receiver resumes. Cancel token to stop waiting; the call then fails.

Definition at line 4717 of file qar_streaming.h.

qar_render_sender_begin_frame_async()​

QarResult qar_render_sender_begin_frame_async (QarRenderSender * stream, qar_render_sender_begin_frame_callback_t callback, void * user_state, QarCancelToken * token)
inline static

Async version of begin_frame. Same poses, same space, same failures and the same wait through a paused stream as qar_render_sender_begin_frame(). The callback fires exactly once, see Async calls.

Definition at line 4756 of file qar_streaming.h.

qar_render_sender_change_layout()​

QarResult qar_render_sender_change_layout (QarRenderSender * stream, const QarVideoFrameLayout * layout)
inline static

Request a layout change for subsequent frames.

Not callable inside a frame cycle: between a successful begin-frame and its qar_render_sender_show_frame() it returns QAR_STATUS_LOGIC_ERROR and changes nothing. The views and textures of later frames keep the order given in layout.

Definition at line 4652 of file qar_streaming.h.

qar_render_sender_create()​

QarResult qar_render_sender_create (QarSession * session, QarRenderSenderInit * init, QarCancelToken * cancel, QarRenderSender ** out_stream)
inline static

Create a rendering stream sender bound to a session.

**init->peer_id is the target this stream renders for**, not this process' own id; see "Basic flow" at the top of this header for where it comes from. The sender attaches that target to init->app_volume_id. A fresh qar_peer_id_unique() belongs to no peer: a stream created with one negotiates with nobody and never produces a frame.

**init->app_volume_id must name an app volume that already exists.** The volume is what places the stream in the shared 3D scene, so create it first with qar_app_volumes_get_or_create() and pass the id it returns.

Parameters
session

Active session handle.

init

Stream configuration (views, formats, target peer, app volume).

cancel

Optional cancellation token for creation.

out_stream

Receives the created stream sender handle.

Returns

QarResult QAR_STATUS_APP_VOLUME_INVALID_ID when no app volume id is given. QAR_STATUS_MEDIA_STREAMING_DEVICE_ON_ANOTHER_ADAPTER when the device in QarStreamParamsVulkan or QarStreamParamsD3D11 is on another GPU than the session's: create it on the adapter qar_session_get_graphics_device_id() reports. QAR_STATUS_GRAPHICS_DEVICE_NOT_INITIALIZED when the session was created with QarGraphicsDeviceDisabledExt; nothing is created.

Definition at line 4608 of file qar_streaming.h.

qar_render_sender_create_async()​

QarResult qar_render_sender_create_async (QarSession * session, QarRenderSenderInit * init, qar_render_sender_create_callback_t callback, void * user_state, QarCancelToken * token)
inline static

Async variant of qar_render_sender_create. The callback fires exactly once, see Async calls; out_stream is the app's only on success. On a session created with QarGraphicsDeviceDisabledExt it returns QAR_STATUS_GRAPHICS_DEVICE_NOT_INITIALIZED and never calls the callback.

Definition at line 4622 of file qar_streaming.h.

qar_render_sender_frame_cpu()​

QarResult qar_render_sender_frame_cpu (QarRenderSender * stream, QarVideoFrameCpu * out_frame)
inline static

Get CPU-backed frame access.

The frame exists from creation, so it may be read – textures, views, sizes – before the first begin-frame. Its contents and synchronization may be written only inside a frame cycle.

Definition at line 4662 of file qar_streaming.h.

qar_render_sender_frame_d3d11()​

QarResult qar_render_sender_frame_d3d11 (QarRenderSender * stream, QarVideoFrameD3D11 * out_frame)
inline static

Get D3D11-backed frame access. Readable before the first begin-frame; writable only inside a frame cycle.

Definition at line 4670 of file qar_streaming.h.

qar_render_sender_get_stream_state()​

QarResult qar_render_sender_get_stream_state (QarRenderSender * stream, QarRenderSenderStreamState * out_state)
inline static

Reads what a render sender's stream is doing right now. Never blocks.

Begin-frame waits through a pause, a reconnect and a missing receiver alike (qar_render_sender_try_begin_frame() reports success with ready false for all of them), so call this when it is not ready to tell them apart:

  • QAR_RENDER_SENDER_STREAM_STATE_CONNECTING: a receiver is attached and its transfer is not established yet.
  • QAR_RENDER_SENDER_STREAM_STATE_WAITING_FOR_RECEIVER: no receiver is attached.
  • QAR_RENDER_SENDER_STREAM_STATE_STREAMING: a receiver is attached and takes frames.
  • QAR_RENDER_SENDER_STREAM_STATE_PAUSED: the receiver paused the stream. The sender and its connection stay up; keep the sender and poll again, frames resume when the receiver resumes.
  • QAR_RENDER_SENDER_STREAM_STATE_RECONNECTING: the receiver's connection was lost and is being re-established.
  • QAR_RENDER_SENDER_STREAM_STATE_CLOSED: the stream is closed for good.

The value is a snapshot and may change right after the call.

Parameters
stream

A render sender.

out_state

Receives the state.

Returns

Success; QAR_STATUS_LOGIC_ERROR for a null or unknown handle; QAR_STATUS_NOT_IMPLEMENTED when loaded dynamically from a runtime older than this function (the rest of the module works; fall back to qar_render_sender_try_begin_frame() alone).

Definition at line 4902 of file qar_streaming.h.

qar_render_sender_is_ready_for_next_frame()​

QarResult qar_render_sender_is_ready_for_next_frame (QarRenderSender * stream, bool * out_ready)
inline static

For a sender declared QAR_RENDER_LOOP_FREE_RUNNING: whether a frame rendered now can be sent without waiting. Never blocks.

out_ready is true once the receiver has handed back the destination of the previous frame: the destination is then reserved for the next frame, and the next qar_render_sender_begin_frame() returns without waiting for it. It stays reserved until that begin-frame. out_ready is false while the destination is still out, and while the stream is paused, reconnecting or has no receiver yet; none of these is an error.

A loop serving several senders calls this for each first, then takes qar_render_sender_next_render_pose(), renders, begins, copies and shows only for the senders that are ready. A slower receiver or a reconnecting stream then holds back no other sender.

Parameters
stream

A render sender created with QarRenderSenderRenderLoopExt set to QAR_RENDER_LOOP_FREE_RUNNING.

out_ready

Receives whether the next frame can be sent without waiting.

Returns

QAR_STATUS_RENDERING_PRODUCER_STREAM_IS_CLOSED once the stream closed, QAR_STATUS_LOGIC_ERROR for a request-driven sender or while a begin-frame of this sender is waiting or its frame is not shown yet.

Definition at line 4870 of file qar_streaming.h.

qar_render_sender_last_hands()​

QarResult qar_render_sender_last_hands (QarRenderSender * stream, QarDeviceHandsWithJoints * out_hands)
inline static

Query the newest hands data the device sent since the previous call.

Drains everything that arrived and returns the last sample. The poses are in the bound app volume's app content space, like the view poses, and so are the joint radii and velocities measured beside them: radii in app units, velocities in app axes, linear ones in app units per second. Never room space - hand data a peer publishes on a data stream is in that peer's room space, but this call converts it. Samples arrive only while the target peer is focused on the volume and not editing it, and while the volume resolves; otherwise both hands are untracked. When nothing arrived since the previous call, the last sample is returned again while it is younger than a second, so polling faster than the device sends never blinks the hands out between its samples. Once no sample has arrived for a second, both hands are reported untracked: a device that stopped sending has no hands. Poll it once per frame.

Parameters
stream

The render sender.

out_hands

Receives the newest sample, the last one while it is younger than a second, or a sample with both hands untracked.

Returns

Success, or an error once the hand stream has closed.

Definition at line 4790 of file qar_streaming.h.

qar_render_sender_layout()​

QarResult qar_render_sender_layout (QarRenderSender * stream, QarVideoFrameLayout * out_layout)
inline static

Retrieve the negotiated video frame layout.

Available as soon as the sender exists: it is what the stream request settled on, so it can be read before the first begin-frame and while a transfer is reconnecting. Size lasting resources from this rather than from a frame that has not arrived yet.

Its views come in exactly the order declared in QarRenderSenderInit::frame_views, and every frame's views and textures match it; after qar_render_sender_change_layout(), in the order of that layout.

Definition at line 4641 of file qar_streaming.h.

qar_render_sender_next_render_pose()​

QarResult qar_render_sender_next_render_pose (QarRenderSender * stream, size_t view_count, QarPose * out_view_poses, QarFov * out_view_fovs)
inline static

For a sender declared QAR_RENDER_LOOP_FREE_RUNNING: the poses and fields of view to render the next frame with, taken before begin-frame.

Predicted now from the newest head pose for when the frame is shown, in the same app content space as the frame info's poses. The next begin-frame opens its frame with exactly these poses, so an application renders into its own target first, then begins the frame, copies into the sender's textures and shows it: while it renders, the receiver hands the frame's destination back. A second call before that begin-frame replaces the poses. Views are in the frame's view order, as qar_render_frame_info_get_view_pose() indexes them.

Parameters
stream

A render sender created with QarRenderSenderRenderLoopExt set to QAR_RENDER_LOOP_FREE_RUNNING.

view_count

How many views to write, at most the sender's views.

out_view_poses

Receives view_count poses.

out_view_fovs

Receives view_count fields of view, in radians.

Returns

QAR_STATUS_RENDERING_PRODUCER_MISSING_POSE_DATA before the first head pose arrived, QAR_STATUS_RENDERING_PRODUCER_APP_VOLUME_UNRESOLVED while the app volume does not resolve, QAR_STATUS_LOGIC_ERROR for a request-driven sender or too many views.

Definition at line 4841 of file qar_streaming.h.

qar_render_sender_show_frame()​

QarResult qar_render_sender_show_frame (QarRenderSender * stream, const QarRenderFrameShow * frame_show)
inline static

Submit the rendered frame for presentation/streaming.

Definition at line 4765 of file qar_streaming.h.

qar_render_sender_subscribe_requests()​

QarResult qar_render_sender_subscribe_requests (QarSession * session, qar_render_sender_request_callback_t callback, void * user_state, QarCancelToken * token)
inline static

Subscribe to render stream requests for this application's content.

A target requests the content only once it is attached to the application's app volume, so this does not discover targets for a new application - see "Basic flow" at the top of this header for that. It sees requests for a volume something else attached a target to.

In the callback, read qar_render_request_get_target_peer_id(), then enqueue that id for the application's render thread, which creates one sender (and a camera using its per-frame pose/FOV) per target. Repeated requests for a target already served do not require another sender.

Callbacks run asynchronously, so synchronize handoff to the render thread. Release each delivered request with qar_render_request_handle_destroy(). Keep user_state alive until the call ending the subscription has returned, see Ending a subscription.

Parameters
session

Active session.

callback

Required callback for each pending request.

user_state

Application state passed unchanged to the callback.

token

Required cancellation token owning the subscription; cancelling or destroying it, or destroying the session, ends it.

Returns

Success when subscribed, QAR_STATUS_GRAPHICS_DEVICE_NOT_INITIALIZED on a session created with QarGraphicsDeviceDisabledExt, or a subscription setup error.

Definition at line 4563 of file qar_streaming.h.

qar_render_sender_try_begin_frame()​

QarResult qar_render_sender_try_begin_frame (QarRenderSender * stream, QarRenderFrameInfo ** out_frame_info, bool * out_ready)
inline static

Non-blocking attempt to begin producing a new frame.

Starts the begin-frame wait on the first call and polls it on every call without blocking. When the wait has completed, out_ready is set to true and out_frame_info receives the per-frame information; otherwise out_ready is set to false and the caller should poll again later. The returned QarResult reports only real failures (invalid arguments, a failed begin-frame); a still-pending wait is reported through out_ready, not as an error. Poll with the same stream until out_ready becomes true. Fails like qar_render_sender_begin_frame(), including QAR_STATUS_RENDERING_PRODUCER_APP_VOLUME_UNRESOLVED while the app volume does not resolve. While the receiver has paused the stream the wait does not complete: out_ready stays false and the call succeeds until it resumes.

A loop that polls once per frame calls it once more right after qar_render_sender_show_frame(): the next wait then runs while the loop is idle, and the next frame's call finds it ready. Started only by the next frame's call, the wait completes a frame later, and the loop serves the stream every other frame.

Definition at line 4744 of file qar_streaming.h.

qar_render_stream_handle_destroy()​

void qar_render_stream_handle_destroy (QarRenderSender * handle)
inline static

Destroy a render stream sender handle.

A begin-frame still waiting on the sender is stopped and fails; the call returns once it has let go of the sender, usually within a frame and at most after 5 s. Avoid calling it from a callback of this library, which runs on the library's own threads.

Definition at line 4536 of file qar_streaming.h.


Generated via doxygen2docusaurus 2.2.1 by Doxygen 1.9.8.