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 | |
| 11 | #include "logging/rtc_event_log/icelogger.h" |
| 12 | |
| 13 | #include "logging/rtc_event_log/rtc_event_log.h" |
| 14 | #include "rtc_base/ptr_util.h" |
| 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; |
| 29 | event_log_->Log(rtc::MakeUnique<RtcEventIceCandidatePairConfig>( |
| 30 | type, candidate_pair_id, candidate_pair_desc)); |
| 31 | } |
| 32 | |
| 33 | void IceEventLog::LogCandidatePairEvent(IceCandidatePairEventType type, |
| 34 | uint32_t candidate_pair_id) { |
| 35 | if (event_log_ == nullptr) { |
Qingsi Wang | 8eca1ff | 2018-02-02 11:49:44 -0800 | [diff] [blame] | 36 | return; |
| 37 | } |
| 38 | event_log_->Log( |
| 39 | rtc::MakeUnique<RtcEventIceCandidatePair>(type, candidate_pair_id)); |
| 40 | } |
| 41 | |
| 42 | void IceEventLog::DumpCandidatePairDescriptionToMemoryAsConfigEvents() const { |
| 43 | for (const auto& desc_id_pair : candidate_pair_desc_by_id_) { |
| 44 | event_log_->Log(rtc::MakeUnique<RtcEventIceCandidatePairConfig>( |
Bjorn Terelius | 59b4e3e | 2018-05-30 17:14:08 +0200 | [diff] [blame] | 45 | IceCandidatePairConfigType::kUpdated, desc_id_pair.first, |
Qingsi Wang | 8eca1ff | 2018-02-02 11:49:44 -0800 | [diff] [blame] | 46 | desc_id_pair.second)); |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | } // namespace webrtc |