blob: c1dbcd8c89e4aa6eb59004287e51ecefd80574a7 [file] [log] [blame]
Qingsi Wang8eca1ff2018-02-02 11:49:44 -08001/*
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
Karl Wiberg918f50c2018-07-05 11:40:33 +020013#include "absl/memory/memory.h"
Qingsi Wang8eca1ff2018-02-02 11:49:44 -080014#include "logging/rtc_event_log/rtc_event_log.h"
Qingsi Wang8eca1ff2018-02-02 11:49:44 -080015
16namespace webrtc {
17
18IceEventLog::IceEventLog() {}
19IceEventLog::~IceEventLog() {}
20
Bjorn Terelius59b4e3e2018-05-30 17:14:08 +020021void IceEventLog::LogCandidatePairConfig(
22 IceCandidatePairConfigType type,
Qingsi Wang8eca1ff2018-02-02 11:49:44 -080023 uint32_t candidate_pair_id,
24 const IceCandidatePairDescription& candidate_pair_desc) {
25 if (event_log_ == nullptr) {
26 return;
27 }
Bjorn Terelius59b4e3e2018-05-30 17:14:08 +020028 candidate_pair_desc_by_id_[candidate_pair_id] = candidate_pair_desc;
Karl Wiberg918f50c2018-07-05 11:40:33 +020029 event_log_->Log(absl::make_unique<RtcEventIceCandidatePairConfig>(
Bjorn Terelius59b4e3e2018-05-30 17:14:08 +020030 type, candidate_pair_id, candidate_pair_desc));
31}
32
33void IceEventLog::LogCandidatePairEvent(IceCandidatePairEventType type,
Zach Stein92c42892018-11-28 11:38:52 -080034 uint32_t candidate_pair_id,
35 uint32_t transaction_id) {
Bjorn Terelius59b4e3e2018-05-30 17:14:08 +020036 if (event_log_ == nullptr) {
Qingsi Wang8eca1ff2018-02-02 11:49:44 -080037 return;
38 }
Zach Stein92c42892018-11-28 11:38:52 -080039 event_log_->Log(absl::make_unique<RtcEventIceCandidatePair>(
40 type, candidate_pair_id, transaction_id));
Qingsi Wang8eca1ff2018-02-02 11:49:44 -080041}
42
43void IceEventLog::DumpCandidatePairDescriptionToMemoryAsConfigEvents() const {
44 for (const auto& desc_id_pair : candidate_pair_desc_by_id_) {
Karl Wiberg918f50c2018-07-05 11:40:33 +020045 event_log_->Log(absl::make_unique<RtcEventIceCandidatePairConfig>(
Bjorn Terelius59b4e3e2018-05-30 17:14:08 +020046 IceCandidatePairConfigType::kUpdated, desc_id_pair.first,
Qingsi Wang8eca1ff2018-02-02 11:49:44 -080047 desc_id_pair.second));
48 }
49}
50
51} // namespace webrtc