LibQuicR
track_status_handler.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) 2026 Cisco Systems
2 // SPDX-License-Identifier: BSD-2-Clause
3 
4 #pragma once
5 
7 
8 namespace quicr {
9 
19  {
20  public:
22  enum class Status : std::uint8_t
23  {
26  kOk,
27  kError,
28  kDoneByFin,
29  kDoneByReset,
31  };
32 
38  static std::shared_ptr<TrackStatusHandler> Create(const FullTrackName& full_track_name)
39  {
40  return std::shared_ptr<TrackStatusHandler>(new TrackStatusHandler(full_track_name));
41  }
42 
44  Status GetStatus() const;
45 
47  std::optional<TrackStatusResponse> GetResponse() const;
48 
50  std::optional<Error<ErrorCode>> GetError() const;
51 
58  virtual void StatusChanged(Status status);
59 
60  protected:
65  explicit TrackStatusHandler(const FullTrackName& full_track_name);
66 
72  void RequestOkReceived(const messages::Parameters& params) override;
73 
80  void RequestError(ErrorCode error_code, std::string reason) override;
81 
89 
90  private:
91  friend class Session;
92 
93  void SetStatus(Status status);
94  void ResponseReceived(TrackStatusResponse response);
95 
96  mutable std::mutex mutex_;
98  std::optional<TrackStatusResponse> response_ QUICR_GUARDED_BY(mutex_);
99  std::optional<Error<ErrorCode>> error_ QUICR_GUARDED_BY(mutex_);
100  };
101 
102 } // namespace quicr
The reply to a callback, which may be answered immediately or deferred.
Definition: reply.h:31
MoQ Session endpoint supporting connection-explicit operations.
Definition: session.h:68
Common request state for track-related handlers.
Definition: track_handler.h:36
Represents one reusable TRACK_STATUS request.
Definition: track_status_handler.h:19
static std::shared_ptr< TrackStatusHandler > Create(const FullTrackName &full_track_name)
Creates a track-status request handler.
Definition: track_status_handler.h:38
Status
Lifecycle state of the most recent query.
Definition: track_status_handler.h:23
@ kNotConnected
Transport disconnected.
@ kPendingResponse
Waiting for response from the peer.
@ kNotRequested
Ready to be passed to Session.
@ kDoneByReset
The peer reset the stream without a response.
@ kError
The peer rejected the query; GetError() contains its reason.
@ kDoneByFin
The peer closed the stream without a response.
std::optional< Error< ErrorCode > > GetError() const
Status GetStatus() const
void RequestOkReceived(const messages::Parameters &params) override
Rejects an impossible generic REQUEST_OK path.
std::optional< TrackStatusResponse > GetResponse() const
void RequestError(ErrorCode error_code, std::string reason) override
Records a peer rejection while a response is pending.
Reply< messages::Parameters, ErrorCode > RequestUpdateReceived(const messages::Parameters &params) override
Rejects REQUEST_UPDATE for a TRACK_STATUS request.
virtual void StatusChanged(Status status)
Reports completion with kOk or kError.
TrackStatusHandler(const FullTrackName &full_track_name)
Constructs an unsubmitted request for a track.
Definition: parameters.h:185
Definition: attributes.h:13
ErrorCode
MOQT error code, as carried by REQUEST_ERROR.
Definition: errors.h:33
Full track name struct.
Definition: track_name.h:436
Response to a received TRACK_STATUS.
Definition: attributes.h:18
#define QUICR_GUARDED_BY(...)
No-op guarded-field annotation when thread-safety annotations are disabled.
Definition: thread_safety.h:64