LibQuicR
|
#include <client.h>
Public Types | |
enum class | Status : uint8_t { kReady = 0 , kNotReady , kInternalError , kInvalidParams , kConnecting , kDisconnecting , kNotConnected , kFailedToConnect , kPendingSeverSetup } |
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 |
enum class | ConnectionStatus : uint8_t { kNotConnected = 0 , kConnecting , kConnected , kIdleTimeout , kClosedByRemote } |
Connection status codes. More... | |
Public Member Functions | |
Client (const ClientConfig &cfg) | |
MoQ Client Constructor to create the client mode instance. | |
~Client ()=default | |
Status | Connect () |
Starts a client connection via a transport thread. | |
Status | Disconnect () |
Disconnect the client connection gracefully. | |
PublishAnnounceStatus | GetAnnounceStatus (const TrackNamespace &track_namespace) |
Get announce status for namespace. | |
void | SubscribeTrack (std::shared_ptr< SubscribeTrackHandler > track_handler) |
Subscribe to a track. | |
void | UnsubscribeTrack (std::shared_ptr< SubscribeTrackHandler > track_handler) |
Unsubscribe track. | |
void | PublishAnnounce (const TrackNamespace &track_namespace) |
Publish a track namespace. | |
void | PublishUnannounce (const TrackNamespace &track_namespace) |
Unannounce a publish namespace. | |
void | SubscribeAnnounces (const TrackNamespace &prefix_namespace) |
Subscribe Announces to prefix namespace. | |
void | UnsubscribeAnnounces (const TrackNamespace &prefix_namespace) |
Unsubscribe announces to prefix namespace. | |
void | PublishTrack (std::shared_ptr< PublishTrackHandler > track_handler) |
Publish to a track. | |
void | UnpublishTrack (std::shared_ptr< PublishTrackHandler > track_handler) |
Unpublish track. | |
void | FetchTrack (std::shared_ptr< FetchTrackHandler > track_handler) |
Fetch track. | |
void | CancelFetchTrack (std::shared_ptr< FetchTrackHandler > track_handler) |
Cancel a given Fetch track handler. | |
std::optional< ConnectionHandle > | GetConnectionHandle () const |
Get the connection handle. | |
const std::shared_ptr< TickService > & | GetTickService () const noexcept |
void | SubscribeTrack (ConnectionHandle connection_handle, std::shared_ptr< SubscribeTrackHandler > track_handler) |
Subscribe to a track. | |
void | UnsubscribeTrack (ConnectionHandle connection_handle, const std::shared_ptr< SubscribeTrackHandler > &track_handler) |
Unsubscribe track. | |
void | UpdateTrackSubscription (ConnectionHandle connection_handle, std::shared_ptr< SubscribeTrackHandler > track_handler) |
Update Subscription to a track. | |
void | PublishTrack (ConnectionHandle connection_handle, std::shared_ptr< PublishTrackHandler > track_handler) |
Publish to a track. | |
void | UnpublishTrack (ConnectionHandle connection_handle, const std::shared_ptr< PublishTrackHandler > &track_handler) |
Unpublish track. | |
void | FetchTrack (ConnectionHandle connection_handle, std::shared_ptr< FetchTrackHandler > track_handler) |
Fetch track. | |
void | CancelFetchTrack (ConnectionHandle connection_handle, std::shared_ptr< FetchTrackHandler > track_handler) |
Cancel Fetch track. | |
Status | GetStatus () const noexcept |
Get the status of the Client. | |
Client Callbacks | |
client transport specific callbacks | |
virtual void | ServerSetupReceived (const ServerSetupAttributes &server_setup_attributes) |
Callback on server setup message. | |
virtual void | AnnounceStatusChanged (const TrackNamespace &track_namespace, const PublishAnnounceStatus status) |
Notification on publish announcement status change. | |
virtual void | AnnounceReceived (const TrackNamespace &track_namespace, const PublishAnnounceAttributes &announce_attributes) |
Callback notification for announce received by subscribe announces. | |
virtual void | UnannounceReceived (const TrackNamespace &track_namespace) |
Callback notification for unannounce received by subscribe announces. | |
virtual void | SubscribeAnnouncesStatusChanged (const TrackNamespace &track_namespace, std::optional< messages::SubscribeAnnouncesErrorCode > error_code, std::optional< messages::ReasonPhrase > reason) |
Callback notification for subscribe announces OK or Error. | |
virtual void | UnpublishedSubscribeReceived (const FullTrackName &track_full_name, const SubscribeAttributes &subscribe_attributes) |
Callback notification for new subscribe received that doesn't match an existing publish track. | |
virtual void | ResolveSubscribe (ConnectionHandle connection_handle, uint64_t subscribe_id, const SubscribeResponse &subscribe_response) |
Accept or reject an subscribe that was received. | |
void | MetricsSampled (const ConnectionMetrics &metrics) override |
Notification callback to provide sampled metrics. | |
Base Calbacks | |
Both client and server implement the same transport base callbacks | |
virtual void | StatusChanged (Status status) |
Callback notification for status/state change. | |
|
stronginherited |
|
stronginherited |
Control message status codes.
|
stronginherited |
|
stronginherited |
|
inline |
|
default |
|
virtual |
Callback notification for announce received by subscribe announces.
track_namespace | Track namespace |
announce_attributes | Publish announce attributes received |
|
virtual |
Notification on publish announcement status change.
Callback notification for a change in publish announcement status
track_namespace | Track namespace to announce |
status | Publish announce status |
|
inline |
Cancel a given Fetch track handler.
track_handler | The given Fetch track handler to cancel. |
|
inherited |
Cancel Fetch track.
connection_handle | Connection ID to send fetch cancel. |
track_handler | Fetch Track handler to cancel. |
Status quicr::Client::Connect | ( | ) |
Starts a client connection via a transport thread.
Makes a client connection session and runs in a newly created thread. All control and track callbacks will be run based on events.
Status quicr::Client::Disconnect | ( | ) |
Disconnect the client connection gracefully.
Unsubscribes and unpublishes all remaining active ones, sends MoQ control messages for those and then closes the QUIC connection gracefully. Stops the transport thread. The class destructor calls this method as well. Status will be updated to reflect not connected.
|
inline |
Fetch track.
track_handler | Track handler to use for handling Fetch related messages. |
|
inherited |
Fetch track.
connection_handle | Connection ID to send fetch |
track_handler | Track handler used for fetching |
PublishAnnounceStatus quicr::Client::GetAnnounceStatus | ( | const TrackNamespace & | track_namespace | ) |
Get announce status for namespace.
track_namespace | Track namespace of the announcement |
|
inline |
Get the connection handle.
|
inlinenoexceptinherited |
|
inlinenoexceptinherited |
|
overridevirtual |
Notification callback to provide sampled metrics.
Callback will be triggered on Config::metrics_sample_ms to provide the sampled data based on the sample period. After this callback, the period/sample based metrics will reset and start over for the new period.
metrics | Copy of the connection metrics for the sample period |
Reimplemented from quicr::Transport.
void quicr::Client::PublishAnnounce | ( | const TrackNamespace & | track_namespace | ) |
Publish a track namespace.
In MoQ, a publish namespace will result in an announce being sent. Announce OK will be reflected in the Status() of the PublishTrackHandler passed. This method can be called at any time, but normally it would be called before publishing any tracks to the same namespace.
If this method is called after a publish track with a matching namespace that already exists or if called more than once, this will result in this track handler being added to the active state of the announce, but it will not result in a repeated announce being sent. Adding track handler to the announce state ensures that the announce will remain active if the other tracks are removed.
track_namespace | Track handler to use for track related functions and callbacks |
|
inline |
Publish to a track.
track_handler | Track handler to use for track related functions and callbacks |
|
inherited |
Publish to a track.
connection_handle | Connection ID from transport for the QUIC connection context |
track_handler | Track handler to use for track related functions and callbacks |
void quicr::Client::PublishUnannounce | ( | const TrackNamespace & | track_namespace | ) |
Unannounce a publish namespace.
Unannounce a publish namespace. ALL tracks will be marked unpublish, as if called by UnpublishTrack()
track_namespace | Track namespace to unannounce |
|
virtual |
Accept or reject an subscribe that was received.
Accept or reject an subscribe received via SubscribeReceived(). The MoQ Transport will send the protocol message based on the SubscribeResponse
connection_handle | source connection ID |
subscribe_id | subscribe ID |
subscribe_response | response to for the subscribe |
|
virtual |
|
inlinevirtualinherited |
Callback notification for status/state change.
Callback notification indicates state change of connection, such as disconnected
status | Changed Status value |
|
inline |
Subscribe Announces to prefix namespace.
prefix_namespace | Prefix namespace to subscribe announces |
|
virtual |
Callback notification for subscribe announces OK or Error.
error_code and reason will be nullopt is the announces status is OK and accepted. If error, the error_code and reason will be set to indicate the error.
track_namespace | Track namespace |
error_code | Set if there is an error; error code |
reason | Set if there is an error; reason phrase |
|
inline |
Subscribe to a track.
track_handler | Track handler to use for track related functions and callbacks |
|
inherited |
Subscribe to a track.
connection_handle | Connection ID to send subscribe |
track_handler | Track handler to use for track related functions and callbacks |
|
virtual |
Callback notification for unannounce received by subscribe announces.
track_namespace | Track namespace |
|
virtual |
Callback notification for new subscribe received that doesn't match an existing publish track.
When a new subscribe is received that doesn't match any existing publish track, this method will be called to signal the client application that there is a new subscribe full track name. The client app should PublishTrack() within this callback (or afterwards) and return true if the subscribe is accepted and publishing will commence. If the subscribe is rejected and a publish track will not begin, then false should be returned. The Transport will send the appropriate message to indicate the accept/reject.
track_full_name | Track full name |
subscribe_attributes | Subscribe attributes received |
|
inline |
Unpublish track.
Unpublish a track that was previously published
track_handler | Track handler used when published track |
|
inherited |
Unpublish track.
connection_handle | Connection ID from transport for the QUIC connection context |
track_handler | Track handler used when published track |
|
inline |
Unsubscribe announces to prefix namespace.
prefix_namespace | Prefix namespace to unsubscribe announces |
|
inline |
Unsubscribe track.
track_handler | Track handler to use for track related functions and callbacks |
|
inherited |
Unsubscribe track.
connection_handle | Connection ID to send subscribe |
track_handler | Track handler to use for track related functions and callbacks |
|
inherited |
Update Subscription to a track.
connection_handle | Connection ID to send subscribe |
track_handler | Track handler to use for track related functions and callbacks |