|
LibQuicR
|
MoQ Session endpoint supporting connection-explicit operations. More...
#include <session.h>
Classes | |
| struct | Callbacks |
| Callback interface for session events common to both client and server mode. More... | |
| struct | ClientCallbacks |
| Callback interface for session events specific to client mode. More... | |
| struct | ConnectionRemoteInfo |
| Connection remote information. More... | |
| struct | ServerCallbacks |
| Callback interface for session events specific to server mode. More... | |
| struct | SubscribeContext |
Public Types | |
| enum class | Status : uint8_t { kReady = 0 , kNotReady , kInternalError , kInvalidParams , kConnecting , kDisconnecting , kNotConnected , kFailedToConnect , kPendingPeerSetup } |
| Status of the transport. More... | |
| enum class | ControlMessageStatus : uint8_t { kMessageIncomplete , kMessageComplete , kStreamBufferCannotBeZero , kStreamBufferMissingType , kUnsupportedMessageType } |
| Control message status codes. More... | |
| enum class | StreamDataMessageStatus : uint8_t |
| Reserved status type for stream-data parsing. More... | |
| enum class | ConnectionStatus : uint8_t { kNotConnected = 0 , kConnecting , kConnected , kIdleTimeout , kClosedByRemote } |
| Connection status codes. More... | |
Public Member Functions | |
| virtual | ~Session () |
| Destroy the session after detaching and releasing its owned state. More... | |
| std::shared_ptr< Connection > | GetDefaultConnection () const noexcept |
| Return shared ownership of the session's default connection. More... | |
| const std::shared_ptr< Clock > & | GetTickService () const noexcept |
| Return shared ownership of the tick service used by the session. More... | |
| const std::shared_ptr< Logger > & | GetLogger () const noexcept |
| Return the optional logger used by the session. More... | |
| Status | GetStatus () const noexcept |
| Return the current session status. More... | |
| void | Disconnect () |
| Close the underlying transport connection and detach this session as delegate. More... | |
| void | SubscribeTrack (std::shared_ptr< SubscribeTrackHandler > track_handler) |
| Subscribe to a track. More... | |
| void | UnsubscribeTrack (const std::shared_ptr< SubscribeTrackHandler > &track_handler) |
| Unsubscribe track. More... | |
| void | UpdateTrackSubscription (std::shared_ptr< SubscribeTrackHandler > track_handler) |
| Update Subscription to a track. More... | |
| void | PublishTrack (std::shared_ptr< PublishTrackHandler > track_handler) |
| Publish to a track. More... | |
| void | UnpublishTrack (const std::shared_ptr< PublishTrackHandler > &track_handler) |
| Unpublish track. More... | |
| void | PublishNamespace (std::shared_ptr< PublishNamespaceHandler > ns_handler, bool passive=false) |
| Publish a track namespace. More... | |
| void | PublishNamespaceDone (const std::shared_ptr< PublishNamespaceHandler > &track_handler) |
| Unpublish track namespace. More... | |
| void | SubscribeNamespace (std::shared_ptr< SubscribeNamespaceHandler > handler) |
| Subscribe to a prefix namespace on a specific connection. More... | |
| void | UnsubscribeNamespace (const std::shared_ptr< SubscribeNamespaceHandler > &handler) |
| Unsubscribe from a prefix namespace on a specific connection. More... | |
| void | SendNamespace (const TrackNamespace &track_namespace) |
| Tell subscribe-namespace subscribers on this connection that a namespace is active. More... | |
| void | SendNamespaceDone (const TrackNamespace &track_namespace) |
| Tell subscribe-namespace subscribers on this connection that a namespace is no longer active. More... | |
| void | FetchTrack (std::shared_ptr< FetchTrackHandler > track_handler) |
| Fetch track. More... | |
| void | CancelFetchTrack (std::shared_ptr< FetchTrackHandler > track_handler) |
| Cancel Fetch track. More... | |
| void | RequestTrackStatus (std::shared_ptr< TrackStatusHandler > handler) |
| Request track status. More... | |
| void | GoAway (const std::string &new_session_uri, std::chrono::milliseconds timeout, std::optional< std::uint64_t > first_unprocessed_request_id=std::nullopt) |
| Send GOAWAY on this session's control stream. More... | |
| void | GoAway (const std::string &new_session_uri, std::chrono::milliseconds timeout, const std::shared_ptr< TrackHandler > &handler) |
| Send GOAWAY on one request stream. More... | |
Server Relay Methods | |
Methods for relaying published content to subscribers. Server mode only. | |
| void | BindPublisherTrack (std::uint64_t src_id, uint64_t request_id, const std::shared_ptr< PublishTrackHandler > &track_handler, bool ephemeral=false) |
| Bind a server publish track handler based on a subscribe. More... | |
| void | UnbindPublisherTrack (std::uint64_t src_id, const std::shared_ptr< PublishTrackHandler > &track_handler, bool send_publish_done=false) |
| Unbind a server publish track handler. More... | |
| void | BindFetchTrack (std::shared_ptr< PublishFetchHandler > track_handler) |
| Bind a server fetch publisher track handler. More... | |
| void | UnbindFetchTrack (const std::shared_ptr< PublishFetchHandler > &track_handler) |
| Unbind a server fetch publisher track handler. More... | |
Static Public Member Functions | |
| static std::shared_ptr< Session > | Create (const ClientConfig &cfg, std::shared_ptr< Transport > transport, std::shared_ptr< Connection > connection, std::shared_ptr< ClientCallbacks > callbacks, std::shared_ptr< Clock > clock, std::shared_ptr< Logger > logger=nullptr) |
| Create a client-mode endpoint. More... | |
| static std::shared_ptr< Session > | Create (const ServerConfig &cfg, std::shared_ptr< Transport > transport, std::shared_ptr< Connection > connection, std::shared_ptr< ServerCallbacks > callbacks, std::shared_ptr< Clock > clock, std::shared_ptr< Logger > logger=nullptr) |
| Create a server-mode endpoint. More... | |
Protected Member Functions | |
| Session ()=delete | |
| Default construction is disabled; use a mode-specific constructor. More... | |
| Session (const ClientConfig &cfg, std::shared_ptr< Transport > transport, std::shared_ptr< Connection > connection, std::shared_ptr< ClientCallbacks > callbacks, std::shared_ptr< Logger > logger) | |
| Client mode constructor. More... | |
| Session (const ServerConfig &cfg, std::shared_ptr< Transport > transport, std::shared_ptr< Connection > connection, std::shared_ptr< ServerCallbacks > callbacks, std::shared_ptr< Logger > logger) | |
| Server mode constructor. More... | |
| Session (const ClientConfig &cfg, std::shared_ptr< Transport > transport, std::shared_ptr< Connection > connection, std::shared_ptr< ClientCallbacks > callbacks, std::shared_ptr< Clock > clock, std::shared_ptr< Logger > logger) | |
| Client mode constructor with explicit tick service. More... | |
| Session (const ServerConfig &cfg, std::shared_ptr< Transport > transport, std::shared_ptr< Connection > connection, std::shared_ptr< ServerCallbacks > callbacks, std::shared_ptr< Clock > clock, std::shared_ptr< Logger > logger) | |
| Server mode constructor with explicit tick service. More... | |
| void | OnStreamClosed (const std::shared_ptr< Stream > &stream, StreamClosedFlag flag) override |
| Handle closure of a stream delegated by the connection. More... | |
MoQ Session endpoint supporting connection-explicit operations.
Unified MoQ transport endpoint that operates in either client or server mode depending on configuration. Client provides the single-connection convenience API for outbound clients.
|
strong |
Connection status codes.
| Enumerator | |
|---|---|
| kNotConnected | No active connection. |
| kConnecting | Connection establishment is in progress. |
| kConnected | Connection is active. |
| kIdleTimeout | Connection closed after an idle timeout. |
| kClosedByRemote | Connection was closed by the peer. |
|
strong |
Control message status codes.
|
strong |
Status of the transport.
| Enumerator | |
|---|---|
| kReady | Setup is complete and the session is ready. |
| kNotReady | Session is not ready for protocol operations. |
| kInternalError | Session encountered an internal failure. |
| kInvalidParams | Session configuration or peer parameters are invalid. |
| kConnecting | Underlying connection establishment is in progress. |
| kDisconnecting | Session teardown is in progress. |
| kNotConnected | No active underlying connection exists. |
| kFailedToConnect | Underlying connection establishment failed. |
| kPendingPeerSetup | Local setup was sent and peer setup is still pending. |
|
strong |
Reserved status type for stream-data parsing.
|
virtual |
Destroy the session after detaching and releasing its owned state.
|
protecteddelete |
Default construction is disabled; use a mode-specific constructor.
|
protected |
Client mode constructor.
| cfg | MoQ Client Configuration |
| transport | Transport retained by the session. |
| connection | Connection retained by the session. |
| callbacks | Client callbacks retained by the session; may be null. |
| logger | Optional logger retained by the session. |
|
protected |
Server mode constructor.
| cfg | MoQ Server Configuration |
| transport | Transport retained by the session. |
| connection | Connection retained by the session. |
| callbacks | Server callbacks retained by the session; may be null. |
| logger | Optional logger retained by the session. |
|
protected |
Client mode constructor with explicit tick service.
| cfg | MoQ Instance Client Configuration |
| transport | Transport retained by the session. |
| connection | Connection retained by the session. |
| callbacks | Client callbacks retained by the session; may be null. |
| clock | Shared pointer to the tick service to use |
| logger | Optional logger retained by the session. |
|
protected |
Server mode constructor with explicit tick service.
| cfg | MoQ Server Configuration |
| transport | Transport retained by the session. |
| connection | Connection retained by the session. |
| callbacks | Server callbacks retained by the session; may be null. |
| clock | Shared pointer to the tick service to use |
| logger | Optional logger retained by the session. |
| void quicr::Session::BindFetchTrack | ( | std::shared_ptr< PublishFetchHandler > | track_handler | ) |
Bind a server fetch publisher track handler.
| track_handler | The fetch publisher |
track_handler must not be null. track_handler must already carry the inbound fetch request identifier. | void quicr::Session::BindPublisherTrack | ( | std::uint64_t | src_id, |
| uint64_t | request_id, | ||
| const std::shared_ptr< PublishTrackHandler > & | track_handler, | ||
| bool | ephemeral = false |
||
| ) |
Bind a server publish track handler based on a subscribe.
The server will create a server publish track handler based on a received subscribe. It will use this handler to send objects to the subscriber.
| src_id | Connection or peering ID for publisher origin |
| request_id | Request ID from the received subscribe |
| track_handler | Server publish track handler |
| ephemeral | Indicates if persistent state tracking is needed |
track_handler must not be null. | void quicr::Session::CancelFetchTrack | ( | std::shared_ptr< FetchTrackHandler > | track_handler | ) |
Cancel Fetch track.
| track_handler | Fetch Track handler to cancel. |
track_handler must not be null.
|
inlinestatic |
Create a client-mode endpoint.
| cfg | MoQ Client Configuration |
| transport | Transport retained by the session. |
| connection | Connection retained by the session. |
| callbacks | Client callbacks retained by the session; may be null. |
| clock | Clock retained by the session; must not be null. |
| logger | Optional logger retained by the session. |
|
inlinestatic |
Create a server-mode endpoint.
| cfg | MoQ Server Configuration |
| transport | Transport retained by the session. |
| connection | Connection retained by the session. |
| callbacks | Server callbacks retained by the session; may be null. |
| clock | Clock retained by the session; must not be null. |
| logger | Optional logger retained by the session. |
| void quicr::Session::Disconnect | ( | ) |
Close the underlying transport connection and detach this session as delegate.
| void quicr::Session::FetchTrack | ( | std::shared_ptr< FetchTrackHandler > | track_handler | ) |
Fetch track.
| track_handler | Track handler used for fetching |
track_handler must not be null.
|
noexcept |
Return shared ownership of the session's default connection.
|
inlinenoexcept |
Return the optional logger used by the session.
|
inlinenoexcept |
Return the current session status.
|
inlinenoexcept |
Return shared ownership of the tick service used by the session.
| void quicr::Session::GoAway | ( | const std::string & | new_session_uri, |
| std::chrono::milliseconds | timeout, | ||
| const std::shared_ptr< TrackHandler > & | handler | ||
| ) |
Send GOAWAY on one request stream.
| new_session_uri | URI the peer should migrate to, or empty to reuse the current URI. |
| timeout | How long the peer has to migrate before the session may be closed. |
| handler | The handler for the request we are sending away. |
| void quicr::Session::GoAway | ( | const std::string & | new_session_uri, |
| std::chrono::milliseconds | timeout, | ||
| std::optional< std::uint64_t > | first_unprocessed_request_id = std::nullopt |
||
| ) |
Send GOAWAY on this session's control stream.
| new_session_uri | URI the peer should migrate to, or empty to reuse the current URI. |
| timeout | How long the peer has to migrate before the session may be closed. |
| first_unprocessed_request_id | Smallest peer request ID that may not have been processed. |
|
overrideprotectedvirtual |
Handle closure of a stream delegated by the connection.
| stream | Closed stream and its associated request state. |
| flag | Event that closed the stream direction. |
Implements quicr::Connection::Delegate.
| void quicr::Session::PublishNamespace | ( | std::shared_ptr< PublishNamespaceHandler > | ns_handler, |
| bool | passive = false |
||
| ) |
Publish a track namespace.
| ns_handler | Namespace handler to use for track related functions and callbacks |
| passive | True indicates that PUBLISH_NAMESPACE will not be sent |
ns_handler must not be null. | void quicr::Session::PublishNamespaceDone | ( | const std::shared_ptr< PublishNamespaceHandler > & | track_handler | ) |
Unpublish track namespace.
| track_handler | Published namespace handler to finish. |
track_handler must not be null. track_handler must retain the request stream and request identifier assigned by PublishNamespace. | void quicr::Session::PublishTrack | ( | std::shared_ptr< PublishTrackHandler > | track_handler | ) |
Publish to a track.
| track_handler | Track handler to use for track related functions and callbacks |
track_handler must not be null. | void quicr::Session::RequestTrackStatus | ( | std::shared_ptr< TrackStatusHandler > | handler | ) |
Request track status.
| handler | Handler for this query's status and response. |
| std::invalid_argument | if handler is null. |
| std::logic_error | if the handler has a pending request. |
| void quicr::Session::SendNamespace | ( | const TrackNamespace & | track_namespace | ) |
Tell subscribe-namespace subscribers on this connection that a namespace is active.
Sends NAMESPACE on each SUBSCRIBE_NAMESPACE request stream whose prefix matches. The value on the wire is the namespace suffix relative to that prefix.
| track_namespace | Fully qualified namespace that became active |
| void quicr::Session::SendNamespaceDone | ( | const TrackNamespace & | track_namespace | ) |
Tell subscribe-namespace subscribers on this connection that a namespace is no longer active.
| track_namespace | Fully qualified namespace that ended |
| void quicr::Session::SubscribeNamespace | ( | std::shared_ptr< SubscribeNamespaceHandler > | handler | ) |
Subscribe to a prefix namespace on a specific connection.
| handler | Namespace handler to subscribe with |
handler must not be null. | void quicr::Session::SubscribeTrack | ( | std::shared_ptr< SubscribeTrackHandler > | track_handler | ) |
Subscribe to a track.
| track_handler | Track handler to use for track related functions and callbacks |
track_handler must not be null. | std::runtime_error | if a publisher-initiated subscription lacks required request metadata. |
| void quicr::Session::UnbindFetchTrack | ( | const std::shared_ptr< PublishFetchHandler > & | track_handler | ) |
Unbind a server fetch publisher track handler.
| track_handler | The fetch publisher |
track_handler must not be null. track_handler must have a request identifier assigned by BindFetchTrack. | void quicr::Session::UnbindPublisherTrack | ( | std::uint64_t | src_id, |
| const std::shared_ptr< PublishTrackHandler > & | track_handler, | ||
| bool | send_publish_done = false |
||
| ) |
Unbind a server publish track handler.
Removes a server publish track handler state.
| src_id | Connection or peering ID of the receiving publisher |
| track_handler | Server publish track handler |
| send_publish_done | Indicates to send publish done or not |
track_handler must not be null. track_handler must have a request identifier assigned by BindPublisherTrack. | void quicr::Session::UnpublishTrack | ( | const std::shared_ptr< PublishTrackHandler > & | track_handler | ) |
Unpublish track.
| track_handler | Track handler used when published track |
track_handler must not be null. | void quicr::Session::UnsubscribeNamespace | ( | const std::shared_ptr< SubscribeNamespaceHandler > & | handler | ) |
Unsubscribe from a prefix namespace on a specific connection.
| handler | Namespace handler to unsubscribe |
handler must not be null. | void quicr::Session::UnsubscribeTrack | ( | const std::shared_ptr< SubscribeTrackHandler > & | track_handler | ) |
Unsubscribe track.
| track_handler | Track handler to use for track related functions and callbacks |
track_handler must not be null. | void quicr::Session::UpdateTrackSubscription | ( | std::shared_ptr< SubscribeTrackHandler > | track_handler | ) |
Update Subscription to a track.
| track_handler | Track handler to use for track related functions and callbacks |
track_handler must not be null.