Elixir Media over QUIC library.

Protocol code is built on top of a small transport adapter boundary so that native QUIC and deterministic support transports can share the same contract.

Summary

Types

Object delivery selected for a published track.

Protocol-neutral reason for publisher-initiated subscription completion.

Option accepted by subscribe/3.

Relative object boundary requested when a subscription begins.

Functions

Accepts one pending inbound publisher subscription.

Registers a track under an active publication.

Gracefully closes the selected protocol connection.

Connects to an endpoint using one explicitly selected protocol implementation.

Finishes every active delivery and withdraws a namespace publication.

Finishes one accepted publisher subscription without withdrawing its track or namespace publication.

Advertises a namespace through the selected protocol implementation.

Publishes one object on a registered track.

Rejects one pending inbound publisher subscription.

Subscribes to a protocol-neutral track address.

Returns the default native QUIC transport implementation.

Ends an active subscription and sends the selected protocol's unsubscribe message.

Updates an active subscription's draft-neutral filter and delivery parameters.

Withdraws one registered track while keeping its publication and siblings active.

Types

publication_delivery()

@type publication_delivery() :: :subgroup | :datagram

Object delivery selected for a published track.

published_subscription_status()

@type published_subscription_status() ::
  :internal_error
  | :unauthorized
  | :track_ended
  | :subscription_ended
  | :going_away
  | :expired
  | :too_far_behind
  | :malformed_track
  | :update_failed

Protocol-neutral reason for publisher-initiated subscription completion.

published_track_option()

@type published_track_option() ::
  {:retention, :live | :latest | :all}
  | {:delivery, publication_delivery()}
  | {:timescale, pos_integer()}
  | {:publisher_priority, 0..255}
  | {:publisher_max_latency, non_neg_integer()}

Option accepted by add_track/4.

subscription_option()

@type subscription_option() ::
  {:start, subscription_start()}
  | {:filter, MOQX.SubscriptionFilter.t()}
  | {:priority, 0..255}
  | {:group_order, :ascending | :descending}
  | {:delivery_timeout, pos_integer()}
  | {:parameters, [MOQX.SubscriptionParameter.t()]}

Option accepted by subscribe/3.

subscription_start()

@type subscription_start() :: :next_object | :next_group

Relative object boundary requested when a subscription begins.

:next_object starts after the publisher's current largest object and is the compatibility default. :next_group waits for the first object in a later group. A selected protocol returns an error when it cannot represent the requested policy.

subscription_update_option()

@type subscription_update_option() ::
  {:start, subscription_start()}
  | {:filter, MOQX.SubscriptionFilter.t()}
  | {:priority, 0..255}
  | {:delivery_timeout, pos_integer()}
  | {:forward, boolean()}
  | {:new_group, non_neg_integer()}
  | {:parameters, [MOQX.SubscriptionParameter.t()]}

Option accepted by update_subscription/3.

withdraw_track_error()

@type withdraw_track_error() ::
  :unknown_published_track
  | :wrong_client_published_track
  | :unsupported_completion_status
  | :invalid_track_completion
  | :timeout
  | {:connection_closed, term()}
  | {:transport_action_failed, term()}

Error returned by withdraw_track/3.

Functions

accept_subscription(client, request, published_track_or_options, options \\ [])

Accepts one pending inbound publisher subscription.

Pass an existing PublishedTrack to attach another subscriber to a registered track; the result contains its PublishedSubscription handle. Pass track options instead to register the requested track reactively and accept its first subscription without sending a separate publisher-initiated PUBLISH; that result contains both the new track and subscription handles.

add_track(client, publication, track, options \\ [])

@spec add_track(MOQX.Client.t(), MOQX.Publication.t(), binary(), [
  published_track_option()
]) ::
  {:ok, MOQX.PublishedTrack.t()} | {:error, term()}

Registers a track under an active publication.

:delivery defaults to :subgroup. The selected protocol rejects a delivery mode it cannot represent. MoQ Lite draft-05 additionally requires a positive :timescale and accepts :publisher_priority and :publisher_max_latency for its immutable TRACK_INFO.

close(client, options \\ [])

@spec close(MOQX.Client.t(), keyword()) :: :ok | {:error, term()}

Gracefully closes the selected protocol connection.

connect(endpoint, options)

@spec connect(binary() | URI.t(), keyword()) ::
  {:ok, MOQX.Client.t()} | {:error, term()}

Connects to an endpoint using one explicitly selected protocol implementation.

finish_publication(client, publication, options \\ [])

@spec finish_publication(MOQX.Client.t(), MOQX.Publication.t(), keyword()) ::
  :ok | {:error, term()}

Finishes every active delivery and withdraws a namespace publication.

Pending controlled subscription requests are cancelled before established subscriptions and published tracks complete. The selected protocol withdraws the namespace only after those per-request completion boundaries.

finish_subscription(client, published_subscription, options \\ [])

@spec finish_subscription(
  MOQX.Client.t(),
  MOQX.PublishedSubscription.t(),
  status: published_subscription_status(),
  reason: binary()
) :: :ok | {:error, term()}

Finishes one accepted publisher subscription without withdrawing its track or namespace publication.

The selected implementation maps the protocol-neutral :status atom to its native PUBLISH_DONE code. The default is :subscription_ended.

publish(client, namespace, options \\ [])

@spec publish(MOQX.Client.t(), [binary()], keyword()) ::
  {:ok, MOQX.Publication.t()} | {:error, term()}

Advertises a namespace through the selected protocol implementation.

publish_object(client, track, object)

@spec publish_object(MOQX.Client.t(), MOQX.PublishedTrack.t(), MOQX.Object.t()) ::
  :ok | {:error, term()}

Publishes one object on a registered track.

reject_subscription(client, request, rejection)

@spec reject_subscription(
  MOQX.Client.t(),
  MOQX.PublicationSubscriptionRequest.t(),
  MOQX.SubscriptionRejection.t()
) :: :ok | {:error, term()}

Rejects one pending inbound publisher subscription.

subscribe(client, track, options \\ [])

@spec subscribe(MOQX.Client.t(), MOQX.TrackRef.t(), [subscription_option()]) ::
  {:ok, MOQX.Subscription.t()} | {:error, term()}

Subscribes to a protocol-neutral track address.

The :start option accepts :next_object or :next_group and defaults to :next_object. Protocol implementations map that application policy to their native subscription filter and reject unsupported policies explicitly.

transport()

@spec transport() :: module()

Returns the default native QUIC transport implementation.

unsubscribe(client, subscription)

@spec unsubscribe(MOQX.Client.t(), MOQX.Subscription.t()) :: :ok | {:error, term()}

Ends an active subscription and sends the selected protocol's unsubscribe message.

update_subscription(client, subscription, options)

@spec update_subscription(
  MOQX.Client.t(),
  MOQX.Subscription.t(),
  [subscription_update_option()]
) :: :ok | {:error, term()}

Updates an active subscription's draft-neutral filter and delivery parameters.

withdraw_track(client, track, options \\ [])

@spec withdraw_track(
  MOQX.Client.t(),
  MOQX.PublishedTrack.t(),
  status: published_subscription_status(),
  reason: binary()
) :: :ok | {:error, withdraw_track_error()}

Withdraws one registered track while keeping its publication and siblings active.

The track is unavailable to new subscribers before this call returns. The selected protocol maps :status to its native terminal code. The default status is :track_ended.