blob: 390deda953b3a6f9ee3f7f67f41a48c66a683965 [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
Steve Anton10542f22019-01-11 09:11:00 -080011#include "logging/rtc_event_log/ice_logger.h"
Qingsi Wang8eca1ff2018-02-02 11:49:44 -080012
Mirko Bonadei317a1f02019-09-17 17:06:18 +020013#include <memory>
14
Danil Chapovalov83bbe912019-08-07 12:24:53 +020015#include "api/rtc_event_log/rtc_event_log.h"
Qingsi Wang8eca1ff2018-02-02 11:49:44 -080016
17namespace webrtc {
18
19IceEventLog::IceEventLog() {}
20IceEventLog::~IceEventLog() {}
21
Bjorn Terelius59b4e3e2018-05-30 17:14:08 +020022void IceEventLog::LogCandidatePairConfig(
23 IceCandidatePairConfigType type,
Qingsi Wang8eca1ff2018-02-02 11:49:44 -080024 uint32_t candidate_pair_id,
25 const IceCandidatePairDescription& candidate_pair_desc) {
26 if (event_log_ == nullptr) {
27 return;
28 }
Bjorn Terelius59b4e3e2018-05-30 17:14:08 +020029 candidate_pair_desc_by_id_[candidate_pair_id] = candidate_pair_desc;
Mirko Bonadei317a1f02019-09-17 17:06:18 +020030 event_log_->Log(std::make_unique<RtcEventIceCandidatePairConfig>(
Bjorn Terelius59b4e3e2018-05-30 17:14:08 +020031 type, candidate_pair_id, candidate_pair_desc));
32}
33
34void IceEventLog::LogCandidatePairEvent(IceCandidatePairEventType type,
Zach Stein92c42892018-11-28 11:38:52 -080035 uint32_t candidate_pair_id,
36 uint32_t transaction_id) {
Bjorn Terelius59b4e3e2018-05-30 17:14:08 +020037 if (event_log_ == nullptr) {
Qingsi Wang8eca1ff2018-02-02 11:49:44 -080038 return;
39 }
Mirko Bonadei317a1f02019-09-17 17:06:18 +020040 event_log_->Log(std::make_unique<RtcEventIceCandidatePair>(
Zach Stein92c42892018-11-28 11:38:52 -080041 type, candidate_pair_id, transaction_id));
Qingsi Wang8eca1ff2018-02-02 11:49:44 -080042}
43
44void IceEventLog::DumpCandidatePairDescriptionToMemoryAsConfigEvents() const {
45 for (const auto& desc_id_pair : candidate_pair_desc_by_id_) {
Mirko Bonadei317a1f02019-09-17 17:06:18 +020046 event_log_->Log(std::make_unique<RtcEventIceCandidatePairConfig>(
Bjorn Terelius59b4e3e2018-05-30 17:14:08 +020047 IceCandidatePairConfigType::kUpdated, desc_id_pair.first,
Qingsi Wang8eca1ff2018-02-02 11:49:44 -080048 desc_id_pair.second));
49 }
50}
51
52} // namespace webrtc