xref: /aosp_15_r20/external/webrtc/logging/rtc_event_log/events/rtc_event_remote_estimate.h (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1 /*
2  *  Copyright (c) 2019 The WebRTC project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 #ifndef LOGGING_RTC_EVENT_LOG_EVENTS_RTC_EVENT_REMOTE_ESTIMATE_H_
11 #define LOGGING_RTC_EVENT_LOG_EVENTS_RTC_EVENT_REMOTE_ESTIMATE_H_
12 
13 #include <memory>
14 #include <string>
15 #include <vector>
16 
17 #include "absl/strings/string_view.h"
18 #include "absl/types/optional.h"
19 #include "api/rtc_event_log/rtc_event.h"
20 #include "api/units/data_rate.h"
21 #include "api/units/timestamp.h"
22 #include "logging/rtc_event_log/events/rtc_event_field_encoding_parser.h"
23 
24 namespace webrtc {
25 
26 struct LoggedRemoteEstimateEvent {
27   LoggedRemoteEstimateEvent() = default;
28 
log_time_usLoggedRemoteEstimateEvent29   int64_t log_time_us() const { return timestamp.us(); }
log_time_msLoggedRemoteEstimateEvent30   int64_t log_time_ms() const { return timestamp.ms(); }
log_timeLoggedRemoteEstimateEvent31   Timestamp log_time() const { return timestamp; }
32 
33   Timestamp timestamp = Timestamp::MinusInfinity();
34   absl::optional<DataRate> link_capacity_lower;
35   absl::optional<DataRate> link_capacity_upper;
36 };
37 
38 class RtcEventRemoteEstimate final : public RtcEvent {
39  public:
40   static constexpr Type kType = Type::RemoteEstimateEvent;
41 
RtcEventRemoteEstimate(DataRate link_capacity_lower,DataRate link_capacity_upper)42   RtcEventRemoteEstimate(DataRate link_capacity_lower,
43                          DataRate link_capacity_upper)
44       : link_capacity_lower_(link_capacity_lower),
45         link_capacity_upper_(link_capacity_upper) {}
46 
GetType()47   Type GetType() const override { return kType; }
IsConfigEvent()48   bool IsConfigEvent() const override { return false; }
49 
Encode(rtc::ArrayView<const RtcEvent * > batch)50   static std::string Encode(rtc::ArrayView<const RtcEvent*> batch) {
51     // TODO(terelius): Implement
52     return "";
53   }
54 
Parse(absl::string_view encoded_bytes,bool batched,std::vector<LoggedRemoteEstimateEvent> & output)55   static RtcEventLogParseStatus Parse(
56       absl::string_view encoded_bytes,
57       bool batched,
58       std::vector<LoggedRemoteEstimateEvent>& output) {
59     // TODO(terelius): Implement
60     return RtcEventLogParseStatus::Error("Not Implemented", __FILE__, __LINE__);
61   }
62 
63   const DataRate link_capacity_lower_;
64   const DataRate link_capacity_upper_;
65 };
66 
67 }  // namespace webrtc
68 #endif  // LOGGING_RTC_EVENT_LOG_EVENTS_RTC_EVENT_REMOTE_ESTIMATE_H_
69