xref: /aosp_15_r20/external/webrtc/logging/rtc_event_log/ice_logger.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_ICE_LOGGER_H_
12 #define LOGGING_RTC_EVENT_LOG_ICE_LOGGER_H_
13 
14 #include <unordered_map>
15 
16 #include "logging/rtc_event_log/events/rtc_event_ice_candidate_pair.h"
17 #include "logging/rtc_event_log/events/rtc_event_ice_candidate_pair_config.h"
18 
19 namespace webrtc {
20 
21 class RtcEventLog;
22 
23 // IceEventLog wraps RtcEventLog and provides structural logging of ICE-specific
24 // events. The logged events are serialized with other RtcEvent's if protobuf is
25 // enabled in the build.
26 class IceEventLog {
27  public:
28   IceEventLog();
29   ~IceEventLog();
30 
set_event_log(RtcEventLog * event_log)31   void set_event_log(RtcEventLog* event_log) { event_log_ = event_log; }
32 
33   void LogCandidatePairConfig(
34       IceCandidatePairConfigType type,
35       uint32_t candidate_pair_id,
36       const IceCandidatePairDescription& candidate_pair_desc);
37 
38   void LogCandidatePairEvent(IceCandidatePairEventType type,
39                              uint32_t candidate_pair_id,
40                              uint32_t transaction_id);
41 
42   // This method constructs a config event for each candidate pair with their
43   // description and logs these config events. It is intended to be called when
44   // logging starts to ensure that we have at least one config for each
45   // candidate pair id.
46   void DumpCandidatePairDescriptionToMemoryAsConfigEvents() const;
47 
48  private:
49   RtcEventLog* event_log_ = nullptr;
50   std::unordered_map<uint32_t, IceCandidatePairDescription>
51       candidate_pair_desc_by_id_;
52 };
53 
54 }  // namespace webrtc
55 
56 #endif  // LOGGING_RTC_EVENT_LOG_ICE_LOGGER_H_
57