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
11 #include "p2p/base/ice_transport_internal.h"
12
13 #include "p2p/base/p2p_constants.h"
14
15 namespace cricket {
16
17 IceConfig::IceConfig() = default;
18
IceConfig(int receiving_timeout_ms,int backup_connection_ping_interval,ContinualGatheringPolicy gathering_policy,bool prioritize_most_likely_candidate_pairs,int stable_writable_connection_ping_interval_ms,bool presume_writable_when_fully_relayed,int regather_on_failed_networks_interval_ms,int receiving_switching_delay_ms)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,
26 int receiving_switching_delay_ms)
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),
37 receiving_switching_delay(receiving_switching_delay_ms) {}
38
39 IceConfig::~IceConfig() = default;
40
receiving_timeout_or_default() const41 int IceConfig::receiving_timeout_or_default() const {
42 return receiving_timeout.value_or(RECEIVING_TIMEOUT);
43 }
backup_connection_ping_interval_or_default() const44 int IceConfig::backup_connection_ping_interval_or_default() const {
45 return backup_connection_ping_interval.value_or(
46 BACKUP_CONNECTION_PING_INTERVAL);
47 }
stable_writable_connection_ping_interval_or_default() const48 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 }
regather_on_failed_networks_interval_or_default() const52 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 }
receiving_switching_delay_or_default() const56 int IceConfig::receiving_switching_delay_or_default() const {
57 return receiving_switching_delay.value_or(RECEIVING_SWITCHING_DELAY);
58 }
ice_check_interval_strong_connectivity_or_default() const59 int IceConfig::ice_check_interval_strong_connectivity_or_default() const {
60 return ice_check_interval_strong_connectivity.value_or(STRONG_PING_INTERVAL);
61 }
ice_check_interval_weak_connectivity_or_default() const62 int IceConfig::ice_check_interval_weak_connectivity_or_default() const {
63 return ice_check_interval_weak_connectivity.value_or(WEAK_PING_INTERVAL);
64 }
ice_check_min_interval_or_default() const65 int IceConfig::ice_check_min_interval_or_default() const {
66 return ice_check_min_interval.value_or(-1);
67 }
ice_unwritable_timeout_or_default() const68 int IceConfig::ice_unwritable_timeout_or_default() const {
69 return ice_unwritable_timeout.value_or(CONNECTION_WRITE_CONNECT_TIMEOUT);
70 }
ice_unwritable_min_checks_or_default() const71 int IceConfig::ice_unwritable_min_checks_or_default() const {
72 return ice_unwritable_min_checks.value_or(CONNECTION_WRITE_CONNECT_FAILURES);
73 }
ice_inactive_timeout_or_default() const74 int IceConfig::ice_inactive_timeout_or_default() const {
75 return ice_inactive_timeout.value_or(CONNECTION_WRITE_TIMEOUT);
76 }
stun_keepalive_interval_or_default() const77 int IceConfig::stun_keepalive_interval_or_default() const {
78 return stun_keepalive_interval.value_or(STUN_KEEPALIVE_INTERVAL);
79 }
80
81 IceTransportInternal::IceTransportInternal() = default;
82
83 IceTransportInternal::~IceTransportInternal() = default;
84
SetIceCredentials(const std::string & ice_ufrag,const std::string & ice_pwd)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
SetRemoteIceCredentials(const std::string & ice_ufrag,const std::string & ice_pwd)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
95 } // namespace cricket
96