Qingsi Wang | 8eca1ff | 2018-02-02 11:49:44 -0800 | [diff] [blame] | 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 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 11 | #include "logging/rtc_event_log/ice_logger.h" |
Qingsi Wang | 8eca1ff | 2018-02-02 11:49:44 -0800 | [diff] [blame] | 12 | |
Mirko Bonadei | 317a1f0 | 2019-09-17 17:06:18 +0200 | [diff] [blame] | 13 | #include <memory> |
| 14 | |
Danil Chapovalov | 83bbe91 | 2019-08-07 12:24:53 +0200 | [diff] [blame] | 15 | #include "api/rtc_event_log/rtc_event_log.h" |
Qingsi Wang | 8eca1ff | 2018-02-02 11:49:44 -0800 | [diff] [blame] | 16 | |
| 17 | namespace webrtc { |
| 18 | |
| 19 | IceEventLog::IceEventLog() {} |
| 20 | IceEventLog::~IceEventLog() {} |
| 21 | |
Bjorn Terelius | 59b4e3e | 2018-05-30 17:14:08 +0200 | [diff] [blame] | 22 | void IceEventLog::LogCandidatePairConfig( |
| 23 | IceCandidatePairConfigType type, |
Qingsi Wang | 8eca1ff | 2018-02-02 11:49:44 -0800 | [diff] [blame] | 24 | uint32_t candidate_pair_id, |
| 25 | const IceCandidatePairDescription& candidate_pair_desc) { |
| 26 | if (event_log_ == nullptr) { |
| 27 | return; |
| 28 | } |
Bjorn Terelius | 59b4e3e | 2018-05-30 17:14:08 +0200 | [diff] [blame] | 29 | candidate_pair_desc_by_id_[candidate_pair_id] = candidate_pair_desc; |
Mirko Bonadei | 317a1f0 | 2019-09-17 17:06:18 +0200 | [diff] [blame] | 30 | event_log_->Log(std::make_unique<RtcEventIceCandidatePairConfig>( |
Bjorn Terelius | 59b4e3e | 2018-05-30 17:14:08 +0200 | [diff] [blame] | 31 | type, candidate_pair_id, candidate_pair_desc)); |
| 32 | } |
| 33 | |
| 34 | void IceEventLog::LogCandidatePairEvent(IceCandidatePairEventType type, |
Zach Stein | 92c4289 | 2018-11-28 11:38:52 -0800 | [diff] [blame] | 35 | uint32_t candidate_pair_id, |
| 36 | uint32_t transaction_id) { |
Bjorn Terelius | 59b4e3e | 2018-05-30 17:14:08 +0200 | [diff] [blame] | 37 | if (event_log_ == nullptr) { |
Qingsi Wang | 8eca1ff | 2018-02-02 11:49:44 -0800 | [diff] [blame] | 38 | return; |
| 39 | } |
Mirko Bonadei | 317a1f0 | 2019-09-17 17:06:18 +0200 | [diff] [blame] | 40 | event_log_->Log(std::make_unique<RtcEventIceCandidatePair>( |
Zach Stein | 92c4289 | 2018-11-28 11:38:52 -0800 | [diff] [blame] | 41 | type, candidate_pair_id, transaction_id)); |
Qingsi Wang | 8eca1ff | 2018-02-02 11:49:44 -0800 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | void IceEventLog::DumpCandidatePairDescriptionToMemoryAsConfigEvents() const { |
| 45 | for (const auto& desc_id_pair : candidate_pair_desc_by_id_) { |
Mirko Bonadei | 317a1f0 | 2019-09-17 17:06:18 +0200 | [diff] [blame] | 46 | event_log_->Log(std::make_unique<RtcEventIceCandidatePairConfig>( |
Bjorn Terelius | 59b4e3e | 2018-05-30 17:14:08 +0200 | [diff] [blame] | 47 | IceCandidatePairConfigType::kUpdated, desc_id_pair.first, |
Qingsi Wang | 8eca1ff | 2018-02-02 11:49:44 -0800 | [diff] [blame] | 48 | desc_id_pair.second)); |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | } // namespace webrtc |