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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
//! Stream information types for interceptor binding.
//!
//! This module provides types that describe media streams for interceptor binding.
//! When a stream is bound to an interceptor chain, [`StreamInfo`] provides all the
//! necessary metadata about the stream's codec, SSRC, and supported features.
//!
//! # Stream Binding
//!
//! Interceptors need to know about streams before they can process packets:
//!
//! - **Local streams** (outgoing): Bind with [`Interceptor::bind_local_stream`]
//! - **Remote streams** (incoming): Bind with [`Interceptor::bind_remote_stream`]
//!
//! # Feature Detection
//!
//! Interceptors use [`StreamInfo`] to detect which features are supported:
//!
//! - **NACK support**: Check [`rtcp_feedback`](StreamInfo::rtcp_feedback) for `type: "nack"`
//! - **TWCC support**: Check [`rtp_header_extensions`](StreamInfo::rtp_header_extensions) for the TWCC URI
//! - **RTX support**: Check if [`ssrc_rtx`](StreamInfo::ssrc_rtx) and [`payload_type_rtx`](StreamInfo::payload_type_rtx) are set
/// RTP header extension as negotiated via SDP (RFC 5285).
///
/// Represents a header extension that can be used to add metadata to RTP packets,
/// such as audio levels, video orientation, or custom application data.
///
/// # Common Extension URIs
///
/// | URI | Description |
/// |-----|-------------|
/// | `urn:ietf:params:rtp-hdrext:ssrc-audio-level` | Audio level indication |
/// | `urn:ietf:params:rtp-hdrext:toffset` | Transmission time offset |
/// | `http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time` | Absolute send time |
/// | `http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01` | TWCC sequence number |
/// RTCP feedback mechanism negotiated for the stream.
///
/// Specifies additional RTCP packet types that can be used for feedback
/// between peers, such as NACK for retransmissions or PLI for picture loss.
///
/// # Common Feedback Types
///
/// | Type | Parameter | Description | RFC |
/// |------|-----------|-------------|-----|
/// | `nack` | (empty) | Generic NACK for retransmission | RFC 4585 |
/// | `nack` | `pli` | Picture Loss Indication | RFC 4585 |
/// | `nack` | `fir` | Full Intra Request | RFC 5104 |
/// | `ccm` | `fir` | Codec Control Message: FIR | RFC 5104 |
/// | `goog-remb` | (empty) | Google REMB for bandwidth estimation | - |
/// | `transport-cc` | (empty) | Transport-wide CC feedback | draft-holmer |
///
/// See: <https://draft.ortc.org/#dom-rtcrtcpfeedback>
/// Stream context passed to interceptor bind/unbind callbacks.
///
/// Contains all relevant information about a media stream (audio or video)
/// when it's bound to or unbound from an interceptor. This includes codec
/// parameters, SSRC, RTP extensions, and RTCP feedback mechanisms.
///
/// Used by [`Interceptor::bind_local_stream`](crate::Interceptor::bind_local_stream),
/// [`Interceptor::unbind_local_stream`](crate::Interceptor::unbind_local_stream),
/// [`Interceptor::bind_remote_stream`](crate::Interceptor::bind_remote_stream), and
/// [`Interceptor::unbind_remote_stream`](crate::Interceptor::unbind_remote_stream).
///
/// # Example
///
/// ```
/// use rtci_interceptor::{StreamInfo, RTCPFeedback, RTPHeaderExtension};
///
/// let info = StreamInfo {
/// ssrc: 0x12345678,
/// clock_rate: 90000,
/// mime_type: "video/VP8".to_string(),
/// payload_type: 96,
/// // Enable NACK for retransmission
/// rtcp_feedback: vec![RTCPFeedback {
/// typ: "nack".to_string(),
/// parameter: String::new(),
/// }],
/// ..Default::default()
/// };
/// ```
/// The FEC stream of a media stream, sent in a separate RTP session (RFC 5109 section 14.1:
/// "the FEC stream and the payload stream SHOULD be sent through two separate RTP session").
///
/// In that session the FEC stream has the media stream's SSRC (section 7.2: "The SSRC value
/// SHALL be the same as the SSRC value of the media stream it protects"). A chain keys what
/// it keeps on the SSRC, and both sessions pass through the one chain, so within the chain
/// the FEC stream is known by an SSRC of its own, [`ssrc`](Self::ssrc); whoever drives the
/// chain puts the media stream's SSRC back on the FEC session's transport and takes it off
/// again on the way in ([`FecSessionSsrcMap`](crate::FecSessionSsrcMap)), and binds
/// [`ssrc`](Self::ssrc) as a stream of that session.
///
/// It is a field of its own, not [`StreamInfo::ssrc_fec`]: a repair flow named there is part
/// of the media stream's own RTP session for every interceptor (the RTCP session reports on
/// it there, the per-session wrappers move the stream with it).
/// Whether `mime_type` is `<type>/<subtype>`, compared without case and exactly: `flexfec` must
/// not match `flexfec-03`.