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 | |
| 21 | bool IceEventLog::IsIceCandidatePairConfigEvent( |
| 22 | IceCandidatePairEventType type) { |
| 23 | return (type == IceCandidatePairEventType::kAdded) || |
| 24 | (type == IceCandidatePairEventType::kUpdated) || |
| 25 | (type == IceCandidatePairEventType::kDestroyed) || |
| 26 | (type == IceCandidatePairEventType::kSelected); |
| 27 | } |
| 28 | |
| 29 | void IceEventLog::LogCandidatePairEvent( |
| 30 | IceCandidatePairEventType type, |
| 31 | uint32_t candidate_pair_id, |
| 32 | const IceCandidatePairDescription& candidate_pair_desc) { |
| 33 | if (event_log_ == nullptr) { |
| 34 | return; |
| 35 | } |
| 36 | if (IsIceCandidatePairConfigEvent(type)) { |
| 37 | candidate_pair_desc_by_id_[candidate_pair_id] = candidate_pair_desc; |
| 38 | event_log_->Log(rtc::MakeUnique<RtcEventIceCandidatePairConfig>( |
| 39 | type, candidate_pair_id, candidate_pair_desc)); |
| 40 | return; |
| 41 | } |
| 42 | event_log_->Log( |
| 43 | rtc::MakeUnique<RtcEventIceCandidatePair>(type, candidate_pair_id)); |
| 44 | } |
| 45 | |
| 46 | void IceEventLog::DumpCandidatePairDescriptionToMemoryAsConfigEvents() const { |
| 47 | for (const auto& desc_id_pair : candidate_pair_desc_by_id_) { |
| 48 | event_log_->Log(rtc::MakeUnique<RtcEventIceCandidatePairConfig>( |
| 49 | IceCandidatePairEventType::kUpdated, desc_id_pair.first, |
| 50 | desc_id_pair.second)); |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | } // namespace webrtc |