rtci 0.5.0

A sans-I/O WebRTC implementation: peer connections with ICE, DTLS-SRTP, SCTP data channels, RTP/RTCP and JSEP negotiation
Documentation
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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
[workspace]
members = [
    "rtci-crypto",
    "rtci-datachannel",
    "rtci-dtls",
    "rtci-ice",
    "rtci-interceptor",
    "rtci-interceptor-derive",
    "rtci-media",
    "rtci-mdns",
    "rtci-rtcp",
    "rtci-rtp",
    "rtci-sctp",
    "rtci-sdp",
    "rtci-sframe",
    "rtci-shared",
    "rtci-srtp",
    "rtci-stun",
    "rtci-turn",
    "rtci-video",
    "rtci-video/interop",
    "examples/custom-runtime",
]
resolver = "2"

[profile.dev]
opt-level = 0

# The video pipeline's tests run minutes of virtual-time calls through two peer connections;
# unoptimised they take far longer. Only this package is optimised in the dev profile.
[profile.dev.package.rtci-video]
opt-level = 2

# rtci-video's codec backends (features `vp8`, `av1`): their tests encode and decode real video.
[profile.dev.package.vp8-decoder]
opt-level = 2

[profile.dev.package.vp8-encoder]
opt-level = 2

[profile.dev.package.rav1d]
opt-level = 2

[profile.dev.package.rav1e]
opt-level = 2

[workspace.package]
version = "0.5.0"
authors = ["The rtci authors"]
edition = "2024"
# The lowest toolchain the workspace builds on (checked by the MSRV job of cargo.yml).
rust-version = "1.89"
license = "MIT OR Apache-2.0"
repository = "https://github.com/Brainwires/rtci"

[workspace.dependencies]
crypto = { version = "0.5.0", path = "rtci-crypto", package = "rtci-crypto", default-features = false }
datachannel = { version = "0.5.0", path = "rtci-datachannel", package = "rtci-datachannel" }
dtls = { version = "0.5.0", path = "rtci-dtls", package = "rtci-dtls", default-features = false }
ice = { version = "0.5.0", path = "rtci-ice", package = "rtci-ice", default-features = false }
interceptor = { version = "0.5.0", path = "rtci-interceptor", package = "rtci-interceptor" }
interceptor-derive = { version = "0.5.0", path = "rtci-interceptor-derive", package = "rtci-interceptor-derive" }
mdns = { version = "0.5.0", path = "rtci-mdns", package = "rtci-mdns" }
media = { version = "0.5.0", path = "rtci-media", package = "rtci-media" }
rtcp = { version = "0.5.0", path = "rtci-rtcp", package = "rtci-rtcp" }
rtp = { version = "0.5.0", path = "rtci-rtp", package = "rtci-rtp" }
sctp = { version = "0.5.0", path = "rtci-sctp", package = "rtci-sctp" }
sdp = { version = "0.5.0", path = "rtci-sdp", package = "rtci-sdp" }
sframe = { version = "0.5.0", path = "rtci-sframe", package = "rtci-sframe", default-features = false }
shared = { version = "0.5.0", path = "rtci-shared", package = "rtci-shared", default-features = false }
srtp = { version = "0.5.0", path = "rtci-srtp", package = "rtci-srtp", default-features = false }
stun = { version = "0.5.0", path = "rtci-stun", package = "rtci-stun", default-features = false }
turn = { version = "0.5.0", path = "rtci-turn", package = "rtci-turn", default-features = false }
# The examples' signalling helper is not published: path only, so `cargo publish` drops the
# root crate's dev-dependency on it.
signal = { path = "examples/signal", package = "rtci-signal" }
# The reference driver depends on `rtci` (its `peer` module), so the root crate's dev-dependency
# on it has no version (`cargo publish` drops it) and leaves that feature off.
stream-driver = { path = "examples/stream-driver", package = "rtci-stream-driver", default-features = false, features = ["runtime-tokio"] }

# common dependencies
sansio = "1"
bytes = "1.12.0"
byteorder = "1.5.0"
log = "0.4.33"
rcgen = { version = "0.14.8", features = ["pem"], default-features = false }
# rtci-ring: rtci's fork of ring 0.17.14 that overwrites an RSA key pair's heap limbs before
# freeing them (https://github.com/Brainwires/rtci-ring, RTCI-FORK.md; docs/key-erasure.md). The
# library is still `ring`.
ring = { package = "rtci-ring", version = "0.17.14" }
aws-lc-rs = { version = "1.17.3", features = ["aws-lc-sys"], default-features = false }
rand = "0.10.1"
serde = { version = "1.0.228", features = ["derive"] }
serde_json = "1.0.114"
thiserror = "2.0.18"
zeroize = { version = "1.8.2", features = ["derive"] }
pem = "3.0.3"
# `zeroize`: the expanded AES key schedules (`aes`) and the CTR keystream buffer (`ctr`, through
# `cipher`) are erased when dropped, including the per-packet ones on the stack.
aes = { version = "0.8.4", features = ["zeroize"] }
ctr = { version = "0.9.2", features = ["zeroize"] }
ccm = "0.5.0"
md-5 = "0.10.6"
# `zeroize` (here and in sha1): the hash states of the ring provider's HMAC-SHA1, and the copy
# of the outer state each MAC is finished on, are overwritten when dropped.
hmac = { version = "0.13.0", features = ["zeroize"] }
sha1 = { version = "0.11.0", features = ["zeroize"] }
sha2 = "0.10.9"
# rtci-crypto's `ecdsa-rfc6979` feature (off by default): RFC 6979 deterministic ECDSA for the
# certificate key (RFC 8446 appendix C.3). Default features off: no PEM, no precomputed tables,
# no std; `pkcs8` reads the provider key's PKCS#8 form.
p256 = { version = "0.14.0", default-features = false, features = ["ecdsa", "pkcs8"] }
p384 = { version = "0.14.0", default-features = false, features = ["ecdsa", "pkcs8"] }
subtle = "2.6.1"
num-bigint = "0.4.6"
x509-parser = "0.16.0"
der-parser = "9.0.0"
rustls = { version = "0.23.27", default-features = false, features = ["std"] }
rkyv = "0.8.17"
bytecheck = "0.8"
url = "2.5.0"
base64 = "0.22.1"
crc = "3.0.1"
precis-profiles = "0.2.0"
slab = "0.4.9"
crc32c = "0.6"
rustc-hash = "2"
memchr = "2.1.1"
socket2 = { version = "0.6", features = ["all"] }
proc-macro2 = "1"
quote = "1"
syn = { version = "2", features = ["full", "parsing", "extra-traits"] }
uuid = { version = "1", features = ["v4"] }
unicase = "2.8"
substring = "1.4.5"

# dev dependencies
env_logger = "0.11.11"
chrono = "0.4.45"
clap = { version = "4.6.1", features = ["derive"] }
ctrlc = "3.5.2"
criterion = "0.8.2"
tokio = { version = "1.52.3", features = ["full"] }
tokio-tungstenite = "0.28.0"
# HTTP/1 only: the examples' signaling servers and clients. No `http2`, so no `h2`.
hyper = { version = "1", features = ["server", "client", "http1"] }
hyper-util = { version = "0.1", features = ["tokio", "client-legacy", "http1"] }
http-body-util = "0.1"
lazy_static = "1.4.0"
hex = "0.4.3"
crossbeam-channel = "0.5"
assert_matches = "1.5.0"
nearly_eq = "0.2"
regex = "1.10.3"
ipnet = "2.9.0"
waitgroup = "0.1.2"
futures = "0.3.30"
futures-util = "0.3"
local-sync = "0.1.1"
core_affinity = "0.8.1"
anyhow = "1.0.80"

[package]
name = "rtci"
version.workspace = true
authors.workspace = true
edition.workspace = true
rust-version.workspace = true
description = "A sans-I/O WebRTC implementation: peer connections with ICE, DTLS-SRTP, SCTP data channels, RTP/RTCP and JSEP negotiation"
license.workspace = true
repository.workspace = true
keywords = ["webrtc", "sans-io", "rtp", "ice", "dtls"]
categories = ["network-programming", "multimedia"]
readme = "README.md"
# The published crate is the library: its sources, the two test files its unit tests include,
# the README and the licence texts. The examples, integration tests, fixtures, documentation,
# test environment and CI files stay in the repository (`cargo publish` drops the example and
# test targets whose files are not in the package).
include = [
    "/src/**",
    "/tests/fixtures/browser-sdp/firefox-152--simulcast-three-rids-send--1-offer.sdp",
    "/tests/testdata/rsa_2048_offerer_key.pem",
    "/README.md",
    "/LICENSE-MIT",
    "/LICENSE-APACHE",
]

[package.metadata.docs.rs]
features = ["crypto-ring", "crypto-aws-lc-rs", "pem", "turn-tls-webpki-roots"]

[features]
default = ["crypto-ring"]
crypto-ring = ["crypto/crypto-ring", "dtls/crypto-ring", "rustls/ring", "rcgen/ring", "ice/crypto-ring", "stun/crypto-ring", "srtp/crypto-ring", "turn/crypto-ring", "sframe/crypto-ring"]
# Kept by the Brainwires fork (upstream removed them): see FORK.md.
openssl = ["srtp/openssl"]
vendored-openssl = ["srtp/vendored-openssl"]
# A no-op kept for compatibility (upstream removed the name): PEM certificate import and export
# (`RTCCertificate::from_pem` / `serialize_pem`, rtci-dtls `Certificate::from_pem`) is always built.
pem = ["dtls/pem"]
# The Mozilla root certificates (webpki-roots, CDLA-Permissive-2.0) for the engine's TURN-over-TLS
# connections; without it the application gives roots or a verifier (`with_turn_tls`).
turn-tls-webpki-roots = ["dep:webpki-roots"]
# Makes `BehaviourProfile::default()` (and with it every `SettingEngine`, `MediaEngine` and
# `DefaultInterceptorOptions` default) `BehaviourProfile::Chrome`: libwebrtc's defaults where
# they differ from the RFCs' (docs/behaviour-profiles.md). Cargo unifies features: one crate of
# a build that turns this on changes the defaults of every user of `rtci` in that build. Prefer
# `SettingEngineBuilder::with_behaviour_profile`.
chrome-defaults = []
# BehaviourProfile::Performance as the default profile (docs/behaviour-profiles.md). With
# chrome-defaults also on, Chrome is the default and the build warns.
performance-defaults = []
# RFC 6979 deterministic ECDSA for the certificate key (RFC 8446 appendix C.3), selected by
# `SettingEngineBuilder::with_deterministic_ecdsa` and the `StrictRfc` profile: RustCrypto's
# p256 / p384 (rtci-crypto's feature of the same name). Off by default: the providers' hedged
# nonce is the default (docs/conformance/audit/rfc8446.md, RFC8446-C.3-1). With the setting
# on and the feature off, the DTLS transport refuses to start and says so.
ecdsa-rfc6979 = ["crypto/ecdsa-rfc6979"]
crypto-aws-lc-rs = ["crypto/crypto-aws-lc-rs", "dtls/crypto-aws-lc-rs", "rustls/aws-lc-rs", "rcgen/aws_lc_rs", "ice/crypto-aws-lc-rs", "stun/crypto-aws-lc-rs", "srtp/crypto-aws-lc-rs", "turn/crypto-aws-lc-rs", "sframe/crypto-aws-lc-rs"]

[dependencies]
shared = { workspace = true, default-features = false, features = ["marshal", "replay"] }
crypto.workspace = true
zeroize.workspace = true
sansio.workspace = true
datachannel.workspace = true
dtls.workspace = true
ice.workspace = true
interceptor.workspace = true
mdns.workspace = true
media.workspace = true
rtcp.workspace = true
rtp.workspace = true
sctp.workspace = true
sdp.workspace = true
srtp.workspace = true
sframe.workspace = true
stun.workspace = true
turn.workspace = true

bytes.workspace = true
rustc-hash.workspace = true
log.workspace = true
serde.workspace = true
rcgen.workspace = true
# `tls12`: the engine's TURN-over-TLS client offers TLS 1.2 beside TLS 1.3 (RFC 8656 3.1 allows
# both). Deployed servers still need it: coturn 4.6.1, which Ubuntu 24.04 and Debian 13 ship,
# refuses a ClientHello that offers TLS 1.3 alone and settles on TLS 1.2 when both are offered
# (fixed in coturn 4.6.2, https://github.com/coturn/coturn/pull/989).
rustls = { workspace = true, features = ["tls12"] }
url.workspace = true
# Feature `turn-tls-webpki-roots`: the Mozilla roots for TURN over TLS.
webpki-roots = { version = "1", optional = true }
hex.workspace = true
base64.workspace = true
pem.workspace = true
x509-parser.workspace = true
unicase.workspace = true
rand.workspace = true

[dev-dependencies]
# The tests, examples and the interop peer run the `StrictRfc` profile, whose deterministic ECDSA
# (RFC 8446 C.3, `with_deterministic_ecdsa`) needs the RFC 6979 signer: the feature is on for
# them, while the library's default graph stays without it.
crypto = { workspace = true, features = ["ecdsa-rfc6979"] }
sansio.workspace = true
shared.workspace = true
ice.workspace = true
signal.workspace = true
stream-driver.workspace = true

tokio.workspace = true
env_logger.workspace = true
anyhow.workspace = true
clap.workspace = true
hyper.workspace = true
chrono.workspace = true
log.workspace = true
ctrlc.workspace = true
tokio-tungstenite.workspace = true
futures-util.workspace = true
# The statistics tests and the interop peer read and write JSON.
serde_json.workspace = true

# Interop tests against the independent (pre-sans-I/O) webrtc implementation. 0.17.3 is the
# last release of that line, and the first whose DTLS uses p256 0.14 (crypto-bigint 0.7, past
# RUSTSEC-2026-0387) and no bincode. webrtc 0.20+ is built on the upstream `rtc` crates, so it
# would test this stack against its own lineage.
webrtc = "0.17.3"

# The integration tests name TLS 1.2 themselves (tests/testenv_turn_streams.rs checks that the
# environment's TLS 1.2-only coturn settles on 1.2). The same feature as the library's own
# dependency above, which is what the engine's TURN-over-TLS client needs.
rustls = { workspace = true, features = ["tls12"] }

# The real-network test environment's tests (tests/testenv_*.rs) create sockets inside Linux
# network namespaces with setns(2).
[target.'cfg(target_os = "linux")'.dev-dependencies]
libc = "0.2"

[[example]]
name = "interop-peer"
path = "examples/interop-peer/interop-peer.rs"
bench = false

[[example]]
name = "broadcast"
path = "examples/broadcast/broadcast.rs"
bench = false

[[example]]
name = "data-channels"
path = "examples/data-channels/data-channels.rs"
bench = false

[[example]]
name = "data-channels-create"
path = "examples/data-channels-create/data-channels-create.rs"
bench = false

[[example]]
name = "data-channels-close"
path = "examples/data-channels-close/data-channels-close.rs"
bench = false

[[example]]
name = "data-channels-flow-control"
path = "examples/data-channels-flow-control/data-channels-flow-control.rs"
bench = false

[[example]]
name = "data-channels-offer"
path = "examples/data-channels-offer-answer/data-channels-offer.rs"
bench = false

[[example]]
name = "data-channels-answer"
path = "examples/data-channels-offer-answer/data-channels-answer.rs"
bench = false

[[example]]
name = "insertable-streams"
path = "examples/insertable-streams/insertable-streams.rs"
bench = false

[[example]]
name = "play-from-disk-vpx"
path = "examples/play-from-disk-vpx/play-from-disk-vpx.rs"
bench = false

[[example]]
name = "play-from-disk-fec"
path = "examples/play-from-disk-fec/play-from-disk-fec.rs"
bench = false

[[example]]
name = "save-to-disk-fec"
path = "examples/save-to-disk-fec/save-to-disk-fec.rs"
bench = false

[[example]]
name = "bandwidth-estimation-from-disk"
path = "examples/bandwidth-estimation-from-disk/bandwidth-estimation-from-disk.rs"
bench = false

[[example]]
name = "play-from-disk-h26x"
path = "examples/play-from-disk-h26x/play-from-disk-h26x.rs"
bench = false

[[example]]
name = "save-to-disk-vpx"
path = "examples/save-to-disk-vpx/save-to-disk-vpx.rs"
bench = false

[[example]]
name = "save-to-disk-h26x"
path = "examples/save-to-disk-h26x/save-to-disk-h26x.rs"
bench = false

[[example]]
name = "play-from-disk-renegotiation"
path = "examples/play-from-disk-renegotiation/play-from-disk-renegotiation.rs"
bench = false

[[example]]
name = "reflect"
path = "examples/reflect/reflect.rs"
bench = false

[[example]]
name = "rtp-forwarder"
path = "examples/rtp-forwarder/rtp-forwarder.rs"
bench = false

[[example]]
name = "rtp-to-webrtc"
path = "examples/rtp-to-webrtc/rtp-to-webrtc.rs"
bench = false

[[example]]
name = "simulcast"
path = "examples/simulcast/simulcast.rs"
bench = false

[[example]]
name = "simulcast_bidirection"
path = "examples/simulcast_bidirection/simulcast_bidirection.rs"
bench = false

[[example]]
name = "stats"
path = "examples/stats/stats.rs"
bench = false

[[example]]
name = "mdns-query-and-gather"
path = "examples/mdns-query-and-gather/mdns-query-and-gather.rs"
bench = false

[[example]]
name = "swap-tracks"
path = "examples/swap-tracks/swap-tracks.rs"
bench = false

[[example]]
name = "ice-restart"
path = "examples/ice-restart/ice-restart.rs"
bench = false

[[example]]
name = "trickle-ice-host"
path = "examples/trickle-ice-host/trickle-ice-host.rs"
bench = false

[[example]]
name = "trickle-ice-srflx"
path = "examples/trickle-ice-srflx/trickle-ice-srflx.rs"
bench = false

[[example]]
name = "trickle-ice-relay"
path = "examples/trickle-ice-relay/trickle-ice-relay.rs"
bench = false

[[example]]
name = "trickle-ice"
path = "examples/trickle-ice/trickle-ice.rs"
bench = false

[[example]]
name = "stream-driver-loopback"
path = "examples/stream-driver-loopback/stream-driver-loopback.rs"
bench = false

[[example]]
name = "ice-tcp"
path = "examples/ice-tcp/ice-tcp.rs"
bench = false

[[example]]
name = "ice-tcp-active-offer"
path = "examples/ice-tcp-active-passive/ice-tcp-active-offer.rs"
bench = false

[[example]]
name = "ice-tcp-passive-answer"
path = "examples/ice-tcp-active-passive/ice-tcp-passive-answer.rs"
bench = false

[[example]]
name = "rtcp-processing"
path = "examples/rtcp-processing/rtcp-processing.rs"
bench = false

[[example]]
name = "data-channels-simple"
path = "examples/data-channels-simple/data-channels-simple.rs"
bench = false

[[example]]
name = "save-to-disk-av1"
path = "examples/save-to-disk-av1/save-to-disk-av1.rs"
bench = false

[[example]]
name = "play-from-disk-playlist-control"
path = "examples/play-from-disk-playlist-control/play-from-disk-playlist-control.rs"
bench = false

[[example]]
name = "perfect-negotiation"
path = "examples/perfect-negotiation/perfect-negotiation.rs"
bench = false

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = [
    'cfg(fuzzing)',
    # examples/interop-peer is also built by the rtci-video-interop package, whose `pipeline`
    # feature adds the video pipeline scenario; this crate has no such feature.
    'cfg(feature, values("pipeline"))',
] }