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
//! ICE candidate event types.
//!
//! Contains ICE candidate information emitted during candidate gathering.
use crateRTCIceCandidate;
/// ICE candidate event (W3C `RTCPeerConnectionIceEvent`).
///
/// Fired for each local candidate the connection surfaces, which the application sends to
/// the remote peer over its signalling channel, and at the end of gathering (W3C webrtc-pc
/// section 5.6):
///
/// - a candidate whose [`end_of_candidates`](RTCIceCandidate::end_of_candidates) is set (its
/// `candidate` attribute is the empty string) when a generation has finished gathering, with
/// that generation's `usernameFragment`;
/// - then, once no transport gathers any more, a `None` candidate: the legacy "gathering is
/// complete" indication, which follows the gathering state's change to `complete`.
///
/// # Candidate Types
///
/// - **Host** - Local network interface address
/// - **Server Reflexive (srflx)** - Public address discovered via STUN
/// - **Peer Reflexive (prflx)** - Address discovered during connectivity checks
/// - **Relay** - Address allocated on TURN server
///
/// # Examples
///
/// ```
/// use rtci::peer_connection::event::RTCPeerConnectionEvent;
/// use rtci::peer_connection::transport::RTCIceCandidateType;
///
/// # fn handle_event(event: RTCPeerConnectionEvent) {
/// match event {
/// RTCPeerConnectionEvent::OnIceCandidateEvent(ice_event) => match ice_event.candidate {
/// Some(candidate) if candidate.end_of_candidates => {
/// // Signal the end of this generation's candidates.
/// }
/// Some(candidate) => {
/// // Only send relay candidates (for privacy), say.
/// if candidate.typ == RTCIceCandidateType::Relay {
/// println!("Sending relay candidate: {}", candidate.address);
/// }
/// if let Some(url) = &ice_event.url {
/// println!("Gathered from URL: {url}");
/// }
/// }
/// None => println!("gathering complete"),
/// },
/// _ => {}
/// }
/// # }
/// ```
///
/// # Specification
///
/// See [RTCPeerConnectionIceEvent](https://www.w3.org/TR/webrtc/#rtcpeerconnectioniceevent)