• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_FAILURE_H_
12 #define LOGGING_RTC_EVENT_LOG_EVENTS_RTC_EVENT_PROBE_RESULT_FAILURE_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 enum class ProbeFailureReason {
28   kInvalidSendReceiveInterval = 0,
29   kInvalidSendReceiveRatio,
30   kTimeout,
31   kLast
32 };
33 
34 struct LoggedBweProbeFailureEvent {
35   LoggedBweProbeFailureEvent() = default;
LoggedBweProbeFailureEventLoggedBweProbeFailureEvent36   LoggedBweProbeFailureEvent(Timestamp timestamp,
37                              int32_t id,
38                              ProbeFailureReason failure_reason)
39       : timestamp(timestamp), id(id), failure_reason(failure_reason) {}
40 
log_time_usLoggedBweProbeFailureEvent41   int64_t log_time_us() const { return timestamp.us(); }
log_time_msLoggedBweProbeFailureEvent42   int64_t log_time_ms() const { return timestamp.ms(); }
log_timeLoggedBweProbeFailureEvent43   Timestamp log_time() const { return timestamp; }
44 
45   Timestamp timestamp = Timestamp::MinusInfinity();
46   int32_t id;
47   ProbeFailureReason failure_reason;
48 };
49 
50 class RtcEventProbeResultFailure final : public RtcEvent {
51  public:
52   static constexpr Type kType = Type::ProbeResultFailure;
53 
54   RtcEventProbeResultFailure(int32_t id, ProbeFailureReason failure_reason);
55   ~RtcEventProbeResultFailure() override = default;
56 
GetType()57   Type GetType() const override { return kType; }
IsConfigEvent()58   bool IsConfigEvent() const override { return false; }
59 
60   std::unique_ptr<RtcEventProbeResultFailure> Copy() const;
61 
id()62   int32_t id() const { return id_; }
failure_reason()63   ProbeFailureReason failure_reason() const { return failure_reason_; }
64 
Encode(rtc::ArrayView<const RtcEvent * > batch)65   static std::string Encode(rtc::ArrayView<const RtcEvent*> batch) {
66     // TODO(terelius): Implement
67     return "";
68   }
69 
Parse(absl::string_view encoded_bytes,bool batched,std::vector<LoggedBweProbeFailureEvent> & output)70   static RtcEventLogParseStatus Parse(
71       absl::string_view encoded_bytes,
72       bool batched,
73       std::vector<LoggedBweProbeFailureEvent>& output) {
74     // TODO(terelius): Implement
75     return RtcEventLogParseStatus::Error("Not Implemented", __FILE__, __LINE__);
76   }
77 
78  private:
79   RtcEventProbeResultFailure(const RtcEventProbeResultFailure& other);
80 
81   const int32_t id_;
82   const ProbeFailureReason failure_reason_;
83 };
84 
85 }  // namespace webrtc
86 
87 #endif  // LOGGING_RTC_EVENT_LOG_EVENTS_RTC_EVENT_PROBE_RESULT_FAILURE_H_
88