xref: /aosp_15_r20/external/webrtc/logging/rtc_event_log/events/rtc_event_probe_result_success.h (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1 /*
2  *  Copyright (c) 2017 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 
11 #ifndef LOGGING_RTC_EVENT_LOG_EVENTS_RTC_EVENT_PROBE_RESULT_SUCCESS_H_
12 #define LOGGING_RTC_EVENT_LOG_EVENTS_RTC_EVENT_PROBE_RESULT_SUCCESS_H_
13 
14 #include <stdint.h>
15 
16 #include <memory>
17 #include <string>
18 #include <vector>
19 
20 #include "absl/strings/string_view.h"
21 #include "api/rtc_event_log/rtc_event.h"
22 #include "api/units/timestamp.h"
23 #include "logging/rtc_event_log/events/rtc_event_field_encoding_parser.h"
24 
25 namespace webrtc {
26 
27 struct LoggedBweProbeSuccessEvent {
28   LoggedBweProbeSuccessEvent() = default;
LoggedBweProbeSuccessEventLoggedBweProbeSuccessEvent29   LoggedBweProbeSuccessEvent(Timestamp timestamp,
30                              int32_t id,
31                              int32_t bitrate_bps)
32       : timestamp(timestamp), id(id), bitrate_bps(bitrate_bps) {}
33 
log_time_usLoggedBweProbeSuccessEvent34   int64_t log_time_us() const { return timestamp.us(); }
log_time_msLoggedBweProbeSuccessEvent35   int64_t log_time_ms() const { return timestamp.ms(); }
log_timeLoggedBweProbeSuccessEvent36   Timestamp log_time() const { return timestamp; }
37 
38   Timestamp timestamp = Timestamp::MinusInfinity();
39   int32_t id;
40   int32_t bitrate_bps;
41 };
42 
43 class RtcEventProbeResultSuccess final : public RtcEvent {
44  public:
45   static constexpr Type kType = Type::ProbeResultSuccess;
46 
47   RtcEventProbeResultSuccess(int32_t id, int32_t bitrate_bps);
48   ~RtcEventProbeResultSuccess() override = default;
49 
GetType()50   Type GetType() const override { return kType; }
IsConfigEvent()51   bool IsConfigEvent() const override { return false; }
52 
53   std::unique_ptr<RtcEventProbeResultSuccess> Copy() const;
54 
id()55   int32_t id() const { return id_; }
bitrate_bps()56   int32_t bitrate_bps() const { return bitrate_bps_; }
57 
Encode(rtc::ArrayView<const RtcEvent * > batch)58   static std::string Encode(rtc::ArrayView<const RtcEvent*> batch) {
59     // TODO(terelius): Implement
60     return "";
61   }
62 
Parse(absl::string_view encoded_bytes,bool batched,std::vector<LoggedBweProbeSuccessEvent> & output)63   static RtcEventLogParseStatus Parse(
64       absl::string_view encoded_bytes,
65       bool batched,
66       std::vector<LoggedBweProbeSuccessEvent>& output) {
67     // TODO(terelius): Implement
68     return RtcEventLogParseStatus::Error("Not Implemented", __FILE__, __LINE__);
69   }
70 
71  private:
72   RtcEventProbeResultSuccess(const RtcEventProbeResultSuccess& other);
73 
74   const int32_t id_;
75   const int32_t bitrate_bps_;
76 };
77 
78 }  // namespace webrtc
79 
80 #endif  // LOGGING_RTC_EVENT_LOG_EVENTS_RTC_EVENT_PROBE_RESULT_SUCCESS_H_
81