File: ice_switch_proposal.h

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (96 lines) | stat: -rw-r--r-- 3,330 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef THIRD_PARTY_WEBRTC_OVERRIDES_P2P_BASE_ICE_SWITCH_PROPOSAL_H_
#define THIRD_PARTY_WEBRTC_OVERRIDES_P2P_BASE_ICE_SWITCH_PROPOSAL_H_

#include <optional>
#include <ostream>
#include <string>
#include <vector>

#include "third_party/webrtc/api/array_view.h"
#include "third_party/webrtc/p2p/base/ice_controller_interface.h"
#include "third_party/webrtc/p2p/base/ice_switch_reason.h"
#include "third_party/webrtc/rtc_base/system/rtc_export.h"
#include "third_party/webrtc_overrides/p2p/base/ice_connection.h"
#include "third_party/webrtc_overrides/p2p/base/ice_proposal.h"

namespace blink {

// Reasons for performing an ICE switch.
enum class IceSwitchReason {
  kUnknown,
  kRemoteCandidateGenerationChange,
  kNetworkPreferenceChange,
  kNewConnectionFromLocalCandidate,
  kNewConnectionFromRemoteCandidate,
  kNewConnectionFromUnknownRemoteAddress,
  kNominationOnControlledSide,
  kDataReceived,
  kConnectStateChange,
  kSelectedConnectionDestroyed,
  kIceControllerRecheck,
  kApplicationRequested,
};

std::string IceSwitchReasonToString(IceSwitchReason reason);
RTC_EXPORT IceSwitchReason
ConvertFromWebrtcIceSwitchReason(webrtc::IceSwitchReason reason);
webrtc::IceSwitchReason ConvertToWebrtcIceSwitchReason(IceSwitchReason reason);

// Represents a future event to check whether an ICE switch should be performed.
struct IceRecheckEvent {
  explicit IceRecheckEvent(const webrtc::IceRecheckEvent& event);

  IceSwitchReason reason;
  int recheck_delay_ms;
};

// A proposal to switch the ICE transport to use the proposed ICE connection.
// Optionally indicates the duration until another check is performed whether to
// switch the connection.
class RTC_EXPORT IceSwitchProposal : public IceProposal {
 public:
  IceSwitchProposal(
      webrtc::IceSwitchReason reason,
      const webrtc::IceControllerInterface::SwitchResult& switch_result,
      bool reply_expected);

  IceSwitchProposal(const IceSwitchProposal&) = default;

  ~IceSwitchProposal() override = default;

  // The reason for which this switch is proposed.
  IceSwitchReason reason() const { return reason_; }
  // The connection that the ICE transport will switch to.
  std::optional<const IceConnection> connection() const { return connection_; }
  // An optional event describing when the next check will be performed to
  // switch to a new connection.
  std::optional<IceRecheckEvent> recheck_event() const {
    return recheck_event_;
  }
  // Connections for which some learnt state should be reset.
  // TODO(crbug.com/1369096): this is probably not necessary, check!
  const webrtc::ArrayView<const IceConnection> connections_to_forget_state_on()
      const {
    return connections_to_forget_state_on_;
  }

  std::string ToString() const;
  // Pretty printing for unit test matchers.
  friend void PrintTo(const IceSwitchProposal& proposal, std::ostream* os) {
    *os << proposal.ToString();
  }

 private:
  IceSwitchReason reason_;
  std::optional<IceConnection> connection_;
  std::optional<IceRecheckEvent> recheck_event_;
  std::vector<IceConnection> connections_to_forget_state_on_;
};

}  // namespace blink

#endif  // THIRD_PARTY_WEBRTC_OVERRIDES_P2P_BASE_ICE_SWITCH_PROPOSAL_H_