• 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_ICE_CANDIDATE_PAIR_H_
12 #define LOGGING_RTC_EVENT_LOG_EVENTS_RTC_EVENT_ICE_CANDIDATE_PAIR_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 IceCandidatePairEventType {
28   kCheckSent,
29   kCheckReceived,
30   kCheckResponseSent,
31   kCheckResponseReceived,
32   kNumValues,
33 };
34 
35 struct LoggedIceCandidatePairEvent {
36   LoggedIceCandidatePairEvent() = default;
LoggedIceCandidatePairEventLoggedIceCandidatePairEvent37   LoggedIceCandidatePairEvent(Timestamp timestamp,
38                               IceCandidatePairEventType type,
39                               uint32_t candidate_pair_id,
40                               uint32_t transaction_id)
41       : timestamp(timestamp),
42         type(type),
43         candidate_pair_id(candidate_pair_id),
44         transaction_id(transaction_id) {}
45 
log_time_usLoggedIceCandidatePairEvent46   int64_t log_time_us() const { return timestamp.us(); }
log_time_msLoggedIceCandidatePairEvent47   int64_t log_time_ms() const { return timestamp.ms(); }
log_timeLoggedIceCandidatePairEvent48   Timestamp log_time() const { return timestamp; }
49 
50   Timestamp timestamp = Timestamp::MinusInfinity();
51   IceCandidatePairEventType type;
52   uint32_t candidate_pair_id;
53   uint32_t transaction_id;
54 };
55 
56 class RtcEventIceCandidatePair final : public RtcEvent {
57  public:
58   static constexpr Type kType = Type::IceCandidatePairEvent;
59 
60   RtcEventIceCandidatePair(IceCandidatePairEventType type,
61                            uint32_t candidate_pair_id,
62                            uint32_t transaction_id);
63 
64   ~RtcEventIceCandidatePair() override;
65 
GetType()66   Type GetType() const override { return kType; }
IsConfigEvent()67   bool IsConfigEvent() const override { return false; }
68 
69   std::unique_ptr<RtcEventIceCandidatePair> Copy() const;
70 
type()71   IceCandidatePairEventType type() const { return type_; }
candidate_pair_id()72   uint32_t candidate_pair_id() const { return candidate_pair_id_; }
transaction_id()73   uint32_t transaction_id() const { return transaction_id_; }
74 
Encode(rtc::ArrayView<const RtcEvent * > batch)75   static std::string Encode(rtc::ArrayView<const RtcEvent*> batch) {
76     // TODO(terelius): Implement
77     return "";
78   }
79 
Parse(absl::string_view encoded_bytes,bool batched,std::vector<LoggedIceCandidatePairEvent> & output)80   static RtcEventLogParseStatus Parse(
81       absl::string_view encoded_bytes,
82       bool batched,
83       std::vector<LoggedIceCandidatePairEvent>& output) {
84     // TODO(terelius): Implement
85     return RtcEventLogParseStatus::Error("Not Implemented", __FILE__, __LINE__);
86   }
87 
88  private:
89   RtcEventIceCandidatePair(const RtcEventIceCandidatePair& other);
90 
91   const IceCandidatePairEventType type_;
92   const uint32_t candidate_pair_id_;
93   const uint32_t transaction_id_;
94 };
95 
96 }  // namespace webrtc
97 
98 #endif  // LOGGING_RTC_EVENT_LOG_EVENTS_RTC_EVENT_ICE_CANDIDATE_PAIR_H_
99