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
//! ICE candidate event types.
//!
//! Contains ICE candidate information emitted during candidate gathering.
use crateRTCIceCandidate;
/// ICE candidate event.
///
/// This event is fired when a new ICE candidate is discovered during the
/// gathering process. The candidate should be sent to the remote peer
/// via the signaling channel.
///
/// # Fields
///
/// - `candidate` - The discovered ICE candidate
/// - `url` - The STUN/TURN URL used to discover this candidate (if applicable)
///
/// # 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
///
/// ## Sending candidates to remote peer
///
/// ```
/// use rtc::peer_connection::event::RTCPeerConnectionEvent;
///
/// # fn handle_event(event: RTCPeerConnectionEvent) {
/// match event {
/// RTCPeerConnectionEvent::OnIceCandidateEvent(ice_event) => {
/// // Send candidate to remote peer via signaling channel
/// println!("Send candidate: {}", ice_event.candidate.address);
///
/// // Also send the URL if needed
/// if !ice_event.url.is_empty() {
/// println!("Gathered from URL: {}", ice_event.url);
/// }
///
/// // Signal candidate to remote peer
/// // signal_candidate(&ice_event.candidate).await;
/// }
/// _ => {}
/// }
/// # }
/// ```
///
/// ## Filtering candidates by type
///
/// ```
/// use rtc::peer_connection::event::RTCPeerConnectionEvent;
/// use rtc::peer_connection::transport::RTCIceCandidateType;
///
/// # fn handle_event(event: RTCPeerConnectionEvent) {
/// match event {
/// RTCPeerConnectionEvent::OnIceCandidateEvent(ice_event) => {
/// // Only send relay candidates (for privacy)
/// if ice_event.candidate.typ == RTCIceCandidateType::Relay {
/// println!("Sending relay candidate: {}", ice_event.candidate.address);
/// // signal_candidate(&ice_event.candidate).await;
/// }
/// }
/// _ => {}
/// }
/// # }
/// ```
///
/// # Specification
///
/// See [RTCPeerConnectionIceEvent](https://www.w3.org/TR/webrtc/#rtcpeerconnectioniceevent)