Compare commits

...
41 Commits
Author SHA1 Message Date
DeFiDude 19ac89ec7a ci: pin rsReticulum f6d0d69 2026-11-20 12:57:55 -07:00
DeFiDude 92baad3898 ci: pin rsReticulum 54c8525 2026-11-19 20:53:05 -07:00
DeFiDude 09a47976fb ci: pin rsReticulum 5e35c9f 2026-11-19 09:33:11 -07:00
DeFiDude 4370a4153a build: lock rsReticulum 1.5.1 in the API fixtures 2026-11-19 09:32:57 -07:00
DeFiDude e9e053a038 ci: pin rsReticulum 0ce5a12 2026-11-19 08:55:25 -07:00
DeFiDude fe3128964b api: record the rsReticulum ~1.5.1 requirement 2026-11-19 08:49:37 -07:00
DeFiDude f323457be5 ci: pin rsReticulum 3d53958 (1.5.1) and Python Reticulum 1.6.1 2026-11-19 07:54:35 -07:00
DeFiDude f52c805d7b ci: the live telephone tests follow Python Reticulum 1.6.1 2026-11-18 20:07:41 -07:00
DeFiDude 0a5c434fc8 tests: Rust telephones announce unstamped unless a test sets the stamp policy 2026-11-18 20:07:41 -07:00
DeFiDude d41528031f tests: the Python Telephone helper stamps announces only when a test asks, as before Reticulum 1.6.1 2026-11-18 20:07:28 -07:00
DeFiDude b39e23cbec ci: pin rsReticulum 184bbfe 2026-11-15 10:08:18 -07:00
DeFiDude 2b04b62e79 ci: pin rsReticulum 81e6188 2026-11-15 08:51:57 -07:00
DeFiDude 7511e99bf1 ci: pin rsReticulum 0680941 2026-11-15 07:21:03 -07:00
DeFiDude c140942a13 tests: Python call pairs compare media in any arrival order 2026-11-15 06:56:25 -07:00
DeFiDude ff602499fa tests: media waits for the caller's audio and takes Python's frames in any order 2026-11-15 06:46:02 -07:00
DeFiDude 7e6e962746 tests: the late-connection announce observer does not announce itself 2026-11-15 05:21:46 -07:00
DeFiDude e8a3a67132 ci: pin rsReticulum cce85ec 2026-11-15 00:26:59 -07:00
DeFiDude 2a7357e0d1 ci: pin rsReticulum 1.5.0 2026-11-14 19:39:17 -07:00
DeFiDude ed9dfdd74b docs: README and changelog for 0.4.0 2026-11-14 00:02:11 -07:00
DeFiDude e01e28693d build: version 0.4.0 on rsReticulum 1.5, with the API baselines and migration guide 2026-11-13 23:06:53 -07:00
DeFiDude 131b592355 build: lock file gains the SQLite dependencies 2026-11-13 11:25:03 -07:00
DeFiDude 958c7f7932 tests: follow the transport's non-exhaustive RPC entries 2026-11-13 11:25:03 -07:00
DeFiDude 15a749ed48 tests: build live test interface entries through the constructor 2026-11-13 10:12:42 -07:00
DeFiDude 73947604ba tests: cover calls across a relay of the other implementation 2026-11-12 16:34:50 -07:00
DeFiDude 0b2a55aadd opus: the Medium profile stays wideband, set explicitly 2026-11-12 16:33:43 -07:00
DeFiDude edc6187472 opus: update opus-rs to 0.1.42 and encode the Medium profile narrowband 2026-11-12 11:06:08 -07:00
DeFiDude 4613264079 opus: reject a packet that panics the decoder and reset the decoder 2026-11-12 10:46:01 -07:00
DeFiDude db48665199 tests: cite upstream files without line numbers in comments 2026-11-12 06:58:08 -07:00
DeFiDude 74b0fb8fd8 api: move the compatibility floor past the async outgoing link calls 2026-11-12 05:27:11 -07:00
DeFiDude aeb400006b api: update the baselines and draft the next release's migration guide 2026-11-12 05:27:02 -07:00
DeFiDude a2f19db8ea telephony: the live interop test registers its server interface 2026-11-12 00:14:50 -07:00
DeFiDude 9f84f6e466 tests: read the reference checkouts from the upstream directory 2026-11-11 21:15:57 -07:00
DeFiDude 6394464f11 telephony: the test transport answers the next-hop MTU query 2026-11-11 21:15:57 -07:00
DeFiDude 9c70a9d67e ci: check against LXST 0.6.0 and Reticulum 1.6.0 2026-11-11 04:19:13 -07:00
DeFiDude 57171563b0 telephony: stamp the link requests that open calls 2026-11-10 13:37:20 -07:00
DeFiDude 56da627f6b build: update the lockfile for the runtime's tempfile dependency 2026-11-10 09:56:26 -07:00
DeFiDude 585405cb3b telephony: announce through the stamped announce builder 2026-11-10 08:41:20 -07:00
DeFiDude 54f8711730 telephony: establish the caller sooner; embedded call times can be set 2026-11-10 05:18:02 -07:00
DeFiDude f4d6daab25 tests: follow the transport path entry and drop-path reply types 2026-11-10 02:16:22 -07:00
DeFiDude cd66bad49a api: move the compatibility floor past the removed answer-retry items 2026-11-10 01:52:31 -07:00
DeFiDude 1c037655b2 telephony: match LXST 0.6.0 signalling, profiles, and call modes 2026-11-10 01:51:43 -07:00
44 changed files with 4897 additions and 1149 deletions

No files matched your search

+7 -4
View File
@@ -10,10 +10,10 @@ permissions:
contents: read
env:
RSLXST_RSRETICULUM_VERSION: 1.4.0
RSLXST_RSRETICULUM_COMMIT: 14241a383910e6ee7665303eff1e7c8d98957cc0
RSLXST_PYTHON_LXST_COMMIT: 1194c9011fe6402edc7aebe7ffe9650ea3b1afee
RSLXST_PYTHON_RNS_COMMIT: b48b96e61676504e0a4e527b33b9a0b4495c6872
RSLXST_RSRETICULUM_VERSION: 1.5.1
RSLXST_RSRETICULUM_COMMIT: f6d0d698dd7e6edc180f9c3697ab1c873571f372
RSLXST_PYTHON_LXST_COMMIT: 6a329bf6d956ca8b15077d4c470afe4cb7c669cc
RSLXST_PYTHON_RNS_COMMIT: cff4d03fdbd6bfb63b765280cd944756ac5cce8d
jobs:
api-compat:
@@ -147,6 +147,9 @@ jobs:
run: brew install opus libogg
- name: Install Python interop deps
run: python -m pip install --upgrade pip && python -m pip install numpy cryptography pyserial cffi "audioop-lts; python_version >= '3.13'"
# The voice relay interop tests run an rnsd-rs transport node.
- run: cargo build -p rns-tools --bin rnsd-rs --locked
working-directory: rsReticulum
- run: cargo test --workspace --locked
working-directory: rsLXST
+20
View File
@@ -2,6 +2,26 @@
## Unreleased
## 0.4.0 - 2026-11-13
### Added
- **Call modes**: calls can be full or half duplex, as in LXST 0.6.0, and switch during a call. `TelephonyControl::Call` takes a `mode`; `None` is full duplex.
- **Stamped calls**: call announces and link requests carry stamps when Reticulum's `[stamps]` settings ask for them, and call links use Link MTU discovery.
### Fixed and improved
- Calls connect as in LXST 0.6.0: the callee is established as soon as it answers, and a lost setup packet no longer ends a call. Check `audio_started` to know when audio is running.
- An outgoing call ends if the callee doesn't ring within `connect_timeout` (5 seconds by default), and the line is busy while a call looks for its path.
- `lxst-embedded` sessions use LXST 0.6.0's ring, wait, and connect times; change them with `SessionConfig::times`.
- The first announce goes out 5 seconds after start, with no startup burst by default.
- `opus-rs` 0.1.42 fixes a decoder crash on a crafted packet, and a damaged frame is now skipped instead of dropping its whole packet.
### Build and compatibility
- rsLXST now uses rsReticulum `~1.5.0`, whose default storage builds a bundled SQLite and needs a C compiler.
- API changes, including the removed answer retry, call modes, and async outgoing link calls, are listed in the [migration guide](api/migrations/next.md).
## 0.3.1 - 2026-11-08
- Telephony wakes on Link events instead of polling, polls once a second when
Generated
+124 -40
View File
@@ -14,6 +14,18 @@ dependencies = [
"zeroize",
]
[[package]]
name = "ahash"
version = "0.8.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75"
dependencies = [
"cfg-if",
"once_cell",
"version_check",
"zerocopy",
]
[[package]]
name = "anyhow"
version = "1.0.102"
@@ -71,15 +83,6 @@ dependencies = [
"generic-array",
]
[[package]]
name = "block2"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c132eebf10f5cad5289222520a4a058514204aed6d791f1cf4fe8088b82d15f"
dependencies = [
"objc2",
]
[[package]]
name = "bytes"
version = "1.11.1"
@@ -104,6 +107,16 @@ dependencies = [
"cipher",
]
[[package]]
name = "cc"
version = "1.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33ef9e3e8154a45c7a95cff4c1299702106ad94062d7bb85fdc5d3a5afd91d45"
dependencies = [
"find-msvc-tools",
"shlex",
]
[[package]]
name = "cesu8"
version = "1.1.0"
@@ -263,6 +276,18 @@ dependencies = [
"windows-sys 0.61.2",
]
[[package]]
name = "fallible-iterator"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649"
[[package]]
name = "fallible-streaming-iterator"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a"
[[package]]
name = "fastrand"
version = "2.4.1"
@@ -275,6 +300,12 @@ version = "0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d"
[[package]]
name = "find-msvc-tools"
version = "0.1.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c66915cc5391097de7a2b0b972e8505aa33c0df401fd3a6811dbdb32881ba48"
[[package]]
name = "fnv"
version = "1.0.7"
@@ -379,6 +410,15 @@ dependencies = [
"zerocopy",
]
[[package]]
name = "hashbrown"
version = "0.14.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
dependencies = [
"ahash",
]
[[package]]
name = "hashbrown"
version = "0.15.5"
@@ -394,6 +434,15 @@ version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4f467dd6dccf739c208452f8014c75c18bb8301b050ad1cfb27153803edb0f51"
[[package]]
name = "hashlink"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ba4ff7128dee98c7dc9794b6a411377e1404dba1c97deb8d1a55297bd25d8af"
dependencies = [
"hashbrown 0.14.5",
]
[[package]]
name = "heck"
version = "0.5.0"
@@ -534,6 +583,17 @@ version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981"
[[package]]
name = "libsqlite3-sys"
version = "0.30.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e99fb7a497b1e3339bc746195567ed8d3e24945ecd636e3619d20b9de9e9149"
dependencies = [
"cc",
"pkg-config",
"vcpkg",
]
[[package]]
name = "linux-raw-sys"
version = "0.12.1"
@@ -557,14 +617,14 @@ checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897"
[[package]]
name = "lxst-codec2"
version = "0.3.1"
version = "0.4.0"
dependencies = [
"libm",
]
[[package]]
name = "lxst-core"
version = "0.3.1"
version = "0.4.0"
dependencies = [
"half",
"hex",
@@ -577,7 +637,7 @@ dependencies = [
[[package]]
name = "lxst-embedded"
version = "0.3.1"
version = "0.4.0"
dependencies = [
"lxst-codec2",
"lxst-core",
@@ -586,7 +646,7 @@ dependencies = [
[[package]]
name = "lxst-rns"
version = "0.3.1"
version = "0.4.0"
dependencies = [
"bytes",
"lxst-core",
@@ -600,7 +660,7 @@ dependencies = [
[[package]]
name = "lxst-telephony"
version = "0.3.1"
version = "0.4.0"
dependencies = [
"bytes",
"hex",
@@ -668,29 +728,21 @@ dependencies = [
"autocfg",
]
[[package]]
name = "objc-sys"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdb91bdd390c7ce1a8607f35f3ca7151b65afc0ff5ff3b34fa350f7d7c7e4310"
[[package]]
name = "objc2"
version = "0.5.2"
version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46a785d4eeff09c14c487497c162e92766fbb3e4059a71840cecc03d9a50b804"
checksum = "08849bbd4767dfae9457696856ae1c84fe4e0281bbe4a7abff2d0e06fb7981f8"
dependencies = [
"objc-sys",
"objc2-encode",
]
[[package]]
name = "objc2-core-bluetooth"
version = "0.2.2"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a644b62ffb826a5277f536cf0f701493de420b13d40e700c452c36567771111"
checksum = "79b30b9eacc37434a61377866f68b27acef9fa5496f25cc9ca8b2549032e0394"
dependencies = [
"bitflags",
"objc2",
"objc2-foundation",
]
@@ -703,13 +755,11 @@ checksum = "ef25abbcd74fb2609453eb695bd2f860d389e457f67dc17cafc8b8cbc89d0c33"
[[package]]
name = "objc2-foundation"
version = "0.2.2"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ee638a5da3799329310ad4cfa62fbf045d5f56e3ef5ba4149e7452dcf89d5a8"
checksum = "e3e0adef53c21f888deb4fa59fc59f7eb17404926ee8a6f59f5df0fd7f9f3272"
dependencies = [
"bitflags",
"block2",
"libc",
"objc2",
]
@@ -721,9 +771,9 @@ checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
[[package]]
name = "opus-rs"
version = "0.1.29"
version = "0.1.42"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eadaf84d53a021172447a8771d74f805ac3719a61041dafa95720ef86b8e271d"
checksum = "bafbcaf2ed381cdf68ced4ed8d16517de90ffd7424e36f0b9e45d67fbe30b1f9"
[[package]]
name = "parking_lot"
@@ -764,6 +814,12 @@ dependencies = [
"spki",
]
[[package]]
name = "pkg-config"
version = "0.3.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548"
[[package]]
name = "ppv-lite86"
version = "0.2.21"
@@ -953,7 +1009,7 @@ dependencies = [
[[package]]
name = "rns-crypto"
version = "1.4.0"
version = "1.5.1"
dependencies = [
"aes",
"cbc",
@@ -971,7 +1027,7 @@ dependencies = [
[[package]]
name = "rns-identity"
version = "1.4.0"
version = "1.5.1"
dependencies = [
"hex",
"libc",
@@ -991,7 +1047,7 @@ dependencies = [
[[package]]
name = "rns-interface"
version = "1.4.0"
version = "1.5.1"
dependencies = [
"bytes",
"hex",
@@ -1019,7 +1075,7 @@ dependencies = [
[[package]]
name = "rns-link"
version = "1.4.0"
version = "1.5.1"
dependencies = [
"hex",
"libc",
@@ -1036,7 +1092,7 @@ dependencies = [
[[package]]
name = "rns-protocol"
version = "1.4.0"
version = "1.5.1"
dependencies = [
"bzip2",
"hex",
@@ -1053,7 +1109,7 @@ dependencies = [
[[package]]
name = "rns-runtime"
version = "1.4.0"
version = "1.5.1"
dependencies = [
"bytes",
"hex",
@@ -1072,6 +1128,7 @@ dependencies = [
"serde",
"sha2",
"subtle",
"tempfile",
"thiserror 2.0.18",
"tokio",
"tracing",
@@ -1080,7 +1137,7 @@ dependencies = [
[[package]]
name = "rns-transport"
version = "1.4.0"
version = "1.5.1"
dependencies = [
"bytes",
"hex",
@@ -1090,6 +1147,7 @@ dependencies = [
"rns-crypto",
"rns-identity",
"rns-wire",
"rusqlite",
"serde",
"subtle",
"thiserror 2.0.18",
@@ -1099,13 +1157,27 @@ dependencies = [
[[package]]
name = "rns-wire"
version = "1.4.0"
version = "1.5.1"
dependencies = [
"rns-crypto",
"sha2",
"thiserror 2.0.18",
]
[[package]]
name = "rusqlite"
version = "0.32.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7753b721174eb8ff87a9a0e799e2d7bc3749323e773db92e0984debb00019d6e"
dependencies = [
"bitflags",
"fallible-iterator",
"fallible-streaming-iterator",
"hashlink",
"libsqlite3-sys",
"smallvec",
]
[[package]]
name = "rustc_version"
version = "0.4.1"
@@ -1266,6 +1338,12 @@ dependencies = [
"digest",
]
[[package]]
name = "shlex"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba"
[[package]]
name = "signal-hook-registry"
version = "1.4.8"
@@ -1480,6 +1558,12 @@ version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853"
[[package]]
name = "vcpkg"
version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
[[package]]
name = "version_check"
version = "0.9.5"
+11 -11
View File
@@ -9,7 +9,7 @@ members = [
]
[workspace.package]
version = "0.3.1"
version = "0.4.0"
edition = "2024"
license-file = "LICENSE"
rust-version = "1.89"
@@ -24,16 +24,16 @@ bytes = "1"
tokio = { version = "1", features = ["sync", "time", "rt", "macros"] }
half = "2"
proptest = "1"
opus-rs = { version = "=0.1.29", default-features = false, features = ["heap"] }
opus-rs = { version = "=0.1.42", default-features = false, features = ["heap"] }
serial_test = "3"
rns-crypto = { path = "../rsReticulum/crates/rns-crypto", version = "~1.4.0" }
rns-identity = { path = "../rsReticulum/crates/rns-identity", version = "~1.4.0" }
rns-interface = { path = "../rsReticulum/crates/rns-interface", version = "~1.4.0" }
rns-link = { path = "../rsReticulum/crates/rns-link", version = "~1.4.0" }
rns-runtime = { path = "../rsReticulum/crates/rns-runtime", version = "~1.4.0" }
rns-transport = { path = "../rsReticulum/crates/rns-transport", version = "~1.4.0" }
rns-wire = { path = "../rsReticulum/crates/rns-wire", version = "~1.4.0" }
rns-crypto = { path = "../rsReticulum/crates/rns-crypto", version = "~1.5.1" }
rns-identity = { path = "../rsReticulum/crates/rns-identity", version = "~1.5.1" }
rns-interface = { path = "../rsReticulum/crates/rns-interface", version = "~1.5.1" }
rns-link = { path = "../rsReticulum/crates/rns-link", version = "~1.5.1" }
rns-runtime = { path = "../rsReticulum/crates/rns-runtime", version = "~1.5.1" }
rns-transport = { path = "../rsReticulum/crates/rns-transport", version = "~1.5.1" }
rns-wire = { path = "../rsReticulum/crates/rns-wire", version = "~1.5.1" }
lxst-core = { path = "crates/lxst-core", version = "0.3.1" }
lxst-rns = { path = "crates/lxst-rns", version = "0.3.1" }
lxst-core = { path = "crates/lxst-core", version = "0.4.0" }
lxst-rns = { path = "crates/lxst-rns", version = "0.4.0" }
+13 -55
View File
@@ -6,7 +6,7 @@
[![License: LXST license](https://img.shields.io/badge/license-LXST%20license-blue.svg)](LICENSE)
[![Rust 1.89+](https://img.shields.io/badge/rust-1.89%2B-orange.svg)](https://www.rust-lang.org)
[![LXST 0.4.5](https://img.shields.io/badge/target-LXST%200.4.5-success.svg)](https://github.com/markqvist/LXST)
[![LXST 0.6.0](https://img.shields.io/badge/target-LXST%200.6.0-success.svg)](https://github.com/markqvist/LXST)
[![Status](https://img.shields.io/badge/status-experimental-yellow.svg)](#release-scope)
[rsLXMF](https://github.com/ratspeak/rsLXMF) |
@@ -21,24 +21,13 @@
rsLXST is a Rust port of [LXST](https://github.com/markqvist/LXST), Mark Qvist's
Lightweight Extensible Signal Transport for real-time voice calls and other
media streams over Reticulum. It was written from the reference source with
interoperability as the primary focus. Python LXST remains the source-of-truth
implementation; do not treat this repository as one.
interoperability as the primary focus.
rsLXST is Ratspeak's voice component. The LXST author licenses this port for
use in Ratspeak only, for non-commercial use, with no derivatives or use outside
Ratspeak; see [License](#license). The build, test, and API notes below document
the code for Ratspeak development.
The current rsLXST is experimental and incomplete. It provides LXST wire codecs,
Reticulum link media packet boundaries, a telephony runtime, and Opus stream
integration for Ratspeak.
This README describes the 0.3.1 release, `v0.3.1`, declaring version **0.3.1**
and using rsReticulum **1.4.0** (`v1.4.0`); it is the source line Ratspeak
builds from. The earlier `v0.3.0` release uses the **1.3.0** Reticulum
dependency line. Keep the dependency set associated with the source you build;
a matching rsLXST package version alone is not enough.
## Contents
- [Release Scope](#release-scope)
@@ -47,23 +36,16 @@ a matching rsLXST package version alone is not enough.
- [Crate Layout](#crate-layout)
- [Using Telephony](#using-telephony)
- [Rust API](api/README.md)
- [Contributing](#contributing)
- [License](#license)
- [Third-party licenses](#third-party-licenses)
## Release Scope
The implemented application path covers telephony signalling and negotiated
Opus or native Codec2 media over Reticulum Links. It does not provide a
`rnphone-rs` client, a general platform microphone/speaker backend, or complete
parity with the Python reference's audio graph and non-telephony features.
`lxst-core::Codec2PacketCodec` provides bounded, fixed-profile packet processing
over a `Codec2Backend`. The workspace supplies native 700C, 1600 and 3200 modes,
plus host stream and embedded integration. Caller-owned buffers and complete
packet validation bound the codec work; a backend error requires replacement
of that packet-codec instance. Board audio, timing, memory and transport still
require qualification. Its mode header belongs to LXST, not LXMF audio fields.
The implemented application path covers telephony signalling, full- and
half-duplex call modes, and negotiated Opus or native Codec2 media over
Reticulum Links. It does not provide a
`rnphone-rs` client, a general platform microphone/speaker backend, or LXST's
non-telephony features.
## Build It
@@ -83,13 +65,12 @@ mkdir ratspeak-src
cd ratspeak-src
git clone https://github.com/ratspeak/rsReticulum
git clone https://github.com/ratspeak/rsLXST
git -C rsReticulum checkout --detach v1.4.0
git -C rsLXST checkout --detach v0.3.1
git -C rsReticulum checkout --detach v1.5.0
git -C rsLXST checkout --detach v0.4.0
cd rsLXST
```
The commands below run from that `rsLXST` directory. For the earlier 0.3.0
release, use `v0.3.0` with its rsReticulum `v1.3.0` sibling instead.
The commands below run from that `rsLXST` directory.
### macOS
@@ -161,11 +142,8 @@ cargo clippy --workspace --all-targets --all-features --locked -- -D warnings
cargo test --workspace --locked
```
The test gate covers wire codecs, telephony state, profile metadata, Opus
stream boundaries, malformed-input handling, the local service runtime, Python
LXST wire parity, and Reticulum destination parity. Live headless Telephone
interop is intentionally excluded from ordinary `cargo test` runs because it
starts Python processes and TCP interfaces. Run that suite explicitly with:
The live call tests against Python LXST are not part of ordinary runs. Run
them explicitly with:
```bash
cargo test -p lxst-telephony --test python_telephone_live_interop -- --ignored
@@ -219,6 +197,7 @@ control_tx
.send(TelephonyControl::Call {
remote_identity,
profile: Some(Profile::QualityMedium),
mode: None,
discovery_timeout: Duration::from_secs(8),
})
.await?;
@@ -236,20 +215,6 @@ The compiled [`service` example](crates/lxst-telephony/examples/service.rs)
checks construction and types. It does not run a transport or place a call. The lower-level endpoint and runtime types remain
available for compatible specialist use, but are experimental SPI.
An initial Reticulum `LINKREQUEST` still follows normal destination routing.
After proof validation, rsLXST binds the call to the exact interface that
established the Link. Signalling, identification, keepalives, media, and close
traffic never reroute through a newly learned path, and packets arriving on a
different interface are rejected before decryption or call accounting.
Interface loss terminates that exact call.
Control and teardown traffic use an ordered, bounded Link endpoint queue. Final
teardown waits for the ordered close-send attempt to drain or fail terminally
before transport removes the endpoint and temporary Link destination. Realtime media uses exact-interface best-effort
delivery instead: it never enters the lossless control queue, reports drops
under backpressure, and intentionally does not request Reticulum delivery
receipts.
For Opus calls, the host app supplies and receives `RawAudioFrame` values through
`StartOpusStream` and `StartOpusReceiveStream`. rsLXST enforces the negotiated
LXST profile and reports profile changes, source/sink closure, frame drops, and
@@ -285,13 +250,6 @@ VLBW and LBW profiles. Device timing, stack and audio qualification remain
required before use on hardware. This backend does not implement Opus voice
memo containers.
## Contributing
If the issue or contribution belongs upstream as well, start there. Python LXST
and Reticulum remain the reference implementations.
PRs are closed for now until I have time to catch up on everything.
## License
rsLXST is used under the license in [LICENSE](LICENSE), reproduced here:
+296 -23
View File
@@ -1,7 +1,7 @@
{
"schemaVersion": 1,
"scope": "Adapted Codec2 and all registry third-party normal/build dependencies reachable from rsLXST workspace members across declared targets; dev-only and first-party path packages are excluded.",
"cargoLockSha256": "fd03a44bf84a060580e6157cb22dd188aad8bce626625424eeccceb885172846",
"cargoLockSha256": "ce5a11b52a7c3d39e944b8dfc48831c6793e42e8e0f04c1d35c9efafbcf6e15d",
"packages": [
{
"name": "aes",
@@ -10,6 +10,20 @@
"repository": "https://github.com/RustCrypto/block-ciphers",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "ahash",
"version": "0.8.12",
"license": "MIT OR Apache-2.0",
"repository": "https://github.com/tkaitchuck/ahash",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "anyhow",
"version": "1.0.102",
"license": "MIT OR Apache-2.0",
"repository": "https://github.com/dtolnay/anyhow",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "autocfg",
"version": "1.5.0",
@@ -45,13 +59,6 @@
"repository": "https://github.com/RustCrypto/utils",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "block2",
"version": "0.5.1",
"license": "MIT",
"repository": "https://github.com/madsmtm/objc2",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "bytes",
"version": "1.11.1",
@@ -73,6 +80,13 @@
"repository": "https://github.com/RustCrypto/block-modes",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "cc",
"version": "1.11.2",
"license": "MIT OR Apache-2.0",
"repository": "https://github.com/rust-lang/cc-rs",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "cesu8",
"version": "1.1.0",
@@ -227,6 +241,13 @@
"repository": "https://github.com/dalek-cryptography/curve25519-dalek/tree/main/ed25519-dalek",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "equivalent",
"version": "1.0.2",
"license": "Apache-2.0 OR MIT",
"repository": "https://github.com/indexmap-rs/equivalent",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "errno",
"version": "0.3.14",
@@ -234,6 +255,27 @@
"repository": "https://github.com/lambda-fairy/rust-errno",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "fallible-iterator",
"version": "0.3.0",
"license": "MIT/Apache-2.0",
"repository": "https://github.com/sfackler/rust-fallible-iterator",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "fallible-streaming-iterator",
"version": "0.1.9",
"license": "MIT/Apache-2.0",
"repository": "https://github.com/sfackler/fallible-streaming-iterator",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "fastrand",
"version": "2.4.1",
"license": "Apache-2.0 OR MIT",
"repository": "https://github.com/smol-rs/fastrand",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "fiat-crypto",
"version": "0.2.9",
@@ -241,6 +283,20 @@
"repository": "https://github.com/mit-plv/fiat-crypto",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "find-msvc-tools",
"version": "0.1.15",
"license": "MIT OR Apache-2.0",
"repository": "https://github.com/rust-lang/cc-rs",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "foldhash",
"version": "0.1.5",
"license": "Zlib",
"repository": "https://github.com/orlp/foldhash",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "generic-array",
"version": "0.14.7",
@@ -255,6 +311,13 @@
"repository": "https://github.com/rust-random/getrandom",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "getrandom",
"version": "0.4.2",
"license": "MIT OR Apache-2.0",
"repository": "https://github.com/rust-random/getrandom",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "half",
"version": "2.7.1",
@@ -262,6 +325,41 @@
"repository": "https://github.com/VoidStarKat/half-rs",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "hashbrown",
"version": "0.14.5",
"license": "MIT OR Apache-2.0",
"repository": "https://github.com/rust-lang/hashbrown",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "hashbrown",
"version": "0.15.5",
"license": "MIT OR Apache-2.0",
"repository": "https://github.com/rust-lang/hashbrown",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "hashbrown",
"version": "0.17.0",
"license": "MIT OR Apache-2.0",
"repository": "https://github.com/rust-lang/hashbrown",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "hashlink",
"version": "0.9.1",
"license": "MIT OR Apache-2.0",
"repository": "https://github.com/kyren/hashlink",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "heck",
"version": "0.5.0",
"license": "MIT OR Apache-2.0",
"repository": "https://github.com/withoutboats/heck",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "hex",
"version": "0.4.3",
@@ -283,6 +381,13 @@
"repository": "https://github.com/RustCrypto/MACs",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "id-arena",
"version": "2.3.0",
"license": "MIT/Apache-2.0",
"repository": "https://github.com/fitzgen/id-arena",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "if-addrs",
"version": "0.13.4",
@@ -290,6 +395,13 @@
"repository": "https://github.com/messense/if-addrs",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "indexmap",
"version": "2.14.0",
"license": "Apache-2.0 OR MIT",
"repository": "https://github.com/indexmap-rs/indexmap",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "inout",
"version": "0.1.4",
@@ -332,6 +444,13 @@
"repository": "https://github.com/jni-rs/jni-sys",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "leb128fmt",
"version": "0.1.0",
"license": "MIT OR Apache-2.0",
"repository": "https://github.com/bluk/leb128fmt",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "libbz2-rs-sys",
"version": "0.2.5",
@@ -353,6 +472,20 @@
"repository": "https://github.com/rust-lang/compiler-builtins",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "libsqlite3-sys",
"version": "0.30.1",
"license": "MIT",
"repository": "https://github.com/rusqlite/rusqlite",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "linux-raw-sys",
"version": "0.12.1",
"license": "Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT",
"repository": "https://github.com/sunfishcode/linux-raw-sys",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "lock_api",
"version": "0.4.14",
@@ -402,24 +535,17 @@
"repository": "https://github.com/rust-num/num-traits",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "objc-sys",
"version": "0.3.5",
"license": "MIT",
"repository": "https://github.com/madsmtm/objc2",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "objc2",
"version": "0.5.2",
"version": "0.6.5",
"license": "MIT",
"repository": "https://github.com/madsmtm/objc2",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "objc2-core-bluetooth",
"version": "0.2.2",
"license": "MIT",
"version": "0.3.2",
"license": "Zlib OR Apache-2.0 OR MIT",
"repository": "https://github.com/madsmtm/objc2",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
@@ -432,7 +558,7 @@
},
{
"name": "objc2-foundation",
"version": "0.2.2",
"version": "0.3.2",
"license": "MIT",
"repository": "https://github.com/madsmtm/objc2",
"source": "registry+https://github.com/rust-lang/crates.io-index"
@@ -446,13 +572,13 @@
},
{
"name": "opus-rs",
"version": "0.1.29",
"version": "0.1.42",
"license": "BSD-3-Clause",
"repository": "https://github.com/restsend/opus-rs",
"source": "registry+https://github.com/rust-lang/crates.io-index",
"crateChecksum": "eadaf84d53a021172447a8771d74f805ac3719a61041dafa95720ef86b8e271d",
"upstreamCommit": "95f8b76430beb8c1bed067354d519c918ceade21",
"licenseText": "third_party/opus-rs-0.1.29-COPYING"
"crateChecksum": "bafbcaf2ed381cdf68ced4ed8d16517de90ffd7424e36f0b9e45d67fbe30b1f9",
"upstreamCommit": "5d8230f362b2618b9e730e6201c0d8f98961dfe1",
"licenseText": "third_party/opus-rs-0.1.42-COPYING"
},
{
"name": "parking_lot",
@@ -482,6 +608,13 @@
"repository": "https://github.com/RustCrypto/formats/tree/master/pkcs8",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "pkg-config",
"version": "0.3.34",
"license": "MIT OR Apache-2.0",
"repository": "https://github.com/rust-lang/pkg-config-rs",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "ppv-lite86",
"version": "0.2.21",
@@ -489,6 +622,13 @@
"repository": "https://github.com/cryptocorrosion/cryptocorrosion",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "prettyplease",
"version": "0.2.37",
"license": "MIT OR Apache-2.0",
"repository": "https://github.com/dtolnay/prettyplease",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "proc-macro2",
"version": "1.0.106",
@@ -503,6 +643,13 @@
"repository": "https://github.com/dtolnay/quote",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "r-efi",
"version": "6.0.0",
"license": "MIT OR Apache-2.0 OR LGPL-2.1-or-later",
"repository": "https://github.com/r-efi/r-efi",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "rand",
"version": "0.8.6",
@@ -552,6 +699,13 @@
"repository": "https://github.com/3Hren/msgpack-rust",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "rusqlite",
"version": "0.32.1",
"license": "MIT",
"repository": "https://github.com/rusqlite/rusqlite",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "rustc_version",
"version": "0.4.1",
@@ -559,6 +713,13 @@
"repository": "https://github.com/djc/rustc-version-rs",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "rustix",
"version": "1.1.4",
"license": "Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT",
"repository": "https://github.com/bytecodealliance/rustix",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "same-file",
"version": "1.0.6",
@@ -622,6 +783,13 @@
"repository": "https://github.com/RustCrypto/hashes",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "shlex",
"version": "2.0.1",
"license": "MIT OR Apache-2.0",
"repository": "https://github.com/comex/rust-shlex",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "signal-hook-registry",
"version": "1.4.8",
@@ -678,6 +846,13 @@
"repository": "https://github.com/dtolnay/syn",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "tempfile",
"version": "3.27.0",
"license": "MIT OR Apache-2.0",
"repository": "https://github.com/Stebalien/tempfile",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "thiserror",
"version": "1.0.69",
@@ -755,6 +930,20 @@
"repository": "https://github.com/dtolnay/unicode-ident",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "unicode-xid",
"version": "0.2.6",
"license": "MIT OR Apache-2.0",
"repository": "https://github.com/unicode-rs/unicode-xid",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "vcpkg",
"version": "0.2.15",
"license": "MIT/Apache-2.0",
"repository": "https://github.com/mcgoo/vcpkg-rs",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "version_check",
"version": "0.9.5",
@@ -776,6 +965,41 @@
"repository": "https://github.com/bytecodealliance/wasi",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "wasip2",
"version": "1.0.3+wasi-0.2.9",
"license": "Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT",
"repository": "https://github.com/bytecodealliance/wasi-rs",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "wasip3",
"version": "0.4.0+wasi-0.3.0-rc-2026-01-06",
"license": "Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT",
"repository": "https://github.com/bytecodealliance/wasi-rs",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "wasm-encoder",
"version": "0.244.0",
"license": "Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT",
"repository": "https://github.com/bytecodealliance/wasm-tools/tree/main/crates/wasm-encoder",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "wasm-metadata",
"version": "0.244.0",
"license": "Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT",
"repository": "https://github.com/bytecodealliance/wasm-tools/tree/main/crates/wasm-metadata",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "wasmparser",
"version": "0.244.0",
"license": "Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT",
"repository": "https://github.com/bytecodealliance/wasm-tools/tree/main/crates/wasmparser",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "winapi-util",
"version": "0.1.11",
@@ -916,6 +1140,55 @@
"repository": "https://github.com/microsoft/windows-rs",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "wit-bindgen",
"version": "0.51.0",
"license": "Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT",
"repository": "https://github.com/bytecodealliance/wit-bindgen",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "wit-bindgen",
"version": "0.57.1",
"license": "Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT",
"repository": "https://github.com/bytecodealliance/wit-bindgen",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "wit-bindgen-core",
"version": "0.51.0",
"license": "Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT",
"repository": "https://github.com/bytecodealliance/wit-bindgen",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "wit-bindgen-rust",
"version": "0.51.0",
"license": "Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT",
"repository": "https://github.com/bytecodealliance/wit-bindgen",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "wit-bindgen-rust-macro",
"version": "0.51.0",
"license": "Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT",
"repository": "https://github.com/bytecodealliance/wit-bindgen",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "wit-component",
"version": "0.244.0",
"license": "Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT",
"repository": "https://github.com/bytecodealliance/wasm-tools/tree/main/crates/wit-component",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "wit-parser",
"version": "0.244.0",
"license": "Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT",
"repository": "https://github.com/bytecodealliance/wasm-tools/tree/main/crates/wit-parser",
"source": "registry+https://github.com/rust-lang/crates.io-index"
},
{
"name": "x25519-dalek",
"version": "2.0.1",
+4 -4
View File
@@ -32,13 +32,13 @@ repository, or source changes.
## Upstream Opus implementation
rsLXST consumes the exact crates.io package `opus-rs` 0.1.29 from
rsLXST consumes the exact crates.io package `opus-rs` 0.1.42 from
[`restsend/opus-rs`](https://github.com/restsend/opus-rs), associated with
upstream commit `95f8b76430beb8c1bed067354d519c918ceade21` and locked crate
checksum `eadaf84d53a021172447a8771d74f805ac3719a61041dafa95720ef86b8e271d`.
upstream commit `5d8230f362b2618b9e730e6201c0d8f98961dfe1` and locked crate
checksum `bafbcaf2ed381cdf68ced4ed8d16517de90ffd7424e36f0b9e45d67fbe30b1f9`.
It is BSD-3-Clause, is not locally modified, and is configured with explicit
heap-backed codec state. The preserved license and Opus patent notice are in
[`third_party/opus-rs-0.1.29-COPYING`](third_party/opus-rs-0.1.29-COPYING).
[`third_party/opus-rs-0.1.42-COPYING`](third_party/opus-rs-0.1.42-COPYING).
This inventory records source and license evidence; it is not legal advice and
does not by itself replace any third-party notice required for a distributed
+180 -41
View File
@@ -14,6 +14,18 @@ dependencies = [
"zeroize",
]
[[package]]
name = "ahash"
version = "0.8.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75"
dependencies = [
"cfg-if",
"once_cell",
"version_check",
"zerocopy",
]
[[package]]
name = "autocfg"
version = "1.5.1"
@@ -50,15 +62,6 @@ dependencies = [
"generic-array",
]
[[package]]
name = "block2"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c132eebf10f5cad5289222520a4a058514204aed6d791f1cf4fe8088b82d15f"
dependencies = [
"objc2",
]
[[package]]
name = "bytes"
version = "1.12.1"
@@ -83,6 +86,16 @@ dependencies = [
"cipher",
]
[[package]]
name = "cc"
version = "1.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33ef9e3e8154a45c7a95cff4c1299702106ad94062d7bb85fdc5d3a5afd91d45"
dependencies = [
"find-msvc-tools",
"shlex",
]
[[package]]
name = "cesu8"
version = "1.1.0"
@@ -236,12 +249,36 @@ dependencies = [
"windows-sys 0.61.2",
]
[[package]]
name = "fallible-iterator"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649"
[[package]]
name = "fallible-streaming-iterator"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a"
[[package]]
name = "fastrand"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223"
[[package]]
name = "fiat-crypto"
version = "0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d"
[[package]]
name = "find-msvc-tools"
version = "0.1.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c66915cc5391097de7a2b0b972e8505aa33c0df401fd3a6811dbdb32881ba48"
[[package]]
name = "generic-array"
version = "0.14.7"
@@ -263,6 +300,17 @@ dependencies = [
"wasi",
]
[[package]]
name = "getrandom"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099"
dependencies = [
"cfg-if",
"libc",
"r-efi",
]
[[package]]
name = "half"
version = "2.7.1"
@@ -274,6 +322,24 @@ dependencies = [
"zerocopy",
]
[[package]]
name = "hashbrown"
version = "0.14.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
dependencies = [
"ahash",
]
[[package]]
name = "hashlink"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ba4ff7128dee98c7dc9794b6a411377e1404dba1c97deb8d1a55297bd25d8af"
dependencies = [
"hashbrown",
]
[[package]]
name = "hex"
version = "0.4.3"
@@ -384,6 +450,23 @@ version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981"
[[package]]
name = "libsqlite3-sys"
version = "0.30.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e99fb7a497b1e3339bc746195567ed8d3e24945ecd636e3619d20b9de9e9149"
dependencies = [
"cc",
"pkg-config",
"vcpkg",
]
[[package]]
name = "linux-raw-sys"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53"
[[package]]
name = "lock_api"
version = "0.4.14"
@@ -401,14 +484,14 @@ checksum = "0ceec5bc11778974d1bcb055b18002eba7f4b3518b6a0081b3af5f21666da9ad"
[[package]]
name = "lxst-codec2"
version = "0.3.1"
version = "0.4.0"
dependencies = [
"libm",
]
[[package]]
name = "lxst-core"
version = "0.3.1"
version = "0.4.0"
dependencies = [
"half",
"opus-rs",
@@ -418,7 +501,7 @@ dependencies = [
[[package]]
name = "lxst-embedded"
version = "0.3.1"
version = "0.4.0"
dependencies = [
"lxst-codec2",
"thiserror 2.0.20",
@@ -426,7 +509,7 @@ dependencies = [
[[package]]
name = "lxst-rns"
version = "0.3.1"
version = "0.4.0"
dependencies = [
"bytes",
"lxst-core",
@@ -439,7 +522,7 @@ dependencies = [
[[package]]
name = "lxst-telephony"
version = "0.3.1"
version = "0.4.0"
dependencies = [
"bytes",
"lxst-codec2",
@@ -516,29 +599,21 @@ dependencies = [
"autocfg",
]
[[package]]
name = "objc-sys"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdb91bdd390c7ce1a8607f35f3ca7151b65afc0ff5ff3b34fa350f7d7c7e4310"
[[package]]
name = "objc2"
version = "0.5.2"
version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46a785d4eeff09c14c487497c162e92766fbb3e4059a71840cecc03d9a50b804"
checksum = "08849bbd4767dfae9457696856ae1c84fe4e0281bbe4a7abff2d0e06fb7981f8"
dependencies = [
"objc-sys",
"objc2-encode",
]
[[package]]
name = "objc2-core-bluetooth"
version = "0.2.2"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a644b62ffb826a5277f536cf0f701493de420b13d40e700c452c36567771111"
checksum = "79b30b9eacc37434a61377866f68b27acef9fa5496f25cc9ca8b2549032e0394"
dependencies = [
"bitflags",
"objc2",
"objc2-foundation",
]
@@ -551,13 +626,11 @@ checksum = "ef25abbcd74fb2609453eb695bd2f860d389e457f67dc17cafc8b8cbc89d0c33"
[[package]]
name = "objc2-foundation"
version = "0.2.2"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ee638a5da3799329310ad4cfa62fbf045d5f56e3ef5ba4149e7452dcf89d5a8"
checksum = "e3e0adef53c21f888deb4fa59fc59f7eb17404926ee8a6f59f5df0fd7f9f3272"
dependencies = [
"bitflags",
"block2",
"libc",
"objc2",
]
@@ -569,9 +642,9 @@ checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
[[package]]
name = "opus-rs"
version = "0.1.29"
version = "0.1.42"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eadaf84d53a021172447a8771d74f805ac3719a61041dafa95720ef86b8e271d"
checksum = "bafbcaf2ed381cdf68ced4ed8d16517de90ffd7424e36f0b9e45d67fbe30b1f9"
[[package]]
name = "parking_lot"
@@ -612,6 +685,12 @@ dependencies = [
"spki",
]
[[package]]
name = "pkg-config"
version = "0.3.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548"
[[package]]
name = "ppv-lite86"
version = "0.2.21"
@@ -639,6 +718,12 @@ dependencies = [
"proc-macro2",
]
[[package]]
name = "r-efi"
version = "6.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
[[package]]
name = "rand"
version = "0.8.7"
@@ -666,7 +751,7 @@ version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
dependencies = [
"getrandom",
"getrandom 0.2.17",
]
[[package]]
@@ -710,7 +795,7 @@ dependencies = [
[[package]]
name = "rns-crypto"
version = "1.4.0"
version = "1.5.1"
dependencies = [
"aes",
"cbc",
@@ -728,7 +813,7 @@ dependencies = [
[[package]]
name = "rns-identity"
version = "1.4.0"
version = "1.5.1"
dependencies = [
"hex",
"libc",
@@ -748,7 +833,7 @@ dependencies = [
[[package]]
name = "rns-interface"
version = "1.4.0"
version = "1.5.1"
dependencies = [
"bytes",
"hex",
@@ -776,7 +861,7 @@ dependencies = [
[[package]]
name = "rns-link"
version = "1.4.0"
version = "1.5.1"
dependencies = [
"hex",
"libc",
@@ -793,7 +878,7 @@ dependencies = [
[[package]]
name = "rns-protocol"
version = "1.4.0"
version = "1.5.1"
dependencies = [
"bzip2",
"hex",
@@ -810,7 +895,7 @@ dependencies = [
[[package]]
name = "rns-runtime"
version = "1.4.0"
version = "1.5.1"
dependencies = [
"bytes",
"hex",
@@ -829,6 +914,7 @@ dependencies = [
"serde",
"sha2",
"subtle",
"tempfile",
"thiserror 2.0.20",
"tokio",
"tracing",
@@ -837,7 +923,7 @@ dependencies = [
[[package]]
name = "rns-transport"
version = "1.4.0"
version = "1.5.1"
dependencies = [
"bytes",
"hex",
@@ -847,6 +933,7 @@ dependencies = [
"rns-crypto",
"rns-identity",
"rns-wire",
"rusqlite",
"serde",
"subtle",
"thiserror 2.0.20",
@@ -856,13 +943,27 @@ dependencies = [
[[package]]
name = "rns-wire"
version = "1.4.0"
version = "1.5.1"
dependencies = [
"rns-crypto",
"sha2",
"thiserror 2.0.20",
]
[[package]]
name = "rusqlite"
version = "0.32.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7753b721174eb8ff87a9a0e799e2d7bc3749323e773db92e0984debb00019d6e"
dependencies = [
"bitflags",
"fallible-iterator",
"fallible-streaming-iterator",
"hashlink",
"libsqlite3-sys",
"smallvec",
]
[[package]]
name = "rustc_version"
version = "0.4.1"
@@ -872,6 +973,19 @@ dependencies = [
"semver",
]
[[package]]
name = "rustix"
version = "1.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5e76742e5294153d4dde1207dbec5bdd81eef6fabdc0d2118babadabfd858aa"
dependencies = [
"bitflags",
"errno",
"libc",
"linux-raw-sys",
"windows-sys 0.61.2",
]
[[package]]
name = "same-file"
version = "1.0.6"
@@ -957,6 +1071,12 @@ dependencies = [
"digest",
]
[[package]]
name = "shlex"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba"
[[package]]
name = "signal-hook-registry"
version = "1.4.8"
@@ -1040,6 +1160,19 @@ dependencies = [
"unicode-ident",
]
[[package]]
name = "tempfile"
version = "3.27.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd"
dependencies = [
"fastrand",
"getrandom 0.4.3",
"once_cell",
"rustix",
"windows-sys 0.61.2",
]
[[package]]
name = "thiserror"
version = "1.0.69"
@@ -1151,6 +1284,12 @@ version = "1.0.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
[[package]]
name = "vcpkg"
version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
[[package]]
name = "version_check"
version = "0.9.5"
+123
View File
@@ -0,0 +1,123 @@
# Migrating to rsLXST 0.4 (draft)
This draft covers source and behaviour changes since rsLXST 0.3.1. Telephony
now follows LXST 0.6.0 signalling, and rsLXST 0.4 runs on rsReticulum 1.5,
which follows Reticulum 1.6.0.
Move rsReticulum dependencies to `~1.5.0` together with rsLXST 0.4; types from
two rsReticulum lines do not mix. rsReticulum types that appear in rsLXST
signatures (`TransportMessage`, `Link`, `LinkManager`, and `Identity`) change
in 1.5; rsReticulum's own migration guide covers them.
## Telephony: answering
LXST 0.6.0 establishes the callee as soon as it answers: CONNECTING and
ESTABLISHED are sent once, with no retry and no wait for the caller's echo.
| Old | New |
| --- | --- |
| `lxst_core::TelephonyCall::retry_answer()` | removed; `answer()` returns the whole answer and ends with `StartAudioPipelines` |
| `lxst_embedded::CallState::retry_answer()` | removed; as above |
| `TelephonyServiceConfig::answer_retry_interval` | removed; delete the field |
| `TelephonyServiceConfig::answer_timeout` | removed; delete the field |
| (none) | `TelephonyServiceConfig::connect_timeout`; a literal without `..TelephonyServiceConfig::default()` must set it |
`request_answer` and `TelephonyControl::Answer` now reply with an ESTABLISHED
snapshot where they replied with CONNECTING.
A caller is ESTABLISHED once it has handled CONNECTING, so a lost ESTABLISHED
no longer ends the call. Its audio still starts only on the callee's
ESTABLISHED, so `status()` no longer shows that audio is running: check
`audio_started()` (`TelephonyCall`, `CallState`) or wait for
`StartAudioPipelines`.
## Telephony: call modes
Full and half duplex are signalled with the profile when the callee rings.
```rust
// old
TelephonyControl::Call { remote_identity, profile, discovery_timeout }
// new; `None` is full duplex
TelephonyControl::Call { remote_identity, profile, mode: None, discovery_timeout }
```
These types gain variants or fields, so exhaustive matches need new arms and
struct literals need the new fields:
| Type | Added |
| --- | --- |
| `Signal` (`lxst-core`, `lxst-embedded`) | `PreferredMode(u8)`; wire values `0xF0` to `0xFE` decode to it, not to `Raw` |
| `TelephonyAction` (`lxst-core`, `lxst-embedded`) | `SendSignalPair`, `SelectMode`, `SwitchMode` |
| `TelephonyCommand` | `SendSignalPair`, `SelectMode`, `SwitchMode` |
| `TelephonyControl` | `SwitchMode`, `SquelchTransmit`, `DisableRemoteModeFollow` |
| `ActiveCallSnapshot` | `mode`, `transmit_squelched` |
A caller that sees RINGING now emits one `SendSignalPair(profile, mode)` where
it emitted `SendSignal(profile)`. Both signals travel in one packet:
`TelephonyCommand::signal()` returns `None` for the pair, so build the packet
with `TelephonyCommand::to_lxst_packet()`.
## Telephony: outgoing call links
LXST 0.6.0 opens the call with a plain `RNS.Link(call_destination, ...)`
(`LXST/Primitives/Telephony.py:840-842`). On Reticulum 1.6.0 that link request
carries a stamp at the link cost the destination announced
(`RNS/Link.py:363`). Generating that stamp is CPU work, so building the link
request is now async:
| Old | New |
| --- | --- |
| `fn TelephonyRnsEndpoint::begin_outgoing_link_with_remote_pubkey(..) -> Result<LinkId, Error>` | `async fn`; add `.await` |
| (none) | `async fn TelephonyRnsEndpoint::begin_outgoing_link_with_mode(..)`, the same call with an `Option<CallMode>` |
```rust
// old
let link_id = endpoint.begin_outgoing_link_with_remote_pubkey(&mut core, identity, pubkey, profile, hops)?;
// new
let link_id = endpoint.begin_outgoing_link_with_remote_pubkey(&mut core, identity, pubkey, profile, hops).await?;
```
`begin_outgoing_link_with_remote_pubkey` no longer sends a path request, and
the new calls send none. When no path is known, call
`request_path_to_identity` first, or use `begin_outgoing_link`, which discovers
the peer and its path.
To stamp off the caller's task, call
`prepare_outgoing_link_request(&transport_tx, identity, hops).await?` and pass
its `OutgoingLinkRequest` to the synchronous
`TelephonyRnsEndpoint::begin_prepared_outgoing_link`.
`Error` gains `LinkStamp(rns_link::stamp::LinkStampError)`, so exhaustive
matches on `lxst_telephony::Error` need a new arm.
## Embedded sessions
`SessionConfig` gains `times: CallTimes`; add `times: CallTimes::DEFAULT` to
struct literals. The defaults are LXST 0.6.0's: an incoming call rings for
60 seconds (was 90), and an outgoing call ends unless the callee rings within
5 seconds and the call is established within 70 seconds of the session start.
The 10 second answer deadline and its three retries are gone.
## Behaviour an operator sees
- Outgoing calls end unless the callee rings within `connect_timeout`
(5 seconds by default) of the call request. The 70 second
`outgoing_call_timeout` also runs from the call request, path discovery
included.
- The line is busy while an outgoing call discovers its path.
- The first announce follows 5 seconds after the service starts, and
`startup_announce_retries` defaults to 0.
- The telephony destination announces through the stamped announce builder.
Calls stamp and check link requests according to the Reticulum `[stamps]`
settings, as upstream does.
- Call links signal the next hop's MTU when Reticulum's `link_mtu_discovery`
is on (`RNS/Link.py:392-397`).
- Received audio is decoded by the codec of each frame. A frame that fails to
decode is reported and skipped; the rest of its packet still plays.
- Raw frames at `RawBitDepth::Float128` carry IEEE binary128 samples, as
numpy's `float128` does on Linux aarch64. rsLXST 0.3.1 wrote an `f64`
padded to 16 bytes.
- The Medium voice profile still encodes wideband SILK at its 8 kbps ceiling.
- `opus-rs` is pinned at 0.1.42 (was 0.1.29). A peer packet that panics the
Opus decoder is rejected, and the decoder is reset.
+34 -1
View File
@@ -6,6 +6,18 @@ impl lxst_core::AudioCodec
pub const fn lxst_core::AudioCodec::channels(self) -> u8
pub const fn lxst_core::AudioCodec::codec_kind(self) -> lxst_core::CodecKind
pub const fn lxst_core::AudioCodec::sample_rate_hz(self) -> u32
#[repr(u8)] pub enum lxst_core::CallMode
pub lxst_core::CallMode::FullDuplex = 1
pub lxst_core::CallMode::HalfDuplex = 2
impl lxst_core::CallMode
pub const lxst_core::CallMode::AVAILABLE: [Self; 2]
pub const lxst_core::CallMode::DEFAULT: Self
pub const fn lxst_core::CallMode::abbreviation(self) -> &'static str
pub const fn lxst_core::CallMode::from_wire(u8) -> core::option::Option<Self>
pub const fn lxst_core::CallMode::name(self) -> &'static str
pub const fn lxst_core::CallMode::wire_value(self) -> u8
impl core::convert::From<lxst_core::CallMode> for lxst_core::Signal
pub fn lxst_core::Signal::from(lxst_core::CallMode) -> Self
pub enum lxst_core::CallRole
pub lxst_core::CallRole::Incoming
pub lxst_core::CallRole::Outgoing
@@ -147,6 +159,7 @@ pub const lxst_core::Profile::DEFAULT: Self
pub const lxst_core::Profile::ORDER: [Self; 8]
pub const fn lxst_core::Profile::abbreviation(self) -> &'static str
pub const fn lxst_core::Profile::audio_codec(self) -> lxst_core::AudioCodec
pub const fn lxst_core::Profile::buffer_frames(self) -> u8
pub const fn lxst_core::Profile::channels(self) -> u8
pub const fn lxst_core::Profile::frame_time_ms(self) -> u16
pub const fn lxst_core::Profile::from_wire(u32) -> core::option::Option<Self>
@@ -169,12 +182,15 @@ pub const fn lxst_core::RawBitDepth::bytes_per_sample(self) -> usize
pub const fn lxst_core::RawBitDepth::from_header_bits(u8) -> core::result::Result<Self, lxst_core::Error>
pub const fn lxst_core::RawBitDepth::numpy_dtype(self) -> &'static str
pub enum lxst_core::Signal
pub lxst_core::Signal::PreferredMode(u8)
pub lxst_core::Signal::PreferredProfile(lxst_core::Profile)
pub lxst_core::Signal::Raw(u32)
pub lxst_core::Signal::Status(lxst_core::SignallingStatus)
impl lxst_core::Signal
pub const fn lxst_core::Signal::from_wire(u32) -> Self
pub const fn lxst_core::Signal::wire_value(self) -> u32
impl core::convert::From<lxst_core::CallMode> for lxst_core::Signal
pub fn lxst_core::Signal::from(lxst_core::CallMode) -> Self
impl core::convert::From<lxst_core::Profile> for lxst_core::Signal
pub fn lxst_core::Signal::from(lxst_core::Profile) -> Self
impl core::convert::From<lxst_core::SignallingStatus> for lxst_core::Signal
@@ -217,10 +233,13 @@ pub lxst_core::TelephonyAction::OpenAudioPipelines
pub lxst_core::TelephonyAction::PrepareDialingPipelines
pub lxst_core::TelephonyAction::ResetDialingPipelines
pub lxst_core::TelephonyAction::RingIncomingCall
pub lxst_core::TelephonyAction::SelectMode(lxst_core::CallMode)
pub lxst_core::TelephonyAction::SelectProfile(lxst_core::Profile)
pub lxst_core::TelephonyAction::SendSignal(lxst_core::Signal)
pub lxst_core::TelephonyAction::SendSignalPair(lxst_core::Signal, lxst_core::Signal)
pub lxst_core::TelephonyAction::StartAudioPipelines
pub lxst_core::TelephonyAction::StartDialTone
pub lxst_core::TelephonyAction::SwitchMode(lxst_core::CallMode)
pub lxst_core::TelephonyAction::SwitchProfile(lxst_core::Profile)
pub lxst_core::TelephonyAction::TeardownLink
pub lxst_core::TelephonyAction::Terminate(core::option::Option<lxst_core::SignallingStatus>)
@@ -301,6 +320,12 @@ pub const fn lxst_core::OpusMonoDecoder::channels(&self) -> u8
pub fn lxst_core::OpusMonoDecoder::decode_packet(&mut self, &[u8]) -> core::result::Result<lxst_core::RawAudioFrame, lxst_core::OpusCodecError>
pub fn lxst_core::OpusMonoDecoder::new() -> core::result::Result<Self, lxst_core::OpusCodecError>
pub const fn lxst_core::OpusMonoDecoder::sample_rate_hz(&self) -> u32
pub struct lxst_core::OpusPacketDecoder
impl lxst_core::OpusPacketDecoder
pub const fn lxst_core::OpusPacketDecoder::channels(&self) -> u8
pub fn lxst_core::OpusPacketDecoder::decode_packet(&mut self, &[u8]) -> core::result::Result<lxst_core::RawAudioFrame, lxst_core::OpusCodecError>
pub fn lxst_core::OpusPacketDecoder::new(u32, u8) -> core::result::Result<Self, lxst_core::OpusCodecError>
pub const fn lxst_core::OpusPacketDecoder::sample_rate_hz(&self) -> u32
pub struct lxst_core::RawAudioFrame
pub lxst_core::RawAudioFrame::channels: u8
pub lxst_core::RawAudioFrame::samples: alloc::vec::Vec<f32>
@@ -308,9 +333,11 @@ impl lxst_core::RawAudioFrame
pub fn lxst_core::RawAudioFrame::from_frame(&lxst_core::Frame) -> core::result::Result<Self, lxst_core::Error>
pub fn lxst_core::RawAudioFrame::from_payload(&[u8]) -> core::result::Result<Self, lxst_core::Error>
pub fn lxst_core::RawAudioFrame::new(u8, impl core::convert::Into<alloc::vec::Vec<f32>>) -> core::result::Result<Self, lxst_core::Error>
pub fn lxst_core::RawAudioFrame::resampled(&self, u32, u32) -> Self
pub fn lxst_core::RawAudioFrame::sample_frames(&self) -> usize
pub fn lxst_core::RawAudioFrame::to_frame(&self, lxst_core::RawBitDepth) -> core::result::Result<lxst_core::Frame, lxst_core::Error>
pub fn lxst_core::RawAudioFrame::to_payload(&self, lxst_core::RawBitDepth) -> core::result::Result<alloc::vec::Vec<u8>, lxst_core::Error>
pub fn lxst_core::RawAudioFrame::with_channels(self, u8) -> core::result::Result<Self, lxst_core::Error>
pub struct lxst_core::RawFrameCollector
impl lxst_core::RawFrameCollector
pub fn lxst_core::RawFrameCollector::frames(&self) -> &[lxst_core::RawAudioFrame]
@@ -337,17 +364,23 @@ pub struct lxst_core::TelephonyCall
impl lxst_core::TelephonyCall
pub fn lxst_core::TelephonyCall::answer(&mut self) -> alloc::vec::Vec<lxst_core::TelephonyAction>
pub const fn lxst_core::TelephonyCall::answered(&self) -> bool
pub const fn lxst_core::TelephonyCall::audio_started(&self) -> bool
pub fn lxst_core::TelephonyCall::caller_identified(&mut self, bool, bool) -> alloc::vec::Vec<lxst_core::TelephonyAction>
pub fn lxst_core::TelephonyCall::disable_remote_mode_follow(&mut self)
pub fn lxst_core::TelephonyCall::hangup(&mut self, bool) -> alloc::vec::Vec<lxst_core::TelephonyAction>
pub fn lxst_core::TelephonyCall::incoming() -> Self
pub fn lxst_core::TelephonyCall::incoming_link_established(bool) -> alloc::vec::Vec<lxst_core::TelephonyAction>
pub const fn lxst_core::TelephonyCall::mode(&self) -> core::option::Option<lxst_core::CallMode>
pub fn lxst_core::TelephonyCall::outgoing(core::option::Option<lxst_core::Profile>) -> Self
pub fn lxst_core::TelephonyCall::outgoing_with_mode(core::option::Option<lxst_core::Profile>, core::option::Option<lxst_core::CallMode>) -> Self
pub const fn lxst_core::TelephonyCall::profile(&self) -> core::option::Option<lxst_core::Profile>
pub fn lxst_core::TelephonyCall::receive_signal(&mut self, lxst_core::Signal) -> alloc::vec::Vec<lxst_core::TelephonyAction>
pub fn lxst_core::TelephonyCall::retry_answer(&self) -> alloc::vec::Vec<lxst_core::TelephonyAction>
pub const fn lxst_core::TelephonyCall::role(&self) -> lxst_core::CallRole
pub fn lxst_core::TelephonyCall::set_transmit_squelched(&mut self, bool)
pub const fn lxst_core::TelephonyCall::status(&self) -> lxst_core::SignallingStatus
pub fn lxst_core::TelephonyCall::switch_mode(&mut self, lxst_core::CallMode) -> alloc::vec::Vec<lxst_core::TelephonyAction>
pub fn lxst_core::TelephonyCall::switch_profile(&mut self, lxst_core::Profile) -> alloc::vec::Vec<lxst_core::TelephonyAction>
pub const fn lxst_core::TelephonyCall::transmit_squelched(&self) -> bool
pub const lxst_core::APP_NAME: &str
pub const lxst_core::FIELD_FRAMES: u8
pub const lxst_core::FIELD_SIGNALLING: u8
+39 -1
View File
@@ -33,12 +33,15 @@ pub lxst_embedded::wire::Error::Truncated
pub lxst_embedded::wire::Error::UnknownCodec(u8)
pub lxst_embedded::wire::Error::UnknownCodec2Mode(u8)
pub enum lxst_embedded::wire::Signal
pub lxst_embedded::wire::Signal::PreferredMode(u8)
pub lxst_embedded::wire::Signal::PreferredProfile(lxst_embedded::Profile)
pub lxst_embedded::wire::Signal::Raw(u32)
pub lxst_embedded::wire::Signal::Status(lxst_embedded::SignallingStatus)
impl lxst_embedded::wire::Signal
pub const fn lxst_embedded::wire::Signal::from_wire(u32) -> Self
pub const fn lxst_embedded::wire::Signal::wire_value(self) -> u32
impl core::convert::From<lxst_embedded::CallMode> for lxst_embedded::wire::Signal
pub fn lxst_embedded::wire::Signal::from(lxst_embedded::CallMode) -> Self
impl core::convert::From<lxst_embedded::Profile> for lxst_embedded::wire::Signal
pub fn lxst_embedded::wire::Signal::from(lxst_embedded::Profile) -> Self
impl core::convert::From<lxst_embedded::SignallingStatus> for lxst_embedded::wire::Signal
@@ -63,6 +66,18 @@ impl lxst_embedded::AudioCodec
pub const fn lxst_embedded::AudioCodec::channels(self) -> u8
pub const fn lxst_embedded::AudioCodec::codec_kind(self) -> lxst_embedded::wire::CodecKind
pub const fn lxst_embedded::AudioCodec::sample_rate_hz(self) -> u32
#[repr(u8)] pub enum lxst_embedded::CallMode
pub lxst_embedded::CallMode::FullDuplex = 1
pub lxst_embedded::CallMode::HalfDuplex = 2
impl lxst_embedded::CallMode
pub const lxst_embedded::CallMode::AVAILABLE: [Self; 2]
pub const lxst_embedded::CallMode::DEFAULT: Self
pub const fn lxst_embedded::CallMode::abbreviation(self) -> &'static str
pub const fn lxst_embedded::CallMode::from_wire(u8) -> core::option::Option<Self>
pub const fn lxst_embedded::CallMode::name(self) -> &'static str
pub const fn lxst_embedded::CallMode::wire_value(self) -> u8
impl core::convert::From<lxst_embedded::CallMode> for lxst_embedded::wire::Signal
pub fn lxst_embedded::wire::Signal::from(lxst_embedded::CallMode) -> Self
pub enum lxst_embedded::CallRole
pub lxst_embedded::CallRole::Incoming
pub lxst_embedded::CallRole::Outgoing
@@ -159,6 +174,7 @@ pub const lxst_embedded::Profile::DEFAULT: Self
pub const lxst_embedded::Profile::ORDER: [Self; 8]
pub const fn lxst_embedded::Profile::abbreviation(self) -> &'static str
pub const fn lxst_embedded::Profile::audio_codec(self) -> lxst_embedded::AudioCodec
pub const fn lxst_embedded::Profile::buffer_frames(self) -> u8
pub const fn lxst_embedded::Profile::channels(self) -> u8
pub const fn lxst_embedded::Profile::frame_time_ms(self) -> u16
pub const fn lxst_embedded::Profile::from_wire(u32) -> core::option::Option<Self>
@@ -176,12 +192,15 @@ pub lxst_embedded::QueueError::Expired
pub lxst_embedded::QueueError::OutputCapacity
pub lxst_embedded::QueueError::PayloadTooLarge
pub enum lxst_embedded::Signal
pub lxst_embedded::Signal::PreferredMode(u8)
pub lxst_embedded::Signal::PreferredProfile(lxst_embedded::Profile)
pub lxst_embedded::Signal::Raw(u32)
pub lxst_embedded::Signal::Status(lxst_embedded::SignallingStatus)
impl lxst_embedded::wire::Signal
pub const fn lxst_embedded::wire::Signal::from_wire(u32) -> Self
pub const fn lxst_embedded::wire::Signal::wire_value(self) -> u32
impl core::convert::From<lxst_embedded::CallMode> for lxst_embedded::wire::Signal
pub fn lxst_embedded::wire::Signal::from(lxst_embedded::CallMode) -> Self
impl core::convert::From<lxst_embedded::Profile> for lxst_embedded::wire::Signal
pub fn lxst_embedded::wire::Signal::from(lxst_embedded::Profile) -> Self
impl core::convert::From<lxst_embedded::SignallingStatus> for lxst_embedded::wire::Signal
@@ -208,10 +227,13 @@ pub lxst_embedded::TelephonyAction::OpenAudioPipelines
pub lxst_embedded::TelephonyAction::PrepareDialingPipelines
pub lxst_embedded::TelephonyAction::ResetDialingPipelines
pub lxst_embedded::TelephonyAction::RingIncomingCall
pub lxst_embedded::TelephonyAction::SelectMode(lxst_embedded::CallMode)
pub lxst_embedded::TelephonyAction::SelectProfile(lxst_embedded::Profile)
pub lxst_embedded::TelephonyAction::SendSignal(lxst_embedded::wire::Signal)
pub lxst_embedded::TelephonyAction::SendSignalPair(lxst_embedded::wire::Signal, lxst_embedded::wire::Signal)
pub lxst_embedded::TelephonyAction::StartAudioPipelines
pub lxst_embedded::TelephonyAction::StartDialTone
pub lxst_embedded::TelephonyAction::SwitchMode(lxst_embedded::CallMode)
pub lxst_embedded::TelephonyAction::SwitchProfile(lxst_embedded::Profile)
pub lxst_embedded::TelephonyAction::TeardownLink
pub lxst_embedded::TelephonyAction::Terminate(core::option::Option<lxst_embedded::SignallingStatus>)
@@ -222,17 +244,31 @@ pub struct lxst_embedded::CallState
impl lxst_embedded::CallState
pub fn lxst_embedded::CallState::answer(&mut self) -> lxst_embedded::Actions
pub const fn lxst_embedded::CallState::answered(&self) -> bool
pub const fn lxst_embedded::CallState::audio_started(&self) -> bool
pub fn lxst_embedded::CallState::caller_identified(&mut self, bool, bool) -> lxst_embedded::Actions
pub fn lxst_embedded::CallState::disable_remote_mode_follow(&mut self)
pub fn lxst_embedded::CallState::hangup(&mut self, bool) -> lxst_embedded::Actions
pub fn lxst_embedded::CallState::incoming() -> Self
pub fn lxst_embedded::CallState::incoming_link_established(bool) -> lxst_embedded::Actions
pub const fn lxst_embedded::CallState::mode(&self) -> core::option::Option<lxst_embedded::CallMode>
pub fn lxst_embedded::CallState::outgoing(core::option::Option<lxst_embedded::Profile>) -> Self
pub fn lxst_embedded::CallState::outgoing_with_mode(core::option::Option<lxst_embedded::Profile>, core::option::Option<lxst_embedded::CallMode>) -> Self
pub const fn lxst_embedded::CallState::profile(&self) -> core::option::Option<lxst_embedded::Profile>
pub fn lxst_embedded::CallState::receive_signal(&mut self, lxst_embedded::wire::Signal) -> lxst_embedded::Actions
pub fn lxst_embedded::CallState::retry_answer(&self) -> lxst_embedded::Actions
pub const fn lxst_embedded::CallState::role(&self) -> lxst_embedded::CallRole
pub fn lxst_embedded::CallState::set_transmit_squelched(&mut self, bool)
pub const fn lxst_embedded::CallState::status(&self) -> lxst_embedded::SignallingStatus
pub fn lxst_embedded::CallState::switch_mode(&mut self, lxst_embedded::CallMode) -> lxst_embedded::Actions
pub fn lxst_embedded::CallState::switch_profile(&mut self, lxst_embedded::Profile) -> lxst_embedded::Actions
pub const fn lxst_embedded::CallState::transmit_squelched(&self) -> bool
pub struct lxst_embedded::CallTimes
pub lxst_embedded::CallTimes::connect_ms: u64
pub lxst_embedded::CallTimes::ring_ms: u64
pub lxst_embedded::CallTimes::wait_ms: u64
impl lxst_embedded::CallTimes
pub const lxst_embedded::CallTimes::DEFAULT: Self
impl core::default::Default for lxst_embedded::CallTimes
pub fn lxst_embedded::CallTimes::default() -> Self
pub struct lxst_embedded::Codec2PacketCodec<B>
impl<B: lxst_embedded::Codec2Backend> lxst_embedded::Codec2PacketCodec<B>
pub fn lxst_embedded::Codec2PacketCodec<B>::decode_into(&mut self, &[u8], &mut [i16]) -> core::result::Result<usize, lxst_embedded::Codec2PacketError<<B as lxst_embedded::Codec2Backend>::Error>>
@@ -272,6 +308,7 @@ pub fn lxst_embedded::Session::end(&mut self, lxst_embedded::EndReason) -> lxst_
pub const fn lxst_embedded::Session::ended(&self) -> core::option::Option<lxst_embedded::EndReason>
pub fn lxst_embedded::Session::link_established(&mut self) -> lxst_embedded::Events
pub fn lxst_embedded::Session::media_ready(&self) -> bool
pub const fn lxst_embedded::Session::mode(&self) -> core::option::Option<lxst_embedded::CallMode>
pub fn lxst_embedded::Session::new(lxst_embedded::CallRole, lxst_embedded::SessionConfig, u64) -> core::result::Result<Self, lxst_embedded::ConfigError>
pub fn lxst_embedded::Session::peer_verified(&mut self, u64) -> lxst_embedded::Events
pub fn lxst_embedded::Session::playback_allowed(&self) -> bool
@@ -287,6 +324,7 @@ pub lxst_embedded::SessionConfig::allowed: lxst_embedded::ProfileSet
pub lxst_embedded::SessionConfig::capture: bool
pub lxst_embedded::SessionConfig::playback: bool
pub lxst_embedded::SessionConfig::preferred: lxst_embedded::Profile
pub lxst_embedded::SessionConfig::times: lxst_embedded::CallTimes
pub trait lxst_embedded::Codec2Backend
pub type lxst_embedded::Codec2Backend::Error
pub fn lxst_embedded::Codec2Backend::decode_native(&mut self, &[u8], &mut [i16]) -> core::result::Result<(), Self::Error>
+34 -3
View File
@@ -12,6 +12,7 @@ pub lxst_telephony::Error::LineBusy
pub lxst_telephony::Error::LinkDestinationClosed
pub lxst_telephony::Error::LinkOperation(alloc::string::String)
pub lxst_telephony::Error::LinkProofInvalid(alloc::string::String)
pub lxst_telephony::Error::LinkStamp(rns_link::stamp::LinkStampError)
pub lxst_telephony::Error::MediaProfileMismatch
pub lxst_telephony::Error::MediaProfileMismatch::active: lxst_core::profile::Profile
pub lxst_telephony::Error::MediaProfileMismatch::requested: lxst_core::profile::Profile
@@ -66,18 +67,27 @@ pub lxst_telephony::TelephonyCommand::ResetDialingPipelines::link_id: lxst_telep
pub lxst_telephony::TelephonyCommand::RingIncomingCall
pub lxst_telephony::TelephonyCommand::RingIncomingCall::link_id: lxst_telephony::LinkId
pub lxst_telephony::TelephonyCommand::RingIncomingCall::remote_identity: lxst_telephony::IdentityHash
pub lxst_telephony::TelephonyCommand::SelectMode
pub lxst_telephony::TelephonyCommand::SelectMode::link_id: lxst_telephony::LinkId
pub lxst_telephony::TelephonyCommand::SelectMode::mode: lxst_core::profile::CallMode
pub lxst_telephony::TelephonyCommand::SelectProfile
pub lxst_telephony::TelephonyCommand::SelectProfile::link_id: lxst_telephony::LinkId
pub lxst_telephony::TelephonyCommand::SelectProfile::profile: lxst_core::profile::Profile
pub lxst_telephony::TelephonyCommand::SendSignal
pub lxst_telephony::TelephonyCommand::SendSignal::link_id: lxst_telephony::LinkId
pub lxst_telephony::TelephonyCommand::SendSignal::signal: lxst_core::wire::Signal
pub lxst_telephony::TelephonyCommand::SendSignalPair
pub lxst_telephony::TelephonyCommand::SendSignalPair::link_id: lxst_telephony::LinkId
pub lxst_telephony::TelephonyCommand::SendSignalPair::signals: [lxst_core::wire::Signal; 2]
pub lxst_telephony::TelephonyCommand::StartAudioPipelines
pub lxst_telephony::TelephonyCommand::StartAudioPipelines::link_id: lxst_telephony::LinkId
pub lxst_telephony::TelephonyCommand::StartDialTone
pub lxst_telephony::TelephonyCommand::StartDialTone::link_id: lxst_telephony::LinkId
pub lxst_telephony::TelephonyCommand::StopAudioPipelines
pub lxst_telephony::TelephonyCommand::StopAudioPipelines::link_id: lxst_telephony::LinkId
pub lxst_telephony::TelephonyCommand::SwitchMode
pub lxst_telephony::TelephonyCommand::SwitchMode::link_id: lxst_telephony::LinkId
pub lxst_telephony::TelephonyCommand::SwitchMode::mode: lxst_core::profile::CallMode
pub lxst_telephony::TelephonyCommand::SwitchProfile
pub lxst_telephony::TelephonyCommand::SwitchProfile::link_id: lxst_telephony::LinkId
pub lxst_telephony::TelephonyCommand::SwitchProfile::profile: lxst_core::profile::Profile
@@ -99,8 +109,10 @@ pub lxst_telephony::TelephonyControl::Answer::expected_link_id: lxst_telephony::
pub lxst_telephony::TelephonyControl::Answer::reply: tokio::sync::oneshot::Sender<core::result::Result<lxst_telephony::ActiveCallSnapshot, lxst_telephony::Error>>
pub lxst_telephony::TelephonyControl::Call
pub lxst_telephony::TelephonyControl::Call::discovery_timeout: core::time::Duration
pub lxst_telephony::TelephonyControl::Call::mode: core::option::Option<lxst_core::profile::CallMode>
pub lxst_telephony::TelephonyControl::Call::profile: core::option::Option<lxst_core::profile::Profile>
pub lxst_telephony::TelephonyControl::Call::remote_identity: lxst_telephony::IdentityHash
pub lxst_telephony::TelephonyControl::DisableRemoteModeFollow
pub lxst_telephony::TelephonyControl::Hangup
pub lxst_telephony::TelephonyControl::Hangup::ring_timeout: bool
pub lxst_telephony::TelephonyControl::SendAudioFrames
@@ -115,6 +127,7 @@ pub lxst_telephony::TelephonyControl::SendRawFrames::frames: alloc::vec::Vec<lxs
pub lxst_telephony::TelephonyControl::SetAccessPolicy(lxst_telephony::CallerAccessPolicy)
pub lxst_telephony::TelephonyControl::SetExternalBusy(bool)
pub lxst_telephony::TelephonyControl::Shutdown
pub lxst_telephony::TelephonyControl::SquelchTransmit(bool)
pub lxst_telephony::TelephonyControl::StartAudioReceiveStream
pub lxst_telephony::TelephonyControl::StartAudioReceiveStream::frames: tokio::sync::mpsc::bounded::Sender<lxst_core::raw::RawAudioFrame>
pub lxst_telephony::TelephonyControl::StartAudioStream
@@ -131,6 +144,8 @@ pub lxst_telephony::TelephonyControl::StopAudioReceiveStream
pub lxst_telephony::TelephonyControl::StopAudioStream
pub lxst_telephony::TelephonyControl::StopOpusReceiveStream
pub lxst_telephony::TelephonyControl::StopOpusStream
pub lxst_telephony::TelephonyControl::SwitchMode
pub lxst_telephony::TelephonyControl::SwitchMode::mode: lxst_core::profile::CallMode
pub lxst_telephony::TelephonyControl::SwitchProfile
pub lxst_telephony::TelephonyControl::SwitchProfile::profile: lxst_core::profile::Profile
pub enum lxst_telephony::TelephonyLinkEvent
@@ -228,10 +243,12 @@ pub lxst_telephony::ActiveCall::remote_identity: lxst_telephony::IdentityHash
pub struct lxst_telephony::ActiveCallSnapshot
pub lxst_telephony::ActiveCallSnapshot::answered: bool
pub lxst_telephony::ActiveCallSnapshot::link_id: lxst_telephony::LinkId
pub lxst_telephony::ActiveCallSnapshot::mode: core::option::Option<lxst_core::profile::CallMode>
pub lxst_telephony::ActiveCallSnapshot::profile: core::option::Option<lxst_core::profile::Profile>
pub lxst_telephony::ActiveCallSnapshot::remote_identity: lxst_telephony::IdentityHash
pub lxst_telephony::ActiveCallSnapshot::role: lxst_core::telephony::CallRole
pub lxst_telephony::ActiveCallSnapshot::status: lxst_core::profile::SignallingStatus
pub lxst_telephony::ActiveCallSnapshot::transmit_squelched: bool
pub struct lxst_telephony::AudioTransmitGate
impl lxst_telephony::AudioTransmitGate
pub fn lxst_telephony::AudioTransmitGate::allows(&self) -> bool
@@ -246,6 +263,9 @@ impl lxst_telephony::CallerAccessPolicy
pub fn lxst_telephony::CallerAccessPolicy::is_allowed(&self, &lxst_telephony::IdentityHash) -> bool
impl core::default::Default for lxst_telephony::CallerAccessPolicy
pub fn lxst_telephony::CallerAccessPolicy::default() -> Self
pub struct lxst_telephony::OutgoingLinkRequest
impl core::fmt::Debug for lxst_telephony::OutgoingLinkRequest
pub fn lxst_telephony::OutgoingLinkRequest::fmt(&self, &mut core::fmt::Formatter<'_>) -> core::fmt::Result
pub struct lxst_telephony::RemoteTelephonyPeer
pub lxst_telephony::RemoteTelephonyPeer::destination_hash: [u8; 16]
pub lxst_telephony::RemoteTelephonyPeer::hops: u8
@@ -265,7 +285,9 @@ impl lxst_telephony::TelephonyRnsEndpoint
pub fn lxst_telephony::TelephonyRnsEndpoint::announce(&self) -> core::result::Result<(), lxst_telephony::Error>
pub fn lxst_telephony::TelephonyRnsEndpoint::await_path_to_identity(&self, lxst_telephony::IdentityHash, core::time::Duration) -> impl core::future::future::Future<Output = core::result::Result<(), lxst_telephony::Error>> + core::marker::Send + 'static
pub async fn lxst_telephony::TelephonyRnsEndpoint::begin_outgoing_link(&mut self, &mut lxst_telephony::TelephonyRuntimeCore, lxst_telephony::IdentityHash, core::option::Option<lxst_core::profile::Profile>, core::time::Duration) -> core::result::Result<lxst_telephony::LinkId, lxst_telephony::Error>
pub fn lxst_telephony::TelephonyRnsEndpoint::begin_outgoing_link_with_remote_pubkey(&mut self, &mut lxst_telephony::TelephonyRuntimeCore, lxst_telephony::IdentityHash, [u8; 64], core::option::Option<lxst_core::profile::Profile>, u8) -> core::result::Result<lxst_telephony::LinkId, lxst_telephony::Error>
pub async fn lxst_telephony::TelephonyRnsEndpoint::begin_outgoing_link_with_mode(&mut self, &mut lxst_telephony::TelephonyRuntimeCore, lxst_telephony::IdentityHash, [u8; 64], core::option::Option<lxst_core::profile::Profile>, core::option::Option<lxst_core::profile::CallMode>, u8) -> core::result::Result<lxst_telephony::LinkId, lxst_telephony::Error>
pub async fn lxst_telephony::TelephonyRnsEndpoint::begin_outgoing_link_with_remote_pubkey(&mut self, &mut lxst_telephony::TelephonyRuntimeCore, lxst_telephony::IdentityHash, [u8; 64], core::option::Option<lxst_core::profile::Profile>, u8) -> core::result::Result<lxst_telephony::LinkId, lxst_telephony::Error>
pub fn lxst_telephony::TelephonyRnsEndpoint::begin_prepared_outgoing_link(&mut self, &mut lxst_telephony::TelephonyRuntimeCore, [u8; 64], core::option::Option<lxst_core::profile::Profile>, core::option::Option<lxst_core::profile::CallMode>, lxst_telephony::OutgoingLinkRequest) -> core::result::Result<lxst_telephony::LinkId, lxst_telephony::Error>
pub fn lxst_telephony::TelephonyRnsEndpoint::deregister_destination(&self) -> core::result::Result<(), lxst_telephony::Error>
pub fn lxst_telephony::TelephonyRnsEndpoint::deregister_link_destination(&self, lxst_telephony::LinkId) -> core::result::Result<(), lxst_telephony::Error>
pub fn lxst_telephony::TelephonyRnsEndpoint::discover_remote_telephony_peer(&self, lxst_telephony::IdentityHash, core::time::Duration) -> impl core::future::future::Future<Output = core::result::Result<lxst_telephony::RemoteTelephonyPeer, lxst_telephony::Error>> + core::marker::Send + 'static
@@ -293,6 +315,8 @@ pub const fn lxst_telephony::TelephonyRuntimeCore::access_policy(&self) -> &lxst
pub fn lxst_telephony::TelephonyRuntimeCore::active_call(&self) -> core::option::Option<&lxst_telephony::ActiveCall>
pub fn lxst_telephony::TelephonyRuntimeCore::answer_active(&mut self, lxst_telephony::LinkId) -> core::result::Result<alloc::vec::Vec<lxst_telephony::TelephonyCommand>, lxst_telephony::Error>
pub fn lxst_telephony::TelephonyRuntimeCore::caller_identified(&mut self, lxst_telephony::LinkId, lxst_telephony::IdentityHash) -> core::result::Result<alloc::vec::Vec<lxst_telephony::TelephonyCommand>, lxst_telephony::Error>
pub const fn lxst_telephony::TelephonyRuntimeCore::dialling(&self) -> bool
pub fn lxst_telephony::TelephonyRuntimeCore::disable_remote_mode_follow(&mut self) -> core::result::Result<(), lxst_telephony::Error>
pub const fn lxst_telephony::TelephonyRuntimeCore::external_busy(&self) -> bool
pub fn lxst_telephony::TelephonyRuntimeCore::hangup_active(&mut self, bool) -> core::result::Result<alloc::vec::Vec<lxst_telephony::TelephonyCommand>, lxst_telephony::Error>
pub fn lxst_telephony::TelephonyRuntimeCore::incoming_link_established(&mut self, lxst_telephony::LinkId) -> alloc::vec::Vec<lxst_telephony::TelephonyCommand>
@@ -303,10 +327,13 @@ pub fn lxst_telephony::TelephonyRuntimeCore::outgoing_link_established(&mut self
pub fn lxst_telephony::TelephonyRuntimeCore::pending_link_count(&self) -> usize
pub fn lxst_telephony::TelephonyRuntimeCore::receive_signal(&mut self, lxst_telephony::LinkId, lxst_core::wire::Signal) -> core::result::Result<alloc::vec::Vec<lxst_telephony::TelephonyCommand>, lxst_telephony::Error>
pub fn lxst_telephony::TelephonyRuntimeCore::set_access_policy(&mut self, lxst_telephony::CallerAccessPolicy)
pub fn lxst_telephony::TelephonyRuntimeCore::set_active_transmit_squelched(&mut self, bool) -> core::result::Result<(), lxst_telephony::Error>
pub fn lxst_telephony::TelephonyRuntimeCore::set_external_busy(&mut self, bool)
pub fn lxst_telephony::TelephonyRuntimeCore::shutdown(&mut self) -> alloc::vec::Vec<lxst_telephony::TelephonyCommand>
pub fn lxst_telephony::TelephonyRuntimeCore::snapshot(&self) -> lxst_telephony::TelephonyRuntimeSnapshot
pub fn lxst_telephony::TelephonyRuntimeCore::start_outgoing_call(&mut self, lxst_telephony::LinkId, lxst_telephony::IdentityHash, core::option::Option<lxst_core::profile::Profile>) -> core::result::Result<(), lxst_telephony::Error>
pub fn lxst_telephony::TelephonyRuntimeCore::start_outgoing_call_with_mode(&mut self, lxst_telephony::LinkId, lxst_telephony::IdentityHash, core::option::Option<lxst_core::profile::Profile>, core::option::Option<lxst_core::profile::CallMode>) -> core::result::Result<(), lxst_telephony::Error>
pub fn lxst_telephony::TelephonyRuntimeCore::switch_active_mode(&mut self, lxst_core::profile::CallMode) -> core::result::Result<alloc::vec::Vec<lxst_telephony::TelephonyCommand>, lxst_telephony::Error>
pub fn lxst_telephony::TelephonyRuntimeCore::switch_active_profile(&mut self, lxst_core::profile::Profile) -> core::result::Result<alloc::vec::Vec<lxst_telephony::TelephonyCommand>, lxst_telephony::Error>
pub fn lxst_telephony::TelephonyRuntimeCore::with_access_policy(lxst_telephony::CallerAccessPolicy) -> Self
pub struct lxst_telephony::TelephonyRuntimeSnapshot
@@ -328,8 +355,7 @@ pub fn lxst_telephony::TelephonyServiceChannelConfig::default() -> Self
pub struct lxst_telephony::TelephonyServiceConfig
pub lxst_telephony::TelephonyServiceConfig::announce_interval: core::option::Option<core::time::Duration>
pub lxst_telephony::TelephonyServiceConfig::announce_on_start: bool
pub lxst_telephony::TelephonyServiceConfig::answer_retry_interval: core::option::Option<core::time::Duration>
pub lxst_telephony::TelephonyServiceConfig::answer_timeout: core::option::Option<core::time::Duration>
pub lxst_telephony::TelephonyServiceConfig::connect_timeout: core::option::Option<core::time::Duration>
pub lxst_telephony::TelephonyServiceConfig::incoming_ring_timeout: core::option::Option<core::time::Duration>
pub lxst_telephony::TelephonyServiceConfig::media_frames_per_tick: usize
pub lxst_telephony::TelephonyServiceConfig::outgoing_call_timeout: core::option::Option<core::time::Duration>
@@ -348,9 +374,14 @@ pub lxst_telephony::TelephonyStep::inbound: core::option::Option<lxst_rns::Inbou
impl lxst_telephony::TelephonyStep
pub fn lxst_telephony::TelephonyStep::commands(alloc::vec::Vec<lxst_telephony::TelephonyCommand>) -> Self
pub const lxst_telephony::TELEPHONY_ANNOUNCE_INTERVAL: core::time::Duration
pub const lxst_telephony::TELEPHONY_CONNECT_TIME: core::time::Duration
pub const lxst_telephony::TELEPHONY_JOB_INTERVAL: core::time::Duration
pub const lxst_telephony::TELEPHONY_RING_TIME: core::time::Duration
pub const lxst_telephony::TELEPHONY_STARTUP_ANNOUNCE_RETRIES: u8
pub const lxst_telephony::TELEPHONY_STARTUP_ANNOUNCE_RETRY_INTERVAL: core::time::Duration
pub const lxst_telephony::TELEPHONY_WAIT_TIME: core::time::Duration
pub fn lxst_telephony::execute_command_with_link(&tokio::sync::mpsc::bounded::Sender<rns_transport::messages::TransportMessage>, &[u8; 64], &rns_identity::identity::Identity, &mut rns_link::link::Link, &lxst_telephony::TelephonyCommand) -> core::result::Result<lxst_telephony::TelephonyCommandEffect, lxst_telephony::Error>
pub async fn lxst_telephony::prepare_outgoing_link_request(&tokio::sync::mpsc::bounded::Sender<rns_transport::messages::TransportMessage>, lxst_telephony::IdentityHash, u8) -> core::result::Result<lxst_telephony::OutgoingLinkRequest, lxst_telephony::Error>
pub async fn lxst_telephony::request_answer(&tokio::sync::mpsc::bounded::Sender<lxst_telephony::TelephonyControl>, lxst_telephony::LinkId) -> core::result::Result<lxst_telephony::ActiveCallSnapshot, lxst_telephony::Error>
pub fn lxst_telephony::signalling_packet(lxst_core::wire::Signal) -> lxst_core::wire::LxstPacket
pub fn lxst_telephony::signalling_packets_from_commands(&[lxst_telephony::TelephonyCommand]) -> alloc::vec::Vec<(lxst_telephony::LinkId, lxst_core::wire::LxstPacket)>
+20 -20
View File
@@ -4,7 +4,7 @@
"packages": [
{
"name": "lxst-codec2",
"version": "0.3.1",
"version": "0.4.0",
"rustVersion": "1.87",
"edition": "2024",
"features": {},
@@ -36,7 +36,7 @@
},
{
"name": "lxst-core",
"version": "0.3.1",
"version": "0.4.0",
"rustVersion": "1.89",
"edition": "2024",
"features": {},
@@ -69,7 +69,7 @@
"rename": null,
"kind": null,
"target": null,
"requirement": "=0.1.29",
"requirement": "=0.1.42",
"optional": false,
"defaultFeatures": false,
"features": [
@@ -103,7 +103,7 @@
},
{
"name": "lxst-embedded",
"version": "0.3.1",
"version": "0.4.0",
"rustVersion": "1.87",
"edition": "2024",
"features": {},
@@ -125,7 +125,7 @@
"rename": null,
"kind": null,
"target": null,
"requirement": "^0.3.1",
"requirement": "^0.4.0",
"optional": false,
"defaultFeatures": true,
"features": [],
@@ -146,7 +146,7 @@
},
{
"name": "lxst-rns",
"version": "0.3.1",
"version": "0.4.0",
"rustVersion": "1.89",
"edition": "2024",
"features": {},
@@ -179,7 +179,7 @@
"rename": null,
"kind": null,
"target": null,
"requirement": "^0.3.1",
"requirement": "^0.4.0",
"optional": false,
"defaultFeatures": true,
"features": [],
@@ -190,7 +190,7 @@
"rename": null,
"kind": null,
"target": null,
"requirement": "~1.4.0",
"requirement": "~1.5.1",
"optional": false,
"defaultFeatures": true,
"features": [],
@@ -201,7 +201,7 @@
"rename": null,
"kind": null,
"target": null,
"requirement": "~1.4.0",
"requirement": "~1.5.1",
"optional": false,
"defaultFeatures": true,
"features": [],
@@ -212,7 +212,7 @@
"rename": null,
"kind": null,
"target": null,
"requirement": "~1.4.0",
"requirement": "~1.5.1",
"optional": false,
"defaultFeatures": true,
"features": [],
@@ -249,7 +249,7 @@
},
{
"name": "lxst-telephony",
"version": "0.3.1",
"version": "0.4.0",
"rustVersion": "1.89",
"edition": "2024",
"features": {},
@@ -282,7 +282,7 @@
"rename": null,
"kind": null,
"target": null,
"requirement": "^0.3.1",
"requirement": "^0.4.0",
"optional": false,
"defaultFeatures": true,
"features": [],
@@ -293,7 +293,7 @@
"rename": null,
"kind": null,
"target": null,
"requirement": "^0.3.1",
"requirement": "^0.4.0",
"optional": false,
"defaultFeatures": true,
"features": [],
@@ -304,7 +304,7 @@
"rename": null,
"kind": null,
"target": null,
"requirement": "^0.3.1",
"requirement": "^0.4.0",
"optional": false,
"defaultFeatures": true,
"features": [],
@@ -315,7 +315,7 @@
"rename": null,
"kind": null,
"target": null,
"requirement": "~1.4.0",
"requirement": "~1.5.1",
"optional": false,
"defaultFeatures": true,
"features": [],
@@ -326,7 +326,7 @@
"rename": null,
"kind": null,
"target": null,
"requirement": "~1.4.0",
"requirement": "~1.5.1",
"optional": false,
"defaultFeatures": true,
"features": [],
@@ -337,7 +337,7 @@
"rename": null,
"kind": null,
"target": null,
"requirement": "~1.4.0",
"requirement": "~1.5.1",
"optional": false,
"defaultFeatures": true,
"features": [],
@@ -348,7 +348,7 @@
"rename": null,
"kind": null,
"target": null,
"requirement": "~1.4.0",
"requirement": "~1.5.1",
"optional": false,
"defaultFeatures": true,
"features": [],
@@ -359,7 +359,7 @@
"rename": null,
"kind": null,
"target": null,
"requirement": "~1.4.0",
"requirement": "~1.5.1",
"optional": false,
"defaultFeatures": true,
"features": [],
@@ -370,7 +370,7 @@
"rename": null,
"kind": null,
"target": null,
"requirement": "~1.4.0",
"requirement": "~1.5.1",
"optional": false,
"defaultFeatures": true,
"features": [],
+9 -12
View File
@@ -14,8 +14,8 @@
"commit": "af89a03094605dbdf7264d06fdc546526ec6980b"
},
"compatibilityFloor": {
"evidenceCommit": "21a54b778472343b70fd71d34ae96c61c44187c3",
"sourceCommit": "af89a03094605dbdf7264d06fdc546526ec6980b"
"evidenceCommit": "aeb400006bdd550f42e494bfc823f66acce0669e",
"sourceCommit": "aeb400006bdd550f42e494bfc823f66acce0669e"
},
"packages": [
{
@@ -33,8 +33,8 @@
"tier": "experimental",
"compatibility": "reviewed-snapshot",
"snapshot": "api/snapshots/lxst-embedded.txt",
"itemCount": 299,
"sha256": "7cfa734581040e35c4b817422376e4e99c9f7d447181d9e3a9e1dac0912b9295"
"itemCount": 337,
"sha256": "e4a86f580d90b6b5589fa0e91ac6d426b7df5d7f10e753683061d7184f64d425"
},
{
"name": "lxst-core",
@@ -42,8 +42,8 @@
"tier": "experimental",
"compatibility": "reviewed-snapshot",
"snapshot": "api/snapshots/lxst-core.txt",
"itemCount": 364,
"sha256": "2c272021cc340af7f779d944bebb336ae1804938239a8ead3cbf11a8074022e4"
"itemCount": 397,
"sha256": "7edc5748c8b212d551756681cbc0815da6102accb5a59126b43d3b23233096cd"
},
{
"name": "lxst-rns",
@@ -60,12 +60,9 @@
"tier": "experimental",
"compatibility": "reviewed-snapshot",
"snapshot": "api/snapshots/lxst-telephony.txt",
"itemCount": 360,
"sha256": "c9b9784a9b09bb41a9beffb29b62085b21f2b22cb8b7d18ef53ea9f673d77698"
"itemCount": 391,
"sha256": "f36724579b879506b8cd4fd3e4378f9b594bf97f169764f1461dd64401679b7a"
}
],
"newPackages": [
"lxst-codec2",
"lxst-embedded"
]
"newPackages": []
}
+2 -2
View File
@@ -21,10 +21,10 @@ mod wire;
pub use codec2::{Codec2Backend, Codec2PacketCodec, Codec2PacketError};
pub use opus::{
OPUS_ENCODED_FRAME_MAX_BYTES, OPUS_ENCODED_PACKET_MAX_BYTES, OPUS_MONO_DECODE_SAMPLE_RATE_HZ,
OpusCodecError, OpusDecoderState, OpusEncoderState, OpusMonoDecoder,
OpusCodecError, OpusDecoderState, OpusEncoderState, OpusMonoDecoder, OpusPacketDecoder,
opus_packet_duration_samples_48k,
};
pub use profile::{AudioCodec, OpusApplication, OpusProfile, Profile, SignallingStatus};
pub use profile::{AudioCodec, CallMode, OpusApplication, OpusProfile, Profile, SignallingStatus};
pub use raw::RawAudioFrame;
pub use stream::{
DropPolicy, FramePacketizer, FrameStreamEvent, FrameStreamState, JitterBuffer, JitterPush,
+198 -97
View File
@@ -1,4 +1,6 @@
use opus_rs::{Application, OpusDecoder, OpusEncoder};
use std::panic::{AssertUnwindSafe, catch_unwind};
use opus_rs::{Application, Bandwidth, OpusDecoder, OpusEncoder};
use thiserror::Error;
use crate::{AudioCodec, CodecKind, Frame, OpusApplication, OpusProfile, Profile, RawAudioFrame};
@@ -66,8 +68,6 @@ pub struct OpusEncoderState {
sample_frames: usize,
subframe_count: usize,
subframe_sample_frames: usize,
encode_sample_frames: usize,
encode_subframe_sample_frames: usize,
max_payload_bytes: usize,
encoder: OpusEncoder,
}
@@ -80,35 +80,28 @@ impl OpusEncoderState {
};
let channels = opus_profile.channels();
let sample_rate = opus_profile.sample_rate();
let encode_sample_rate = encode_sample_rate(opus_profile);
let sample_frames = profile.sample_frames_per_packet();
let encode_sample_frames =
scale_sample_frames(sample_frames, sample_rate, encode_sample_rate)?;
let packet_layout = PacketLayout::new(encode_sample_rate, encode_sample_frames)?;
let subframe_sample_frames = sample_frames
.checked_div(packet_layout.subframe_count)
.filter(|frames| frames * packet_layout.subframe_count == sample_frames)
.ok_or(OpusCodecError::UnsupportedFrameDuration {
sample_rate_hz: sample_rate,
sample_frames,
})?;
let packet_layout = PacketLayout::new(sample_rate, sample_frames)?;
let mut encoder = OpusEncoder::new(
encode_sample_rate as i32,
sample_rate as i32,
usize::from(channels),
opus_application(opus_profile.application()),
)
.map_err(|err| OpusCodecError::Codec(err.to_string()))?;
encoder.bitrate_bps = opus_profile.bitrate_ceiling() as i32;
encoder.use_cbr = false;
if matches!(opus_profile, OpusProfile::VoiceMedium) {
// At 8 kbps libopus builds disagree (1.5 wideband, 1.6 narrowband); wideband is
// what this profile has always sent.
encoder.set_bandwidth(Bandwidth::Wideband);
}
Ok(Self {
profile,
channels,
sample_frames,
subframe_count: packet_layout.subframe_count,
subframe_sample_frames,
encode_sample_frames,
encode_subframe_sample_frames: packet_layout.subframe_sample_frames,
subframe_sample_frames: packet_layout.subframe_sample_frames,
max_payload_bytes: opus_profile.max_bytes_per_frame_ms(profile.frame_time_ms()),
encoder,
})
@@ -144,22 +137,10 @@ impl OpusEncoderState {
return self.encode_multi_subframe_packet(frame);
}
let resampled;
let input = if self.encode_sample_frames == self.sample_frames {
&frame.samples
} else {
resampled = resample_interleaved_linear(
&frame.samples,
self.sample_frames,
self.encode_sample_frames,
usize::from(self.channels),
);
&resampled
};
let mut encoded = vec![0u8; self.max_payload_bytes];
let written = self
.encoder
.encode(input, self.encode_sample_frames, &mut encoded)
.encode(&frame.samples, self.sample_frames, &mut encoded)
.map_err(|err| OpusCodecError::Codec(err.to_string()))?;
encoded.truncate(written);
Ok(Frame::new(CodecKind::Opus, encoded))
@@ -176,22 +157,14 @@ impl OpusEncoderState {
for (subframe_index, payload_budget) in budgets.into_iter().enumerate() {
let start = subframe_index * self.subframe_sample_frames * channels;
let end = start + self.subframe_sample_frames * channels;
let resampled;
let input = if self.encode_subframe_sample_frames == self.subframe_sample_frames {
&frame.samples[start..end]
} else {
resampled = resample_interleaved_linear(
&frame.samples[start..end],
self.subframe_sample_frames,
self.encode_subframe_sample_frames,
channels,
);
&resampled
};
let mut encoded = vec![0u8; payload_budget + 1];
let written = self
.encoder
.encode(input, self.encode_subframe_sample_frames, &mut encoded)
.encode(
&frame.samples[start..end],
self.subframe_sample_frames,
&mut encoded,
)
.map_err(|err| OpusCodecError::Codec(err.to_string()))?;
encoded.truncate(written);
if encoded.first().is_none_or(|toc| toc & 0x03 != 0) {
@@ -247,6 +220,7 @@ impl OpusEncoderState {
pub struct OpusDecoderState {
profile: Profile,
sample_rate_hz: u32,
channels: u8,
sample_frames: usize,
subframe_count: usize,
@@ -269,6 +243,7 @@ impl OpusDecoderState {
Ok(Self {
profile,
sample_rate_hz: sample_rate,
channels,
sample_frames,
subframe_count: packet_layout.subframe_count,
@@ -302,10 +277,14 @@ impl OpusDecoderState {
fn decode_direct_packet(&mut self, frame: &Frame) -> Result<RawAudioFrame, OpusCodecError> {
let mut samples = vec![0.0f32; self.sample_frames * usize::from(self.channels)];
let decoded = self
.decoder
.decode(&frame.payload, self.sample_frames, &mut samples)
.map_err(|err| OpusCodecError::Codec(err.to_string()))?;
let decoded = decode_guarded(
&mut self.decoder,
self.sample_rate_hz,
usize::from(self.channels),
&frame.payload,
self.sample_frames,
&mut samples,
)?;
samples.truncate(decoded * usize::from(self.channels));
Ok(RawAudioFrame::new(self.channels, samples)?)
}
@@ -325,13 +304,14 @@ impl OpusDecoderState {
let mut subpacket = Vec::with_capacity(subpayload.len() + 1);
subpacket.push(toc);
subpacket.extend_from_slice(subpayload);
self.decoder
.decode(
&subpacket,
self.subframe_sample_frames,
&mut samples[start..end],
)
.map_err(|err| OpusCodecError::Codec(err.to_string()))?;
decode_guarded(
&mut self.decoder,
self.sample_rate_hz,
channels,
&subpacket,
self.subframe_sample_frames,
&mut samples[start..end],
)?;
}
Ok(RawAudioFrame::new(self.channels, samples)?)
@@ -383,14 +363,14 @@ impl OpusMonoDecoder {
let output_start = samples.len();
samples.resize(output_start + inspected.samples_per_frame_48k, 0.0);
let decoded = self
.decoder
.decode(
&direct_packet,
inspected.samples_per_frame_48k,
&mut samples[output_start..],
)
.map_err(|err| OpusCodecError::Codec(err.to_string()))?;
let decoded = decode_guarded(
&mut self.decoder,
OPUS_MONO_DECODE_SAMPLE_RATE_HZ,
1,
&direct_packet,
inspected.samples_per_frame_48k,
&mut samples[output_start..],
)?;
if decoded != inspected.samples_per_frame_48k {
return Err(OpusCodecError::DecodedPacketDurationMismatch {
expected: inspected.samples_per_frame_48k,
@@ -404,6 +384,113 @@ impl OpusMonoDecoder {
}
}
/// Decodes any legal Opus packet (2.5 to 120 ms, mono or stereo) to a fixed sample rate
/// and channel count, as Python's libopus decoder does whatever the local profile is.
pub struct OpusPacketDecoder {
sample_rate_hz: u32,
channels: u8,
decoders: [Option<OpusDecoder>; 2],
}
impl OpusPacketDecoder {
pub fn new(sample_rate_hz: u32, channels: u8) -> Result<Self, OpusCodecError> {
if !matches!(sample_rate_hz, 8_000 | 12_000 | 16_000 | 24_000 | 48_000) {
return Err(OpusCodecError::UnsupportedFrameDuration {
sample_rate_hz,
sample_frames: 0,
});
}
if !matches!(channels, 1 | 2) {
return Err(OpusCodecError::ChannelMismatch {
expected: 2,
actual: channels,
});
}
Ok(Self {
sample_rate_hz,
channels,
decoders: [None, None],
})
}
pub const fn sample_rate_hz(&self) -> u32 {
self.sample_rate_hz
}
pub const fn channels(&self) -> u8 {
self.channels
}
pub fn decode_packet(&mut self, packet: &[u8]) -> Result<RawAudioFrame, OpusCodecError> {
let inspected = inspect_opus_packet(packet)?;
let packet_channels = usize::from(inspected.channels);
let samples_per_frame =
inspected.samples_per_frame_48k * self.sample_rate_hz as usize / 48_000;
let slot = &mut self.decoders[packet_channels - 1];
if slot.is_none() {
*slot = Some(
OpusDecoder::new(self.sample_rate_hz as i32, packet_channels)
.map_err(|err| OpusCodecError::Codec(err.to_string()))?,
);
}
let decoder = slot.as_mut().expect("decoder exists after creation");
let mut samples =
Vec::with_capacity(samples_per_frame * inspected.frames.len() * packet_channels);
let direct_toc = inspected.toc & !0x03;
for payload in inspected.frames {
let mut direct_packet = Vec::with_capacity(payload.len() + 1);
direct_packet.push(direct_toc);
direct_packet.extend_from_slice(payload);
let output_start = samples.len();
samples.resize(output_start + samples_per_frame * packet_channels, 0.0);
let decoded = decode_guarded(
decoder,
self.sample_rate_hz,
packet_channels,
&direct_packet,
samples_per_frame,
&mut samples[output_start..],
)?;
if decoded != samples_per_frame {
return Err(OpusCodecError::DecodedPacketDurationMismatch {
expected: samples_per_frame,
actual: decoded,
});
}
}
let frame = RawAudioFrame::new(inspected.channels, samples)?;
Ok(frame.with_channels(self.channels)?)
}
}
/// Peer packets reach opus-rs, which has panicked on hostile input (0.1.29: negative SILK LTP
/// start index, fixed in 0.1.42). A panicked decoder's state is undefined, so it is replaced
/// and the packet rejected. Remove once the pinned opus-rs passes a decoder fuzz campaign.
fn decode_guarded(
decoder: &mut OpusDecoder,
sample_rate_hz: u32,
channels: usize,
packet: &[u8],
frame_size: usize,
output: &mut [f32],
) -> Result<usize, OpusCodecError> {
match catch_unwind(AssertUnwindSafe(|| {
decoder.decode(packet, frame_size, output)
})) {
Ok(result) => result.map_err(|err| OpusCodecError::Codec(err.to_string())),
Err(_) => {
*decoder = OpusDecoder::new(sample_rate_hz as i32, channels)
.map_err(|err| OpusCodecError::Codec(err.to_string()))?;
Err(OpusCodecError::MalformedPacket(
"Opus decoder rejected the packet",
))
}
}
}
/// Returns a supported packet's total duration in samples at the Opus 48 kHz clock.
///
/// The packet is structurally inspected using the framing rules from RFC 6716. Every legal
@@ -646,44 +733,11 @@ fn opus_application(application: OpusApplication) -> Application {
}
}
fn encode_sample_rate(profile: OpusProfile) -> u32 {
match profile {
// Python LXST uses libopus with an output byte ceiling but no fixed
// bitrate or bandwidth CTLs. At Medium's 8 kbps ceiling, libopus is
// free to pick lower voice bandwidth; opus-rs otherwise forces
// superwideband/hybrid from the 24 kHz API rate, which is poor for
// speech at this budget.
OpusProfile::VoiceMedium => 16_000,
_ => profile.sample_rate(),
}
}
fn scale_sample_frames(
sample_frames: usize,
source_sample_rate: u32,
encode_sample_rate: u32,
) -> Result<usize, OpusCodecError> {
let numerator = sample_frames
.checked_mul(encode_sample_rate as usize)
.ok_or(OpusCodecError::UnsupportedFrameDuration {
sample_rate_hz: encode_sample_rate,
sample_frames,
})?;
let denominator = source_sample_rate as usize;
if !numerator.is_multiple_of(denominator) {
return Err(OpusCodecError::UnsupportedFrameDuration {
sample_rate_hz: encode_sample_rate,
sample_frames,
});
}
Ok(numerator / denominator)
}
fn supports_direct_frame(sample_rate_hz: u32, sample_frames: usize) -> bool {
sample_frames != 0 && (sample_rate_hz as usize).is_multiple_of(sample_frames)
}
fn resample_interleaved_linear(
pub(crate) fn resample_interleaved_linear(
input: &[f32],
input_frames: usize,
output_frames: usize,
@@ -1281,4 +1335,51 @@ mod tests {
));
}
}
// Fuzz-found sequence: the last packet drove opus-rs 0.1.29 `silk_decode_core` to a
// negative LTP start index and a panic. 0.1.42 decodes or refuses it.
fn silk_panic_window() -> Vec<Vec<u8>> {
include_str!("../tests/data/opus_silk_negative_ltp_start.hex")
.lines()
.map(|line| hex::decode(line).unwrap())
.collect()
}
#[test]
fn mono_decoder_survives_fuzz_found_silk_frame() {
let window = silk_panic_window();
let (last, prefix) = window.split_last().unwrap();
let mut decoder = OpusMonoDecoder::new().unwrap();
for packet in prefix {
let _ = decoder.decode_packet(packet);
}
let _ = decoder.decode_packet(last);
let good = encoded_mono_packet(960, 32_000);
let after = decoder.decode_packet(&good).unwrap();
let fresh = OpusMonoDecoder::new()
.unwrap()
.decode_packet(&good)
.unwrap();
assert_eq!(after.samples.len(), fresh.samples.len());
}
#[test]
fn packet_decoder_survives_fuzz_found_silk_frame() {
let window = silk_panic_window();
let (last, prefix) = window.split_last().unwrap();
let mut decoder = OpusPacketDecoder::new(OPUS_MONO_DECODE_SAMPLE_RATE_HZ, 1).unwrap();
for packet in prefix {
let _ = decoder.decode_packet(packet);
}
let _ = decoder.decode_packet(last);
let good = encoded_mono_packet(960, 32_000);
let after = decoder.decode_packet(&good).unwrap();
let fresh = OpusPacketDecoder::new(OPUS_MONO_DECODE_SAMPLE_RATE_HZ, 1)
.unwrap()
.decode_packet(&good)
.unwrap();
assert_eq!(after.samples.len(), fresh.samples.len());
}
}
+80 -14
View File
@@ -46,6 +46,46 @@ impl RawAudioFrame {
})
}
/// Convert to `channels`: mono is duplicated, extra channels are averaged to mono,
/// otherwise the leading channels are kept and the last one repeated.
pub fn with_channels(self, channels: u8) -> Result<Self, Error> {
if channels == self.channels {
return Ok(self);
}
let source = usize::from(self.channels);
let target = usize::from(channels);
let mut samples = Vec::with_capacity(self.sample_frames() * target);
for frame in self.samples.chunks_exact(source) {
if target == 1 {
samples.push(frame.iter().sum::<f32>() / source as f32);
} else {
for channel in 0..target {
samples.push(frame[channel.min(source - 1)]);
}
}
}
Self::new(channels, samples)
}
/// Linearly resample from `input_rate_hz` to `output_rate_hz`.
pub fn resampled(&self, input_rate_hz: u32, output_rate_hz: u32) -> Self {
if input_rate_hz == output_rate_hz || input_rate_hz == 0 {
return self.clone();
}
let input_frames = self.sample_frames();
let output_frames =
(input_frames as u64 * u64::from(output_rate_hz) / u64::from(input_rate_hz)) as usize;
Self {
channels: self.channels,
samples: crate::opus::resample_interleaved_linear(
&self.samples,
input_frames,
output_frames,
usize::from(self.channels),
),
}
}
pub fn to_payload(&self, bit_depth: RawBitDepth) -> Result<Vec<u8>, Error> {
validate_sample_count(self.channels, self.samples.len())?;
let header = RawFrameHeader::new(self.channels, bit_depth)?;
@@ -92,7 +132,7 @@ fn decode_samples(bytes: &[u8], bit_depth: RawBitDepth) -> Result<Vec<f32>, Erro
}
RawBitDepth::Float128 => {
for chunk in bytes.as_chunks::<16>().0 {
samples.push(decode_float128_lossy(chunk));
samples.push(decode_float128(chunk));
}
}
}
@@ -125,24 +165,50 @@ fn encode_samples(samples: &[f32], bit_depth: RawBitDepth, out: &mut Vec<u8>) {
}
}
fn decode_float128_lossy(bytes: &[u8]) -> f32 {
// Python/Numpy names this dtype "float128", but on common little-endian
// platforms it may be backed by an 80-bit extended value padded to 16 bytes.
// We preserve finite zero exactly and otherwise use the leading f64 lane as
// a conservative lossy fallback until a platform-specific long-double codec
// is introduced.
if bytes.iter().all(|byte| *byte == 0) {
// numpy float128 is IEEE binary128 on Linux aarch64; x86_64 pads an 80-bit value instead.
const BINARY128_EXPONENT_BIAS: i32 = 16_383;
const BINARY128_MANTISSA_BITS: u32 = 112;
fn decode_float128(bytes: &[u8]) -> f32 {
let mut le = [0u8; 16];
le.copy_from_slice(bytes);
let bits = u128::from_le_bytes(le);
let negative = bits >> 127 != 0;
let exponent = ((bits >> BINARY128_MANTISSA_BITS) & 0x7FFF) as i32;
let mantissa = bits & ((1u128 << BINARY128_MANTISSA_BITS) - 1);
let magnitude = if exponent == 0x7FFF {
if mantissa == 0 {
f64::INFINITY
} else {
f64::NAN
}
} else if exponent == 0 {
// Subnormal binary128 values are far below the f32 range.
0.0
} else {
f64::from_le_bytes([
bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5], bytes[6], bytes[7],
]) as f32
}
let fraction = (mantissa >> (BINARY128_MANTISSA_BITS - 52)) as f64 / (1u64 << 52) as f64;
(1.0 + fraction) * 2f64.powi(exponent - BINARY128_EXPONENT_BIAS)
};
(if negative { -magnitude } else { magnitude }) as f32
}
fn encode_float128_from_f32(sample: f32, out: &mut Vec<u8>) {
out.extend_from_slice(&f64::from(sample).to_le_bytes());
out.extend_from_slice(&[0u8; 8]);
let value = f64::from(sample);
let f64_bits = value.to_bits();
let sign = u128::from(f64_bits >> 63) << 127;
let exponent = ((f64_bits >> 52) & 0x7FF) as i32;
let mantissa = u128::from(f64_bits & ((1u64 << 52) - 1));
let bits = if value == 0.0 {
sign
} else if exponent == 0x7FF {
let nan_mantissa = if mantissa == 0 { 0 } else { 1u128 << 111 };
sign | (0x7FFFu128 << BINARY128_MANTISSA_BITS) | nan_mantissa
} else {
// Every f32 widens to a normal f64.
let exponent = (exponent - 1023 + BINARY128_EXPONENT_BIAS) as u128;
sign | (exponent << BINARY128_MANTISSA_BITS) | (mantissa << (BINARY128_MANTISSA_BITS - 52))
};
out.extend_from_slice(&bits.to_le_bytes());
}
#[cfg(test)]
+3 -3
View File
@@ -1,16 +1,16 @@
use crate::Signal;
use crate::TelephonyAction;
/// Every current transition emits at most four ordered actions.
/// Every current transition emits at most six ordered actions.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Actions {
items: [TelephonyAction; 4],
items: [TelephonyAction; 6],
length: usize,
}
impl Actions {
pub(crate) fn new() -> Self {
Self {
items: [const { TelephonyAction::IgnoreSignal(Signal::Raw(0)) }; 4],
items: [const { TelephonyAction::IgnoreSignal(Signal::Raw(0)) }; 6],
length: 0,
}
}
+5 -1
View File
@@ -1,4 +1,4 @@
use crate::{Profile, Signal, SignallingStatus};
use crate::{CallMode, Profile, Signal, SignallingStatus};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum CallRole {
@@ -9,6 +9,8 @@ pub enum CallRole {
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum TelephonyAction {
SendSignal(Signal),
/// Send both signals in one packet, as Python sends profile and mode on RINGING.
SendSignalPair(Signal, Signal),
IdentifyLocalIdentity,
SelectProfile(Profile),
PrepareDialingPipelines,
@@ -20,5 +22,7 @@ pub enum TelephonyAction {
TeardownLink,
RingIncomingCall,
SwitchProfile(Profile),
SelectMode(CallMode),
SwitchMode(CallMode),
IgnoreSignal(Signal),
}
+53
View File
@@ -159,6 +159,21 @@ impl Profile {
}
}
/// Python `Profiles.get_buffer_frames`: its sink holds one frame more than this and
/// starts playback at `max(1, buffer_frames() - 2)` frames.
pub const fn buffer_frames(self) -> u8 {
match self {
Self::BandwidthUltraLow => 2,
Self::BandwidthVeryLow => 2,
Self::BandwidthLow => 2,
Self::QualityMedium => 5,
Self::QualityHigh => 5,
Self::QualityMax => 5,
Self::LatencyLow => 3,
Self::LatencyUltraLow => 2,
}
}
pub fn next(self) -> Self {
let index = Self::ORDER
.iter()
@@ -168,6 +183,44 @@ impl Profile {
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[repr(u8)]
pub enum CallMode {
FullDuplex = 0x01,
HalfDuplex = 0x02,
}
impl CallMode {
pub const DEFAULT: Self = Self::FullDuplex;
pub const AVAILABLE: [Self; 2] = [Self::FullDuplex, Self::HalfDuplex];
pub const fn wire_value(self) -> u8 {
self as u8
}
pub const fn from_wire(value: u8) -> Option<Self> {
match value {
0x01 => Some(Self::FullDuplex),
0x02 => Some(Self::HalfDuplex),
_ => None,
}
}
pub const fn name(self) -> &'static str {
match self {
Self::FullDuplex => "Full Duplex",
Self::HalfDuplex => "Half Duplex",
}
}
pub const fn abbreviation(self) -> &'static str {
match self {
Self::FullDuplex => "FDX",
Self::HalfDuplex => "HDX",
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum AudioCodec {
Opus(OpusProfile),
+123 -40
View File
@@ -1,5 +1,5 @@
use crate::actions::Actions;
use crate::{CallRole, Profile, Signal, SignallingStatus, TelephonyAction};
use crate::{CallMode, CallRole, Profile, Signal, SignallingStatus, TelephonyAction};
macro_rules! actions {
($($value:expr),* $(,)?) => { Actions::from_array([$($value),*]) };
@@ -10,16 +10,29 @@ pub struct CallState {
role: CallRole,
status: SignallingStatus,
profile: Option<Profile>,
/// Raw mode value; Python stores unknown modes without acting on them.
mode: Option<u8>,
answered: bool,
pipelines_started: bool,
transmit_squelched: bool,
remote_mode_follow_disabled: bool,
}
impl CallState {
pub fn outgoing(profile: Option<Profile>) -> Self {
Self::outgoing_with_mode(profile, None)
}
pub fn outgoing_with_mode(profile: Option<Profile>, mode: Option<CallMode>) -> Self {
Self {
role: CallRole::Outgoing,
status: SignallingStatus::Calling,
profile,
mode: mode.map(|mode| mode.wire_value()),
answered: false,
pipelines_started: false,
transmit_squelched: false,
remote_mode_follow_disabled: false,
}
}
@@ -28,7 +41,11 @@ impl CallState {
role: CallRole::Incoming,
status: SignallingStatus::Available,
profile: None,
mode: None,
answered: false,
pipelines_started: false,
transmit_squelched: false,
remote_mode_follow_disabled: false,
}
}
@@ -48,6 +65,34 @@ impl CallState {
self.answered
}
/// Whether audio pipelines were started; a caller only starts them on the callee's ESTABLISHED.
pub const fn audio_started(&self) -> bool {
self.pipelines_started
}
/// Selected call mode, or `None` before selection or for an unknown remote mode.
pub const fn mode(&self) -> Option<CallMode> {
match self.mode {
Some(value) => CallMode::from_wire(value),
None => None,
}
}
/// Whether outbound media frames are dropped, as Python's squelched Packetizer.
pub const fn transmit_squelched(&self) -> bool {
self.transmit_squelched
}
/// Squelch or unsquelch transmit locally without signalling, as Python `squelch_transmit`.
pub fn set_transmit_squelched(&mut self, squelched: bool) {
self.transmit_squelched = squelched;
}
/// Ignore later remote mode switches, as Python `disable_remote_mode_follow`.
pub fn disable_remote_mode_follow(&mut self) {
self.remote_mode_follow_disabled = true;
}
pub fn incoming_link_established(line_busy: bool) -> Actions {
if line_busy {
actions![
@@ -84,36 +129,16 @@ impl CallState {
let mut actions = Actions::new();
self.answered = true;
self.ensure_profile(&mut actions);
self.ensure_mode(&mut actions);
self.squelch_for_opened_pipelines();
self.push_status_signal(SignallingStatus::Connecting, &mut actions);
actions.push(TelephonyAction::OpenAudioPipelines);
// Python LXST sends ESTABLISHED as the final half of the answer offer,
// then the outgoing peer echoes ESTABLISHED while opening its own
// pipelines. Keep the incoming call in CONNECTING until that remote
// echo is observed: local queue admission alone is not proof that the
// caller received the answer.
actions.push(TelephonyAction::SendSignal(Signal::from(
SignallingStatus::Established,
)));
self.push_status_signal(SignallingStatus::Established, &mut actions);
actions.push(TelephonyAction::StartAudioPipelines);
self.pipelines_started = true;
actions
}
/// Return the answer offer again without reopening pipelines or changing state.
/// The caller controls retry timing and count. No actions are returned once
/// the incoming call leaves CONNECTING, including after an ESTABLISHED echo.
pub fn retry_answer(&self) -> Actions {
if self.role != CallRole::Incoming
|| !self.answered
|| self.status != SignallingStatus::Connecting
{
return Actions::new();
}
actions![
TelephonyAction::SendSignal(Signal::from(SignallingStatus::Connecting)),
TelephonyAction::SendSignal(Signal::from(SignallingStatus::Established)),
]
}
pub fn receive_signal(&mut self, signal: Signal) -> Actions {
if self.role == CallRole::Incoming && !self.answered && matches!(signal, Signal::Status(_))
{
@@ -143,11 +168,13 @@ impl CallState {
}
let mut actions = Actions::new();
self.status = SignallingStatus::Ringing;
self.ensure_profile(&mut actions);
let profile = self.ensure_profile(&mut actions);
let mode = self.ensure_mode(&mut actions);
actions.push(TelephonyAction::PrepareDialingPipelines);
if let Some(profile) = self.profile {
actions.push(TelephonyAction::SendSignal(Signal::from(profile)));
}
actions.push(TelephonyAction::SendSignalPair(
Signal::from(profile),
Signal::PreferredMode(mode),
));
actions.push(TelephonyAction::StartDialTone);
actions
}
@@ -155,9 +182,8 @@ impl CallState {
if self.role == CallRole::Outgoing
&& self.status.wire_value() >= SignallingStatus::Connecting.wire_value()
{
// A delayed/retried CONNECTING must not regress an already
// established call. Re-echo ESTABLISHED so an incoming
// peer can recover if its first acknowledgement was lost.
// Python answers every CONNECTING with ESTABLISHED, and callees
// from rsLXST 0.3.1 and earlier resend CONNECTING until they see it.
return actions![TelephonyAction::SendSignal(Signal::from(
SignallingStatus::Established,
))];
@@ -166,24 +192,24 @@ impl CallState {
return actions![TelephonyAction::IgnoreSignal(signal)];
}
self.status = SignallingStatus::Connecting;
self.squelch_for_opened_pipelines();
let mut actions = actions![
TelephonyAction::ResetDialingPipelines,
TelephonyAction::OpenAudioPipelines,
];
if self.role == CallRole::Outgoing {
// This mirrors Python Telephone.__open_pipelines(): the
// caller echoes ESTABLISHED after observing CONNECTING.
actions.push(TelephonyAction::SendSignal(Signal::from(
SignallingStatus::Established,
)));
// Python's caller signals ESTABLISHED once its pipelines are open,
// which makes its own call status ESTABLISHED.
self.push_status_signal(SignallingStatus::Established, &mut actions);
}
actions
}
Signal::Status(SignallingStatus::Established) => {
if self.status == SignallingStatus::Established {
if self.role != CallRole::Outgoing || self.pipelines_started {
return actions![TelephonyAction::IgnoreSignal(signal)];
}
self.status = SignallingStatus::Established;
self.pipelines_started = true;
actions![TelephonyAction::StartAudioPipelines]
}
Signal::PreferredProfile(profile) => {
@@ -198,10 +224,45 @@ impl CallState {
actions![TelephonyAction::SelectProfile(profile)]
}
}
Signal::PreferredMode(mode) => {
if self.status == SignallingStatus::Established {
if self.remote_mode_follow_disabled || self.mode == Some(mode) {
return Actions::new();
}
let Some(known) = CallMode::from_wire(mode) else {
return Actions::new();
};
self.mode = Some(mode);
self.apply_mode_squelch(known);
actions![TelephonyAction::SwitchMode(known)]
} else {
self.mode = Some(mode);
match CallMode::from_wire(mode) {
Some(known) => {
self.apply_mode_squelch(known);
actions![TelephonyAction::SelectMode(known)]
}
None => Actions::new(),
}
}
}
Signal::Raw(_) => actions![TelephonyAction::IgnoreSignal(signal)],
}
}
/// Switch the mode of an established call and signal it, as Python `switch_mode`.
pub fn switch_mode(&mut self, mode: CallMode) -> Actions {
if self.status != SignallingStatus::Established || self.mode == Some(mode.wire_value()) {
return Actions::new();
}
self.mode = Some(mode.wire_value());
self.apply_mode_squelch(mode);
actions![
TelephonyAction::SendSignal(Signal::from(mode)),
TelephonyAction::SwitchMode(mode),
]
}
pub fn switch_profile(&mut self, profile: Profile) -> Actions {
if self.profile == Some(profile) {
return Actions::new();
@@ -233,13 +294,35 @@ impl CallState {
actions.push(TelephonyAction::TeardownLink);
self.status = SignallingStatus::Available;
self.answered = false;
self.pipelines_started = false;
actions
}
fn ensure_profile(&mut self, actions: &mut Actions) {
fn ensure_profile(&mut self, actions: &mut Actions) -> Profile {
let profile = self.profile.unwrap_or(Profile::DEFAULT);
self.profile = Some(profile);
actions.push(TelephonyAction::SelectProfile(profile));
profile
}
/// Python `__select_call_mode`: an unset mode becomes the default, an unknown one is kept.
fn ensure_mode(&mut self, actions: &mut Actions) -> u8 {
let mode = self.mode.unwrap_or(CallMode::DEFAULT.wire_value());
self.mode = Some(mode);
if let Some(known) = CallMode::from_wire(mode) {
self.apply_mode_squelch(known);
actions.push(TelephonyAction::SelectMode(known));
}
mode
}
fn apply_mode_squelch(&mut self, mode: CallMode) {
self.transmit_squelched = mode == CallMode::HalfDuplex;
}
/// Python builds a new Packetizer when pipelines open and squelches it only for half duplex.
fn squelch_for_opened_pipelines(&mut self) {
self.transmit_squelched = self.mode == Some(CallMode::HalfDuplex.wire_value());
}
fn push_status_signal(&mut self, status: SignallingStatus, actions: &mut Actions) {
+13 -1
View File
@@ -1,6 +1,7 @@
// Shared directly with lxst-embedded. The enclosing wire module supplies its
// own error type; wire identifiers and conversions have one implementation.
use crate::profile::{Profile, SignallingStatus};
use crate::profile::{CallMode, Profile, SignallingStatus};
const PREFERRED_MODE_BASE: u32 = 0xF0;
const PREFERRED_PROFILE_BASE: u32 = 0xFF;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
@@ -36,6 +37,8 @@ impl CodecKind {
pub enum Signal {
Status(SignallingStatus),
PreferredProfile(Profile),
/// Raw mode byte after `0xF0`; unknown modes are carried, not rejected.
PreferredMode(u8),
Raw(u32),
}
@@ -44,6 +47,7 @@ impl Signal {
match self {
Self::Status(status) => status.wire_value(),
Self::PreferredProfile(profile) => PREFERRED_PROFILE_BASE + profile.wire_value(),
Self::PreferredMode(mode) => PREFERRED_MODE_BASE + mode as u32,
Self::Raw(value) => value,
}
}
@@ -58,6 +62,8 @@ impl Signal {
} else {
Self::Raw(value)
}
} else if value >= PREFERRED_MODE_BASE {
Self::PreferredMode((value - PREFERRED_MODE_BASE) as u8)
} else {
Self::Raw(value)
}
@@ -70,6 +76,12 @@ impl From<SignallingStatus> for Signal {
}
}
impl From<CallMode> for Signal {
fn from(value: CallMode) -> Self {
Self::PreferredMode(value.wire_value())
}
}
impl From<Profile> for Signal {
fn from(value: Profile) -> Self {
Self::PreferredProfile(value)
+229 -20
View File
@@ -12,6 +12,11 @@ impl TelephonyCall {
state: CallState::outgoing(profile),
}
}
pub fn outgoing_with_mode(profile: Option<Profile>, mode: Option<CallMode>) -> Self {
Self {
state: CallState::outgoing_with_mode(profile, mode),
}
}
pub fn incoming() -> Self {
Self {
state: CallState::incoming(),
@@ -29,6 +34,24 @@ impl TelephonyCall {
pub const fn answered(&self) -> bool {
self.state.answered()
}
pub const fn audio_started(&self) -> bool {
self.state.audio_started()
}
pub const fn mode(&self) -> Option<CallMode> {
self.state.mode()
}
pub const fn transmit_squelched(&self) -> bool {
self.state.transmit_squelched()
}
pub fn set_transmit_squelched(&mut self, squelched: bool) {
self.state.set_transmit_squelched(squelched);
}
pub fn disable_remote_mode_follow(&mut self) {
self.state.disable_remote_mode_follow();
}
pub fn switch_mode(&mut self, mode: CallMode) -> Vec<TelephonyAction> {
self.state.switch_mode(mode).as_slice().to_vec()
}
pub fn incoming_link_established(line_busy: bool) -> Vec<TelephonyAction> {
CallState::incoming_link_established(line_busy)
.as_slice()
@@ -43,9 +66,6 @@ impl TelephonyCall {
pub fn answer(&mut self) -> Vec<TelephonyAction> {
self.state.answer().as_slice().to_vec()
}
pub fn retry_answer(&self) -> Vec<TelephonyAction> {
self.state.retry_answer().as_slice().to_vec()
}
pub fn receive_signal(&mut self, signal: Signal) -> Vec<TelephonyAction> {
self.state.receive_signal(signal).as_slice().to_vec()
}
@@ -93,22 +113,27 @@ mod tests {
);
let answer = call.answer();
assert_eq!(call.status(), SignallingStatus::Connecting);
assert_eq!(call.status(), SignallingStatus::Established);
assert!(call.answered());
assert_eq!(call.profile(), Some(Profile::DEFAULT));
assert_eq!(call.mode(), Some(CallMode::FullDuplex));
assert_eq!(
answer,
vec![
TelephonyAction::SelectProfile(Profile::DEFAULT),
TelephonyAction::SelectMode(CallMode::FullDuplex),
TelephonyAction::SendSignal(Signal::from(SignallingStatus::Connecting)),
TelephonyAction::OpenAudioPipelines,
TelephonyAction::SendSignal(Signal::from(SignallingStatus::Established)),
TelephonyAction::StartAudioPipelines,
]
);
assert_eq!(
call.receive_signal(Signal::from(SignallingStatus::Established)),
vec![TelephonyAction::StartAudioPipelines]
vec![TelephonyAction::IgnoreSignal(Signal::from(
SignallingStatus::Established
))]
);
assert_eq!(call.status(), SignallingStatus::Established);
}
@@ -128,8 +153,12 @@ mod tests {
ringing,
vec![
TelephonyAction::SelectProfile(Profile::DEFAULT),
TelephonyAction::SelectMode(CallMode::FullDuplex),
TelephonyAction::PrepareDialingPipelines,
TelephonyAction::SendSignal(Signal::from(Profile::DEFAULT)),
TelephonyAction::SendSignalPair(
Signal::from(Profile::DEFAULT),
Signal::from(CallMode::FullDuplex),
),
TelephonyAction::StartDialTone,
]
);
@@ -150,29 +179,18 @@ mod tests {
}
#[test]
fn answer_retry_and_established_echo_are_bounded_idempotent_transitions() {
fn callee_is_established_on_answer_and_ignores_the_caller_echo() {
let mut incoming = TelephonyCall::incoming();
incoming.caller_identified(false, true);
incoming.answer();
assert_eq!(
incoming.retry_answer(),
vec![
TelephonyAction::SendSignal(Signal::from(SignallingStatus::Connecting)),
TelephonyAction::SendSignal(Signal::from(SignallingStatus::Established)),
]
);
assert_eq!(
incoming.receive_signal(Signal::from(SignallingStatus::Established)),
vec![TelephonyAction::StartAudioPipelines]
);
assert!(incoming.retry_answer().is_empty());
assert_eq!(incoming.status(), SignallingStatus::Established);
assert_eq!(
incoming.receive_signal(Signal::from(SignallingStatus::Established)),
vec![TelephonyAction::IgnoreSignal(Signal::from(
SignallingStatus::Established
))]
);
assert!(incoming.answer().is_empty());
let mut outgoing = TelephonyCall::outgoing(Some(Profile::DEFAULT));
outgoing.receive_signal(Signal::from(SignallingStatus::Available));
@@ -188,6 +206,197 @@ mod tests {
assert_eq!(outgoing.status(), SignallingStatus::Established);
}
#[test]
fn caller_is_established_after_connecting_and_starts_audio_on_callee_established() {
let mut call = TelephonyCall::outgoing(None);
call.receive_signal(Signal::from(SignallingStatus::Available));
call.receive_signal(Signal::from(SignallingStatus::Ringing));
call.receive_signal(Signal::from(SignallingStatus::Connecting));
assert_eq!(call.status(), SignallingStatus::Established);
assert_eq!(
call.receive_signal(Signal::from(SignallingStatus::Established)),
vec![TelephonyAction::StartAudioPipelines]
);
assert_eq!(
call.receive_signal(Signal::from(SignallingStatus::Established)),
vec![TelephonyAction::IgnoreSignal(Signal::from(
SignallingStatus::Established
))]
);
}
fn signals(packet: &str) -> Vec<Signal> {
crate::LxstPacket::decode(&hex::decode(packet).unwrap())
.unwrap()
.signals
}
fn sent(actions: &[TelephonyAction]) -> Vec<Vec<u8>> {
actions
.iter()
.filter_map(|action| match action {
TelephonyAction::SendSignal(signal) => Some(vec![*signal]),
TelephonyAction::SendSignalPair(first, second) => Some(vec![*first, *second]),
_ => None,
})
.map(|signals| crate::LxstPacket::signalling(signals).encode().unwrap())
.collect()
}
// Packets recorded from the rsLXST 0.3.1 call state machine; it decodes the mode
// byte of a profile-and-mode packet as an ignored raw signal.
#[test]
fn caller_completes_a_call_with_a_0_3_1_callee() {
let mut call = TelephonyCall::outgoing(None);
let mut out = Vec::new();
for packet in ["81009103", "81009104", "81009105", "81009106", "81009105"] {
for signal in signals(packet) {
out.extend(sent(&call.receive_signal(signal)));
}
}
assert_eq!(
out.iter().map(hex::encode).collect::<Vec<_>>(),
["810092cd013fccf1", "81009106", "81009106"]
);
assert_eq!(call.status(), SignallingStatus::Established);
assert!(call.audio_started());
}
#[test]
fn callee_completes_a_call_with_a_0_3_1_caller() {
let mut call = TelephonyCall::incoming();
call.caller_identified(false, true);
for signal in signals("810091cd013f") {
call.receive_signal(signal);
}
assert_eq!(
sent(&call.answer())
.iter()
.map(hex::encode)
.collect::<Vec<_>>(),
["81009105", "81009106"]
);
for signal in signals("81009106") {
assert!(matches!(
call.receive_signal(signal).as_slice(),
[TelephonyAction::IgnoreSignal(_)]
));
}
assert_eq!(call.status(), SignallingStatus::Established);
assert_eq!(call.profile(), Some(Profile::QualityMedium));
assert_eq!(call.mode(), Some(CallMode::FullDuplex));
}
#[test]
fn ringing_sends_profile_and_requested_mode_in_one_packet() {
let mut call = TelephonyCall::outgoing_with_mode(
Some(Profile::BandwidthLow),
Some(CallMode::HalfDuplex),
);
call.receive_signal(Signal::from(SignallingStatus::Available));
let ringing = call.receive_signal(Signal::from(SignallingStatus::Ringing));
assert!(ringing.contains(&TelephonyAction::SendSignalPair(
Signal::from(Profile::BandwidthLow),
Signal::from(CallMode::HalfDuplex),
)));
assert!(call.transmit_squelched());
assert_eq!(Signal::from(CallMode::HalfDuplex).wire_value(), 0xF2);
}
#[test]
fn mode_signal_before_answer_is_selected_but_status_is_ignored() {
let mut call = TelephonyCall::incoming();
call.caller_identified(false, true);
assert_eq!(
call.receive_signal(Signal::from_wire(0xF2)),
vec![TelephonyAction::SelectMode(CallMode::HalfDuplex)]
);
assert!(call.transmit_squelched());
assert_eq!(
call.receive_signal(Signal::from(SignallingStatus::Connecting)),
vec![TelephonyAction::IgnoreSignal(Signal::from(
SignallingStatus::Connecting
))]
);
let answer = call.answer();
assert!(answer.contains(&TelephonyAction::SelectMode(CallMode::HalfDuplex)));
assert!(call.transmit_squelched());
}
#[test]
fn unknown_mode_is_stored_without_squelch_change_or_error() {
let mut call = TelephonyCall::incoming();
call.caller_identified(false, true);
assert!(call.receive_signal(Signal::from_wire(0xF3)).is_empty());
assert_eq!(call.mode(), None);
assert!(!call.transmit_squelched());
call.answer();
assert!(!call.transmit_squelched());
assert!(call.receive_signal(Signal::from_wire(0xF0)).is_empty());
}
#[test]
fn opening_pipelines_squelches_only_for_half_duplex() {
let mut callee = TelephonyCall::incoming();
callee.caller_identified(false, true);
callee.receive_signal(Signal::from(CallMode::HalfDuplex));
assert!(callee.receive_signal(Signal::from_wire(0xF5)).is_empty());
assert!(callee.transmit_squelched());
callee.answer();
assert!(!callee.transmit_squelched());
let mut caller = TelephonyCall::outgoing(None);
caller.receive_signal(Signal::from(SignallingStatus::Available));
caller.receive_signal(Signal::from(SignallingStatus::Ringing));
caller.set_transmit_squelched(true);
caller.receive_signal(Signal::from(SignallingStatus::Connecting));
assert!(!caller.transmit_squelched());
let mut half_duplex = TelephonyCall::outgoing_with_mode(None, Some(CallMode::HalfDuplex));
half_duplex.receive_signal(Signal::from(SignallingStatus::Available));
half_duplex.receive_signal(Signal::from(SignallingStatus::Ringing));
half_duplex.receive_signal(Signal::from(SignallingStatus::Connecting));
assert!(half_duplex.transmit_squelched());
}
#[test]
fn established_mode_switch_follows_remote_unless_disabled() {
let mut call = TelephonyCall::incoming();
call.caller_identified(false, true);
call.answer();
assert_eq!(
call.receive_signal(Signal::from(CallMode::HalfDuplex)),
vec![TelephonyAction::SwitchMode(CallMode::HalfDuplex)]
);
assert!(call.transmit_squelched());
assert!(
call.receive_signal(Signal::from(CallMode::HalfDuplex))
.is_empty()
);
call.disable_remote_mode_follow();
assert!(
call.receive_signal(Signal::from(CallMode::FullDuplex))
.is_empty()
);
assert!(call.transmit_squelched());
assert_eq!(
call.switch_mode(CallMode::FullDuplex),
vec![
TelephonyAction::SendSignal(Signal::from(CallMode::FullDuplex)),
TelephonyAction::SwitchMode(CallMode::FullDuplex),
]
);
assert!(!call.transmit_squelched());
assert!(call.switch_mode(CallMode::FullDuplex).is_empty());
}
#[test]
fn local_mode_switch_requires_established_call() {
let mut call = TelephonyCall::outgoing(None);
assert!(call.switch_mode(CallMode::HalfDuplex).is_empty());
assert_eq!(call.mode(), None);
}
#[test]
fn profile_signals_select_or_switch_profile_by_call_status() {
let mut call = TelephonyCall::outgoing(None);
@@ -0,0 +1,16 @@
28afe918bca8941139ab60f9598427e7ae4741723a388b9907d9eb8c4c7d301b337931e7ee
98b066163f47095412beadde8cb2f6a7c5df75e88d045d1e36272773afcb27b26be0d70dee
98afe91a1c2d353ffebd6f412832c22d1cbd6c385de5967c27342e8cb160865b694472efee
98b04dcf34ff809b86a63aae0319326095c1ab2eb02d7203ace62921c6b25a99e5e135ee
98aca7b59d0483411f3e7a1882d257dfb0b842f92f88fa1cb0b3c920ea9ce7a1282031ee
98afe918bca8941139ab60f9598427e7ae4741723a388b9907d9eb8c4c7d301b337931e7ee
98b066f13f47095412beadde8cb2f6a7c5df75e88d045d1e36272773afcb27b26be0ee0d98
e9afd71a1c2d353ffebd6f412832c22d1cbd6c385de5967c27342e8cb160865b694472efee
98b04dcf34ff809b86a63aae0319326095c1ab2e002d7203ace62921c6b25a99e5e136ee
98aca7b59d0483411f3e7a1882d257dfb0b842f92f88fa1cb0b3c920ea9ce7a1282031ee
98afe918bca8941139ab60f9598427e7ae4741723a388b9907d9eb8c4c7d301b337931e7ee
98b066f13f47095412beadde8cb2f6a7c5df75e88d045d1e36272773afcb27b26be0d70dee
98afe91a1c2d353ffebd6f412832c22d1cbd6c385de5967c27342e8cb160865b694472efee
98b04dcf34ff809b86a63aae0319326095c1ab2eb02d7203ace62921c6b25a99e5e135ee
98aca7b59d0483411f3e7a1882d257dfb0b842f92f88fa1cb0b3c920ea9ce7a12820323d
00000018bca8941139ab60f9598427e7ae4741723a388b9907d9eb8c4c7d302d337931e7ee
+2 -2
View File
@@ -9,7 +9,7 @@ description = "Bounded no_std LXST framing and authenticated PTT session policy"
[dependencies]
thiserror = { version = "2", default-features = false }
lxst-codec2 = { path = "../lxst-codec2", version = "0.3.1" }
lxst-codec2 = { path = "../lxst-codec2", version = "0.4.0" }
[dev-dependencies]
lxst-core = { path = "../lxst-core", version = "0.3.1" }
lxst-core = { path = "../lxst-core", version = "0.4.0" }
+4 -2
View File
@@ -17,14 +17,16 @@ pub use call_state::CallState;
#[path = "../../lxst-core/src/shared/call_types.rs"]
mod call_types;
pub use call_types::{CallRole, TelephonyAction};
pub use profile::{AudioCodec, OpusApplication, OpusProfile, Profile, SignallingStatus};
pub use profile::{AudioCodec, CallMode, OpusApplication, OpusProfile, Profile, SignallingStatus};
pub use wire::{Codec2Mode, CodecKind, Signal};
#[path = "../../lxst-core/src/shared/codec2.rs"]
mod codec2;
pub use codec2::{Codec2Backend, Codec2PacketCodec, Codec2PacketError};
mod session;
pub use session::{ConfigError, EndReason, Event, Events, ProfileSet, Session, SessionConfig};
pub use session::{
CallTimes, ConfigError, EndReason, Event, Events, ProfileSet, Session, SessionConfig,
};
impl Codec2Backend for &mut lxst_codec2::Codec {
type Error = lxst_codec2::Error;
+52 -27
View File
@@ -1,10 +1,11 @@
//! Local admission and microphone policy around the trusted call transitions.
//! No extra wire extension, turn token or directional capability is invented.
use crate::{Actions, CallRole, CallState, Profile, Signal, SignallingStatus, TelephonyAction};
use crate::{
Actions, CallMode, CallRole, CallState, Profile, Signal, SignallingStatus, TelephonyAction,
};
/// Local limit for an incoming link to identify its caller; Python has no counterpart.
const SETUP_MS: u64 = 30_000;
const RING_MS: u64 = 90_000;
const ANSWER_MS: u64 = 10_000;
const PROFILE_MS: u64 = 5_000;
pub const TALK_LIMIT_MS: u64 = 30_000;
@@ -24,6 +25,29 @@ impl ProfileSet {
}
}
/// Call setup limits in milliseconds; the defaults are Python `Telephone`'s.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct CallTimes {
/// Python `CONNECT_TIME` (`set_connect_timeout`): the callee must ring within this time of the call start.
pub connect_ms: u64,
/// Python `wait_time`, measured from the start of the outgoing call.
pub wait_ms: u64,
/// Python `ring_time`.
pub ring_ms: u64,
}
impl CallTimes {
pub const DEFAULT: Self = Self {
connect_ms: 5_000,
wait_ms: 70_000,
ring_ms: 60_000,
};
}
impl Default for CallTimes {
fn default() -> Self {
Self::DEFAULT
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct SessionConfig {
/// The embedder must qualify each selected codec and route before admission.
@@ -31,6 +55,7 @@ pub struct SessionConfig {
pub preferred: Profile,
pub capture: bool,
pub playback: bool,
pub times: CallTimes,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ConfigError {
@@ -94,11 +119,10 @@ pub struct Session {
audio_generation: u32,
ended: Option<EndReason>,
deadline: u64,
connect_deadline: Option<u64>,
talk_started: u64,
suggested: bool,
profile_deadline: Option<u64>,
answer_retry: u64,
retries: u8,
}
impl Session {
pub fn new(role: CallRole, config: SessionConfig, now_ms: u64) -> Result<Self, ConfigError> {
@@ -123,12 +147,17 @@ impl Session {
input_down: false,
audio_generation: 1,
ended: None,
deadline: now_ms.saturating_add(SETUP_MS),
deadline: now_ms.saturating_add(match role {
CallRole::Incoming => SETUP_MS,
CallRole::Outgoing => config.times.wait_ms,
}),
connect_deadline: match role {
CallRole::Incoming => None,
CallRole::Outgoing => Some(now_ms.saturating_add(config.times.connect_ms)),
},
talk_started: 0,
suggested: false,
profile_deadline: None,
answer_retry: 0,
retries: 0,
})
}
pub const fn status(&self) -> SignallingStatus {
@@ -137,6 +166,9 @@ impl Session {
pub const fn profile(&self) -> Option<Profile> {
self.call.profile()
}
pub const fn mode(&self) -> Option<CallMode> {
self.call.mode()
}
pub const fn ended(&self) -> Option<EndReason> {
self.ended
}
@@ -153,6 +185,7 @@ impl Session {
&& self.ready
&& self.profile_deadline.is_none()
&& self.call.status() == SignallingStatus::Established
&& self.call.audio_started()
}
pub fn playback_allowed(&self) -> bool {
self.media_ready() && self.config.playback && !self.transmitting
@@ -178,7 +211,7 @@ impl Session {
}
self.verified = true;
if self.call.role() == CallRole::Incoming {
self.deadline = now_ms.saturating_add(RING_MS);
self.deadline = now_ms.saturating_add(self.config.times.ring_ms);
events.transitions(self.call.caller_identified(false, true));
events.push(Event::Transition(TelephonyAction::SendSignal(
self.config.preferred.into(),
@@ -186,7 +219,7 @@ impl Session {
}
events
}
pub fn answer(&mut self, now_ms: u64) -> Events {
pub fn answer(&mut self, _now_ms: u64) -> Events {
let mut events = Events::new();
if self.ended.is_some()
|| !self.verified
@@ -195,8 +228,6 @@ impl Session {
{
return events;
}
self.deadline = now_ms.saturating_add(ANSWER_MS);
self.answer_retry = now_ms.saturating_add(1000);
events.transitions(self.call.answer());
events
}
@@ -220,6 +251,7 @@ impl Session {
return events;
}
self.profile_deadline = None;
self.suggested = false;
if self.call.profile() != Some(profile) {
self.stop_capture(&mut events);
self.ready = false;
@@ -273,11 +305,8 @@ impl Session {
if !allowed {
return events;
}
if status == SignallingStatus::Ringing && current != status {
self.deadline = now_ms.saturating_add(RING_MS);
}
if status == SignallingStatus::Connecting && current == SignallingStatus::Ringing {
self.deadline = now_ms.saturating_add(ANSWER_MS);
if status == SignallingStatus::Ringing {
self.connect_deadline = None;
}
}
events.transitions(self.call.receive_signal(signal));
@@ -352,20 +381,16 @@ impl Session {
if self.status() != SignallingStatus::Established && now_ms >= self.deadline {
return self.end(EndReason::Timeout);
}
if self
.connect_deadline
.is_some_and(|deadline| now_ms >= deadline)
{
return self.end(EndReason::Timeout);
}
if self.transmitting && now_ms.saturating_sub(self.talk_started) >= TALK_LIMIT_MS {
self.stop_capture(&mut events);
events.push(Event::FlushMedia);
}
if self.call.role() == CallRole::Incoming
&& self.call.answered()
&& self.status() == SignallingStatus::Connecting
&& now_ms >= self.answer_retry
&& self.retries < 3
{
self.retries += 1;
self.answer_retry = now_ms.saturating_add(1000);
events.transitions(self.call.retry_answer());
}
events
}
pub fn end(&mut self, reason: EndReason) -> Events {
+130 -18
View File
@@ -1,6 +1,6 @@
use lxst_embedded::{
CallRole, CallState, EndReason, Event, Profile, ProfileSet, Session, SessionConfig, Signal,
SignallingStatus as Status, TelephonyAction as Action,
CallMode, CallRole, CallState, CallTimes, EndReason, Event, Profile, ProfileSet, Session,
SessionConfig, Signal, SignallingStatus as Status, TelephonyAction as Action,
};
#[test]
@@ -24,14 +24,22 @@ fn crossed_profile_offers_converge_before_media_without_an_echo_loop() {
for event in receiver.peer_verified(1).as_slice() {
if let Event::Transition(Action::SendSignal(signal)) = event {
for action in caller.receive_signal(*signal).as_slice() {
if let Action::SendSignal(signal) = action {
in_flight.push(*signal);
match action {
Action::SendSignal(signal) => in_flight.push(*signal),
Action::SendSignalPair(first, second) => {
in_flight.push(*first);
in_flight.push(*second);
}
_ => {}
}
}
}
}
assert_eq!(caller.profile(), Some(preferred));
assert_eq!(in_flight, vec![Signal::from(offered)]);
assert_eq!(
in_flight,
vec![Signal::from(offered), Signal::from(CallMode::FullDuplex)]
);
for signal in in_flight {
for event in receiver.receive_signal(signal, 2).as_slice() {
if let Event::Transition(Action::SendSignal(signal)) = event {
@@ -72,6 +80,7 @@ fn config() -> SessionConfig {
preferred: Profile::BandwidthVeryLow,
capture: true,
playback: true,
times: CallTimes::default(),
}
}
fn connect(role: CallRole) -> Session {
@@ -200,26 +209,35 @@ fn unsupported_profile_has_one_bounded_offer_then_closes() {
session.receive_signal(Profile::QualityHigh.into(), 20);
session.receive_signal(Profile::BandwidthVeryLow.into(), 21);
assert!(session.media_ready());
session.receive_signal(Profile::QualityHigh.into(), 22);
let events = session.receive_signal(Profile::QualityHigh.into(), 22);
assert_eq!(session.ended(), None);
assert!(
events
.as_slice()
.contains(&Event::Transition(Action::SendSignal(
Profile::BandwidthVeryLow.into()
)))
);
session.receive_signal(Profile::QualityMax.into(), 23);
assert_eq!(session.ended(), Some(EndReason::ProfileUnsupported));
}
#[test]
fn retries_are_bounded_and_one_direction_devices_work() {
fn answer_establishes_without_retries_and_one_direction_devices_work() {
let mut session = Session::new(CallRole::Incoming, config(), 0).unwrap();
session.link_established();
session.peer_verified(1);
session.answer(2);
for n in 1..=3 {
let events = session.tick(2 + n * 1000);
assert_eq!(events.as_slice().len(), 2);
assert_eq!(
events.as_slice()[1],
Event::Transition(Action::SendSignal(Status::Established.into()))
);
let answer = session.answer(2);
let sent = answer
.as_slice()
.iter()
.filter(|event| matches!(event, Event::Transition(Action::SendSignal(_))))
.count();
assert_eq!(sent, 2);
assert_eq!(session.status(), Status::Established);
for n in 1..=20 {
assert!(session.tick(2 + n * 1000).as_slice().is_empty());
}
assert!(session.tick(4002).as_slice().is_empty());
session.tick(10002);
assert_eq!(session.ended(), Some(EndReason::Timeout));
assert_eq!(session.ended(), None);
for (capture, playback) in [(true, false), (false, true)] {
let mut cfg = config();
cfg.capture = capture;
@@ -304,3 +322,97 @@ fn authenticated_matching_media_confirms_standard_profile_fallback_without_echo(
ringing.tick(5100);
assert_eq!(ringing.ended(), Some(EndReason::ProfileUnsupported));
}
#[test]
fn incoming_ring_times_out_after_python_ring_time() {
let mut session = Session::new(CallRole::Incoming, config(), 0).unwrap();
session.link_established();
session.peer_verified(0);
session.tick(59_999);
assert_eq!(session.ended(), None);
session.tick(60_000);
assert_eq!(session.ended(), Some(EndReason::Timeout));
}
#[test]
fn outgoing_call_ends_when_callee_does_not_ring_within_connect_time() {
let mut session = Session::new(CallRole::Outgoing, config(), 0).unwrap();
session.link_established();
session.peer_verified(1);
session.receive_signal(Status::Available.into(), 100);
session.tick(4_999);
assert_eq!(session.ended(), None);
session.tick(5_000);
assert_eq!(session.ended(), Some(EndReason::Timeout));
}
#[test]
fn outgoing_wait_time_runs_from_call_start_once_ringing() {
let mut session = Session::new(CallRole::Outgoing, config(), 0).unwrap();
session.link_established();
session.peer_verified(1);
session.receive_signal(Status::Available.into(), 100);
session.receive_signal(Status::Ringing.into(), 4_000);
session.tick(69_999);
assert_eq!(session.ended(), None);
session.tick(70_000);
assert_eq!(session.ended(), Some(EndReason::Timeout));
}
#[test]
fn preferred_mode_signal_is_recorded_by_the_session() {
let mut session = Session::new(CallRole::Incoming, config(), 0).unwrap();
session.link_established();
session.peer_verified(1);
session.receive_signal(Signal::from_wire(0xF2), 2);
assert_eq!(session.mode(), Some(CallMode::HalfDuplex));
assert_eq!(session.ended(), None);
}
#[test]
fn configured_call_times_replace_the_python_defaults() {
let slow = SessionConfig {
times: CallTimes {
connect_ms: 20_000,
wait_ms: 200_000,
ring_ms: 150_000,
},
..config()
};
let mut outgoing = Session::new(CallRole::Outgoing, slow, 0).unwrap();
outgoing.link_established();
outgoing.peer_verified(1);
outgoing.tick(19_999);
assert_eq!(outgoing.ended(), None);
outgoing.receive_signal(Status::Available.into(), 19_999);
outgoing.receive_signal(Status::Ringing.into(), 19_999);
outgoing.tick(199_999);
assert_eq!(outgoing.ended(), None);
outgoing.tick(200_000);
assert_eq!(outgoing.ended(), Some(EndReason::Timeout));
let mut incoming = Session::new(CallRole::Incoming, slow, 0).unwrap();
incoming.link_established();
incoming.peer_verified(0);
incoming.tick(149_999);
assert_eq!(incoming.ended(), None);
incoming.tick(150_000);
assert_eq!(incoming.ended(), Some(EndReason::Timeout));
}
#[test]
fn caller_keeps_call_past_wait_time_when_callee_established_is_lost() {
let mut session = Session::new(CallRole::Outgoing, config(), 0).unwrap();
session.link_established();
session.peer_verified(1);
for status in [Status::Available, Status::Ringing, Status::Connecting] {
session.receive_signal(status.into(), 100);
}
session.audio_ready(session.audio_generation(), true);
assert_eq!(session.status(), Status::Established);
assert!(!session.media_ready());
session.tick(70_001);
assert_eq!(session.ended(), None);
session.receive_signal(Status::Established.into(), 70_002);
assert!(session.media_ready());
}
+17 -3
View File
@@ -123,7 +123,22 @@ fn shared_transitions_retain_full_rust_actions() {
use lxst_embedded::{CallState, SignallingStatus};
let mut embedded = CallState::outgoing(Some(Profile::BandwidthVeryLow));
let mut host = lxst_core::TelephonyCall::outgoing(Some(lxst_core::Profile::BandwidthVeryLow));
for signal in [3, 4, 5, 6, 5, 6, 0x11f, 0x12f, 0, 1, u32::MAX] {
for signal in [
3,
4,
5,
6,
5,
6,
0x11f,
0x12f,
0xf1,
0xf2,
0xf3,
0,
1,
u32::MAX,
] {
let a = embedded.receive_signal(Signal::from_wire(signal));
let b = host.receive_signal(lxst_core::Signal::from_wire(signal));
assert_eq!(format!("{:?}", a.as_slice()), format!("{b:?}"));
@@ -132,13 +147,12 @@ fn shared_transitions_retain_full_rust_actions() {
// Explore combinations including adversarial order to prove the shared
// fixed action bound; session policy separately restricts allowed ordering.
for first in 0..512 {
for second in [0, 3, 4, 5, 6, 0x11f, 0x12f, 0x13f] {
for second in [0, 3, 4, 5, 6, 0x11f, 0x12f, 0x13f, 0xf1, 0xf2] {
let mut call = CallState::incoming();
call.caller_identified(false, true);
call.receive_signal(Signal::from_wire(first));
call.answer();
call.receive_signal(Signal::from_wire(second));
call.retry_answer();
call.hangup(false);
assert_eq!(call.status(), SignallingStatus::Available);
}
+2 -1
View File
@@ -9,7 +9,7 @@ publish.workspace = true
[dependencies]
bytes.workspace = true
lxst-core.workspace = true
lxst-codec2 = { path = "../lxst-codec2", version = "0.3.1" }
lxst-codec2 = { path = "../lxst-codec2", version = "0.4.0" }
lxst-rns.workspace = true
rns-crypto.workspace = true
rns-identity.workspace = true
@@ -21,6 +21,7 @@ thiserror.workspace = true
tokio.workspace = true
[dev-dependencies]
tokio = { workspace = true, features = ["test-util"] }
hex.workspace = true
rns-interface.workspace = true
serial_test.workspace = true
File diff suppressed because it is too large. Load diff
+77 -32
View File
@@ -3,8 +3,8 @@
use crate::Error;
use lxst_codec2::{Codec, Mode};
use lxst_core::{
AudioCodec, Codec2Backend, Codec2Mode, Codec2PacketCodec, CodecKind, Frame, OpusDecoderState,
OpusEncoderState, Profile, RawAudioFrame,
AudioCodec, Codec2Backend, Codec2Mode, Codec2PacketCodec, CodecKind, Frame, OpusEncoderState,
OpusPacketDecoder, Profile, RawAudioFrame,
};
struct Native(Box<Codec>);
@@ -74,33 +74,11 @@ impl Codec2Audio {
result?;
Ok(Frame::new(CodecKind::Codec2, payload))
}
fn decode(&mut self, frame: &Frame) -> Result<RawAudioFrame, Error> {
if frame.codec != CodecKind::Codec2 {
return Err(Error::Audio("unexpected media codec".into()));
}
self.codec
.decode_into(&frame.payload, &mut self.pcm)
.map_err(|e| Error::Audio(e.to_string()))?;
let samples = self
.pcm
.iter()
.map(|v| f32::from(*v) / 32768.0)
.collect::<Vec<_>>();
self.pcm.fill(0);
Ok(RawAudioFrame {
channels: 1,
samples,
})
}
}
pub(crate) enum AudioEncoder {
Opus(Box<OpusEncoderState>),
Codec2(Codec2Audio),
}
pub(crate) enum AudioDecoder {
Opus(Box<OpusDecoderState>),
Codec2(Codec2Audio),
}
impl AudioEncoder {
pub(crate) fn new(profile: Profile) -> Result<Self, Error> {
match profile.audio_codec() {
@@ -115,17 +93,84 @@ impl AudioEncoder {
}
}
}
impl AudioDecoder {
pub(crate) fn new(profile: Profile) -> Result<Self, Error> {
match profile.audio_codec() {
AudioCodec::Opus(_) => Ok(Self::Opus(Box::new(OpusDecoderState::new(profile)?))),
AudioCodec::Codec2(_) => Ok(Self::Codec2(Codec2Audio::new(profile)?)),
const CODEC2_SAMPLE_RATE_HZ: u32 = 8_000;
/// Follows the codec and Codec2 mode of each received frame, as Python `LinkSource`
/// does, and converts the output to the local profile's sample rate and channels.
pub(crate) struct ReceiveDecoder {
sample_rate_hz: u32,
channels: u8,
opus: Option<OpusPacketDecoder>,
codec2: Vec<(Codec2Mode, Box<Codec>)>,
}
impl ReceiveDecoder {
pub(crate) fn new(profile: Profile) -> Self {
Self {
sample_rate_hz: profile.sample_rate_hz(),
channels: profile.channels(),
opus: None,
codec2: Vec::new(),
}
}
pub(crate) fn decode_frame(&mut self, frame: &Frame) -> Result<RawAudioFrame, Error> {
match self {
Self::Opus(codec) => Ok(codec.decode_frame(frame)?),
Self::Codec2(codec) => codec.decode(frame),
match frame.codec {
CodecKind::Opus => {
if self.opus.is_none() {
self.opus = Some(OpusPacketDecoder::new(self.sample_rate_hz, self.channels)?);
}
let decoder = self
.opus
.as_mut()
.expect("Opus decoder exists after creation");
Ok(decoder.decode_packet(&frame.payload)?)
}
CodecKind::Codec2 => self.decode_codec2(&frame.payload),
other => Err(Error::Audio(format!("unexpected media codec {other:?}"))),
}
}
fn decode_codec2(&mut self, payload: &[u8]) -> Result<RawAudioFrame, Error> {
let (&header, bytes) = payload
.split_first()
.ok_or_else(|| Error::Audio("empty Codec2 frame".into()))?;
let wire_mode =
Codec2Mode::from_header(header).map_err(|error| Error::Audio(error.to_string()))?;
let mode = match wire_mode {
Codec2Mode::Mode700C => Mode::Rate700C,
Codec2Mode::Mode1600 => Mode::Rate1600,
Codec2Mode::Mode3200 => Mode::Rate3200,
other => {
return Err(Error::Audio(format!(
"unsupported native Codec2 mode {other:?}"
)));
}
};
let index = match self.codec2.iter().position(|(m, _)| *m == wire_mode) {
Some(index) => index,
None => {
let mut storage = Box::<Codec>::new_uninit();
Codec::initialise(&mut storage, mode);
// SAFETY: initialise completed in final storage above.
self.codec2
.push((wire_mode, unsafe { storage.assume_init() }));
self.codec2.len() - 1
}
};
let codec = &mut self.codec2[index].1;
// Python decodes every whole native frame in the payload.
let mut pcm = vec![0i16; mode.samples()];
let mut samples = Vec::with_capacity(bytes.len() / mode.bytes() * mode.samples());
for chunk in bytes.chunks_exact(mode.bytes()) {
codec
.decode(chunk, &mut pcm)
.map_err(|_| Error::Audio("invalid native frame".into()))?;
samples.extend(pcm.iter().map(|v| f32::from(*v) / 32768.0));
}
let mono = RawAudioFrame::new(1, samples).map_err(|e| Error::Audio(e.to_string()))?;
mono.resampled(CODEC2_SAMPLE_RATE_HZ, self.sample_rate_hz)
.with_channels(self.channels)
.map_err(|e| Error::Audio(e.to_string()))
}
}
File diff suppressed because it is too large. Load diff
+15
View File
@@ -0,0 +1,15 @@
{
"generator": "tools/fixtures/lxst_media_fixtures.py",
"lxst_version": "0.6.0",
"lxst_commit": "6a329bf6d956ca8b15077d4c470afe4cb7c669cc",
"rns_version": "1.6.0",
"rns_commit": "cb1260891d1b6da8f6e9b21542c4f0cc0725cac4",
"buffer_frames": {"16": 2, "32": 2, "48": 2, "64": 5, "80": 5, "96": 5, "112": 2, "128": 3},
"frame_time_ms": {"16": 400, "32": 320, "48": 200, "64": 60, "80": 60, "96": 60, "112": 10, "128": 20},
"raw128": {"machine": "aarch64", "longdouble_bits": 128, "longdouble_nmant": 112, "samples": [0.0, 0.5, -0.25, 1.0], "payload_hex": "c0000000000000000000000000000000000000000000000000000000000000fe3f0000000000000000000000000000fdbf0000000000000000000000000000ff3f", "decoded": [0.0, 0.5, -0.25, 1.0]},
"mixed_batch": [
{"name": "opus_60ms", "codec": 1, "wire_hex": "01db037b5af3c47e60df913de2a4bc5f21a2bd4eb9afea6c144d002a6a9a8c966f0ffd97d00daeb04dcf27e9a5f40332fd4ef0fcea52582fae", "decoded_sample_frames": 2880},
{"name": "codec2_3200_200ms", "codec": 2, "wire_hex": "0206c07d231bd4ace738c0002900d6bdeb5ac681000019f81dd0c5b962029b86d5ffc5884a0094bd6b5ac591840194adebdac5802900d6bdeb5ac581000019f81dd0c5b962029b86d5ffc5884a0094bd6b5a", "decoded_sample_frames": 9595},
{"name": "opus_20ms", "codec": 1, "wire_hex": "01d8b51a679c5c8787e2a9b61c6bc130233e9db6b2", "decoded_sample_frames": 960}
]
}
@@ -69,7 +69,8 @@ fn python_telephone_helper_loads_reference_and_creates_destination() {
.expect("READY event");
assert_eq!(ready["app_name"], "lxst");
assert_eq!(ready["primitive_name"], "telephony");
assert_eq!(ready["lxst_version"], "0.4.5");
assert_eq!(ready["lxst_version"], "0.6.0");
assert_eq!(ready["rns_version"], "1.6.1");
let lxst_root = PathBuf::from(ready["lxst_root"].as_str().expect("LXST root"));
if let Ok(configured) = std::env::var("LXST_UPSTREAM_DIR") {
let configured = PathBuf::from(configured)
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,152 @@
#!/usr/bin/env python3
"""The headless Telephone helper, plus path hop counts and per-frame codec headers.
Commands added to tools/interop/lxst_telephone_helper.py:
{"cmd": "hops", "destination_hash": hex, "timeout": s}
-> HOPS with RNS.Transport.hops_to
{"cmd": "send_call_frames", "count": n}
encodes n 48 kHz sine frames with a fresh copy of the Telephone's transmit
codec, paced at its target frame time -> CALL_FRAMES_DONE
{"cmd": "profile_codec", "profile": p}
-> PROFILE_CODEC, the codec header byte, channels and frame time Telephony.Profiles gives p
Events added:
FRAME_SENT {"codec", "stereo" (Opus TOC s bit), "digest"} of each frame Packetizer puts on the wire
FRAME_RECEIVED {"frames": [{"codec", "stereo", "digest"}]} of each packet LinkSource reads
"""
from __future__ import annotations
import hashlib
import math
import sys
import threading
import time
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[3] / "tools" / "interop"))
import lxst_telephone_helper as helper # noqa: E402
OPUS = 0x01
_setup_python_stack = helper.setup_python_stack
_handle_command = helper.handle_command
def frame_fields(frame: bytes) -> dict:
return {
"codec": int(frame[0]),
"stereo": bool(frame[1] & 0x04) if frame[0] == OPUS and len(frame) > 1 else None,
"digest": hashlib.sha256(bytes(frame)).hexdigest()[:16],
}
def setup_python_stack():
codec2_stubbed = _setup_python_stack()
import LXST.Network as Network
import RNS.vendor.umsgpack as mp
from LXST.Codecs import codec_header_byte
packetizer_handle_frame = Network.Packetizer.handle_frame
link_source_packet = Network.LinkSource._packet
def handle_frame(self, frame, source=None):
sendable = not (
type(self.destination) == helper._RNS.Link and not self.destination.status == helper._RNS.Link.ACTIVE
) and not self.squelched
result = packetizer_handle_frame(self, frame, source)
if sendable:
helper.emit({"event": "FRAME_SENT", **frame_fields(codec_header_byte(type(self.source.codec)) + frame)})
return result
def packet(self, data, packet):
try:
unpacked = mp.unpackb(data)
if type(unpacked) == dict and Network.FIELD_FRAMES in unpacked:
frames = unpacked[Network.FIELD_FRAMES]
if type(frames) != list:
frames = [frames]
helper.emit({"event": "FRAME_RECEIVED", "frames": [frame_fields(frame) for frame in frames]})
except Exception:
pass
return link_source_packet(self, data, packet)
Network.Packetizer.handle_frame = handle_frame
Network.LinkSource._packet = packet
return codec2_stubbed
def send_call_frames(command: dict) -> None:
np = helper._np
telephone = helper._telephone
profile = telephone.active_profile
codec = type(telephone.transmit_codec)(profile=telephone.transmit_codec.profile)
frame_ms = telephone.target_frame_time_ms
class Source:
samplerate = 48000
channels = 1
samples = 48000 * frame_ms // 1000
sent = 0
started = time.time()
for index in range(int(command["count"])):
t = (np.arange(samples) + index * samples) / 48000.0
frame = (0.25 * np.sin(2 * math.pi * 440.0 * t)).astype(np.float32).reshape((samples, 1))
# send_packetized_frame rebinds codec.source to the packetizer's source.
codec.source = Source()
sent += bool(helper.send_packetized_frame(codec, codec.encode(frame)))
time.sleep(max(0.0, started + (index + 1) * frame_ms / 1000.0 - time.time()))
helper.emit({"event": "CALL_FRAMES_DONE", "id": command.get("id"), "profile": profile, "frame_ms": frame_ms, "sent": sent})
def profile_codec(command: dict) -> None:
from LXST.Codecs import codec_header_byte
Profiles = helper._Telephony.Profiles
profile = int(command["profile"])
helper.emit(
{
"event": "PROFILE_CODEC",
"id": command.get("id"),
"profile": profile,
"codec": codec_header_byte(type(Profiles.get_codec(profile)))[0],
"channels": Profiles.get_codec(profile).channels,
"frame_ms": Profiles.get_frame_time(profile),
}
)
def handle_command(command: dict, args) -> bool:
if command.get("cmd") == "profile_codec":
profile_codec(command)
return True
if command.get("cmd") == "send_call_frames":
threading.Thread(target=send_call_frames, args=(command,), daemon=True).start()
return True
if command.get("cmd") != "hops":
return _handle_command(command, args)
RNS = helper._RNS
destination_hash = bytes.fromhex(command["destination_hash"])
deadline = time.time() + float(command.get("timeout", 10))
requested = 0.0
while not RNS.Transport.has_path(destination_hash) and time.time() < deadline:
if time.time() - requested > 1.0:
RNS.Transport.request_path(destination_hash)
requested = time.time()
time.sleep(0.1)
helper.emit(
{
"event": "HOPS",
"id": command.get("id"),
"has_path": bool(RNS.Transport.has_path(destination_hash)),
"hops": RNS.Transport.hops_to(destination_hash),
}
)
return True
helper.setup_python_stack = setup_python_stack
helper.handle_command = handle_command
if __name__ == "__main__":
raise SystemExit(helper.main())
File renamed without changes.
+5 -5
View File
@@ -14,10 +14,10 @@ ROOT = Path(__file__).resolve().parents[1]
EXPECTED_PACKAGES = {"lxst-core", "lxst-codec2", "lxst-embedded", "lxst-rns", "lxst-telephony"}
EXPECTED_MSRV = "1.89"
EMBEDDED_MSRV = {"lxst-codec2": "1.87", "lxst-embedded": "1.87"}
EXPECTED_RETICULUM_VERSION = "1.4.0"
EXPECTED_RETICULUM_COMMIT = "14241a383910e6ee7665303eff1e7c8d98957cc0"
EXPECTED_RETICULUM_VERSION = "1.5.1"
EXPECTED_RETICULUM_COMMIT = "f6d0d698dd7e6edc180f9c3697ab1c873571f372"
EXPECTED_OPUS_DEPENDENCY = (
'opus-rs = { version = "=0.1.29", default-features = false, '
'opus-rs = { version = "=0.1.42", default-features = false, '
'features = ["heap"] }'
)
SHA_PATTERN = re.compile(r"^[0-9a-f]{40}$")
@@ -79,7 +79,7 @@ if "## Unreleased" not in (ROOT / "CHANGELOG.md").read_text(encoding="utf-8"):
root_manifest = (ROOT / "Cargo.toml").read_text(encoding="utf-8")
if EXPECTED_OPUS_DEPENDENCY not in root_manifest:
fail("workspace must consume exact upstream opus-rs 0.1.29 with heap state")
fail("workspace must consume exact upstream opus-rs 0.1.42 with heap state")
if (ROOT / "vendor/opus-rs").exists():
fail("local opus-rs vendor/fork must not exist")
@@ -143,7 +143,7 @@ python_pins = {
"RSLXST_PYTHON_LXST_COMMIT",
json.loads((ROOT / "tools/reference/lxst_reference_lock.json").read_text())["commit"],
),
"Reticulum": ("RSLXST_PYTHON_RNS_COMMIT", "b48b96e61676504e0a4e527b33b9a0b4495c6872"),
"Reticulum": ("RSLXST_PYTHON_RNS_COMMIT", "cff4d03fdbd6bfb63b765280cd944756ac5cce8d"),
}
for name, (variable, revision) in python_pins.items():
pin = re.search(rf"^ {variable}: ([0-9a-f]{{40}})$", workflow, re.MULTILINE)
+4 -4
View File
@@ -13,15 +13,15 @@ import tomllib
ROOT = Path(__file__).resolve().parents[1]
INVENTORY = ROOT / "THIRD_PARTY_LICENSES.json"
UPSTREAM_OPUS_COMMIT = "95f8b76430beb8c1bed067354d519c918ceade21"
UPSTREAM_OPUS_VERSION = "0.1.29"
UPSTREAM_OPUS_COMMIT = "5d8230f362b2618b9e730e6201c0d8f98961dfe1"
UPSTREAM_OPUS_VERSION = "0.1.42"
UPSTREAM_OPUS_LICENSE = "BSD-3-Clause"
UPSTREAM_OPUS_REPOSITORY = "https://github.com/restsend/opus-rs"
UPSTREAM_OPUS_SOURCE = "registry+https://github.com/rust-lang/crates.io-index"
UPSTREAM_OPUS_CRATE_CHECKSUM = (
"eadaf84d53a021172447a8771d74f805ac3719a61041dafa95720ef86b8e271d"
"bafbcaf2ed381cdf68ced4ed8d16517de90ffd7424e36f0b9e45d67fbe30b1f9"
)
UPSTREAM_OPUS_COPYING = "third_party/opus-rs-0.1.29-COPYING"
UPSTREAM_OPUS_COPYING = "third_party/opus-rs-0.1.42-COPYING"
UPSTREAM_OPUS_COPYING_SHA256 = (
"67c6f0a4bac3019fb08948838d7203bf661a629416f69057081c6f39db5e96a5"
)
+6 -2
View File
@@ -23,8 +23,12 @@ def main_root() -> Path:
return repo_root().parent
def _upstream_checkout(name: str) -> Path:
return main_root() / "upstream" / name
def upstream_lxst_root() -> Path:
return Path(os.environ.get("LXST_UPSTREAM_DIR", main_root() / "upstream" / "LXST")).resolve()
return Path(os.environ.get("LXST_UPSTREAM_DIR", _upstream_checkout("LXST"))).resolve()
def upstream_reticulum_root() -> Path:
@@ -32,7 +36,7 @@ def upstream_reticulum_root() -> Path:
if configured:
return Path(configured).resolve()
upstream = main_root() / "upstream" / "Reticulum"
upstream = _upstream_checkout("Reticulum")
if upstream.exists():
return upstream.resolve()
+118
View File
@@ -0,0 +1,118 @@
#!/usr/bin/env python3
"""Generate LXST media-path vectors by calling upstream Python LXST.
usage: python tools/fixtures/lxst_media_fixtures.py crates/lxst-telephony/tests/fixtures/media_vectors.json
Upstream checkouts come from LXST_UPSTREAM_DIR / RETICULUM_UPSTREAM_DIR, or the
workspace upstream directory (see tools/common/lxst_reference.py). Real Opus and
Codec2 codecs are required: the generator refuses to run with the Codec2 stub.
Emits buffer_frames and frame_time_ms per profile, raw128 (Raw(bitdepth=128) bytes,
platform-specific) and mixed_batch (one packet switching codec mid-batch, with the
sample counts upstream's per-frame codec switching decodes, Network.py LinkSource).
"""
from __future__ import annotations
import json
import platform
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "common"))
from lxst_reference import git_output, prepare_python_path, upstream_lxst_root, upstream_reticulum_root # noqa: E402
try:
import pycodec2 # noqa: F401 loaded first so the locator never installs its Codec2 stub
except ImportError:
raise SystemExit("pycodec2 is not installed; Codec2 vectors need the real codec")
prepare_python_path()
import numpy as np # noqa: E402
import RNS # noqa: E402
from LXST._version import __version__ as LXST_VERSION # noqa: E402
from LXST.Codecs import Codec2, Opus, Raw, codec_header_byte, codec_type # noqa: E402
from LXST.Primitives.Telephony import Profiles # noqa: E402
assert LXST_VERSION == "0.6.0", LXST_VERSION
assert RNS.__version__ == "1.6.0", RNS.__version__
class Src: # encoders read only samplerate from their source
def __init__(self, rate):
self.samplerate = rate
class Sink: # decoders read samplerate and channels from their sink
def __init__(self, rate, channels):
self.samplerate = rate
self.channels = channels
def tone(rate, ms):
n = int(rate * ms / 1000)
t = np.arange(n) / rate
return (0.3 * np.sin(2 * np.pi * 440 * t)).reshape(n, 1).astype("float32")
def main() -> None:
out_path = Path(sys.argv[1])
lxst_root = upstream_lxst_root()
out = {
"generator": "tools/fixtures/lxst_media_fixtures.py",
"lxst_version": LXST_VERSION,
"lxst_commit": git_output(["rev-parse", "HEAD"], lxst_root),
"rns_version": RNS.__version__,
"rns_commit": git_output(["rev-parse", "HEAD"], upstream_reticulum_root()),
}
profiles = [Profiles.BANDWIDTH_ULTRA_LOW, Profiles.BANDWIDTH_VERY_LOW, Profiles.BANDWIDTH_LOW,
Profiles.QUALITY_MEDIUM, Profiles.QUALITY_HIGH, Profiles.QUALITY_MAX,
Profiles.LATENCY_ULTRA_LOW, Profiles.LATENCY_LOW]
out["buffer_frames"] = {str(p): Profiles.get_buffer_frames(p) for p in profiles}
out["frame_time_ms"] = {str(p): Profiles.get_frame_time(p) for p in profiles}
samples = np.array([[0.0], [0.5], [-0.25], [1.0]], dtype="float32")
encoded = Raw(channels=1, bitdepth=128).encode(samples)
decoded = Raw().decode(encoded)
out["raw128"] = {"machine": platform.machine(),
"longdouble_bits": int(np.finfo(np.longdouble).bits),
"longdouble_nmant": int(np.finfo(np.longdouble).nmant),
"samples": samples[:, 0].tolist(), "payload_hex": encoded.hex(),
"decoded": [float(x) for x in decoded[:, 0]]}
frames = []
opus = Opus(profile=Opus.PROFILE_VOICE_MEDIUM)
opus.source = Src(24000)
frames.append(("opus_60ms", codec_header_byte(Opus) + opus.encode(tone(24000, 60))))
codec2 = Codec2(mode=Codec2.CODEC2_3200)
codec2.source = Src(8000)
frames.append(("codec2_3200_200ms", codec_header_byte(Codec2) + codec2.encode(np.repeat(tone(8000, 200), 2, axis=1))))
frames.append(("opus_20ms", codec_header_byte(Opus) + opus.encode(tone(24000, 20))))
sink = Sink(48000, 1)
codec = Opus()
codec.sink = sink
batch = []
for name, wire in frames:
frame_codec = codec_type(wire[0])
if type(codec) != frame_codec:
codec = frame_codec()
codec.sink = sink
samples_out = codec.decode(wire[1:])
batch.append({"name": name, "codec": int(wire[0]), "wire_hex": wire.hex(),
"decoded_sample_frames": int(samples_out.shape[0])})
out["mixed_batch"] = batch
lines = []
for key, value in out.items():
if isinstance(value, list):
items = ",\n".join(" " + json.dumps(item) for item in value)
lines.append(f"{json.dumps(key)}: [\n{items}\n ]")
else:
lines.append(f"{json.dumps(key)}: {json.dumps(value)}")
out_path.write_text("{\n " + ",\n ".join(lines) + "\n}\n")
if __name__ == "__main__":
main()
+66 -3
View File
@@ -86,6 +86,12 @@ def patch_headless_audio(Telephony, LXST, np, opus_available: bool) -> None:
self.should_run = False
self.samplerate = 48000
self.channels = 1
self.buffer_max_height = 3
self.autostart_min = 1
self.streaming = False
def wait_for_frames(self):
return None
def start(self):
self.should_run = True
@@ -249,6 +255,8 @@ def patch_headless_audio(Telephony, LXST, np, opus_available: bool) -> None:
Telephony.Pipeline = HeadlessPipeline
Telephony.BandPass = NoopFilter
Telephony.AGC = NoopFilter
if hasattr(Telephony, "EchoSuppressor"):
Telephony.EchoSuppressor = NoopFilter
if not opus_available:
original_get_codec = Telephony.Profiles.get_codec
@@ -269,14 +277,49 @@ def patch_headless_audio(Telephony, LXST, np, opus_available: bool) -> None:
def patch_signalling_events(Telephony) -> None:
original = Telephony.Telephone.signalling_received
# LXST_HELPER_DROP_RECEIVED lists signal values this phone never sees, to model loss.
dropped = {int(value) for value in os.environ.get("LXST_HELPER_DROP_RECEIVED", "").split(",") if value.strip()}
def signalling_received(self, signals, source):
emit({"event": "SIGNALS", "signals": [int(signal) for signal in signals]})
signals = [signal for signal in signals if int(signal) not in dropped]
return original(self, signals, source)
Telephony.Telephone.signalling_received = signalling_received
def patch_dropped_signals() -> None:
# LXST_HELPER_DROP_SENT lists signal values this phone never puts on the wire, to model loss.
dropped = {int(value) for value in os.environ.get("LXST_HELPER_DROP_SENT", "").split(",") if value.strip()}
if not dropped:
return
import LXST.Network as Network
original = Network.SignallingReceiver.signal
def signal(self, signal, destination, immediate=True):
signals = signal if type(signal) == list else [signal]
kept = [value for value in signals if value not in dropped]
if kept:
return original(self, kept, destination, immediate)
Network.SignallingReceiver.signal = signal
def patch_open_pipelines_observer(Telephony) -> None:
# LXST_HELPER_OPEN_DELAY delays the caller's pipeline setup to model a slow or distant phone.
delay = float(os.environ.get("LXST_HELPER_OPEN_DELAY", "0") or 0)
original = Telephony.Telephone._Telephone__open_pipelines
def open_pipelines(self, identity):
emit({"event": "OPEN_PIPELINES"})
if delay and self.active_call is not None and getattr(self.active_call, "is_outgoing", False):
time.sleep(delay)
return original(self, identity)
Telephony.Telephone._Telephone__open_pipelines = open_pipelines
def setup_python_stack():
global _RNS, _LXST, _Telephony, _np, _opus_available
_RNS, _LXST, codec2_stubbed = import_rns_lxst()
@@ -286,6 +329,8 @@ def setup_python_stack():
_opus_available = python_opus_available(Telephony)
patch_headless_audio(Telephony, _LXST, np, _opus_available)
patch_signalling_events(Telephony)
patch_open_pipelines_observer(Telephony)
patch_dropped_signals()
_Telephony = Telephony
_np = np
return codec2_stubbed
@@ -299,8 +344,11 @@ def snapshot_event():
active = {
"identity_hash": bytes(remote.hash).hex() if remote else None,
"profile": getattr(telephone.active_call, "profile", None),
"call_mode": getattr(telephone.active_call, "call_mode", None),
"squelched": bool(getattr(getattr(telephone.active_call, "packetizer", None), "squelched", False)),
"status": telephone.call_status,
"answered": bool(getattr(telephone.active_call, "answered", False)),
"audio_started": bool(telephone.audio_input is not None and telephone.audio_input.should_run),
}
return {
@@ -322,6 +370,7 @@ def emit_ready(identity, telephone, codec2_stubbed):
"app_name": "lxst",
"primitive_name": "telephony",
"lxst_version": lxst_version,
"rns_version": _RNS.__version__,
"lxst_root": str(upstream_lxst_root()),
"codec2_stubbed": bool(codec2_stubbed),
"headless_audio": True,
@@ -368,9 +417,13 @@ def setup_reticulum(storage: Path, tcp_role: str, tcp_host: str, tcp_port: int,
config_dir = storage / "rns"
config_dir.mkdir(parents=True, exist_ok=True)
(config_dir / "config").write_text(
build_rns_config(tcp_role, tcp_host, tcp_port, enable_transport),
build_rns_config(tcp_role, tcp_host, tcp_port, enable_transport)
+ ("\n[stamps]\n" + os.environ["LXST_HELPER_STAMPS"].replace(";", "\n") + "\n" if os.environ.get("LXST_HELPER_STAMPS") else ""),
encoding="utf-8",
)
# Destination stamping opt-in, as before Reticulum 1.6.1 ([stamps] still turns it on):
# macOS stamps on one core, and a value-25 stamp takes about a minute there.
_RNS.Transport.STAMP_DESTINATIONS = False
loglevel = os.environ.get("LXST_PYTHON_LOGLEVEL")
if loglevel:
@@ -391,7 +444,7 @@ def create_telephone(args):
telephone = _Telephony.Telephone(
identity,
ring_time=args.ring_time,
wait_time=args.wait_time,
wait_time=float(os.environ.get("LXST_HELPER_WAIT_TIME", args.wait_time)),
)
configure_callbacks(telephone)
_telephone = telephone
@@ -491,7 +544,7 @@ def handle_command(command: dict, args) -> bool:
}
)
return True
_telephone.call(identity, profile=command.get("profile"))
_telephone.call(identity, profile=command.get("profile"), mode=command.get("mode"))
emit(
{
"event": "CALL_REQUESTED",
@@ -547,6 +600,16 @@ def handle_command(command: dict, args) -> bool:
emit({"event": "OPUS_FRAME_SENT", "id": command.get("id"), "sent": sent})
return True
if cmd == "switch_mode":
_telephone.switch_mode(int(command["mode"]))
emit({"event": "MODE_SWITCHED", "id": command.get("id"), "mode": _telephone.active_mode})
return True
if cmd == "unsquelch":
_telephone.unsquelch_transmit()
emit({"event": "UNSQUELCHED", "id": command.get("id")})
return True
if cmd == "switch_profile":
profile = int(command["profile"])
_telephone.switch_profile(profile)
+15 -15
View File
@@ -1,38 +1,38 @@
{
"commit": "1194c9011fe6402edc7aebe7ffe9650ea3b1afee",
"commit": "6a329bf6d956ca8b15077d4c470afe4cb7c669cc",
"dirty": false,
"files": {
"LXST/Codecs/Codec2.py": {
"bytes": 4107,
"sha256": "e43a0be0b3b5b66665c47f468e8b102040632652a88e73598fc8cdbad8d4819a"
"bytes": 4221,
"sha256": "bb5727a4da4083ceddc0f692a12cf4aa17c8ad48c4394bcc71a61d4bdf5d572c"
},
"LXST/Codecs/Opus.py": {
"bytes": 7806,
"sha256": "0f0e6f9ffa48e899a80220b33485226fc411d70cd07dce3ff0b7582a208deb03"
"bytes": 8688,
"sha256": "bd3c7b0d777bddfbfc80acd51765b3d9bf623ba02bc0f1d1a6e128a2ab5bdd48"
},
"LXST/Codecs/Raw.py": {
"bytes": 2316,
"sha256": "8bda42cb8602797e7ef62dd71bac074d2ec547278ec2b0bc5bf8bcb7c100a026"
"bytes": 2451,
"sha256": "bce228630cf26a0c3a72b8d068eef3f9bbd099f077184b4ebf467259a42dbb0f"
},
"LXST/Codecs/__init__.py": {
"bytes": 704,
"sha256": "48c3f7adaf9c89326a81abf29f394f9857b11ea17315b3790214eaf7d45c03de"
"bytes": 739,
"sha256": "7977e713a3b8fa2167762db122024d1dcad8d09a1e8d98d25099271b22abfe1b"
},
"LXST/Network.py": {
"bytes": 6172,
"sha256": "3da8422a5c2c73f6e9c7d8e784b1e9cb307d079ebb5bf99183fc5daadfbd9701"
"bytes": 6458,
"sha256": "1f58806a43b2eadac536e1062857493fede551688ef92414b427aaffd6492923"
},
"LXST/Primitives/Telephony.py": {
"bytes": 37026,
"sha256": "35b2a4093368223145a548ac671504b43a4dcdac62368db754b082fe40138825"
"bytes": 46484,
"sha256": "da13879d66d2f4f83ea3b39c141a6566f29fc0ef7c96636a4c0b5dd619c0ab1c"
},
"LXST/_version.py": {
"bytes": 22,
"sha256": "12b90b908d930c15f5388aa2d8619adb408f7aee1972e9448be5df7d16cb53a3"
"sha256": "7080f58cb9c2fef8f8f0680c37a61bd4503726c43de73366087991604f131616"
}
},
"missing_files": [],
"package_version": "0.4.5",
"package_version": "0.6.0",
"remote": "https://github.com/markqvist/LXST.git",
"upstream": "../upstream/LXST"
}