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 #include "logging/rtc_event_log/ice_logger.h"
12 
13 #include <memory>
14 
15 #include "api/rtc_event_log/rtc_event_log.h"
16 
17 namespace webrtc {
18 
IceEventLog()19 IceEventLog::IceEventLog() {}
~IceEventLog()20 IceEventLog::~IceEventLog() {}
21 
LogCandidatePairConfig(IceCandidatePairConfigType type,uint32_t candidate_pair_id,const IceCandidatePairDescription & candidate_pair_desc)22 void IceEventLog::LogCandidatePairConfig(
23     IceCandidatePairConfigType type,
24     uint32_t candidate_pair_id,
25     const IceCandidatePairDescription& candidate_pair_desc) {
26   if (event_log_ == nullptr) {
27     return;
28   }
29   candidate_pair_desc_by_id_[candidate_pair_id] = candidate_pair_desc;
30   event_log_->Log(std::make_unique<RtcEventIceCandidatePairConfig>(
31       type, candidate_pair_id, candidate_pair_desc));
32 }
33 
LogCandidatePairEvent(IceCandidatePairEventType type,uint32_t candidate_pair_id,uint32_t transaction_id)34 void IceEventLog::LogCandidatePairEvent(IceCandidatePairEventType type,
35                                         uint32_t candidate_pair_id,
36                                         uint32_t transaction_id) {
37   if (event_log_ == nullptr) {
38     return;
39   }
40   event_log_->Log(std::make_unique<RtcEventIceCandidatePair>(
41       type, candidate_pair_id, transaction_id));
42 }
43 
DumpCandidatePairDescriptionToMemoryAsConfigEvents() const44 void IceEventLog::DumpCandidatePairDescriptionToMemoryAsConfigEvents() const {
45   for (const auto& desc_id_pair : candidate_pair_desc_by_id_) {
46     event_log_->Log(std::make_unique<RtcEventIceCandidatePairConfig>(
47         IceCandidatePairConfigType::kUpdated, desc_id_pair.first,
48         desc_id_pair.second));
49   }
50 }
51 
52 }  // namespace webrtc
53