|
LibQuicR
|
Handler for receiving a bounded FETCH response. More...
#include <fetch_track_handler.h>
Public Types | |
| enum class | Error : uint8_t { kOk = 0 , kNotAuthorized , kNotSubscribed , kNoData } |
| Receive status codes. More... | |
| enum class | Status : uint8_t { kOk = 0 , kNotConnected , kError , kNotAuthorized , kNotSubscribed , kPendingResponse , kSendingUnsubscribe , kPaused , kNewGroupRequested , kCancelled , kDoneByFin , kDoneByReset } |
| Status codes for the subscribe track. More... | |
Public Member Functions | |
| constexpr const messages::Location & | GetStartLocation () const noexcept |
| Get the start location of the Fetch. More... | |
| constexpr const messages::FetchEndLocation & | GetEndLocation () const noexcept |
| Get the end location of the Fetch. More... | |
| constexpr Status | GetStatus () const noexcept |
| Get the status of the subscribe. More... | |
| void | SetSubscriberPriority (uint8_t priority) noexcept |
| Sets the subscriber priority used in subsequent control updates. More... | |
| constexpr std::uint8_t | GetSubscriberPriority () const noexcept |
| Get subscription priority. More... | |
| constexpr std::optional< messages::GroupOrder > | GetGroupOrder () const noexcept |
| Get subscription group order. More... | |
| constexpr messages::GroupOrder | GetPublisherDefaultGroupOrder () const noexcept |
| void | SetPublisherDefaultGroupOrder (messages::GroupOrder group_order) noexcept |
| Stores the publisher's default group order. More... | |
| messages::FilterType | GetFilterType () const noexcept |
| Get subscription filter type. More... | |
| constexpr const messages::Filter & | GetFilter () const noexcept |
| constexpr std::optional< messages::Location > | GetLatestLocation () const noexcept |
| constexpr void | SetLatestLocation (messages::Location new_location) noexcept |
| Records the latest object location. More... | |
| std::optional< messages::Location > | GetLatestDeliveredLocation () const |
| std::optional< JoiningFetch > | GetJoiningFetch () const noexcept |
| Gets joining-fetch attributes. More... | |
| void | SetTrackAlias (uint64_t track_alias) |
| Set the track alias. More... | |
| std::optional< uint64_t > | GetTrackAlias () const noexcept |
| Get the track alias. More... | |
| void | SetReceivedTrackAlias (uint64_t track_alias) |
| Set the received track alias. More... | |
| void | SetNewGroupRequestId (uint64_t group_id) |
| Set the new group request Id. More... | |
| std::optional< uint64_t > | GetReceivedTrackAlias () const noexcept |
| Get the received track alias. More... | |
| void | SetPublishInitiated () noexcept |
| Marks this handler publisher-initiated. More... | |
| void | Pause () noexcept |
| Pause receiving data. More... | |
| void | Resume () noexcept |
| Resume receiving data. More... | |
| void | RequestNewGroup (uint64_t group_id=0) noexcept |
| Generate a new group request for this subscription. More... | |
| void | SupportNewGroupRequest (bool is_supported) noexcept |
| Indicate if subscribe handler should send new group requests or not. More... | |
| bool | IsNewGroupRequestSupported () const noexcept |
| Indicate if subscribe handler can send new group requests or not. More... | |
| const std::optional< std::chrono::milliseconds > & | GetDeliveryTimeout () const noexcept |
| Gets the requested delivery timeout. More... | |
| void | SetDeliveryTimeout (std::chrono::milliseconds timeout) noexcept |
| Stores a requested delivery timeout. More... | |
| constexpr std::chrono::milliseconds | GetRendezvousTimeout () const noexcept |
| Gets the requested rendezvous timeout. More... | |
| void | SetRendezvousTimeout (std::chrono::milliseconds timeout) |
| Set the subscription's rendezvous timeout. More... | |
| bool | IsPublisherInitiated () const noexcept |
| Check if the subscribe is publisher initiated or not. More... | |
| template<typename T > | |
| requires std::is_base_of_v< TrackHandler, T > std::shared_ptr< T > | Get () |
| Get the derived type of the track handler. More... | |
| void | SetRequestId (std::optional< uint64_t > request_id) |
| Sets or clears the connection-scoped request ID. More... | |
| std::optional< uint64_t > | GetRequestId () const noexcept |
| Get the request ID. More... | |
| std::optional< uint64_t > | GetRequestStreamId () const |
| Get the stream ID of the request control stream. More... | |
| FullTrackName | GetFullTrackName () const noexcept |
| Get the full track name. More... | |
| uint64_t | GetConnectionId () const noexcept |
| Gets the transport connection identifier assigned by the session. More... | |
| std::shared_ptr< Connection > | GetConnection () const |
| Binding | GetBinding () const |
| virtual void | RequestError (ErrorCode error_code, std::string reason) |
| Handles a REQUEST_ERROR for this handler. More... | |
Callbacks | |
| virtual void | ObjectReceived ([[maybe_unused]] const ObjectHeaders &object_headers, [[maybe_unused]] BytesSpan data, std::optional< messages::StreamHeaderProperties > stream_mode=std::nullopt) |
| Notification of received [full] data object. More... | |
| virtual void | ObjectStatusReceived ([[maybe_unused]] uint64_t group_id, [[maybe_unused]] uint64_t object_id, [[maybe_unused]] std::uint8_t priority, [[maybe_unused]] ObjectStatus status, [[maybe_unused]] std::optional< Extensions > extensions, [[maybe_unused]] std::optional< Extensions > immutable_extensions) |
| Notification of received object status. More... | |
| virtual void | SubgroupEnded ([[maybe_unused]] std::uint64_t group_id, [[maybe_unused]] std::uint64_t subgroup_id, [[maybe_unused]] bool reset) |
| Notification that no more objects are coming for a subgroup. More... | |
| virtual void | DgramDataRecv (std::shared_ptr< const std::vector< uint8_t >> data) |
| Notification of received datagram data. More... | |
| virtual void | PartialObjectReceived ([[maybe_unused]] const ObjectHeaders &object_headers, [[maybe_unused]] BytesSpan data) |
| Notification of a partial object received data object. More... | |
| virtual void | StatusChanged ([[maybe_unused]] Status status) |
| Notification of subscribe status. More... | |
| virtual void | MetricsSampled ([[maybe_unused]] const SubscribeTrackMetrics &metrics) |
| Notification callback to provide sampled metrics. More... | |
| Reply< messages::Parameters, ErrorCode > | RequestUpdateReceived (const messages::Parameters ¶ms) override |
| Handles an update received from the publisher. More... | |
Static Public Member Functions | |
| static std::shared_ptr< FetchTrackHandler > | Create (const FullTrackName &full_track_name, const std::uint8_t priority, const messages::Location &start_location, const messages::FetchEndLocation &end_location, const messages::GroupOrder group_order=messages::GroupOrder::kAscending) |
| Create shared Fetch track handler. More... | |
| static std::shared_ptr< SubscribeTrackHandler > | Create (const FullTrackName &full_track_name, std::uint8_t priority, std::optional< messages::GroupOrder > group_order=messages::GroupOrder::kAscending, const messages::Filter &filter=std::monostate{}, bool publisher_initiated=false) |
| Create shared Subscribe track handler. More... | |
Public Attributes | |
| SubscribeTrackMetrics | subscribe_track_metrics_ |
| Subscribe metrics for the track. More... | |
Protected Member Functions | |
| FetchTrackHandler (const FullTrackName &full_track_name, const std::uint8_t priority, const messages::Location &start_location, const messages::FetchEndLocation &end_location, const messages::GroupOrder group_order=messages::GroupOrder::kAscending) | |
| Fetch track handler constructor. More... | |
| void | RequestOkReceived (const messages::Parameters ¶ms) override |
| Validates REQUEST_UPDATE_OK parameters. More... | |
| void | SetStatus (Status status) noexcept |
| Set the subscribe status. More... | |
| void | SetTransport (std::shared_ptr< Session > transport) |
| Sets the session used for control and data operations. More... | |
| const std::weak_ptr< Session > & | GetSession () const noexcept |
| Gets the non-owning session handle. More... | |
Protected Attributes | |
| std::optional< uint64_t > | pending_new_group_request_id_ |
| Pending new-group request ID; zero denotes an unspecified group. More... | |
| StreamBuffer< uint8_t > | dgram_buffer_ |
| Reusable internal datagram decode buffer; derived classes should not retain views into it. More... | |
| FullTrackName | full_track_name_ |
| Full track identity retained for the handler's lifetime. More... | |
| std::mutex | binding_operation_mutex_ |
Handler for receiving a bounded FETCH response.
A fetch uses the subscription object callbacks but requests an inclusive range. Instances are heap-owned through Create() and are retained by the session while active.
|
stronginherited |
|
stronginherited |
Status codes for the subscribe track.
| Enumerator | |
|---|---|
| kOk | Subscription is active and may receive data. |
| kNotConnected | Transport is disconnected. |
| kError | Subscription failed for an unspecified error. |
| kNotAuthorized | Peer denied authorization. |
| kNotSubscribed | Initial/inactive state. |
| kPendingResponse | Waiting for the peer's response. |
| kSendingUnsubscribe | In this state, callbacks will not be called,. |
| kPaused | Forwarding is locally marked paused. |
| kNewGroupRequested | A new-group transition is in progress. |
| kCancelled | Subscription was cancelled. |
| kDoneByFin | Request or data stream ended normally. |
| kDoneByReset | Request or data stream was reset. |
|
inlineprotected |
Fetch track handler constructor.
| full_track_name | Full track name struct. |
| priority | The priority of the track. |
| start_location | The starting location of the fetch's range (inclusive). |
| end_location | The ending location of the fetch's range (inclusive). |
| group_order | The requested object delivery order. |
|
inlinestatic |
Create shared Fetch track handler.
| full_track_name | Full track name struct. |
| priority | The priority of the track. |
| start_location | The starting location of the fetch's range (inclusive). |
| end_location | The ending location of the fetch's range (inclusive). |
| group_order | The requested object delivery order. |
|
inlinestaticinherited |
Create shared Subscribe track handler.
| full_track_name | Full track name struct |
| priority | Subscription priority, if omitted, publisher priority is considered |
| group_order | Order for group delivery, or nullopt for publisher default |
| filter | Subscription selection filter |
| publisher_initiated | Whether the peer publisher initiated the subscription |
|
virtualinherited |
Notification of received datagram data.
Event notification to provide the caller the raw data received as a datagram
| data | Shared immutable ownership of the complete encoded datagram; an override may retain it after return. |
The default implementation decodes the datagram synchronously, updates object counters, and invokes ObjectReceived or ObjectStatusReceived. The pointer must not be null and the buffer must not be empty.
| messages::ProtocolViolationException | Propagated for malformed protocol fields. |
|
inlineinherited |
Get the derived type of the track handler.
| T | Derived type of the track handler. |
T, or null when the dynamic type is incompatible. | std::bad_weak_ptr | if this object is not currently owned by a shared_ptr. |
|
inlineinherited |
|
inherited |
|
inlinenoexceptinherited |
Gets the transport connection identifier assigned by the session.
|
inlinenoexceptinherited |
Gets the requested delivery timeout.
|
inlineconstexprnoexcept |
Get the end location of the Fetch.
|
inlineconstexprnoexceptinherited |
|
inlinenoexceptinherited |
Get subscription filter type.
GetFilter().
|
inlinenoexceptinherited |
Get the full track name.
|
inlineconstexprnoexceptinherited |
Get subscription group order.
std::nullopt when the publisher chooses.
|
inlinenoexceptinherited |
Gets joining-fetch attributes.
std::nullopt when no joining fetch was requested.
|
inlineinherited |
|
inlineconstexprnoexceptinherited |
std::nullopt if none is known.
|
inlineconstexprnoexceptinherited |
|
inlinenoexceptinherited |
Get the received track alias.
If the track alias is set, it will be returned, otherwise std::nullopt.
|
inlineconstexprnoexceptinherited |
Gets the requested rendezvous timeout.
|
inlinenoexceptinherited |
Get the request ID.
std::nullopt when none is assigned.
|
inherited |
Get the stream ID of the request control stream.
std::nullopt if no stream is attached.
|
protectednoexceptinherited |
Gets the non-owning session handle.
|
inlineconstexprnoexcept |
Get the start location of the Fetch.
|
inlineconstexprnoexceptinherited |
Get the status of the subscribe.
|
inlineconstexprnoexceptinherited |
Get subscription priority.
|
inlinenoexceptinherited |
Get the track alias.
If the track alias is set, it will be returned, otherwise std::nullopt.
|
inlinenoexceptinherited |
Indicate if subscribe handler can send new group requests or not.
|
inlinenoexceptinherited |
Check if the subscribe is publisher initiated or not.
|
inlinevirtualinherited |
Notification callback to provide sampled metrics.
Called at the connection metrics cadence, including idle periods, on the session's metrics-reporting path. The structure is a cumulative live snapshot for object and byte counters; those counters are not reset after the callback.
| metrics | Copy of the subscribed metrics for the sample period |
|
virtualinherited |
Notification of received [full] data object.
Event notification to provide the caller the received full data object
data is borrowed and invalid after this method returns. Copy it to retain it.| object_headers | Object headers, must include group and object Ids |
| data | Object payload data received, MUST match ObjectHeaders::payload_length. |
| stream_mode | If this is the first object of a subgroup, its properties. |
|
inlinevirtualinherited |
Notification of received object status.
Event notification when an ObjectDatagramStatus message is received.
| group_id | Group ID of the status |
| object_id | Object ID of the status |
| priority | Priority of the status |
| status | Status |
| extensions | Mutable extensions, if any |
| immutable_extensions | Immutable extensions, if any |
|
inlinevirtualinherited |
Notification of a partial object received data object.
Event notification to provide the caller the received data object
data is borrowed and invalid after this method returns. Copy it to retain it.| object_headers | Object headers, must include group and object Ids |
| data | Object payload data received, can be <= ObjectHeaders::payload_length |
|
noexceptinherited |
Pause receiving data.
Sends a REQUEST_UPDATE with forwarding disabled and immediately changes local state to kPaused. It silently does nothing without a live session/request stream, when already paused, or in kNotConnected. No StatusChanged callback is made.
|
virtualinherited |
Handles a REQUEST_ERROR for this handler.
| error_code | Peer-provided request error code. |
| reason | Peer-provided reason, passed by value for optional retention. |
Reimplemented in quicr::TrackStatusHandler, quicr::SubscribeNamespaceHandler, and quicr::PublishNamespaceHandler.
|
noexceptinherited |
Generate a new group request for this subscription.
| group_id | Value of group requested or zero if unknown |
Silently does nothing unless status is kOk, new-group requests are enabled, and both the session and request stream are available. Local status is unchanged.
|
overrideprotectedvirtualinherited |
Validates REQUEST_UPDATE_OK parameters.
| params | Borrowed response parameters; only expiration and largest-object are accepted. |
| messages::ProtocolViolationException | for unsupported parameters. |
Implements quicr::TrackHandler.
|
overridevirtualinherited |
Handles an update received from the publisher.
| params | Borrowed update parameters. |
| messages::ProtocolViolationException | for updates to subscriber-initiated subscriptions or unsupported parameters. |
Implements quicr::TrackHandler.
|
noexceptinherited |
Resume receiving data.
Sends a REQUEST_UPDATE with forwarding enabled and immediately changes local state to kOk. It silently does nothing unless currently paused and attached to a live session/request stream. No StatusChanged callback is made.
|
inlinenoexceptinherited |
Stores a requested delivery timeout.
| timeout | Timeout to store; negative values are accepted and no update is sent. |
|
inlineconstexprnoexceptinherited |
Records the latest object location.
| new_location | Location to store. |
|
inlineinherited |
Set the new group request Id.
| group_id | Group ID to request via new group request |
Stores the larger pending ID. A non-increasing ID replaces the pending value with zero, which represents an unknown/new group request.
|
inlinenoexceptinherited |
Stores the publisher's default group order.
| group_order | New default. |
|
inlinenoexceptinherited |
Marks this handler publisher-initiated.
Also changes kNotSubscribed to kOk. No callback or protocol message is sent, and any previously retained joining-fetch attributes are not cleared.
|
inlineinherited |
Set the received track alias.
| track_alias | MoQ track alias for track namespace+name that is relative to the QUIC connection session |
|
inlineinherited |
Set the subscription's rendezvous timeout.
This requests that the peer holds this subscribe pending for up to this amount of time if a publisher is not yet present for this track.
| timeout | Non-negative duration to request. |
| std::invalid_argument | if the timeout is negative. |
|
inlineinherited |
Sets or clears the connection-scoped request ID.
| request_id | Request ID assigned by the session, or std::nullopt when unbound. |
|
inlineprotectednoexceptinherited |
Set the subscribe status.
| status | Status of the subscribe |
Assigns the status and synchronously invokes StatusChanged, even when the value did not change.
|
inlinenoexceptinherited |
Sets the subscriber priority used in subsequent control updates.
| priority | Priority value; existing streams and already-sent requests are unchanged. |
|
inlineinherited |
Set the track alias.
| track_alias | MoQ track alias for track namespace+name that is relative to the QUIC connection session |
|
protectedinherited |
Sets the session used for control and data operations.
| transport | Session retained weakly; passing null clears effective access. |
|
inlinevirtualinherited |
|
inlinevirtualinherited |
Notification that no more objects are coming for a subgroup.
The publisher has either finished the subgroup or given up on it, so a subscriber forwarding it on can close out the subgroup it is publishing. Only reported for subgroups at least one object arrived for.
| group_id | Group the subgroup belongs to |
| subgroup_id | Subgroup that has ended |
| reset | True if the publisher gave up on the subgroup rather than finishing it |
|
noexceptinherited |
Indicate if subscribe handler should send new group requests or not.
| is_supported | True to send new group requests, False to disable sending |
|
protectedinherited |
|
protectedinherited |
Reusable internal datagram decode buffer; derived classes should not retain views into it.
|
protectedinherited |
Full track identity retained for the handler's lifetime.
|
protectedinherited |
Pending new-group request ID; zero denotes an unspecified group.
|
inherited |
Subscribe metrics for the track.
Public live counters updated by receive/session processing. Object counters include decoded data and status datagrams; byte counters count payload bytes for decoded objects and transport stream bytes for streamed delivery. Values are cumulative and are not reset after MetricsSampled. Unsynchronized application writes race with session updates.