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