Steve Anton | 33f69db | 2017-10-30 10:01:15 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 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 "p2p/base/ice_transport_internal.h" |
Steve Anton | 33f69db | 2017-10-30 10:01:15 -0700 | [diff] [blame] | 12 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 13 | #include "p2p/base/p2p_constants.h" |
Qingsi Wang | 866e08d | 2018-03-22 17:54:23 -0700 | [diff] [blame] | 14 | |
Steve Anton | 33f69db | 2017-10-30 10:01:15 -0700 | [diff] [blame] | 15 | namespace cricket { |
| 16 | |
Taylor Brandstetter | 6e2e7ce | 2017-12-19 10:26:23 -0800 | [diff] [blame] | 17 | IceConfig::IceConfig() = default; |
| 18 | |
| 19 | IceConfig::IceConfig(int receiving_timeout_ms, |
| 20 | int backup_connection_ping_interval, |
| 21 | ContinualGatheringPolicy gathering_policy, |
| 22 | bool prioritize_most_likely_candidate_pairs, |
| 23 | int stable_writable_connection_ping_interval_ms, |
| 24 | bool presume_writable_when_fully_relayed, |
| 25 | int regather_on_failed_networks_interval_ms, |
Qingsi Wang | 866e08d | 2018-03-22 17:54:23 -0700 | [diff] [blame] | 26 | int receiving_switching_delay_ms) |
Taylor Brandstetter | 6e2e7ce | 2017-12-19 10:26:23 -0800 | [diff] [blame] | 27 | : receiving_timeout(receiving_timeout_ms), |
| 28 | backup_connection_ping_interval(backup_connection_ping_interval), |
| 29 | continual_gathering_policy(gathering_policy), |
| 30 | prioritize_most_likely_candidate_pairs( |
| 31 | prioritize_most_likely_candidate_pairs), |
| 32 | stable_writable_connection_ping_interval( |
| 33 | stable_writable_connection_ping_interval_ms), |
| 34 | presume_writable_when_fully_relayed(presume_writable_when_fully_relayed), |
| 35 | regather_on_failed_networks_interval( |
| 36 | regather_on_failed_networks_interval_ms), |
Qingsi Wang | 866e08d | 2018-03-22 17:54:23 -0700 | [diff] [blame] | 37 | receiving_switching_delay(receiving_switching_delay_ms) {} |
Taylor Brandstetter | 6e2e7ce | 2017-12-19 10:26:23 -0800 | [diff] [blame] | 38 | |
| 39 | IceConfig::~IceConfig() = default; |
| 40 | |
Qingsi Wang | 866e08d | 2018-03-22 17:54:23 -0700 | [diff] [blame] | 41 | int IceConfig::receiving_timeout_or_default() const { |
| 42 | return receiving_timeout.value_or(RECEIVING_TIMEOUT); |
| 43 | } |
| 44 | int IceConfig::backup_connection_ping_interval_or_default() const { |
| 45 | return backup_connection_ping_interval.value_or( |
| 46 | BACKUP_CONNECTION_PING_INTERVAL); |
| 47 | } |
| 48 | int IceConfig::stable_writable_connection_ping_interval_or_default() const { |
| 49 | return stable_writable_connection_ping_interval.value_or( |
| 50 | STRONG_AND_STABLE_WRITABLE_CONNECTION_PING_INTERVAL); |
| 51 | } |
| 52 | int IceConfig::regather_on_failed_networks_interval_or_default() const { |
| 53 | return regather_on_failed_networks_interval.value_or( |
| 54 | REGATHER_ON_FAILED_NETWORKS_INTERVAL); |
| 55 | } |
| 56 | int IceConfig::receiving_switching_delay_or_default() const { |
| 57 | return receiving_switching_delay.value_or(RECEIVING_SWITCHING_DELAY); |
| 58 | } |
| 59 | int IceConfig::ice_check_interval_strong_connectivity_or_default() const { |
| 60 | return ice_check_interval_strong_connectivity.value_or(STRONG_PING_INTERVAL); |
| 61 | } |
| 62 | int IceConfig::ice_check_interval_weak_connectivity_or_default() const { |
| 63 | return ice_check_interval_weak_connectivity.value_or(WEAK_PING_INTERVAL); |
| 64 | } |
| 65 | int IceConfig::ice_check_min_interval_or_default() const { |
| 66 | return ice_check_min_interval.value_or(-1); |
| 67 | } |
| 68 | int IceConfig::ice_unwritable_timeout_or_default() const { |
| 69 | return ice_unwritable_timeout.value_or(CONNECTION_WRITE_CONNECT_TIMEOUT); |
| 70 | } |
| 71 | int IceConfig::ice_unwritable_min_checks_or_default() const { |
| 72 | return ice_unwritable_min_checks.value_or(CONNECTION_WRITE_CONNECT_FAILURES); |
| 73 | } |
Jiawei Ou | 9d4fd555 | 2018-12-06 23:30:17 -0800 | [diff] [blame] | 74 | int IceConfig::ice_inactive_timeout_or_default() const { |
| 75 | return ice_inactive_timeout.value_or(CONNECTION_WRITE_TIMEOUT); |
| 76 | } |
Qingsi Wang | 866e08d | 2018-03-22 17:54:23 -0700 | [diff] [blame] | 77 | int IceConfig::stun_keepalive_interval_or_default() const { |
| 78 | return stun_keepalive_interval.value_or(STUN_KEEPALIVE_INTERVAL); |
| 79 | } |
| 80 | |
Steve Anton | 33f69db | 2017-10-30 10:01:15 -0700 | [diff] [blame] | 81 | IceTransportInternal::IceTransportInternal() = default; |
| 82 | |
| 83 | IceTransportInternal::~IceTransportInternal() = default; |
| 84 | |
| 85 | void IceTransportInternal::SetIceCredentials(const std::string& ice_ufrag, |
| 86 | const std::string& ice_pwd) { |
| 87 | SetIceParameters(IceParameters(ice_ufrag, ice_pwd, false)); |
| 88 | } |
| 89 | |
| 90 | void IceTransportInternal::SetRemoteIceCredentials(const std::string& ice_ufrag, |
| 91 | const std::string& ice_pwd) { |
| 92 | SetRemoteIceParameters(IceParameters(ice_ufrag, ice_pwd, false)); |
| 93 | } |
| 94 | |
Steve Anton | 33f69db | 2017-10-30 10:01:15 -0700 | [diff] [blame] | 95 | } // namespace cricket |