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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
//! NACK (Negative Acknowledgement) Interceptors.
//!
//! This module provides interceptors for handling RTCP NACK-based packet loss recovery
//! as specified in RFC 4585 (Extended RTP Profile for RTCP-Based Feedback).
//!
//! # Interceptors
//!
//! - [`NackGeneratorInterceptor`]: Monitors incoming RTP packets and generates
//! NACK requests for missing packets.
//! - [`NackResponderInterceptor`]: Buffers outgoing RTP packets and retransmits
//! them when NACK requests are received.
//!
//! # How NACK Works
//!
//! 1. **Detection**: The receiver detects missing packets by tracking sequence numbers
//! 2. **Request**: The receiver sends an RTCP NACK packet listing missing sequence numbers
//! 3. **Retransmission**: The sender retransmits the requested packets
//!
//! # RTX Support (RFC 4588)
//!
//! The responder supports RFC 4588 RTX (Retransmission) format, which uses a separate
//! SSRC and payload type for retransmissions. This allows the receiver to distinguish
//! between original and retransmitted packets. RTX is enabled by setting `ssrc_rtx`
//! and `payload_type_rtx` in [`StreamInfo`](crate::StreamInfo).
//!
//! # NACK Support Detection
//!
//! Both interceptors check if a stream supports NACK by looking for an [`RTCPFeedback`](crate::RTCPFeedback)
//! entry with `type: "nack"` and empty `parameter`. Streams without NACK support
//! are passed through without modification.
//!
//! # References
//!
//! - [RFC 4585](https://datatracker.ietf.org/doc/html/rfc4585) - Extended RTP Profile for RTCP-Based Feedback (RTP/AVPF)
//! - [RFC 4588](https://datatracker.ietf.org/doc/html/rfc4588) - RTP Retransmission Payload Format
//!
//! # Example
//!
//! ```ignore
//! use rtc_interceptor::{Registry, NackGeneratorBuilder, NackResponderBuilder};
//! use std::time::Duration;
//!
//! let chain = Registry::new()
//! // Generator for incoming streams (detects loss, sends NACKs)
//! .with(NackGeneratorBuilder::new()
//! .with_size(512) // Buffer size for tracking
//! .with_interval(Duration::from_millis(100)) // NACK generation interval
//! .with_skip_last_n(2) // Skip recent packets (may just be delayed)
//! .build())
//! // Responder for outgoing streams (buffers packets, handles NACKs)
//! .with(NackResponderBuilder::new()
//! .with_size(1024) // Buffer size for retransmission
//! .build())
//! .build();
//! ```
pub
pub
pub
pub
use crateStreamInfo;
/// Check if a stream supports NACK feedback.
///
/// Returns `true` if the stream has an RTCPFeedback entry with `type: "nack"`
/// and empty `parameter`.
pub