From 7be745452b7d4da1f2c007c0e51a18eae5c44f99 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sat, 7 Nov 2026 20:22:20 -0800 Subject: [PATCH 1/4] chore(quest): claim quest/m2/api-shape/reexports.md Quest-Claim: 98781f6b892c40d6 From 7f57d723684e7163caabd6e67ee20c81807c14ca Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sat, 7 Nov 2026 21:13:58 -0800 Subject: [PATCH 2/4] refactor!: crates re-export no whole crate Drop every whole-crate `pub use` from moq's crates, moq's own included, so a breaking release of a dependency is no longer a semver break of the crates that re-exported it. Callers name the crate as their own dependency. Wrap the few third-party types a signature named only in passing: WebTransport `reject` takes a u16 status and `HandshakeError::Status` carries one (moq-tokio and moq-uring), `watch::Files::new` returns moq-tokio's error, and `moq_tokio::jemalloc::Allocator` replaces the `tikv_jemallocator` re-export. moq-mux's `container` re-exports the `Guard` that `Producer::modify` returns. Co-Authored-By: Claude Opus 5.5 --- Cargo.lock | 10 ++++ Cargo.toml | 3 + rs/hang/src/lib.rs | 3 - rs/moq-archive/README.md | 4 +- rs/moq-archive/benches/producer.rs | 2 +- rs/moq-archive/src/consumer/mod.rs | 2 +- rs/moq-archive/src/lib.rs | 2 - rs/moq-archive/src/producer/mod.rs | 2 +- rs/moq-audio/src/encode/producer.rs | 4 +- rs/moq-bench/Cargo.toml | 1 + rs/moq-bench/src/connection.rs | 4 +- rs/moq-boy/src/main.rs | 2 +- rs/moq-boy/src/status.rs | 2 +- rs/moq-c/src/consume.rs | 33 ++++++----- rs/moq-cli/Cargo.toml | 7 ++- rs/moq-cli/benches/play_buffer.rs | 2 +- rs/moq-cli/src/announced.rs | 2 +- rs/moq-cli/src/archive.rs | 1 - rs/moq-cli/src/args.rs | 21 +++---- rs/moq-cli/src/auth.rs | 9 ++- rs/moq-cli/src/fetch.rs | 1 - rs/moq-cli/src/hls.rs | 1 - rs/moq-cli/src/hls/record.rs | 1 - rs/moq-cli/src/main.rs | 5 +- rs/moq-cli/src/moq.rs | 2 - rs/moq-cli/src/play/buffer.rs | 1 - rs/moq-cli/src/play/fake.rs | 2 +- rs/moq-cli/src/play/headless.rs | 2 +- rs/moq-cli/src/play/media.rs | 1 - rs/moq-cli/src/play/mod.rs | 2 +- rs/moq-cli/src/play/playback.rs | 2 +- rs/moq-cli/src/play/video.rs | 3 +- rs/moq-cli/src/play/window.rs | 2 - rs/moq-cli/src/publish.rs | 5 +- rs/moq-cli/src/report.rs | 5 +- rs/moq-cli/src/report/echo_test.rs | 2 +- rs/moq-cli/src/rtc.rs | 1 - rs/moq-cli/src/rtmp.rs | 1 - rs/moq-cli/src/rtsp.rs | 1 - rs/moq-cli/src/srt.rs | 1 - rs/moq-cli/src/transcode.rs | 9 ++- rs/moq-cli/tests/integration/export.rs | 4 +- rs/moq-cli/tests/integration/import.rs | 2 +- rs/moq-cli/tests/integration/instances.rs | 2 +- rs/moq-cli/tests/integration/listen.rs | 5 +- rs/moq-cli/tests/integration/report.rs | 1 - rs/moq-cli/tests/integration/rtsp.rs | 1 - rs/moq-ffi/Cargo.toml | 4 ++ rs/moq-ffi/src/android.rs | 12 ++-- rs/moq-ffi/src/producer.rs | 2 +- rs/moq-gst/src/sink/imp.rs | 5 +- rs/moq-gst/src/sink/pad.rs | 1 - rs/moq-gst/src/sink/request_pad.rs | 5 +- rs/moq-gst/src/sink/session.rs | 4 +- rs/moq-gst/src/source/imp.rs | 8 +-- rs/moq-hls/Cargo.toml | 1 + rs/moq-hls/src/export/archive_tests.rs | 12 ++-- rs/moq-hls/src/export/mod.rs | 6 +- rs/moq-hls/src/lib.rs | 8 --- rs/moq-mux/src/container/consumer.rs | 2 +- rs/moq-mux/src/container/fmp4/mod.rs | 4 -- rs/moq-mux/src/container/mod.rs | 2 +- rs/moq-mux/src/container/ts/export_test.rs | 8 +-- rs/moq-net-tests/Cargo.toml | 3 +- rs/moq-net-tests/tests/announce_allocs.rs | 2 +- rs/moq-net-tests/tests/integration/refresh.rs | 2 +- .../tests/integration/snapshot.rs | 2 +- rs/moq-net/benches/bandwidth.rs | 2 +- rs/moq-net/benches/origin.rs | 2 +- rs/moq-net/benches/path.rs | 2 +- rs/moq-net/benches/retirement.rs | 2 +- rs/moq-net/benches/synced.rs | 6 +- rs/moq-net/benches/tail.rs | 2 +- rs/moq-net/benches/viewers.rs | 2 +- rs/moq-net/src/lib.rs | 6 -- .../tests/integration/lazy_discovery.rs | 2 +- rs/moq-net/tests/integration/model.rs | 2 +- rs/moq-net/tests/integration/range_fill.rs | 2 +- rs/moq-net/tests/integration/slow_joiner.rs | 2 +- .../tests/integration/support/harness.rs | 2 +- rs/moq-net/tests/integration/support/mock.rs | 3 +- rs/moq-net/tests/integration/support/mod.rs | 6 +- rs/moq-net/tests/integration/synced.rs | 6 +- rs/moq-net/tests/integration/viewer_target.rs | 18 +++--- .../tests/integration/widened_max_age.rs | 2 +- rs/moq-quic/src/lib.rs | 3 - rs/moq-relay/Cargo.toml | 10 +++- rs/moq-relay/src/auth.rs | 2 +- rs/moq-relay/src/cache.rs | 2 +- rs/moq-relay/src/critical.rs | 1 - rs/moq-relay/src/main.rs | 2 +- rs/moq-relay/src/shutdown.rs | 2 +- rs/moq-relay/src/uring.rs | 4 +- rs/moq-relay/src/web.rs | 20 +++---- rs/moq-relay/src/websocket.rs | 4 +- rs/moq-relay/tests/drills.rs | 1 - .../tests/integration/auth_lifetime.rs | 5 +- .../tests/integration/bitrate_caps.rs | 1 - rs/moq-relay/tests/integration/embed.rs | 1 - .../tests/integration/goaway_cluster.rs | 2 +- .../tests/integration/public_rules.rs | 1 - rs/moq-relay/tests/integration/refusals.rs | 2 +- .../tests/integration/runtime_uring.rs | 19 +++---- .../tests/integration/runtime_workers.rs | 1 - .../tests/integration/session_revalidate.rs | 1 - .../tests/integration/shutdown_signal.rs | 57 +++++++------------ rs/moq-relay/tests/integration/smoke.rs | 1 - .../tests/integration/tenant_matrix.rs | 3 +- rs/moq-rtmp/src/lib.rs | 6 -- rs/moq-stats/src/aggregate.rs | 2 +- rs/moq-stats/src/produce.rs | 2 +- rs/moq-tokio/Cargo.toml | 6 +- rs/moq-tokio/examples/chat.rs | 17 ++---- rs/moq-tokio/examples/clock.rs | 4 +- rs/moq-tokio/src/cli.rs | 3 - rs/moq-tokio/src/client.rs | 2 +- rs/moq-tokio/src/connection.rs | 1 - rs/moq-tokio/src/error.rs | 5 ++ rs/moq-tokio/src/jemalloc.rs | 33 ++++++++++- rs/moq-tokio/src/lib.rs | 18 ------ rs/moq-tokio/src/quic.rs | 2 +- rs/moq-tokio/src/quic/backend.rs | 9 +-- rs/moq-tokio/src/quic/driver/connection.rs | 2 +- rs/moq-tokio/src/quic/web/connect.rs | 2 +- rs/moq-tokio/src/quic/web/error.rs | 7 ++- rs/moq-tokio/src/quic/web/mod.rs | 6 -- rs/moq-tokio/src/quic/web/server.rs | 22 +++---- rs/moq-tokio/src/quic/web/session.rs | 15 ++--- rs/moq-tokio/src/quic/web/settings.rs | 2 +- rs/moq-tokio/src/server.rs | 6 +- rs/moq-tokio/src/watch.rs | 7 ++- rs/moq-tokio/src/websocket.rs | 5 +- rs/moq-tokio/tests/integration/backend.rs | 20 +++---- rs/moq-tokio/tests/integration/broadcast.rs | 35 ++++++------ rs/moq-tokio/tests/integration/close_code.rs | 2 - .../tests/integration/datagram_delivery.rs | 2 +- rs/moq-tokio/tests/integration/fresh_port.rs | 2 +- rs/moq-tokio/tests/integration/keylog.rs | 2 +- rs/moq-tokio/tests/integration/migrate.rs | 2 - .../tests/integration/receive_credit.rs | 6 +- rs/moq-tokio/tests/integration/reconnect.rs | 2 - rs/moq-tokio/tests/integration/runtime.rs | 1 - rs/moq-tokio/tests/integration/sim.rs | 2 +- .../integration/subscription_end_integrity.rs | 2 - rs/moq-tokio/tests/integration/tokens.rs | 2 - rs/moq-tokio/tests/integration/unannounce.rs | 2 - rs/moq-uring/benches/echo_quic.rs | 2 +- rs/moq-uring/src/lib.rs | 6 -- rs/moq-uring/src/quic/web.rs | 18 +++--- rs/moq-uring/src/quic/web/error.rs | 6 +- rs/moq-uring/tests/integration/echo.rs | 2 +- rs/moq-uring/tests/integration/local_addr.rs | 5 +- .../tests/integration/receive_credit.rs | 2 +- rs/moq-uring/tests/integration/support.rs | 2 +- rs/moq-uring/tests/integration/web.rs | 50 +++++++--------- rs/moq-uring/tests/integration/web_headers.rs | 2 +- rs/moq-video/Cargo.toml | 2 +- rs/moq-video/examples/d3d11-resize-probe.rs | 18 +++--- rs/moq-video/src/lib.rs | 24 -------- rs/moq-video/src/render/mod.rs | 10 +--- rs/moq-webrtc/src/lib.rs | 13 ----- rs/qmux/Cargo.toml | 2 +- rs/qmux/benches/receive.rs | 3 +- rs/qmux/examples/bench.rs | 2 +- rs/qmux/src/ws.rs | 17 +----- test/interop/clients/rust/catalog.rs | 1 - test/interop/clients/rust/control.rs | 1 - test/interop/clients/rust/finish.rs | 1 - test/interop/clients/rust/goaway.rs | 1 - test/interop/clients/rust/hls.rs | 1 - test/interop/clients/rust/socket-js.rs | 1 - test/interop/clients/rust/socket.rs | 2 +- test/interop/clients/rust/tail.rs | 1 - test/interop/compat.sh | 12 +++- test/interop/compat/container.rs | 4 +- 175 files changed, 398 insertions(+), 567 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7aa7d9729c7..1d0b1f70fa5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4385,6 +4385,7 @@ name = "moq-bench" version = "0.1.0" dependencies = [ "anyhow", + "bytes", "humantime", "kio", "libc", @@ -4488,6 +4489,7 @@ dependencies = [ "moq-hls", "moq-json", "moq-mux", + "moq-net", "moq-relay", "moq-rtmp", "moq-rtsp", @@ -4497,6 +4499,7 @@ dependencies = [ "moq-transcode", "moq-video", "moq-webrtc", + "mp4-atom", "mpeg2ts", "object_store", "percent-encoding", @@ -4518,6 +4521,7 @@ dependencies = [ "url", "usage-rs", "vt100", + "wgpu", "winit", "workspace-hack", ] @@ -4566,6 +4570,7 @@ version = "0.4.12" dependencies = [ "bytes", "hang", + "jni", "kio", "libc", "moq-audio", @@ -4633,6 +4638,7 @@ dependencies = [ "moq-net", "moq-tokio", "mp4-atom", + "object_store", "percent-encoding", "rand 0.10.3", "reqwest", @@ -4789,6 +4795,7 @@ dependencies = [ name = "moq-net-tests" version = "0.0.0" dependencies = [ + "bytes", "futures", "kio", "moq-json", @@ -4923,12 +4930,14 @@ dependencies = [ "thiserror 2.0.21", "tokio", "tokio-rustls", + "tokio-tungstenite", "toml 1.1.8+spec-1.1.0", "tower-service", "tracing", "tracing-subscriber", "url", "usage-rs", + "web-transport-proto", "workspace-hack", ] @@ -5146,6 +5155,7 @@ dependencies = [ "time", "tokio", "tokio-rustls", + "tokio-tungstenite", "toml 1.1.8+spec-1.1.0", "tracing", "tracing-android", diff --git a/Cargo.toml b/Cargo.toml index 970cb4f8a12..3d122b43138 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -123,6 +123,7 @@ hyper-util = { version = "0.1.21", features = ["tokio"] } if-addrs = "0.15" indexmap = "2.14.2" io-uring = "0.7.15" +jni = "0.22" jsonwebtoken = "11" kio = { version = "0.6.2", path = "rs/kio" } kio-macros = { version = "0.1.0", path = "rs/kio/macros" } @@ -237,6 +238,7 @@ thiserror = "2" time = "0.3" tokio = "1.48" tokio-rustls = { version = "0.26", default-features = false } +tokio-tungstenite = { version = "0.30", default-features = false } tokio-util = "0.7" toml = "1.1" tower-http = { version = "0.7", features = ["cors"] } @@ -251,6 +253,7 @@ usage-rs = "7.1.0" uuid = { version = "1.26", features = ["v7"] } web-transport-proto = "0.6.4" web-transport-trait = "0.5" +wgpu = "30" x11rb = { version = "0.14.0", features = ["randr", "xfixes"] } x509-cert = { version = "0.3", default-features = false } x509-parser = "0.18" diff --git a/rs/hang/src/lib.rs b/rs/hang/src/lib.rs index d5b4a4a066e..5f96cb0582a 100644 --- a/rs/hang/src/lib.rs +++ b/rs/hang/src/lib.rs @@ -33,8 +33,5 @@ pub mod catalog; /// The container is the contents of each media track. pub mod container; -/// Export the moq-net version we use. -pub use moq_net; - pub use catalog::Catalog; pub use error::*; diff --git a/rs/moq-archive/README.md b/rs/moq-archive/README.md index da623fa263d..a695529fe66 100644 --- a/rs/moq-archive/README.md +++ b/rs/moq-archive/README.md @@ -21,11 +21,11 @@ are fetched from the store on request, and a growing archive is followed until its producer marks it complete. ```bash -cargo add moq-archive +cargo add moq-archive object_store ``` ```rust -use moq_archive::object_store::memory::InMemory; +use object_store::memory::InMemory; // `broadcast` is a `moq_net::broadcast::Consumer`. let store = moq_archive::Store::new(InMemory::new(), "recordings/demo"); diff --git a/rs/moq-archive/benches/producer.rs b/rs/moq-archive/benches/producer.rs index a2f9155cdce..7b7758c6a1d 100644 --- a/rs/moq-archive/benches/producer.rs +++ b/rs/moq-archive/benches/producer.rs @@ -13,9 +13,9 @@ use std::time::{Duration, Instant}; use criterion::{BenchmarkId, Criterion, Throughput, criterion_group, criterion_main}; -use moq_archive::object_store::memory::InMemory; use moq_archive::{Producer, Store, producer}; use moq_net::{Timescale, Timestamp, broadcast, group, track}; +use object_store::memory::InMemory; const FRAMES_PER_GROUP: u64 = 2; diff --git a/rs/moq-archive/src/consumer/mod.rs b/rs/moq-archive/src/consumer/mod.rs index 92c86d92cac..d45206bc2c6 100644 --- a/rs/moq-archive/src/consumer/mod.rs +++ b/rs/moq-archive/src/consumer/mod.rs @@ -17,7 +17,7 @@ //! //! ```no_run //! # async fn example(broadcast: moq_net::broadcast::Producer) -> moq_archive::Result<()> { -//! use moq_archive::object_store::memory::InMemory; +//! use object_store::memory::InMemory; //! //! let store = moq_archive::Store::new(InMemory::new(), "recordings/demo"); //! let consumer = moq_archive::Consumer::open(store, broadcast, Default::default()).await?; diff --git a/rs/moq-archive/src/lib.rs b/rs/moq-archive/src/lib.rs index f329f8742a8..46d31819983 100644 --- a/rs/moq-archive/src/lib.rs +++ b/rs/moq-archive/src/lib.rs @@ -56,8 +56,6 @@ #![warn(missing_docs)] -pub use object_store; - pub mod consumer; mod error; /// The `.info` object holding a track's immutable properties. diff --git a/rs/moq-archive/src/producer/mod.rs b/rs/moq-archive/src/producer/mod.rs index a8e37e18cf3..13bc888f5a8 100644 --- a/rs/moq-archive/src/producer/mod.rs +++ b/rs/moq-archive/src/producer/mod.rs @@ -13,7 +13,7 @@ //! //! ```no_run //! # async fn example(broadcast: moq_net::broadcast::Consumer) -> moq_archive::Result<()> { -//! use moq_archive::object_store::memory::InMemory; +//! use object_store::memory::InMemory; //! //! let store = moq_archive::Store::new(InMemory::new(), "recordings/demo"); //! moq_archive::Producer::new(store, broadcast, Default::default()).run().await?; diff --git a/rs/moq-audio/src/encode/producer.rs b/rs/moq-audio/src/encode/producer.rs index f9d51c29bec..988bed10ea4 100644 --- a/rs/moq-audio/src/encode/producer.rs +++ b/rs/moq-audio/src/encode/producer.rs @@ -1840,11 +1840,11 @@ mod tests { "packets forward before the group fills" ); } - assert!(partial.poll_read_frame(&moq_net::kio::Waiter::noop()).is_pending()); + assert!(partial.poll_read_frame(&kio::Waiter::noop()).is_pending()); if deferred { producer.reanchor(); - assert!(partial.poll_read_frame(&moq_net::kio::Waiter::noop()).is_pending()); + assert!(partial.poll_read_frame(&kio::Waiter::noop()).is_pending()); } else { producer.discontinuity().unwrap(); assert!(partial.read_frame().await.unwrap().is_none()); diff --git a/rs/moq-bench/Cargo.toml b/rs/moq-bench/Cargo.toml index 314ce160c8f..fe9f2ca90e6 100644 --- a/rs/moq-bench/Cargo.toml +++ b/rs/moq-bench/Cargo.toml @@ -26,6 +26,7 @@ websocket = ["moq-tokio/websocket"] [dependencies] anyhow = { workspace = true, features = ["backtrace"] } +bytes = { workspace = true } humantime = { workspace = true } kio = { workspace = true, features = ["runtime"] } moq-net = { workspace = true } diff --git a/rs/moq-bench/src/connection.rs b/rs/moq-bench/src/connection.rs index a612ea23d8a..1d1144c66ab 100644 --- a/rs/moq-bench/src/connection.rs +++ b/rs/moq-bench/src/connection.rs @@ -4,9 +4,9 @@ use std::sync::Arc; use std::sync::atomic::{AtomicBool, AtomicU64, Ordering}; use std::time::Duration; +use bytes::Bytes; +use moq_net::{broadcast, group, track}; use moq_tokio::Status; -use moq_tokio::moq_net::{self, bytes::Bytes}; -use moq_tokio::moq_net::{broadcast, group, track}; use rand::RngExt; use serde::{Deserialize, Serialize}; use tokio::task::JoinSet; diff --git a/rs/moq-boy/src/main.rs b/rs/moq-boy/src/main.rs index 157553d1e91..ee0aa763469 100644 --- a/rs/moq-boy/src/main.rs +++ b/rs/moq-boy/src/main.rs @@ -35,7 +35,7 @@ use std::time::Duration; #[cfg(feature = "jemalloc")] #[global_allocator] -static ALLOC: moq_tokio::jemalloc::tikv_jemallocator::Jemalloc = moq_tokio::jemalloc::tikv_jemallocator::Jemalloc; +static ALLOC: moq_tokio::jemalloc::Allocator = moq_tokio::jemalloc::Allocator; mod audio; mod emulator; diff --git a/rs/moq-boy/src/status.rs b/rs/moq-boy/src/status.rs index eb69625d105..339785ad1cb 100644 --- a/rs/moq-boy/src/status.rs +++ b/rs/moq-boy/src/status.rs @@ -57,7 +57,7 @@ impl StatusPublisher { /// Also restates the status in a fresh group when a joiner wants one. Status is published every /// frame, so checking here answers a joiner within a frame without a task of its own. pub fn publish(&mut self, status: &Status) { - if let std::task::Poll::Ready(Err(err)) = self.producer.poll_refresh(&moq_net::kio::Waiter::noop()) { + if let std::task::Poll::Ready(Err(err)) = self.producer.poll_refresh(&kio::Waiter::noop()) { tracing::warn!(%err, "failed to refresh status"); } if let Err(err) = self diff --git a/rs/moq-c/src/consume.rs b/rs/moq-c/src/consume.rs index dd462013b59..26b72cdc54e 100644 --- a/rs/moq-c/src/consume.rs +++ b/rs/moq-c/src/consume.rs @@ -753,25 +753,24 @@ impl Consume { // `close` is a oneshot that panics if polled after completion, so a `Stop` // must unwind the whole task rather than fall through to the outer loop. loop { - let mut group = - match moq_net::kio::wait(|waiter| -> Poll, Error>> { - if Pin::new(&mut close).poll(&mut waiter.context()).is_ready() { - return Poll::Ready(Ok(RawStep::Stop)); - } - match ready!(track.poll_next_group(waiter))? { - Some(group) => Poll::Ready(Ok(RawStep::Item(group))), - None => Poll::Ready(Ok(RawStep::End)), - } - }) - .await? - { - RawStep::Item(group) => group, - // Track finished or the consumer was closed: nothing left to deliver. - RawStep::End | RawStep::Stop => return Ok(()), - }; + let mut group = match kio::wait(|waiter| -> Poll, Error>> { + if Pin::new(&mut close).poll(&mut waiter.context()).is_ready() { + return Poll::Ready(Ok(RawStep::Stop)); + } + match ready!(track.poll_next_group(waiter))? { + Some(group) => Poll::Ready(Ok(RawStep::Item(group))), + None => Poll::Ready(Ok(RawStep::End)), + } + }) + .await? + { + RawStep::Item(group) => group, + // Track finished or the consumer was closed: nothing left to deliver. + RawStep::End | RawStep::Stop => return Ok(()), + }; loop { - let frame = match moq_net::kio::wait(|waiter| -> Poll, Error>> { + let frame = match kio::wait(|waiter| -> Poll, Error>> { if Pin::new(&mut close).poll(&mut waiter.context()).is_ready() { return Poll::Ready(Ok(RawStep::Stop)); } diff --git a/rs/moq-cli/Cargo.toml b/rs/moq-cli/Cargo.toml index a08da3ed7cd..e12e0385f3a 100644 --- a/rs/moq-cli/Cargo.toml +++ b/rs/moq-cli/Cargo.toml @@ -59,7 +59,7 @@ transcode = ["dep:moq-transcode", "dep:moq-video"] # Native playback (`moq ... play`): decode into a wgpu window and a cpal # speaker. Off by default because it pulls both graphics and audio device stacks # into a binary that may only be routing containers or serving gateways. -play = ["dep:moq-video", "moq-video/render", "dep:moq-audio", "moq-audio/playback", "dep:pollster", "dep:winit"] +play = ["dep:moq-video", "moq-video/render", "dep:moq-audio", "moq-audio/playback", "dep:pollster", "dep:wgpu", "dep:winit"] # NVIDIA hardware codecs (NVENC + NVDEC) on Linux, on by default. Just turns on # the matching moq-video feature, so it only bites when something else pulls in # moq-video: `capture`, `transcode`, or `play`. For a build with no CUDA @@ -113,6 +113,7 @@ moq-hls = { workspace = true, features = ["server"] } # Writes and reads the stats and feedback snapshots. moq-json = { workspace = true, features = ["async"] } moq-mux = { workspace = true, features = ["async"] } +moq-net = { workspace = true } # Cluster, LAN mesh, and inbound `/.cluster` auth. default-features off so the # CLI's own feature set (quic, cluster-lan) is what selects them. moq-relay = { workspace = true } @@ -141,6 +142,8 @@ tower-http = { workspace = true } tracing = { workspace = true } url = { workspace = true, features = ["serde"] } usage-rs = { workspace = true, features = ["completions", "config"] } +# The device, queue, and surface `play` hands moq-video's renderer. +wgpu = { workspace = true, optional = true } winit = { version = "0.30.13", optional = true } [target.'cfg(unix)'.dependencies] @@ -155,6 +158,8 @@ moq-relay = { path = "../moq-relay", default-features = false, features = ["test moq-rtsp = { path = "../moq-rtsp", features = ["test-support"] } # Applies the finite bufferbloat queue to redundant-ingest acceptance tests. moq-shaper = { path = "../moq-shaper" } +# Reads back the boxes of an exported MP4. +mp4-atom = { workspace = true } # Writes the PAT and PMTs, CRCs included, of the two-program input `import ts --program all` splits. mpeg2ts = "0.6.0" tempfile = { workspace = true } diff --git a/rs/moq-cli/benches/play_buffer.rs b/rs/moq-cli/benches/play_buffer.rs index 94d14ea174e..bc1834faa4d 100644 --- a/rs/moq-cli/benches/play_buffer.rs +++ b/rs/moq-cli/benches/play_buffer.rs @@ -21,7 +21,7 @@ fn main() { for payload_bytes in [1_024, 65_536] { let frames: Vec<_> = (0..300) .map(|index| moq_mux::container::Frame { - timestamp: hang::moq_net::Timestamp::from_millis(index * 33).unwrap(), + timestamp: moq_net::Timestamp::from_millis(index * 33).unwrap(), duration: None, payload: bytes::Bytes::from(vec![128; payload_bytes]), keyframe: index % 30 == 0, diff --git a/rs/moq-cli/src/announced.rs b/rs/moq-cli/src/announced.rs index ac9ed23d9c9..8ec9b04b934 100644 --- a/rs/moq-cli/src/announced.rs +++ b/rs/moq-cli/src/announced.rs @@ -5,7 +5,7 @@ use std::collections::BTreeSet; use std::io::IsTerminal; use anyhow::Context; -use hang::moq_net::{self, announce::Event}; +use moq_net::announce::Event; use tokio::io::{AsyncWrite, AsyncWriteExt}; use crate::args::MoqSide; diff --git a/rs/moq-cli/src/archive.rs b/rs/moq-cli/src/archive.rs index a728a8c0b77..0776c554141 100644 --- a/rs/moq-cli/src/archive.rs +++ b/rs/moq-cli/src/archive.rs @@ -6,7 +6,6 @@ use std::sync::Arc; use std::time::Duration; use anyhow::Context; -use hang::moq_net; use object_store::path::{Path, PathPart}; use object_store::{ObjectStore, ObjectStoreScheme}; use url::Url; diff --git a/rs/moq-cli/src/args.rs b/rs/moq-cli/src/args.rs index 3f79060000d..985abb59664 100644 --- a/rs/moq-cli/src/args.rs +++ b/rs/moq-cli/src/args.rs @@ -347,19 +347,19 @@ impl Invocation { } // A reader refuses the whole catalog over a path it cannot resolve. let broadcast = command.broadcast(&self.moq); - let rel = hang::moq_net::path::Relative::new(path) - .map_err(|err| anyhow::anyhow!("invalid --echo-path: {err}"))?; - let broadcast = hang::moq_net::Path::new(&broadcast) - .map_err(|err| anyhow::anyhow!("invalid --broadcast: {err}"))?; + let rel = + moq_net::path::Relative::new(path).map_err(|err| anyhow::anyhow!("invalid --echo-path: {err}"))?; + let broadcast = + moq_net::Path::new(&broadcast).map_err(|err| anyhow::anyhow!("invalid --broadcast: {err}"))?; let Some(prefix) = broadcast.try_resolve(&rel) else { anyhow::bail!("--echo-path `{path}` walks above the connection root from broadcast `{broadcast}`"); }; // An origin refuses a broadcast a pattern could not name, so no viewer could // publish its `.echo` beneath this. - let feedback = prefix.join(&hang::moq_net::Path::from_static("viewer.echo")); + let feedback = prefix.join(&moq_net::Path::from_static("viewer.echo")); let literal = feedback .map_err(anyhow::Error::from) - .and_then(|feedback| Ok(hang::moq_net::Pattern::literal(feedback.as_str())?)); + .and_then(|feedback| Ok(moq_net::Pattern::literal(feedback.as_str())?)); if let Err(err) = literal { anyhow::bail!( "--echo-path `{path}` resolves to `{prefix}`, where no viewer can publish its feedback: {err}" @@ -1868,10 +1868,7 @@ mod tests { }; // `viewers` from `` resolves to n parts, and the feedback sits one beneath. let deep = |parts: usize| (0..parts).map(|i| format!("p{i}")).collect::>().join("/"); - let (fits, too_deep) = ( - deep(hang::moq_net::Path::MAX_PARTS - 1), - deep(hang::moq_net::Path::MAX_PARTS), - ); + let (fits, too_deep) = (deep(moq_net::Path::MAX_PARTS - 1), deep(moq_net::Path::MAX_PARTS)); for (broadcast, path) in [ ("room", "viewers"), ("room/live", "../viewers"), @@ -2080,7 +2077,7 @@ mod tests { #[test] fn independent_importers_cannot_select_a_shared_instance() { - let instance = hang::moq_net::Instance::random().to_string(); + let instance = moq_net::Instance::random().to_string(); let refused = Invocation::try_parse_from([ "moq", "--connect", @@ -3216,7 +3213,7 @@ mod tests { // Every wire code moq-net parses, including the opt-in `-wip` drafts. let codes = (0xff0dad00..=0xff0dadff).chain(0xff000000..=0xff0000ff); let mut expected: Vec<&str> = codes - .filter_map(hang::moq_net::Version::from_code) + .filter_map(moq_net::Version::from_code) .map(|version| version.as_str()) .collect(); expected.sort_unstable(); diff --git a/rs/moq-cli/src/auth.rs b/rs/moq-cli/src/auth.rs index 7ce136a8097..53f0c870a58 100644 --- a/rs/moq-cli/src/auth.rs +++ b/rs/moq-cli/src/auth.rs @@ -1753,11 +1753,10 @@ relay = ["https://relay.example"] let mut internal_config = moq_relay::internal::Config::default(); internal_config.listen = Some("127.0.0.1:0".parse().unwrap()); - let internal = - moq_relay::internal::Internal::new(internal_config, moq_tokio::moq_net::stats::Registry::disabled()) - .with_sessions(sessions) - .bind() - .expect("bind internal listener"); + let internal = moq_relay::internal::Internal::new(internal_config, moq_net::stats::Registry::disabled()) + .with_sessions(sessions) + .bind() + .expect("bind internal listener"); let listen = internal.addr().expect("internal listener is configured"); tokio::spawn(async move { let _ = internal.run().await; diff --git a/rs/moq-cli/src/fetch.rs b/rs/moq-cli/src/fetch.rs index 23420c51dae..49ce22168b2 100644 --- a/rs/moq-cli/src/fetch.rs +++ b/rs/moq-cli/src/fetch.rs @@ -5,7 +5,6 @@ use std::time::Duration; use anyhow::Context; use base64::Engine; -use hang::moq_net; use kio::clock::Instant; use kio::clock::timeout_at; use tokio::io::{AsyncWrite, AsyncWriteExt}; diff --git a/rs/moq-cli/src/hls.rs b/rs/moq-cli/src/hls.rs index fee57d0b649..bfd75a50d0c 100644 --- a/rs/moq-cli/src/hls.rs +++ b/rs/moq-cli/src/hls.rs @@ -7,7 +7,6 @@ use std::path::PathBuf; use anyhow::Context; use axum::http::Method; use futures::FutureExt; -use hang::moq_net; use url::Url; use crate::moq::{ImportTarget, notify_ready}; diff --git a/rs/moq-cli/src/hls/record.rs b/rs/moq-cli/src/hls/record.rs index 6b545b2d125..f091ede1519 100644 --- a/rs/moq-cli/src/hls/record.rs +++ b/rs/moq-cli/src/hls/record.rs @@ -597,7 +597,6 @@ async fn append(path: &Path, contents: &str) -> anyhow::Result<()> { #[cfg(test)] mod tests { use super::*; - use hang::moq_net; type Video = moq_mux::container::Producer; diff --git a/rs/moq-cli/src/main.rs b/rs/moq-cli/src/main.rs index 0a8a4d2590b..5df18ab39e7 100644 --- a/rs/moq-cli/src/main.rs +++ b/rs/moq-cli/src/main.rs @@ -28,7 +28,6 @@ mod transcode; mod web; use args::{Command, Export, ExportSink, Import, ImportSource, Invocation, MoqSide, TsImport, TsProgram}; -use hang::moq_net; use publish::Publish; use subscribe::{Subscribe, SubscribeArgs}; @@ -39,7 +38,7 @@ use tokio_util::sync::CancellationToken; #[cfg(feature = "jemalloc")] #[global_allocator] -static ALLOC: moq_tokio::jemalloc::tikv_jemallocator::Jemalloc = moq_tokio::jemalloc::tikv_jemallocator::Jemalloc; +static ALLOC: moq_tokio::jemalloc::Allocator = moq_tokio::jemalloc::Allocator; /// Everything needed to build MoQ clients/servers. #[derive(Clone)] @@ -615,7 +614,7 @@ async fn run_stages(moq: MoqSide, stages: Vec, net: Net) -> anyhow::Res let echo = import .echo_path .as_deref() - .map(hang::moq_net::path::Relative::new) + .map(moq_net::path::Relative::new) .transpose()? .map(hang::catalog::Echo::new); if let Some(mut publish) = diff --git a/rs/moq-cli/src/moq.rs b/rs/moq-cli/src/moq.rs index 55b7c505b96..229ff7ebe01 100644 --- a/rs/moq-cli/src/moq.rs +++ b/rs/moq-cli/src/moq.rs @@ -4,8 +4,6 @@ //! and `Server::serve_publish`/`serve_consume`); this module carries the systemd //! readiness notification used by every endpoint plus the MoQ side of an import. -use hang::moq_net; - /// The MoQ side of an import: where a gateway publishes, under what name, the /// max age it declares on the media tracks it mints, how long a clean end stays /// up, and the connection allocator those tracks claim on. diff --git a/rs/moq-cli/src/play/buffer.rs b/rs/moq-cli/src/play/buffer.rs index 66a92e52177..309e87774e1 100644 --- a/rs/moq-cli/src/play/buffer.rs +++ b/rs/moq-cli/src/play/buffer.rs @@ -1,6 +1,5 @@ //! Encoded playback retention in media time. -use hang::moq_net; use moq_mux::container::Frame; use std::collections::VecDeque; use std::time::Duration; diff --git a/rs/moq-cli/src/play/fake.rs b/rs/moq-cli/src/play/fake.rs index e0707a582a6..656952ff292 100644 --- a/rs/moq-cli/src/play/fake.rs +++ b/rs/moq-cli/src/play/fake.rs @@ -49,7 +49,7 @@ impl Recorder { } /// Present the newest due frame, just as the window does on a redraw. - pub fn present(&self, media: &super::media::Media) -> Option { + pub fn present(&self, media: &super::media::Media) -> Option { self.present_frame(media).map(|frame| frame.timestamp) } diff --git a/rs/moq-cli/src/play/headless.rs b/rs/moq-cli/src/play/headless.rs index b8bd1c2e9c5..b98df1c7430 100644 --- a/rs/moq-cli/src/play/headless.rs +++ b/rs/moq-cli/src/play/headless.rs @@ -4,7 +4,7 @@ use std::collections::VecDeque; use std::sync::{Arc, Mutex}; use anyhow::Context; -use hang::moq_net::origin; +use moq_net::origin; use tokio::sync::{Notify, mpsc}; use moq_audio::playback::Observer; diff --git a/rs/moq-cli/src/play/media.rs b/rs/moq-cli/src/play/media.rs index 402a8bd2eca..6143cf307b3 100644 --- a/rs/moq-cli/src/play/media.rs +++ b/rs/moq-cli/src/play/media.rs @@ -6,7 +6,6 @@ use std::sync::{Arc, Mutex}; use std::time::Duration; use anyhow::Context; -use hang::moq_net; use moq_mux::catalog::{self, Stream}; // The ambient clock, which follows tokio's paused clock when a test drives the // playout clock itself. diff --git a/rs/moq-cli/src/play/mod.rs b/rs/moq-cli/src/play/mod.rs index 1850cd5e8d2..b0d31a42918 100644 --- a/rs/moq-cli/src/play/mod.rs +++ b/rs/moq-cli/src/play/mod.rs @@ -44,7 +44,7 @@ pub use args::Args; /// Play a broadcast through a window or an audio-only speaker. #[cfg(feature = "play")] pub async fn run( - origin: hang::moq_net::origin::Consumer, + origin: moq_net::origin::Consumer, broadcast: String, args: Args, network: tokio::task::JoinSet>, diff --git a/rs/moq-cli/src/play/playback.rs b/rs/moq-cli/src/play/playback.rs index 217079a23fc..4ce6469a17b 100644 --- a/rs/moq-cli/src/play/playback.rs +++ b/rs/moq-cli/src/play/playback.rs @@ -12,7 +12,7 @@ pub(super) use moq_mux::timeline::Kind; #[derive(Clone, Debug, PartialEq, Eq, Hash)] pub(super) struct Track { /// Resolved rather than as written, since several references name one broadcast. - broadcast: Option, + broadcast: Option, name: String, } diff --git a/rs/moq-cli/src/play/video.rs b/rs/moq-cli/src/play/video.rs index 96d92b7564c..d98e329d1e6 100644 --- a/rs/moq-cli/src/play/video.rs +++ b/rs/moq-cli/src/play/video.rs @@ -132,7 +132,7 @@ impl Video { let selector = Mutex::new(Selector::new(refresh.is_some(), interval)); // The newest presentation time fed to the min-delay decoder, which the // max-delay decoder may always decode up to. - let edge: Mutex> = Mutex::new(None); + let edge: Mutex> = Mutex::new(None); // Wakes the max-delay decoder when the clock, the segments, or the selector change. let wake = tokio::sync::Notify::new(); let closed = std::sync::atomic::AtomicBool::new(false); @@ -645,7 +645,6 @@ mod tests { media::Media, }; use super::*; - use hang::moq_net; use moq_mux::container::Container as _; /// A codec whose reorder buffer holds `depth` pictures and bumps the diff --git a/rs/moq-cli/src/play/window.rs b/rs/moq-cli/src/play/window.rs index 4e99d266ea8..9e06751b53a 100644 --- a/rs/moq-cli/src/play/window.rs +++ b/rs/moq-cli/src/play/window.rs @@ -8,8 +8,6 @@ use std::time::Duration; use kio::clock::Instant; use anyhow::Context; -use hang::moq_net; -use moq_video::render::wgpu; use winit::application::ApplicationHandler; use winit::dpi::LogicalSize; use winit::event::{ElementState, KeyEvent, WindowEvent}; diff --git a/rs/moq-cli/src/publish.rs b/rs/moq-cli/src/publish.rs index 9ac4a09799d..f9dae3256f9 100644 --- a/rs/moq-cli/src/publish.rs +++ b/rs/moq-cli/src/publish.rs @@ -1,5 +1,4 @@ use anyhow::Context; -use hang::moq_net; use moq_mux::container::{flv, fmp4, ts}; /// Container format read from stdin on the import (source) side. @@ -377,7 +376,7 @@ impl Pending { /// Announce the broadcast if its catalog has gone out, returning whether it has. fn announce(&mut self) -> anyhow::Result { if !matches!( - self.catalog.poll_largest(&moq_net::kio::Waiter::noop()), + self.catalog.poll_largest(&kio::Waiter::noop()), std::task::Poll::Ready(Some(_)) ) { return Ok(false); @@ -1905,7 +1904,7 @@ pub(crate) mod tests { let mut track = consumer.track(Catalog::DEFAULT_NAME).unwrap(); let mut published = || { matches!( - track.poll_largest(&moq_net::kio::Waiter::noop()), + track.poll_largest(&kio::Waiter::noop()), std::task::Poll::Ready(Some(_)) ) }; diff --git a/rs/moq-cli/src/report.rs b/rs/moq-cli/src/report.rs index 4617dc16ebd..26bed00e290 100644 --- a/rs/moq-cli/src/report.rs +++ b/rs/moq-cli/src/report.rs @@ -11,7 +11,6 @@ use std::sync::{Arc, Mutex, PoisonError}; use std::time::Duration; use anyhow::Context; -use hang::moq_net; use moq_mux::catalog::{CatalogFormat, Stream}; use moq_mux::container::ts; use moq_tokio::connection::Monitor; @@ -77,7 +76,7 @@ impl ReportTrack { let Some(track) = &mut self.track else { return; }; - let refreshed = match track.poll_refresh(&moq_net::kio::Waiter::noop()) { + let refreshed = match track.poll_refresh(&kio::Waiter::noop()) { std::task::Poll::Ready(Err(err)) => Err(err), _ => Ok(()), }; @@ -325,7 +324,7 @@ impl Echo { } let prefix = prefix?; let name = format!("{}{}", self.target.name.0, hang::echo::SUFFIX); - hang::moq_net::Path::new(&name) + moq_net::Path::new(&name) .and_then(|name| prefix.join(&name)) .inspect_err(|err| tracing::warn!(%err, path = %echo.path.as_str(), "the feedback path is too long")) .ok() diff --git a/rs/moq-cli/src/report/echo_test.rs b/rs/moq-cli/src/report/echo_test.rs index e17d81c2e72..a60e33e5b08 100644 --- a/rs/moq-cli/src/report/echo_test.rs +++ b/rs/moq-cli/src/report/echo_test.rs @@ -20,7 +20,7 @@ async fn export_echo_reports_where_the_import_solicits() { let mut broadcast = publication.broadcast().clone(); let mut catalog_value = moq_mux::catalog::hang::Catalog::::default(); catalog_value.echo = Some(hang::catalog::Echo::new( - hang::moq_net::path::Relative::new("viewers").unwrap(), + moq_net::path::Relative::new("viewers").unwrap(), )); let config = moq_mux::catalog::Config::default() .with_catalog(catalog_value) diff --git a/rs/moq-cli/src/rtc.rs b/rs/moq-cli/src/rtc.rs index 2065dc1f6f3..c1f5fa7adb8 100644 --- a/rs/moq-cli/src/rtc.rs +++ b/rs/moq-cli/src/rtc.rs @@ -6,7 +6,6 @@ use std::net::SocketAddr; use anyhow::Context; use axum::http::Method; -use hang::moq_net; use moq_tokio::RedactedUrl; use url::Url; diff --git a/rs/moq-cli/src/rtmp.rs b/rs/moq-cli/src/rtmp.rs index 38f7fdac36a..7b9aeeadc7c 100644 --- a/rs/moq-cli/src/rtmp.rs +++ b/rs/moq-cli/src/rtmp.rs @@ -6,7 +6,6 @@ use std::net::SocketAddr; use std::time::Duration; use anyhow::Context; -use hang::moq_net; use moq_rtmp::{Client, Request, Server}; use url::Url; diff --git a/rs/moq-cli/src/rtsp.rs b/rs/moq-cli/src/rtsp.rs index 5cbbb41d7c8..c047c3ac63c 100644 --- a/rs/moq-cli/src/rtsp.rs +++ b/rs/moq-cli/src/rtsp.rs @@ -3,7 +3,6 @@ use std::time::Duration; use anyhow::Context; -use hang::moq_net; use moq_tokio::RedactedUrl; use url::Url; diff --git a/rs/moq-cli/src/srt.rs b/rs/moq-cli/src/srt.rs index d2217f26e8f..091a15eab4b 100644 --- a/rs/moq-cli/src/srt.rs +++ b/rs/moq-cli/src/srt.rs @@ -5,7 +5,6 @@ use std::net::SocketAddr; use std::time::Duration; use anyhow::Context; -use hang::moq_net; use moq_srt::{Reject, Request, Server}; use moq_tokio::RedactedUrl; use url::Url; diff --git a/rs/moq-cli/src/transcode.rs b/rs/moq-cli/src/transcode.rs index acd4adde43b..6f81a265c04 100644 --- a/rs/moq-cli/src/transcode.rs +++ b/rs/moq-cli/src/transcode.rs @@ -11,7 +11,6 @@ use anyhow::Context; use crate::Net; use crate::args::MoqSide; -use hang::moq_net; /// Ladder and codec options for the `transcode` verb. #[derive(usage_rs::Args, Clone)] @@ -239,8 +238,8 @@ mod tests { let following = Following { origin: origin.consume(), publish: publish.clone(), - source_path: hang::moq_net::Path::from_static("source"), - output_path: hang::moq_net::Path::from_static("derived"), + source_path: moq_net::Path::from_static("source"), + output_path: moq_net::Path::from_static("derived"), config: Default::default(), }; let task = tokio::spawn(following.run()); @@ -287,8 +286,8 @@ mod tests { let following = Following { origin: origin.consume(), publish: publish.clone(), - source_path: hang::moq_net::Path::from_static("source"), - output_path: hang::moq_net::Path::from_static("derived"), + source_path: moq_net::Path::from_static("source"), + output_path: moq_net::Path::from_static("derived"), config: Default::default(), }; let task = tokio::spawn(following.run()); diff --git a/rs/moq-cli/tests/integration/export.rs b/rs/moq-cli/tests/integration/export.rs index 968257e22dd..5e91c9c1fb5 100644 --- a/rs/moq-cli/tests/integration/export.rs +++ b/rs/moq-cli/tests/integration/export.rs @@ -16,8 +16,6 @@ use std::time::Duration; use kio::clock::Instant; -use hang::moq_net; -use moq_mux::container::fmp4::mp4_atom; use moq_mux::container::ts; use mpeg2ts::ts::{ReadTsPacket, TsPacketReader, TsPayload}; use tokio::io::{AsyncBufReadExt, AsyncReadExt, AsyncWriteExt, BufReader}; @@ -98,7 +96,7 @@ async fn relay() -> Relay { config.listen.bind = Some("127.0.0.1:0".parse().unwrap()); config.listen.tls.generate = vec!["localhost".into()]; config.listen.version = std::iter::once(LITE_07.parse().unwrap()) - .chain(hang::moq_net::Versions::all().iter().copied()) + .chain(moq_net::Versions::all().iter().copied()) .collect(); config.auth.public = vec![moq_auth::Pattern::all()]; let relay = moq_relay::Relay::load(config).await.expect("test relay"); diff --git a/rs/moq-cli/tests/integration/import.rs b/rs/moq-cli/tests/integration/import.rs index 5ff5817e8f9..d1815f44166 100644 --- a/rs/moq-cli/tests/integration/import.rs +++ b/rs/moq-cli/tests/integration/import.rs @@ -90,7 +90,7 @@ async fn import_delivers_the_catalog_finish_at_eof() { let event = running(&mut child, "the announce", announced.next()) .await .expect("origin closed"); - let moq_tokio::moq_net::announce::Event::Present(announce) = event else { + let moq_net::announce::Event::Present(announce) = event else { panic!("the first announce event is {event:?}, not a start"); }; assert_eq!(announce.prefix.as_str(), "demo"); diff --git a/rs/moq-cli/tests/integration/instances.rs b/rs/moq-cli/tests/integration/instances.rs index 90c15ddb30e..bcd5a494604 100644 --- a/rs/moq-cli/tests/integration/instances.rs +++ b/rs/moq-cli/tests/integration/instances.rs @@ -5,8 +5,8 @@ use std::time::Duration; -use hang::moq_net::{self, Instance, Timestamp, origin, track}; use moq_mux::catalog::Stream; +use moq_net::{Instance, Timestamp, origin, track}; const LITE_07: &str = "moq-lite-07-wip"; diff --git a/rs/moq-cli/tests/integration/listen.rs b/rs/moq-cli/tests/integration/listen.rs index 2186d2ebe07..5510eb03c43 100644 --- a/rs/moq-cli/tests/integration/listen.rs +++ b/rs/moq-cli/tests/integration/listen.rs @@ -3,7 +3,6 @@ use std::{process::Stdio, time::Duration}; -use hang::moq_net; use tokio::io::{AsyncBufReadExt, AsyncReadExt, BufReader}; use tokio::process::Child; @@ -122,7 +121,7 @@ async fn drains(stage: &str) { let (connection, _origin) = connects(&listening, stage).await; let draining = connection.draining().unwrap(); listening.signal(); - let goaway = kio::clock::timeout(TIMEOUT, moq_net::kio::wait(|waiter| draining.poll(waiter))) + let goaway = kio::clock::timeout(TIMEOUT, kio::wait(|waiter| draining.poll(waiter))) .await .expect("no GOAWAY after SIGTERM") .expect("CLI closed the session without GOAWAY"); @@ -182,7 +181,7 @@ async fn an_export_stage_ending_during_drain_waits_for_every_session() { let draining = publisher.draining().unwrap(); let signalled = kio::clock::now(); listening.signal(); - kio::clock::timeout(TIMEOUT, moq_net::kio::wait(|waiter| draining.poll(waiter))) + kio::clock::timeout(TIMEOUT, kio::wait(|waiter| draining.poll(waiter))) .await .unwrap() .unwrap(); diff --git a/rs/moq-cli/tests/integration/report.rs b/rs/moq-cli/tests/integration/report.rs index aa096cc47f9..5854817ab15 100644 --- a/rs/moq-cli/tests/integration/report.rs +++ b/rs/moq-cli/tests/integration/report.rs @@ -6,7 +6,6 @@ use std::collections::BTreeMap; use std::process::Stdio; use std::time::Duration; -use hang::moq_net; use moq_mux::container::ts; use tokio::io::{AsyncBufReadExt, AsyncWriteExt, BufReader, Lines}; use tokio::process::{Child, ChildStdout}; diff --git a/rs/moq-cli/tests/integration/rtsp.rs b/rs/moq-cli/tests/integration/rtsp.rs index 685939d52f4..111fc7a1112 100644 --- a/rs/moq-cli/tests/integration/rtsp.rs +++ b/rs/moq-cli/tests/integration/rtsp.rs @@ -5,7 +5,6 @@ use std::process::Stdio; use std::time::Duration; use moq_rtsp::fake::{self, Media, Server}; -use moq_tokio::moq_net; use tokio::io::AsyncReadExt; use tokio::process::Child; diff --git a/rs/moq-ffi/Cargo.toml b/rs/moq-ffi/Cargo.toml index 46350b28d85..5be4398e067 100644 --- a/rs/moq-ffi/Cargo.toml +++ b/rs/moq-ffi/Cargo.toml @@ -66,6 +66,10 @@ tracing = { workspace = true } uniffi = { workspace = true } url = { workspace = true } +[target.'cfg(target_os = "android")'.dependencies] +# `JNI_OnLoad` finds the app Context for moq-tokio's platform verifier. +jni = { workspace = true } + [dev-dependencies] moq-shaper = { path = "../moq-shaper" } # The video tests encode with OpenH264, the one encoder a GPU-less host has, so diff --git a/rs/moq-ffi/src/android.rs b/rs/moq-ffi/src/android.rs index f5948a0b6f7..7b24f2aff0a 100644 --- a/rs/moq-ffi/src/android.rs +++ b/rs/moq-ffi/src/android.rs @@ -8,8 +8,8 @@ use std::ffi::c_void; -use moq_tokio::jni::sys::{self, JNI_VERSION_1_6, jint}; -use moq_tokio::jni::{Env, JavaVM, jni_sig, jni_str}; +use jni::sys::{self, JNI_VERSION_1_6, jint}; +use jni::{Env, JavaVM, jni_sig, jni_str}; /// Called by the JVM on `System.loadLibrary("moq_ffi")`. The name is fixed by /// the JNI spec, so it can't follow Rust's snake_case convention. @@ -36,13 +36,11 @@ fn init_platform_tls(vm: &JavaVM) -> Result<(), Box> { fn discover_context_and_init(env: &mut Env) -> Result<(), Box> { // The app Context isn't passed to native code, so fetch it from // android.app.ActivityThread.currentApplication() (a long-stable internal API). - // The `jni = ...` override points the compile-time encoders at moq-tokio's - // re-export, since moq-ffi has no direct `jni` dependency of its own. let app = env .call_static_method( - jni_str!(jni = moq_tokio::jni, "android/app/ActivityThread"), - jni_str!(jni = moq_tokio::jni, "currentApplication"), - jni_sig!(jni = moq_tokio::jni, "()Landroid/app/Application;"), + jni_str!("android/app/ActivityThread"), + jni_str!("currentApplication"), + jni_sig!("()Landroid/app/Application;"), &[], )? .l()?; diff --git a/rs/moq-ffi/src/producer.rs b/rs/moq-ffi/src/producer.rs index 6aecedbf9d5..70797e3fcdb 100644 --- a/rs/moq-ffi/src/producer.rs +++ b/rs/moq-ffi/src/producer.rs @@ -1005,7 +1005,7 @@ mod metadata_tests { let binding = MoqGroupProducer::from_inner(group); drop(binding); assert!(matches!( - consumer.poll_read_frame(&moq_net::kio::Waiter::noop()), + consumer.poll_read_frame(&kio::Waiter::noop()), std::task::Poll::Ready(Err(moq_net::Error::Unroutable)) )); } diff --git a/rs/moq-gst/src/sink/imp.rs b/rs/moq-gst/src/sink/imp.rs index 7521edfc020..ea68ef1160f 100644 --- a/rs/moq-gst/src/sink/imp.rs +++ b/rs/moq-gst/src/sink/imp.rs @@ -18,7 +18,6 @@ use bytes::Bytes; use gst::glib; use gst::prelude::*; use gst::subclass::prelude::*; -use hang::moq_net; use super::listed::{Listed, Watch}; use super::pad::{CapsOutcome, Names, ProducerOptions, PushOutcome, caps_supported}; @@ -1453,7 +1452,7 @@ mod tests { catalog: &mut moq_mux::catalog::Consumer, ) -> std::task::Poll>> { use moq_mux::catalog::Stream; - catalog.poll_next(&moq_net::kio::Waiter::noop()) + catalog.poll_next(&kio::Waiter::noop()) } #[test] @@ -1532,7 +1531,7 @@ mod tests { let subscriber = futures::executor::block_on(broadcast.track(name).unwrap().subscribe(None)).unwrap(); let mut consumer = moq_mux::container::Consumer::new(subscriber, moq_mux::catalog::hang::Container::Legacy(kind)); - let std::task::Poll::Ready(Ok(Some(read))) = consumer.poll_read(&moq_net::kio::Waiter::noop()) else { + let std::task::Poll::Ready(Ok(Some(read))) = consumer.poll_read(&kio::Waiter::noop()) else { panic!("published media frame") }; let moq_mux::container::Read::Frame { frame, .. } = read else { diff --git a/rs/moq-gst/src/sink/pad.rs b/rs/moq-gst/src/sink/pad.rs index 806abe8e5d5..f82dc356d6f 100644 --- a/rs/moq-gst/src/sink/pad.rs +++ b/rs/moq-gst/src/sink/pad.rs @@ -9,7 +9,6 @@ use std::time::Duration; use anyhow::{Context, Result, ensure}; use bytes::Bytes; -use hang::moq_net; use moq_mux::import; use super::listed::Listed; diff --git a/rs/moq-gst/src/sink/request_pad.rs b/rs/moq-gst/src/sink/request_pad.rs index 7291f38d478..3eb3d7309f5 100644 --- a/rs/moq-gst/src/sink/request_pad.rs +++ b/rs/moq-gst/src/sink/request_pad.rs @@ -6,7 +6,6 @@ use std::sync::{LazyLock, Mutex, MutexGuard}; use gst::glib; use gst::prelude::*; use gst::subclass::prelude::*; -use hang::moq_net; use super::MediaContainer; use super::listed::Listed; @@ -108,9 +107,9 @@ impl Bandwidth { let mut grant = self.grant.clone(); // Activation emits the initial notification synchronously. Prime this clone so the task only // reports subsequent changes instead of immediately duplicating that notification. - let _ = demand.poll_wanted_changed(&moq_net::kio::Waiter::noop()); + let _ = demand.poll_wanted_changed(&kio::Waiter::noop()); if let Some(grant) = &mut grant { - let _ = grant.poll_changed(&moq_net::kio::Waiter::noop()); + let _ = grant.poll_changed(&kio::Waiter::noop()); } self.watch_task = Some(RUNTIME.spawn(async move { loop { diff --git a/rs/moq-gst/src/sink/session.rs b/rs/moq-gst/src/sink/session.rs index bd58d2d95c5..bbf84a83f9f 100644 --- a/rs/moq-gst/src/sink/session.rs +++ b/rs/moq-gst/src/sink/session.rs @@ -13,8 +13,6 @@ use gst::glib; use gst::prelude::*; use gst::subclass::prelude::*; -use hang::moq_net; - use super::MoqSink as Element; pub(crate) static RUNTIME: LazyLock = LazyLock::new(|| { @@ -590,7 +588,7 @@ mod tests { } fn is_closed(connection: &moq_tokio::Connection) -> bool { - connection.poll_closed(&moq_net::kio::Waiter::noop()).is_ready() + connection.poll_closed(&kio::Waiter::noop()).is_ready() } // A dial still running once the element reached NULL would outlive the state change an application diff --git a/rs/moq-gst/src/source/imp.rs b/rs/moq-gst/src/source/imp.rs index 46bd3c189ee..f989689f532 100644 --- a/rs/moq-gst/src/source/imp.rs +++ b/rs/moq-gst/src/source/imp.rs @@ -9,8 +9,6 @@ use gst::prelude::*; use gst::subclass::prelude::*; use tokio::sync::{oneshot, watch}; -use hang::moq_net; - static CAT: LazyLock = LazyLock::new(|| gst::DebugCategory::new("moq-src", gst::DebugColorFlags::empty(), Some("MoQ Source Element"))); @@ -851,7 +849,7 @@ impl Session { // Stop closes the connection only after the session ends, so the dial races shutdown here. let mut shutdown = self.shutdown.clone(); tokio::select! { - established = moq_net::kio::wait(|waiter| connection.poll_established(waiter)) => established?, + established = kio::wait(|waiter| connection.poll_established(waiter)) => established?, _ = shutdown.changed() => return Ok(()), } @@ -1344,7 +1342,7 @@ impl Follower { let mut stop = self.playback.stop.clone(); // The catalog's own broadcast is ready at once, so its renditions play even when the // catalog closed before this follower ran. - match instances.poll_next(&moq_net::kio::Waiter::noop()) { + match instances.poll_next(&kio::Waiter::noop()) { std::task::Poll::Ready(Ok(Some(instance))) => self.start(instance), std::task::Poll::Ready(Err(err)) => { gst::warning!(CAT, "lost {}: {err:?}", self.path); @@ -3809,7 +3807,7 @@ mod session_tests { } fn is_closed(connection: &moq_tokio::Connection) -> bool { - connection.poll_closed(&moq_net::kio::Waiter::noop()).is_ready() + connection.poll_closed(&kio::Waiter::noop()).is_ready() } fn started(element: &super::super::MoqSrc) -> (SessionController, moq_tokio::Connection) { diff --git a/rs/moq-hls/Cargo.toml b/rs/moq-hls/Cargo.toml index 0b72c392f72..0986744447b 100644 --- a/rs/moq-hls/Cargo.toml +++ b/rs/moq-hls/Cargo.toml @@ -51,6 +51,7 @@ moq-hls = { path = ".", default-features = false, features = ["async"] } moq-json = { path = "../moq-json" } moq-tokio = { path = "../moq-tokio", default-features = false, features = ["tcp", "quic"] } mp4-atom = { workspace = true } +object_store = { workspace = true } tempfile = { workspace = true } tokio = { workspace = true, features = ["test-util"] } tower = { version = "0.5", features = ["util"] } diff --git a/rs/moq-hls/src/export/archive_tests.rs b/rs/moq-hls/src/export/archive_tests.rs index 660321f85b7..48520e07b64 100644 --- a/rs/moq-hls/src/export/archive_tests.rs +++ b/rs/moq-hls/src/export/archive_tests.rs @@ -13,13 +13,13 @@ use std::time::Duration; use bytes::{Bytes, BytesMut}; use futures::stream::BoxStream; use moq_archive::Store; -use moq_archive::object_store::memory::InMemory; -use moq_archive::object_store::path::Path; -use moq_archive::object_store::{ - self, CopyOptions, GetOptions, GetResult, ListResult, MultipartUpload, ObjectMeta, ObjectStore, - PutMultipartOptions, PutOptions, PutPayload, PutResult, -}; use moq_net::{Timescale, Timestamp, group, track}; +use object_store::memory::InMemory; +use object_store::path::Path; +use object_store::{ + CopyOptions, GetOptions, GetResult, ListResult, MultipartUpload, ObjectMeta, ObjectStore, PutMultipartOptions, + PutOptions, PutPayload, PutResult, +}; use super::*; diff --git a/rs/moq-hls/src/export/mod.rs b/rs/moq-hls/src/export/mod.rs index 143f1d1028a..8f005c01e0d 100644 --- a/rs/moq-hls/src/export/mod.rs +++ b/rs/moq-hls/src/export/mod.rs @@ -842,7 +842,7 @@ mod tests { fn aac_avg_bitrate(init: &bytes::Bytes) -> u32 { let wire = moq_mux::container::fmp4::Wire::from_init(init).unwrap(); let codec = &wire.trak().mdia.minf.stbl.stsd.codecs[0]; - let moq_mux::container::fmp4::mp4_atom::Codec::Mp4a(mp4a) = codec else { + let mp4_atom::Codec::Mp4a(mp4a) = codec else { panic!("expected mp4a, got {codec:?}"); }; mp4a.esds.es_desc.dec_config.avg_bitrate @@ -850,7 +850,7 @@ mod tests { /// The `trun` sample durations of a fragment. fn sample_durations(fragment: &bytes::Bytes) -> Vec> { - use moq_mux::container::fmp4::mp4_atom::{self, DecodeMaybe}; + use mp4_atom::DecodeMaybe; let mut cursor = std::io::Cursor::new(fragment.as_ref()); while let Some(atom) = mp4_atom::Any::decode_maybe(&mut cursor).unwrap() { @@ -2553,7 +2553,7 @@ mod tests { } async fn live_fmp4_segments(version: Option<&str>, late: bool) { - use moq_mux::container::fmp4::mp4_atom::{self, DecodeMaybe, Encode}; + use mp4_atom::{DecodeMaybe, Encode}; // Reuse the A/V descriptors; opaque samples exercise segment discovery and FETCH, // without involving a codec decoder. let mut fixture = diff --git a/rs/moq-hls/src/lib.rs b/rs/moq-hls/src/lib.rs index 31fa623e46d..b5c93781051 100644 --- a/rs/moq-hls/src/lib.rs +++ b/rs/moq-hls/src/lib.rs @@ -45,14 +45,6 @@ pub use error::*; #[cfg(feature = "server")] pub use server::Server; -/// Re-export of the HTTP stack behind the export server, so consumers can name the -/// types that surface through [`Server::router`] (and layer their own middleware on -/// it) without adding their own axum dependency and risking a version mismatch. -/// `axum::http` covers the `http` crate types too. A major axum bump is therefore a -/// breaking change for this crate. -#[cfg(feature = "server")] -pub use axum; - /// Test helper: a [`moq_mux::Source`] for the broadcast at `path`, resolved through `origin`. #[cfg(test)] pub(crate) async fn resolved(origin: &moq_net::origin::Producer, path: &str) -> moq_mux::Source { diff --git a/rs/moq-mux/src/container/consumer.rs b/rs/moq-mux/src/container/consumer.rs index fbfd63b514c..da112b678a9 100644 --- a/rs/moq-mux/src/container/consumer.rs +++ b/rs/moq-mux/src/container/consumer.rs @@ -2244,7 +2244,7 @@ mod tests { let mut subscriber = track.subscribe( moq_net::track::Subscription::default().with_delay(Delay::default().with_max(Duration::from_millis(500))), ); - let edge = match subscriber.poll_largest(&moq_net::kio::Waiter::noop()) { + let edge = match subscriber.poll_largest(&kio::Waiter::noop()) { std::task::Poll::Ready(Some(edge)) => edge, _ => panic!("the empty group is the largest"), }; diff --git a/rs/moq-mux/src/container/fmp4/mod.rs b/rs/moq-mux/src/container/fmp4/mod.rs index c545ea96e47..6d5cff7193c 100644 --- a/rs/moq-mux/src/container/fmp4/mod.rs +++ b/rs/moq-mux/src/container/fmp4/mod.rs @@ -21,10 +21,6 @@ pub use fragmenter::*; pub use import::*; pub use muxer::*; -/// Re-export of the [`mp4_atom`] crate, whose types appear in this module's public API. -/// A major version bump of `mp4_atom` is a breaking change for moq-mux. -pub use mp4_atom; - /// The largest text sample [`Import`] holds whole. /// /// A text sample is rewritten only once its last byte arrives, so a larger one is refused before diff --git a/rs/moq-mux/src/container/mod.rs b/rs/moq-mux/src/container/mod.rs index 337db08b722..cb111e7e307 100644 --- a/rs/moq-mux/src/container/mod.rs +++ b/rs/moq-mux/src/container/mod.rs @@ -35,7 +35,7 @@ pub mod ts; pub use consumer::{Consumer, Playout}; pub use group::GroupConsumer; pub(crate) use input::Input; -pub use producer::Producer; +pub use producer::{Guard, Producer}; pub(crate) use source::{ExportSource, Resume}; /// The media role that determines how a container represents frame durations. diff --git a/rs/moq-mux/src/container/ts/export_test.rs b/rs/moq-mux/src/container/ts/export_test.rs index b6a47a44adf..74d826b8ef1 100644 --- a/rs/moq-mux/src/container/ts/export_test.rs +++ b/rs/moq-mux/src/container/ts/export_test.rs @@ -11898,7 +11898,7 @@ async fn a_stitched_switch_keeps_the_healthy_legs_held_frames() { for ms in (1000..2000).step_by(20) { write_aac(&mut old_audio, ms); } - let _ = export.poll_next(&moq_net::kio::Waiter::noop()); + let _ = export.poll_next(&kio::Waiter::noop()); let held = export.buffered(); assert!(held > 0, "the old healthy leg has future output buffered"); let (new, mut new_catalog) = publish_live::<()>(&origin, route()); @@ -11948,7 +11948,7 @@ async fn a_healthy_stitch_feeds_the_old_generation_until_the_new_clock_acquires( } tokio::task::yield_now().await; loop { - match follower.poll_next(&moq_net::kio::Waiter::noop()) { + match follower.poll_next(&kio::Waiter::noop()) { Poll::Ready(Ok(Some(frame))) => { frames.push((start.elapsed(), follower.export().discontinuity(), frame)) } @@ -12025,7 +12025,7 @@ async fn repeated_stitches_keep_the_delay() { } tokio::task::yield_now().await; loop { - match follower.poll_next(&moq_net::kio::Waiter::noop()) { + match follower.poll_next(&kio::Waiter::noop()) { Poll::Ready(Ok(Some(frame))) => { frames.push((start.elapsed(), follower.export().discontinuity(), frame)) } @@ -12319,7 +12319,7 @@ async fn a_newer_pending_instance_discards_the_unemitted_held_replacement() { for ms in (1000..4000).step_by(20) { write_aac(&mut a_audio, ms); tokio::task::yield_now().await; - if let std::task::Poll::Ready(Ok(Some(frame))) = export.poll_next(&moq_net::kio::Waiter::noop()) { + if let std::task::Poll::Ready(Ok(Some(frame))) = export.poll_next(&kio::Waiter::noop()) { out.push(frame); } } diff --git a/rs/moq-net-tests/Cargo.toml b/rs/moq-net-tests/Cargo.toml index 1cead4b99ae..a1e43a5349a 100644 --- a/rs/moq-net-tests/Cargo.toml +++ b/rs/moq-net-tests/Cargo.toml @@ -10,9 +10,10 @@ publish = false # Used by the shared transport harness outside this package's source tree. [package.metadata.cargo-shear] -ignored = ["tokio"] +ignored = ["bytes", "tokio"] [dev-dependencies] +bytes = { workspace = true } futures = { workspace = true } kio = { path = "../kio", features = ["sim"] } moq-json = { path = "../moq-json", features = ["async"] } diff --git a/rs/moq-net-tests/tests/announce_allocs.rs b/rs/moq-net-tests/tests/announce_allocs.rs index 7e01c4bdd7c..487eaa4e855 100644 --- a/rs/moq-net-tests/tests/announce_allocs.rs +++ b/rs/moq-net-tests/tests/announce_allocs.rs @@ -16,7 +16,7 @@ use std::cell::Cell; use moq_net::{ Client, Path, Pattern, Patterns, Server, Version, fuzz::{decode_path, decode_subscribe, encode_path, encode_subscribe}, - kio, origin, + origin, time::{Driver, Instant}, track, transport::memory, diff --git a/rs/moq-net-tests/tests/integration/refresh.rs b/rs/moq-net-tests/tests/integration/refresh.rs index c22b9b44794..8ce1e0492c1 100644 --- a/rs/moq-net-tests/tests/integration/refresh.rs +++ b/rs/moq-net-tests/tests/integration/refresh.rs @@ -1,6 +1,6 @@ //! Refresh joins traverse real protocol hops, judged independently from each cache. use crate::support::harness::{MockConnectOptions, connect_mock, peer, spawn, subscribed}; -use moq_net::{Version, kio, origin, track}; +use moq_net::{Version, origin, track}; use std::time::Duration; fn origin(hop: u64) -> origin::Producer { diff --git a/rs/moq-net-tests/tests/integration/snapshot.rs b/rs/moq-net-tests/tests/integration/snapshot.rs index 85177a91ce1..a5c8b8d24d2 100644 --- a/rs/moq-net-tests/tests/integration/snapshot.rs +++ b/rs/moq-net-tests/tests/integration/snapshot.rs @@ -1,6 +1,6 @@ //! A snapshot reader on a received track never waits on a hole the subscription still owes. use moq_json::snapshot; -use moq_net::{fuzz, group, kio, track}; +use moq_net::{fuzz, group, track}; use serde_json::{Value, json}; use std::{task::Poll, time::Duration}; diff --git a/rs/moq-net/benches/bandwidth.rs b/rs/moq-net/benches/bandwidth.rs index eefec953067..c15c908e908 100644 --- a/rs/moq-net/benches/bandwidth.rs +++ b/rs/moq-net/benches/bandwidth.rs @@ -29,7 +29,7 @@ use std::time::Duration; use criterion::{BenchmarkId, Criterion, criterion_group}; use moq_net::bandwidth::{Allocator, Consumer, Producer, Rate, Reservation, Viewers}; -use moq_net::{broadcast, fuzz, kio, track}; +use moq_net::{broadcast, fuzz, track}; /// Reservations sharing the allocator. const RESERVATIONS: [usize; 4] = [1, 10, 1_000, 10_000]; diff --git a/rs/moq-net/benches/origin.rs b/rs/moq-net/benches/origin.rs index 3784a59ee51..f0a502b6e86 100644 --- a/rs/moq-net/benches/origin.rs +++ b/rs/moq-net/benches/origin.rs @@ -51,7 +51,7 @@ use std::time::Duration; use criterion::{BatchSize, BenchmarkId, Criterion, Throughput, criterion_group, criterion_main}; use futures::FutureExt; -use moq_net::{Instance, Pattern, Patterns, Timestamp, auth, broadcast, kio, origin, track}; +use moq_net::{Instance, Pattern, Patterns, Timestamp, auth, broadcast, origin, track}; use support::harness::{MockConnectOptions, MockPair, connect_mock}; /// A millisecond track: the frames written here carry timestamps. diff --git a/rs/moq-net/benches/path.rs b/rs/moq-net/benches/path.rs index 52683bb9571..c18454b1c30 100644 --- a/rs/moq-net/benches/path.rs +++ b/rs/moq-net/benches/path.rs @@ -16,7 +16,7 @@ use futures::FutureExt; use moq_net::{ Path, Pattern, Patterns, fuzz::{Announced, Messages, decode_announces, decode_namespaces, encode_announces, encode_namespaces}, - kio, origin, + origin, }; struct Counting; diff --git a/rs/moq-net/benches/retirement.rs b/rs/moq-net/benches/retirement.rs index 7fe34dfcde7..62b4afecd68 100644 --- a/rs/moq-net/benches/retirement.rs +++ b/rs/moq-net/benches/retirement.rs @@ -2,7 +2,7 @@ //! The route-only control models the old gate: a more-specific source does not retract the broad route. use criterion::{BatchSize, BenchmarkId, Criterion, criterion_group, criterion_main}; -use moq_net::{Path, fuzz::RequestValidity, kio, origin}; +use moq_net::{Path, fuzz::RequestValidity, origin}; use std::{hint::black_box, time::Duration}; fn retirement(c: &mut Criterion) { diff --git a/rs/moq-net/benches/synced.rs b/rs/moq-net/benches/synced.rs index 3fa53100e24..a04daad9327 100644 --- a/rs/moq-net/benches/synced.rs +++ b/rs/moq-net/benches/synced.rs @@ -60,9 +60,9 @@ fn bench_land(c: &mut Criterion) { let watcher = scoped(&table.producer, "room/incoming").routes(); b.iter(|| { let snapshot = fuzz::snapshot(&table.producer, "room/incoming"); - assert!(!watcher.poll_synced(&moq_net::kio::Waiter::noop()).is_ready()); + assert!(!watcher.poll_synced(&kio::Waiter::noop()).is_ready()); drop(snapshot); - assert!(watcher.poll_synced(&moq_net::kio::Waiter::noop()).is_ready()); + assert!(watcher.poll_synced(&kio::Waiter::noop()).is_ready()); }); }); } @@ -79,7 +79,7 @@ fn bench_register(c: &mut Criterion) { let _held = fuzz::snapshot(&table.producer, "room/incoming"); b.iter(|| { let watcher = incoming.routes(); - assert!(!watcher.poll_synced(&moq_net::kio::Waiter::noop()).is_ready()); + assert!(!watcher.poll_synced(&kio::Waiter::noop()).is_ready()); }); }); } diff --git a/rs/moq-net/benches/tail.rs b/rs/moq-net/benches/tail.rs index 7e9db2780dd..faa5425f642 100644 --- a/rs/moq-net/benches/tail.rs +++ b/rs/moq-net/benches/tail.rs @@ -10,7 +10,7 @@ use std::{hint::black_box, task::Poll, time::Duration}; use criterion::{BenchmarkId, Criterion, Throughput, criterion_group, criterion_main}; -use moq_net::{broadcast, group, kio, track}; +use moq_net::{broadcast, group, track}; /// Tracks each holding a reader at the tail. const TRACKS: [usize; 3] = [1, 32, 1024]; diff --git a/rs/moq-net/benches/viewers.rs b/rs/moq-net/benches/viewers.rs index 77d9ffde5bf..b3ce7ecd2a4 100644 --- a/rs/moq-net/benches/viewers.rs +++ b/rs/moq-net/benches/viewers.rs @@ -14,7 +14,7 @@ use std::sync::atomic::{AtomicBool, AtomicIsize, Ordering}; use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main}; use futures::FutureExt; -use moq_net::{Timestamp, kio, origin}; +use moq_net::{Timestamp, origin}; /// A millisecond track: the frames written here carry timestamps. fn timed() -> moq_net::track::Info { diff --git a/rs/moq-net/src/lib.rs b/rs/moq-net/src/lib.rs index fcffa24aca1..8ca3ed74a7e 100644 --- a/rs/moq-net/src/lib.rs +++ b/rs/moq-net/src/lib.rs @@ -164,9 +164,3 @@ pub use version::*; /// A wrapper prepends its own token, space-separated, outermost first: /// `format!("moq-ffi/{v} {}", moq_net::IMPLEMENTATION)`. pub const IMPLEMENTATION: &str = concat!("moq-net-rs/", env!("CARGO_PKG_VERSION")); - -// Re-export the bytes crate -pub use bytes; - -// Re-export the kio crate, since it appears in the public API (e.g. poll_* waiters). -pub use kio; diff --git a/rs/moq-net/tests/integration/lazy_discovery.rs b/rs/moq-net/tests/integration/lazy_discovery.rs index 81022bdbd7e..9d1e80a46dc 100644 --- a/rs/moq-net/tests/integration/lazy_discovery.rs +++ b/rs/moq-net/tests/integration/lazy_discovery.rs @@ -103,7 +103,7 @@ impl Lazy { /// Read until the stream syncs, returning the prefixes it then holds. async fn synced(announced: &mut origin::Routes) -> Vec { let mut seen = Vec::new(); - while !announced.poll_synced(&moq_net::kio::Waiter::noop()).is_ready() { + while !announced.poll_synced(&kio::Waiter::noop()).is_ready() { let event = kio::clock::timeout(SETTLE, announced.next()) .await .expect("synced in time") diff --git a/rs/moq-net/tests/integration/model.rs b/rs/moq-net/tests/integration/model.rs index 744f47f3f56..34f5a538398 100644 --- a/rs/moq-net/tests/integration/model.rs +++ b/rs/moq-net/tests/integration/model.rs @@ -1,6 +1,6 @@ //! The explicit-time model works without async helpers or a runtime. -use moq_net::{Error, Timestamp, broadcast, frame, group, kio, origin, track}; +use moq_net::{Error, Timestamp, broadcast, frame, group, origin, track}; use std::task::Poll; fn ready(value: Poll) -> T { diff --git a/rs/moq-net/tests/integration/range_fill.rs b/rs/moq-net/tests/integration/range_fill.rs index 3a035fcbb3d..337a06b054e 100644 --- a/rs/moq-net/tests/integration/range_fill.rs +++ b/rs/moq-net/tests/integration/range_fill.rs @@ -10,7 +10,7 @@ use std::collections::BTreeSet; use std::time::Duration; use moq_net::track::{Delay, Info, Range, Subscription}; -use moq_net::{Timescale, Timestamp, Version, cache, kio}; +use moq_net::{Timescale, Timestamp, Version, cache}; use support::harness::{MockConnectOptions, MockPair, connect_mock}; const TIMEOUT: Duration = Duration::from_secs(10); diff --git a/rs/moq-net/tests/integration/slow_joiner.rs b/rs/moq-net/tests/integration/slow_joiner.rs index 684702222c1..3056145d751 100644 --- a/rs/moq-net/tests/integration/slow_joiner.rs +++ b/rs/moq-net/tests/integration/slow_joiner.rs @@ -6,7 +6,7 @@ use std::collections::BTreeSet; use std::time::Duration; -use moq_net::{Timescale, Timestamp, Version, kio, origin, track}; +use moq_net::{Timescale, Timestamp, Version, origin, track}; use crate::support::harness::{MockConnectOptions, connect_mock, spawn, subscribed}; diff --git a/rs/moq-net/tests/integration/support/harness.rs b/rs/moq-net/tests/integration/support/harness.rs index 2fb68611a8d..093da948ed6 100644 --- a/rs/moq-net/tests/integration/support/harness.rs +++ b/rs/moq-net/tests/integration/support/harness.rs @@ -13,7 +13,7 @@ use std::sync::{ }; use std::task::Poll; -use moq_net::{Client, Server, Session, Version, kio, origin}; +use moq_net::{Client, Server, Session, Version, origin}; use super::mock::{MockSession, MockStats, create_mock_session_pair}; diff --git a/rs/moq-net/tests/integration/support/mock.rs b/rs/moq-net/tests/integration/support/mock.rs index 4ea9c31a15d..bbe57dfe8d2 100644 --- a/rs/moq-net/tests/integration/support/mock.rs +++ b/rs/moq-net/tests/integration/support/mock.rs @@ -20,9 +20,8 @@ use std::{ time::Duration, }; +use bytes::{Buf, Bytes}; use moq_net::{ - bytes::{Buf, Bytes}, - kio, time::Instant, transport::{memory, poll}, }; diff --git a/rs/moq-net/tests/integration/support/mod.rs b/rs/moq-net/tests/integration/support/mod.rs index f9d2a692771..fceba9b8da1 100644 --- a/rs/moq-net/tests/integration/support/mod.rs +++ b/rs/moq-net/tests/integration/support/mod.rs @@ -29,7 +29,7 @@ pub async fn unwanted(mut demand: track::Demand) -> moq_net::Result<()> { pub async fn datagram_priority(producer: &datagram::Producer, want: Option) { let mut priority = producer.priority(); while priority != want { - priority = moq_net::kio::wait(|waiter| producer.poll_priority(waiter, priority)).await; + priority = kio::wait(|waiter| producer.poll_priority(waiter, priority)).await; } } @@ -108,14 +108,14 @@ pub trait Draining { impl Draining for goaway::Consumer { fn peek(&self) -> Option { - match self.poll(&moq_net::kio::Waiter::noop()) { + match self.poll(&kio::Waiter::noop()) { std::task::Poll::Ready(Ok(goaway)) => Some(goaway), _ => None, } } async fn recv(&self) -> Option { - moq_net::kio::wait(|waiter| self.poll(waiter)).await.ok() + kio::wait(|waiter| self.poll(waiter)).await.ok() } } diff --git a/rs/moq-net/tests/integration/synced.rs b/rs/moq-net/tests/integration/synced.rs index 0d043420e80..23fcd8c660b 100644 --- a/rs/moq-net/tests/integration/synced.rs +++ b/rs/moq-net/tests/integration/synced.rs @@ -24,7 +24,7 @@ fn produce_origin(hop: u64) -> origin::Producer { /// Read events until the consumer syncs, returning the prefixes then announced. async fn read_until_synced(announced: &mut origin::Routes) -> BTreeSet { let mut seen = BTreeSet::new(); - while !announced.poll_synced(&moq_net::kio::Waiter::noop()).is_ready() { + while !announced.poll_synced(&kio::Waiter::noop()).is_ready() { let event = kio::clock::timeout(SETTLE, announced.next()) .await .expect("synced in time") @@ -129,7 +129,7 @@ async fn a_cold_relay_syncs_then_forwards_upstream_routes_as_live() { downstream.client_subscribe = Some(subscriber.clone()); let _downstream = connect_mock(downstream).await; let mut announced = subscriber.consume().routes(); - moq_net::kio::wait(|waiter| announced.poll_synced(waiter)).await; + kio::wait(|waiter| announced.poll_synced(waiter)).await; assert!(announced.try_next().is_none()); let upstream = produce_origin(1); @@ -143,5 +143,5 @@ async fn a_cold_relay_syncs_then_forwards_upstream_routes_as_live() { let _upstream = connect_mock(options).await; let event = announced.next().await.unwrap(); assert!(matches!(event, origin::RouteEvent::Start(route) if route.prefix.as_str() == "room/cam")); - assert!(announced.poll_synced(&moq_net::kio::Waiter::noop()).is_ready()); + assert!(announced.poll_synced(&kio::Waiter::noop()).is_ready()); } diff --git a/rs/moq-net/tests/integration/viewer_target.rs b/rs/moq-net/tests/integration/viewer_target.rs index 583fcb5b934..5a4bfa743e9 100644 --- a/rs/moq-net/tests/integration/viewer_target.rs +++ b/rs/moq-net/tests/integration/viewer_target.rs @@ -34,7 +34,7 @@ fn mbps(n: u64) -> Rate { /// Run until `transport`'s sender is handed `target`. async fn probes_to(transport: &MockSession, target: Rate) { while transport.probe_target() != target { - moq_net::kio::clock::sleep(Duration::from_millis(1)).await; + kio::clock::sleep(Duration::from_millis(1)).await; } } @@ -45,7 +45,7 @@ fn reservable() -> (broadcast::Producer, track::Producer) { (broadcast, track) } -#[moq_net::kio::test] +#[kio::test] async fn viewers_sum_into_the_peers_target() { for version in VERSIONS { let pair = pair(version, true).await; @@ -66,7 +66,7 @@ async fn viewers_sum_into_the_peers_target() { } } -#[moq_net::kio::test] +#[kio::test] async fn the_sender_probes_to_the_larger_target() { for version in VERSIONS { let pair = pair(version, true).await; @@ -85,7 +85,7 @@ async fn the_sender_probes_to_the_larger_target() { /// The sender's override covers its own reservations only: zeroing it stops probing /// for them, while the peer's target still sets how high to probe. -#[moq_net::kio::test] +#[kio::test] async fn a_local_override_leaves_the_peers_target() { for version in VERSIONS { let pair = pair(version, true).await; @@ -107,7 +107,7 @@ async fn a_local_override_leaves_the_peers_target() { /// A session that publishes and watches probes its uplink for what it sends, never /// for what it watches, and its peer the other way around. -#[moq_net::kio::test] +#[kio::test] async fn the_directions_stay_apart() { for version in VERSIONS { let pair = pair(version, true).await; @@ -117,13 +117,13 @@ async fn the_directions_stay_apart() { probes_to(&pair.client_transport, mbps(1)).await; probes_to(&pair.server_transport, mbps(6)).await; - moq_net::kio::clock::sleep(Duration::from_secs(1)).await; + kio::clock::sleep(Duration::from_secs(1)).await; assert_eq!(pair.client_transport.probe_target(), mbps(1), "{version}"); assert_eq!(pair.server_transport.probe_target(), mbps(6), "{version}"); } } -#[moq_net::kio::test] +#[kio::test] async fn opting_out_sends_no_target() { for version in VERSIONS { let pair = pair(version, true).await; @@ -133,7 +133,7 @@ async fn opting_out_sends_no_target() { let mut grant = viewer.consume(); // The estimate arrives, so the PROBE stream is up and the target would have too. assert_eq!(grant.changed().await.unwrap(), Some(mbps(6)), "{version}"); - moq_net::kio::clock::sleep(Duration::from_secs(1)).await; + kio::clock::sleep(Duration::from_secs(1)).await; assert_eq!(pair.server_transport.probe_target(), Rate::ZERO, "{version}"); assert!(!grant.probed(), "{version}: opted out, nothing probes for it"); @@ -144,7 +144,7 @@ async fn opting_out_sends_no_target() { } /// A peer without a sender advertises `Report`, so its viewers are never probed for. -#[moq_net::kio::test] +#[kio::test] async fn a_peer_without_a_sender_is_sent_no_target() { for version in VERSIONS { let pair = pair(version, false).await; diff --git a/rs/moq-net/tests/integration/widened_max_age.rs b/rs/moq-net/tests/integration/widened_max_age.rs index f3b147f4d6e..9f402387348 100644 --- a/rs/moq-net/tests/integration/widened_max_age.rs +++ b/rs/moq-net/tests/integration/widened_max_age.rs @@ -12,7 +12,7 @@ use std::time::Duration; use moq_net::track::Delay; use moq_net::track::{Info, Range, Subscription}; -use moq_net::{Timescale, Timestamp, Version, kio, origin, track}; +use moq_net::{Timescale, Timestamp, Version, origin, track}; use crate::support::harness::{MockConnectOptions, MockPair, connect_mock, peer, spawn}; diff --git a/rs/moq-quic/src/lib.rs b/rs/moq-quic/src/lib.rs index dbc61a6e7d2..5d29677ce32 100644 --- a/rs/moq-quic/src/lib.rs +++ b/rs/moq-quic/src/lib.rs @@ -52,9 +52,6 @@ pub mod stream; pub use connection::mux; pub(crate) use stream::{Dir, Id as StreamId}; -// The configs take and report rustls types, so callers name the same version. -pub use rustls; - mod config; mod limits; pub use config::{ConfigError, client, server, transport}; diff --git a/rs/moq-relay/Cargo.toml b/rs/moq-relay/Cargo.toml index 185bdd036ae..a0878b5f358 100644 --- a/rs/moq-relay/Cargo.toml +++ b/rs/moq-relay/Cargo.toml @@ -42,7 +42,7 @@ _quic = [] # congestion-control testing. Covers the io_uring workers too, so one feature # means one thing whichever runtime is serving. qlog = ["moq-tokio/qlog", "moq-uring?/qlog"] -websocket = ["moq-tokio/websocket", "dep:qmux", "dep:hyper"] +websocket = ["moq-tokio/websocket", "dep:qmux", "dep:hyper", "dep:tokio-tungstenite"] # Unix-domain-socket stream listener (`--server-unix-bind`), unix-only. In the # default set; drop via --no-default-features on platforms without Unix sockets. uds = ["moq-tokio/uds"] @@ -50,7 +50,7 @@ uds = ["moq-tokio/uds"] # This is off by default: the relay is useful without io_uring. io-uring = ["_uring", "moq-uring/quic"] # The listener machinery shared by the feature above. -_uring = ["dep:moq-sock", "dep:moq-uring"] +_uring = ["dep:moq-sock", "dep:moq-uring", "dep:web-transport-proto"] [dependencies] anyhow = { workspace = true, features = ["backtrace"] } @@ -92,6 +92,8 @@ sysinfo = { version = "0.39", default-features = false, features = ["system"] } thiserror = { workspace = true } tokio = { workspace = true, features = ["full"] } tokio-rustls = { workspace = true } +# Reclaims the socket under a WebSocket upgrade as a WebSocket stream. +tokio-tungstenite = { workspace = true, optional = true } toml = { workspace = true } tower-service = "0.3" tracing = { workspace = true } @@ -101,6 +103,8 @@ usage-rs = { workspace = true, features = ["completions", "config"] } [target.'cfg(target_os = "linux")'.dependencies] moq-sock = { workspace = true, optional = true } moq-uring = { workspace = true, optional = true } +# The WebTransport CONNECT response the io_uring listener answers with. +web-transport-proto = { workspace = true, optional = true } [target.'cfg(unix)'.dependencies] sd-notify = { workspace = true } @@ -127,6 +131,8 @@ tempfile = { workspace = true } test-env = { path = "../test-env" } tokio = { workspace = true, features = ["test-util"] } tracing-subscriber = { workspace = true } +# The CONNECT requests the WebTransport tests dial with. +web-transport-proto = { workspace = true } workspace-hack = { path = "../workspace-hack" } [target.'cfg(target_os = "linux")'.dev-dependencies] diff --git a/rs/moq-relay/src/auth.rs b/rs/moq-relay/src/auth.rs index 5e0bb770b67..c87b1527431 100644 --- a/rs/moq-relay/src/auth.rs +++ b/rs/moq-relay/src/auth.rs @@ -747,7 +747,7 @@ impl Lease { // may have ended with a reason a replacement outlived. match &mut self.refresh { None => { - if let std::task::Poll::Ready(ended) = self.consumer.poll_closed(&moq_net::kio::Waiter::noop()) { + if let std::task::Poll::Ready(ended) = self.consumer.poll_closed(&kio::Waiter::noop()) { reason = ended; } self.consumer.close(reason, bytes) diff --git a/rs/moq-relay/src/cache.rs b/rs/moq-relay/src/cache.rs index 281a101fd4e..6b143492b9f 100644 --- a/rs/moq-relay/src/cache.rs +++ b/rs/moq-relay/src/cache.rs @@ -286,7 +286,7 @@ mod tests { fn drive(mut driver: crate::cluster::Driver) -> Arc { let running = Arc::new(AtomicUsize::new(driver.len())); let report = running.clone(); - tokio::spawn(moq_net::kio::wait(move |waiter| { + tokio::spawn(kio::wait(move |waiter| { let poll = driver.poll(waiter); report.store(driver.len(), Ordering::SeqCst); poll diff --git a/rs/moq-relay/src/critical.rs b/rs/moq-relay/src/critical.rs index 923a1b4d29d..a4125cd5165 100644 --- a/rs/moq-relay/src/critical.rs +++ b/rs/moq-relay/src/critical.rs @@ -12,7 +12,6 @@ use std::{future::Future, panic::AssertUnwindSafe, task::Poll}; use futures::{FutureExt, future::BoxFuture}; -use moq_net::kio; /// A named future polled as a [`kio::Tasks`] child, whose panic becomes an error /// instead of unwinding through the owner's poll. diff --git a/rs/moq-relay/src/main.rs b/rs/moq-relay/src/main.rs index 39c9eb70058..9c46f87567c 100644 --- a/rs/moq-relay/src/main.rs +++ b/rs/moq-relay/src/main.rs @@ -2,7 +2,7 @@ use moq_relay::{Config, Relay}; #[cfg(feature = "jemalloc")] #[global_allocator] -static ALLOC: moq_tokio::jemalloc::tikv_jemallocator::Jemalloc = moq_tokio::jemalloc::tikv_jemallocator::Jemalloc; +static ALLOC: moq_tokio::jemalloc::Allocator = moq_tokio::jemalloc::Allocator; #[tokio::main] async fn main() -> anyhow::Result<()> { diff --git a/rs/moq-relay/src/shutdown.rs b/rs/moq-relay/src/shutdown.rs index 08551bd6957..64865855451 100644 --- a/rs/moq-relay/src/shutdown.rs +++ b/rs/moq-relay/src/shutdown.rs @@ -679,7 +679,7 @@ mod tests { admission.grant(consumer); let connection = connecting.await.unwrap().unwrap(); let draining = connection.draining().unwrap(); - let goaway = moq_net::kio::wait(|waiter| draining.poll(waiter)).await.unwrap(); + let goaway = kio::wait(|waiter| draining.poll(waiter)).await.unwrap(); assert_eq!(goaway.uri(), ""); connection.closed().await.unwrap(); running.await.unwrap().unwrap(); diff --git a/rs/moq-relay/src/uring.rs b/rs/moq-relay/src/uring.rs index 9a888aa7ef9..7c2e9ef982b 100644 --- a/rs/moq-relay/src/uring.rs +++ b/rs/moq-relay/src/uring.rs @@ -711,7 +711,7 @@ async fn accept( .iter() .find(|offered| serve.alpns.iter().any(|alpn| alpn == *offered)) .cloned(); - let mut response = moq_uring::quic::web::proto::ConnectResponse::OK; + let mut response = web_transport_proto::ConnectResponse::OK; if let Some(protocol) = &protocol { response = response.with_protocol(protocol); } @@ -780,7 +780,7 @@ pub(crate) struct Request { identity: Option, alpn: Option, /// The request URL, on WebTransport only. - url: Option, + url: Option, /// The latest caps the lease paced, `None` until it paces any. The lease lives on the /// shared runtime, so a task on this worker applies them to the connection. caps: kio::Producer>, diff --git a/rs/moq-relay/src/web.rs b/rs/moq-relay/src/web.rs index 88f3f576eca..1f400eb4ead 100644 --- a/rs/moq-relay/src/web.rs +++ b/rs/moq-relay/src/web.rs @@ -2532,7 +2532,7 @@ mod tests { async fn websocket_upgrade_advertises_the_configured_receive_windows() { use bytes::Buf; use futures::StreamExt; - use qmux::ws::tungstenite::{Message, client::IntoClientRequest}; + use tokio_tungstenite::tungstenite::{Message, client::IntoClientRequest}; // QMux's frame type, lengths, and QUIC transport parameter values use QUIC varints. fn decode_quic(bytes: &mut bytes::Bytes) -> Result { @@ -2565,7 +2565,7 @@ mod tests { request .headers_mut() .insert("sec-websocket-protocol", version.alpn().parse().unwrap()); - let (mut socket, _) = qmux::ws::tokio_tungstenite::connect_async(request).await.unwrap(); + let (mut socket, _) = tokio_tungstenite::connect_async(request).await.unwrap(); let Message::Binary(mut record) = kio::clock::timeout(std::time::Duration::from_secs(5), socket.next()) .await .unwrap() @@ -2860,9 +2860,9 @@ mod tests { "{}", String::from_utf8_lossy(&response) ); - let socket = qmux::ws::tokio_tungstenite::WebSocketStream::from_raw_socket( + let socket = tokio_tungstenite::WebSocketStream::from_raw_socket( stream, - qmux::ws::tungstenite::protocol::Role::Client, + tokio_tungstenite::tungstenite::protocol::Role::Client, None, ) .await; @@ -2903,9 +2903,7 @@ mod tests { None => socket_step(upgrade_while_draining(web.stream, true)).await, }; let draining = session.draining(); - let goaway = socket_step(moq_net::kio::wait(|waiter| draining.poll(waiter))) - .await - .unwrap(); + let goaway = socket_step(kio::wait(|waiter| draining.poll(waiter))).await.unwrap(); assert_eq!(goaway.uri(), ""); session.abort(moq_net::Error::Cancel); socket_step(web.running).await.unwrap().unwrap(); @@ -3015,22 +3013,22 @@ mod tests { let session = socket_step(upgrade_while_draining(web.stream, false)).await; drop(pending); let draining = session.draining(); - let goaway = socket_step(moq_net::kio::wait(|waiter| draining.poll(waiter))).await; + let goaway = socket_step(kio::wait(|waiter| draining.poll(waiter))).await; assert_eq!(goaway.unwrap().uri(), ""); session.abort(moq_net::Error::Cancel); socket_step(web.running).await.unwrap().unwrap(); } async fn refused_upgrade(stream: tokio::net::TcpStream) { - use qmux::ws::tungstenite::client::IntoClientRequest; + use tokio_tungstenite::tungstenite::client::IntoClientRequest; let mut request = format!("ws://{}/room", stream.peer_addr().unwrap()) .into_client_request() .unwrap(); request .headers_mut() .insert("sec-websocket-protocol", "qmux-01.moq-lite-06".parse().unwrap()); - let result = qmux::ws::tokio_tungstenite::client_async(request, stream).await; - let Err(qmux::ws::tungstenite::Error::Http(response)) = result else { + let result = tokio_tungstenite::client_async(request, stream).await; + let Err(tokio_tungstenite::tungstenite::Error::Http(response)) = result else { panic!("an upgrade after drain admission closed was not refused"); }; assert_eq!(response.status(), http::StatusCode::SERVICE_UNAVAILABLE); diff --git a/rs/moq-relay/src/websocket.rs b/rs/moq-relay/src/websocket.rs index 662c37106cb..b64b99f776a 100644 --- a/rs/moq-relay/src/websocket.rs +++ b/rs/moq-relay/src/websocket.rs @@ -1,9 +1,9 @@ use bytes::Bytes; use hyper_util::rt::TokioIo; -use qmux::ws::tokio_tungstenite::WebSocketStream; -use qmux::ws::tungstenite::{self, protocol::Role}; use std::sync::Arc; use tokio::io::{AsyncRead, AsyncWrite}; +use tokio_tungstenite::WebSocketStream; +use tokio_tungstenite::tungstenite::{self, protocol::Role}; use axum::{ extract::{ConnectInfo, Extension, OriginalUri, Request, State}, diff --git a/rs/moq-relay/tests/drills.rs b/rs/moq-relay/tests/drills.rs index b22e68f8ecd..09353f1137f 100644 --- a/rs/moq-relay/tests/drills.rs +++ b/rs/moq-relay/tests/drills.rs @@ -31,7 +31,6 @@ use std::time::Duration; use futures::FutureExt; use moq_relay::{Config, Relay}; -use moq_tokio::moq_net; /// A millisecond track with no publisher max age: the frames written here carry timestamps, /// and superseded groups stay readable. diff --git a/rs/moq-relay/tests/integration/auth_lifetime.rs b/rs/moq-relay/tests/integration/auth_lifetime.rs index ec565144d90..d75b7cca174 100644 --- a/rs/moq-relay/tests/integration/auth_lifetime.rs +++ b/rs/moq-relay/tests/integration/auth_lifetime.rs @@ -22,11 +22,10 @@ use axum::response::{IntoResponse, Response}; use axum::routing::post; use axum::{Json, Router}; use moq_auth::{Event, Grant, Pattern, Patterns, Request}; +use moq_net::stats; #[cfg(feature = "websocket")] use moq_relay::web; use moq_relay::{Config, Connection, Relay, auth, cluster}; -use moq_tokio::moq_net; -use moq_tokio::moq_net::stats; /// A millisecond track: the frames written here carry timestamps. fn timed() -> moq_net::track::Info { @@ -1233,7 +1232,7 @@ async fn the_drain_waits_for_a_closed_session_to_report_its_end() { trigger.start(); let started = kio::clock::now(); for client in &clients { - kio::clock::timeout(TIMEOUT, moq_net::kio::wait(|waiter| client.draining().poll(waiter))) + kio::clock::timeout(TIMEOUT, kio::wait(|waiter| client.draining().poll(waiter))) .await .expect("GOAWAY timeout") .expect("a GOAWAY"); diff --git a/rs/moq-relay/tests/integration/bitrate_caps.rs b/rs/moq-relay/tests/integration/bitrate_caps.rs index fe76cb7864d..01c7f32ba74 100644 --- a/rs/moq-relay/tests/integration/bitrate_caps.rs +++ b/rs/moq-relay/tests/integration/bitrate_caps.rs @@ -9,7 +9,6 @@ use std::time::Duration; use moq_relay::{Config, Relay}; -use moq_tokio::moq_net; use moq_tokio::quic::driver; const TIMEOUT: Duration = Duration::from_secs(10); diff --git a/rs/moq-relay/tests/integration/embed.rs b/rs/moq-relay/tests/integration/embed.rs index 8cd2f762b10..c7927b0c8d2 100644 --- a/rs/moq-relay/tests/integration/embed.rs +++ b/rs/moq-relay/tests/integration/embed.rs @@ -15,7 +15,6 @@ use std::net::TcpListener; use std::time::Duration; use moq_relay::{Config, Relay}; -use moq_tokio::moq_net; /// A millisecond track: the frames written here carry timestamps. fn timed() -> moq_net::track::Info { diff --git a/rs/moq-relay/tests/integration/goaway_cluster.rs b/rs/moq-relay/tests/integration/goaway_cluster.rs index cd252b9ca78..9f594e69f72 100644 --- a/rs/moq-relay/tests/integration/goaway_cluster.rs +++ b/rs/moq-relay/tests/integration/goaway_cluster.rs @@ -548,7 +548,7 @@ async fn cluster_diamond_goaway_seamless_failover_inner() { sub_connection .draining() .expect("connected") - .poll(&moq_net::kio::Waiter::noop()) + .poll(&kio::Waiter::noop()) .is_pending(), "BOTTOM must not propagate the upstream GOAWAY downstream" ); diff --git a/rs/moq-relay/tests/integration/public_rules.rs b/rs/moq-relay/tests/integration/public_rules.rs index fb11c502d46..40a7b698021 100644 --- a/rs/moq-relay/tests/integration/public_rules.rs +++ b/rs/moq-relay/tests/integration/public_rules.rs @@ -12,7 +12,6 @@ use std::time::Duration; use moq_relay::{auth, cluster, web}; -use moq_tokio::moq_net; /// A millisecond track: the frames written here carry timestamps. fn timed() -> moq_net::track::Info { diff --git a/rs/moq-relay/tests/integration/refusals.rs b/rs/moq-relay/tests/integration/refusals.rs index 6bb073888b0..4052dfe0131 100644 --- a/rs/moq-relay/tests/integration/refusals.rs +++ b/rs/moq-relay/tests/integration/refusals.rs @@ -447,7 +447,7 @@ async fn web_peer(addr: SocketAddr, alpn: &str) -> moq_tokio::quic::web::Session .unwrap() .await .unwrap(); - let request = web::proto::ConnectRequest::new( + let request = web_transport_proto::ConnectRequest::new( format!("https://{addr}/room?jwt=url-token") .parse::() .unwrap(), diff --git a/rs/moq-relay/tests/integration/runtime_uring.rs b/rs/moq-relay/tests/integration/runtime_uring.rs index 6861cd286ff..8a59886e89f 100644 --- a/rs/moq-relay/tests/integration/runtime_uring.rs +++ b/rs/moq-relay/tests/integration/runtime_uring.rs @@ -11,7 +11,6 @@ use std::net::SocketAddr; use std::time::Duration; use moq_relay::{Config, Relay}; -use moq_tokio::moq_net; use crate::logs::Logs; @@ -452,7 +451,7 @@ async fn drain_on_the_trigger(version: Option) { trigger.start(); let deadline = kio::clock::now() + DRAIN; let draining = established.draining().expect("connected"); - let goaway = kio::clock::timeout(TIMEOUT, moq_net::kio::wait(|waiter| draining.poll(waiter))) + let goaway = kio::clock::timeout(TIMEOUT, kio::wait(|waiter| draining.poll(waiter))) .await .unwrap_or_else(|_| panic!("{label}: no GOAWAY after the trigger")) .expect("session closed without a GOAWAY"); @@ -481,13 +480,10 @@ async fn drain_on_the_trigger(version: Option) { pending.grant(arrival_consumer); let arrival = arriving.await.expect("arrival task"); let draining = arrival.draining().expect("connected"); - let goaway = kio::clock::timeout( - Duration::from_secs(1), - moq_net::kio::wait(|waiter| draining.poll(waiter)), - ) - .await - .unwrap_or_else(|_| panic!("{label}: an arrival mid-drain was not sent a GOAWAY")) - .expect("arrival closed without a GOAWAY"); + let goaway = kio::clock::timeout(Duration::from_secs(1), kio::wait(|waiter| draining.poll(waiter))) + .await + .unwrap_or_else(|_| panic!("{label}: an arrival mid-drain was not sent a GOAWAY")) + .expect("arrival closed without a GOAWAY"); assert_eq!(goaway.uri(), "", "{label}: expected a reconnect-to-me GOAWAY"); if ietf { // Only what is left of the window, not a fresh one that would outlive the @@ -1000,7 +996,7 @@ async fn uring_forwards_the_setup_token() { .unwrap(); let session = if webtransport { let url: url::Url = format!("https://{addr}/room?source=setup").parse().unwrap(); - let request = web::proto::ConnectRequest::new(url).with_protocol("moqt-18".to_string()); + let request = web_transport_proto::ConnectRequest::new(url).with_protocol("moqt-18".to_string()); web::Session::connect(conn, request).await.unwrap() } else { web::Session::raw(conn) @@ -1231,7 +1227,8 @@ fn uring_workers_bound_stalled_handshakes() { } if scheme == "https" { let url: url::Url = format!("https://{addr}/stalled").parse().unwrap(); - let request = web::proto::ConnectRequest::new(url).with_protocol("moq-lite-06".to_string()); + let request = + web_transport_proto::ConnectRequest::new(url).with_protocol("moq-lite-06".to_string()); web::Session::connect(conn, request).await.unwrap() } else { web::Session::raw(conn) diff --git a/rs/moq-relay/tests/integration/runtime_workers.rs b/rs/moq-relay/tests/integration/runtime_workers.rs index 2a96182fc7f..b5e470903d0 100644 --- a/rs/moq-relay/tests/integration/runtime_workers.rs +++ b/rs/moq-relay/tests/integration/runtime_workers.rs @@ -9,7 +9,6 @@ use std::time::Duration; use moq_relay::{Config, Relay}; -use moq_tokio::moq_net; /// A millisecond track: the frames written here carry timestamps. fn timed() -> moq_net::track::Info { diff --git a/rs/moq-relay/tests/integration/session_revalidate.rs b/rs/moq-relay/tests/integration/session_revalidate.rs index 380531fd960..555dbe5cfcd 100644 --- a/rs/moq-relay/tests/integration/session_revalidate.rs +++ b/rs/moq-relay/tests/integration/session_revalidate.rs @@ -16,7 +16,6 @@ use axum::{Json, Router}; use moq_auth::{Event, Grant, Pattern, Patterns, Request}; use moq_relay::session::{Filter, List, Nudged}; use moq_relay::{Connection, auth, cluster, internal, web}; -use moq_tokio::moq_net; const TIMEOUT: Duration = Duration::from_secs(10); diff --git a/rs/moq-relay/tests/integration/shutdown_signal.rs b/rs/moq-relay/tests/integration/shutdown_signal.rs index 4127f328288..a6f0c0beeb6 100644 --- a/rs/moq-relay/tests/integration/shutdown_signal.rs +++ b/rs/moq-relay/tests/integration/shutdown_signal.rs @@ -178,13 +178,10 @@ async fn sigint_drains_sessions_before_exiting_inner() { // handler, registered above. assert_eq!(unsafe { libc::raise(libc::SIGINT) }, 0, "failed to raise SIGINT"); - let goaway = kio::clock::timeout( - Duration::from_secs(5), - moq_net::kio::wait(|waiter| draining.poll(waiter)), - ) - .await - .expect("no GOAWAY within 5s of SIGINT") - .expect("session closed without a GOAWAY"); + let goaway = kio::clock::timeout(Duration::from_secs(5), kio::wait(|waiter| draining.poll(waiter))) + .await + .expect("no GOAWAY within 5s of SIGINT") + .expect("session closed without a GOAWAY"); // Empty URI: the relay is restarting, not moving. The window itself is the // sender's own timer here (only moq-transport puts it on the wire), // so it is the elapsed time below that proves it was honored. @@ -220,13 +217,10 @@ async fn a_signal_right_after_ready_drains_inner() { // for SIGTERM, so in a process of its own (nextest) the relay's handler is all // that keeps this from killing the test. assert_eq!(unsafe { libc::raise(libc::SIGTERM) }, 0, "failed to raise SIGTERM"); - let goaway = kio::clock::timeout( - Duration::from_secs(5), - moq_net::kio::wait(|waiter| draining.poll(waiter)), - ) - .await - .expect("no GOAWAY within 5s of SIGTERM") - .expect("session closed without a GOAWAY"); + let goaway = kio::clock::timeout(Duration::from_secs(5), kio::wait(|waiter| draining.poll(waiter))) + .await + .expect("no GOAWAY within 5s of SIGTERM") + .expect("session closed without a GOAWAY"); assert_eq!(goaway.uri(), "", "expected a reconnect-to-me GOAWAY"); kio::clock::timeout(Duration::from_secs(15), run) .await @@ -302,13 +296,10 @@ async fn an_embedder_drains_on_its_trigger_inner() { // The embedder decides when. let started = kio::clock::now(); trigger.start(); - let goaway = kio::clock::timeout( - Duration::from_secs(5), - moq_net::kio::wait(|waiter| draining.poll(waiter)), - ) - .await - .expect("no GOAWAY within 5s of the trigger") - .expect("session closed without a GOAWAY"); + let goaway = kio::clock::timeout(Duration::from_secs(5), kio::wait(|waiter| draining.poll(waiter))) + .await + .expect("no GOAWAY within 5s of the trigger") + .expect("session closed without a GOAWAY"); assert_eq!(goaway.uri(), "", "expected a reconnect-to-me GOAWAY"); kio::clock::timeout(Duration::from_secs(15), run) @@ -343,13 +334,10 @@ async fn a_session_arriving_mid_drain_gets_what_is_left_inner() { let _straggler = straggler(port).await; trigger.start(); let deadline = kio::clock::now() + DRAIN_TIMEOUT; - let goaway = kio::clock::timeout( - Duration::from_secs(5), - moq_net::kio::wait(|waiter| draining.poll(waiter)), - ) - .await - .expect("no GOAWAY within 5s of the trigger") - .expect("session closed without a GOAWAY"); + let goaway = kio::clock::timeout(Duration::from_secs(5), kio::wait(|waiter| draining.poll(waiter))) + .await + .expect("no GOAWAY within 5s of the trigger") + .expect("session closed without a GOAWAY"); assert_eq!(goaway.uri(), "", "expected a reconnect-to-me GOAWAY"); let timeout = goaway.timeout().expect("the GOAWAY carries its deadline"); assert!( @@ -363,13 +351,10 @@ async fn a_session_arriving_mid_drain_gets_what_is_left_inner() { let dialed = kio::clock::now(); let arrival = connect(&client, port).await; let draining = arrival.draining().expect("connected"); - let goaway = kio::clock::timeout( - Duration::from_secs(1), - moq_net::kio::wait(|waiter| draining.poll(waiter)), - ) - .await - .expect("an arrival mid-drain was not sent a GOAWAY") - .expect("arrival closed without a GOAWAY"); + let goaway = kio::clock::timeout(Duration::from_secs(1), kio::wait(|waiter| draining.poll(waiter))) + .await + .expect("an arrival mid-drain was not sent a GOAWAY") + .expect("arrival closed without a GOAWAY"); assert_eq!(goaway.uri(), "", "expected a reconnect-to-me GOAWAY"); // Only what is left of the window, not a fresh one that would outlive the @@ -533,7 +518,7 @@ async fn a_reconnecting_client_rides_out_a_restart_inner() { /// A one-shot client offering `version` (every version when empty): a /// reconnecting one would migrate on the GOAWAY and hide whether the relay /// closed the original session. -fn client(version: Vec) -> moq_tokio::Client { +fn client(version: Vec) -> moq_tokio::Client { let mut client_config = moq_tokio::connect::Config::default(); client_config.tls.insecure = Some(true); client_config.version = version; diff --git a/rs/moq-relay/tests/integration/smoke.rs b/rs/moq-relay/tests/integration/smoke.rs index 5f028189eca..3872cfb6c9c 100644 --- a/rs/moq-relay/tests/integration/smoke.rs +++ b/rs/moq-relay/tests/integration/smoke.rs @@ -12,7 +12,6 @@ use std::time::Duration; #[cfg(all(feature = "quic", feature = "websocket"))] use moq_relay::{Config, Relay}; use moq_relay::{Connection, auth, cluster, web}; -use moq_tokio::moq_net; #[cfg(feature = "websocket")] use crate::logs::Logs; diff --git a/rs/moq-relay/tests/integration/tenant_matrix.rs b/rs/moq-relay/tests/integration/tenant_matrix.rs index a8fa9d0e8a4..0726b52ddd5 100644 --- a/rs/moq-relay/tests/integration/tenant_matrix.rs +++ b/rs/moq-relay/tests/integration/tenant_matrix.rs @@ -21,7 +21,6 @@ use axum::routing::post; use axum::{Json, Router}; use moq_auth::{Event, Grant, Pattern, Patterns, Request}; use moq_relay::Relay; -use moq_tokio::moq_net; use moq_tokio::quic::driver; use crate::refusals::{client, config}; @@ -345,7 +344,7 @@ async fn synced_listing(url: url::Url) -> BTreeSet { kio::clock::timeout(TIMEOUT, async { loop { // Synced counts only once every event queued before it was read. - let next = moq_net::kio::wait(|waiter| match routes.poll_next(waiter) { + let next = kio::wait(|waiter| match routes.poll_next(waiter) { Poll::Ready(event) => Poll::Ready(event), Poll::Pending => routes.poll_synced(waiter).map(|()| None), }) diff --git a/rs/moq-rtmp/src/lib.rs b/rs/moq-rtmp/src/lib.rs index c8d0d1684b2..2d43e987003 100644 --- a/rs/moq-rtmp/src/lib.rs +++ b/rs/moq-rtmp/src/lib.rs @@ -79,9 +79,3 @@ const DEFAULT_DELAY: Duration = Duration::from_millis(500); pub use dial::Client; pub use error::{Error, Result}; pub use server::{Conn, PUBLISH_IDLE_TIMEOUT, Play, Publish, Request, Server, Stream, accept_stream, configure_socket}; - -/// Re-export of the `rustls` version [`Server::with_tls`] takes, -/// so consumers construct a matching [`rustls::ServerConfig`] (a major `rustls` -/// bump is a breaking change). Only available with the `tls` feature. -#[cfg(feature = "tls")] -pub use rustls; diff --git a/rs/moq-stats/src/aggregate.rs b/rs/moq-stats/src/aggregate.rs index 4d55994184f..05af6d6faca 100644 --- a/rs/moq-stats/src/aggregate.rs +++ b/rs/moq-stats/src/aggregate.rs @@ -12,7 +12,7 @@ use std::task::Poll; use std::time::Duration; use kio::clock::Instant; -use moq_net::kio::{self, Pending, Waiter}; +use kio::{Pending, Waiter}; use moq_net::stats::{Presence, Traffic}; use moq_net::track::Resolving; use moq_net::{Instance, Path, broadcast, origin}; diff --git a/rs/moq-stats/src/produce.rs b/rs/moq-stats/src/produce.rs index 5aaf91b2f62..724a3a1e446 100644 --- a/rs/moq-stats/src/produce.rs +++ b/rs/moq-stats/src/produce.rs @@ -8,7 +8,7 @@ use std::task::{Poll, ready}; use kio::clock::Instant; use moq_net::stats::{Presence, Registry, Report, Tier, Traffic, TrafficEntry}; -use moq_net::{Path, broadcast, kio, origin, track}; +use moq_net::{Path, broadcast, origin, track}; use serde::Serialize; use crate::{ diff --git a/rs/moq-tokio/Cargo.toml b/rs/moq-tokio/Cargo.toml index 8d481b5fa13..1537866f4e8 100644 --- a/rs/moq-tokio/Cargo.toml +++ b/rs/moq-tokio/Cargo.toml @@ -39,7 +39,7 @@ qlog = ["moq-quic?/qlog"] # LAN peer discovery over mDNS (the `mdns` module). mdns = ["dep:mdns-sd"] jemalloc = ["dep:tikv-jemallocator", "dep:tikv-jemalloc-ctl"] -websocket = ["qmux", "watch", "dep:dns-lookup"] +websocket = ["qmux", "watch", "dep:dns-lookup", "dep:tokio-tungstenite"] # Qmux over TCP: plaintext `tcp://`, and `tls://`. Server-side and client-side. tcp = ["qmux", "dep:dns-lookup", "dep:tokio-rustls"] # MoQ over a qmux session established elsewhere, such as moq-webrtc's data channel: @@ -95,6 +95,8 @@ time = { workspace = true } tokio = { workspace = true, features = ["full"] } # The TLS stream `tcp::TlsAcceptor` accepts from a listener sharing its port. tokio-rustls = { workspace = true, optional = true } +# The WebSocket fallback dials and accepts with its own rustls config. +tokio-tungstenite = { workspace = true, features = ["handshake", "rustls-tls-native-roots"], optional = true } toml = { workspace = true } tracing = "0.1" tracing-subscriber = { version = "0.3", features = ["env-filter"] } @@ -107,7 +109,7 @@ x509-parser = { workspace = true } # Android's platform verifier needs a JNI handle to the app Context (see # `tls::init_android`); jni is the bridge. Until init runs, verification falls # back to the bundled Mozilla roots. -jni = "0.22" +jni = { workspace = true } tracing-android = "0.2" webpki-roots = "1" diff --git a/rs/moq-tokio/examples/chat.rs b/rs/moq-tokio/examples/chat.rs index ff99cb49c9b..61a6a30b163 100644 --- a/rs/moq-tokio/examples/chat.rs +++ b/rs/moq-tokio/examples/chat.rs @@ -51,7 +51,7 @@ async fn run_broadcast(origin: moq_net::origin::Producer) -> anyhow::Result<()> // Create a track that we'll insert into the broadcast. // A track is a series of groups representing a live stream. // Frames are stamped with the wall clock, so the track declares a timescale. - let info = moq_tokio::moq_net::track::Info::default().with_timescale(moq_tokio::moq_net::Timescale::MILLI); + let info = moq_net::track::Info::default().with_timescale(moq_net::Timescale::MILLI); let mut track = route.broadcast().create_track("chat", info)?; // Create a group. @@ -60,14 +60,8 @@ async fn run_broadcast(origin: moq_net::origin::Producer) -> anyhow::Result<()> // Write frames to the group. // Each frame is dependent on the previous frame, so older frames are prioritized. - group.write_frame( - moq_tokio::moq_net::Timestamp::now(), - bytes::Bytes::from_static(b"Hello"), - )?; - group.write_frame( - moq_tokio::moq_net::Timestamp::now(), - bytes::Bytes::from_static(b"World"), - )?; + group.write_frame(moq_net::Timestamp::now(), bytes::Bytes::from_static(b"Hello"))?; + group.write_frame(moq_net::Timestamp::now(), bytes::Bytes::from_static(b"World"))?; group.finish()?; tracing::info!("wrote hello + world"); @@ -76,10 +70,7 @@ async fn run_broadcast(origin: moq_net::origin::Producer) -> anyhow::Result<()> kio::clock::sleep(tokio::time::Duration::from_secs(10)).await; // There's also a helper method to create a group with a single frame. - track.write_frame( - moq_tokio::moq_net::Timestamp::now(), - bytes::Bytes::from_static(b"foobarbaz"), - )?; + track.write_frame(moq_net::Timestamp::now(), bytes::Bytes::from_static(b"foobarbaz"))?; tracing::info!("wrote foobarbaz"); // Sleep before exiting and closing the broadcast. diff --git a/rs/moq-tokio/examples/clock.rs b/rs/moq-tokio/examples/clock.rs index c5f4da8cf19..d88c9b9c613 100644 --- a/rs/moq-tokio/examples/clock.rs +++ b/rs/moq-tokio/examples/clock.rs @@ -171,11 +171,11 @@ impl Publisher { // Everything but the second. let base = now.format("%Y-%m-%d %H:%M:").to_string(); - segment.write_frame(moq_tokio::moq_net::Timestamp::now(), base.clone())?; + segment.write_frame(moq_net::Timestamp::now(), base.clone())?; loop { let delta = now.format("%S").to_string(); - segment.write_frame(moq_tokio::moq_net::Timestamp::now(), delta.clone())?; + segment.write_frame(moq_net::Timestamp::now(), delta.clone())?; let next = now + chrono::Duration::try_seconds(1).unwrap(); let next = next.with_nanosecond(0).unwrap(); diff --git a/rs/moq-tokio/src/cli.rs b/rs/moq-tokio/src/cli.rs index 372346b2786..05bebdbcb55 100644 --- a/rs/moq-tokio/src/cli.rs +++ b/rs/moq-tokio/src/cli.rs @@ -29,9 +29,6 @@ pub use deprecated::Deprecated; pub use duration::Duration; pub use env::{UnknownEnv, check_env}; -/// Re-exported because [`Merge`] and [`answer`] use Usage types in their APIs. -pub use usage_rs; - /// What a Usage parse result asks the process to do. #[non_exhaustive] pub enum Answer { diff --git a/rs/moq-tokio/src/client.rs b/rs/moq-tokio/src/client.rs index ceee5ccb887..ead235bde59 100644 --- a/rs/moq-tokio/src/client.rs +++ b/rs/moq-tokio/src/client.rs @@ -1098,7 +1098,7 @@ mod tests { .expect("failed to create track"); let mut group = track.append_group().expect("failed to append group"); group - .write_frame(crate::moq_net::Timestamp::ZERO, b"hello".as_ref()) + .write_frame(moq_net::Timestamp::ZERO, b"hello".as_ref()) .expect("failed to write frame"); group.finish().expect("failed to finish group"); diff --git a/rs/moq-tokio/src/connection.rs b/rs/moq-tokio/src/connection.rs index 428c214e347..167abaa035e 100644 --- a/rs/moq-tokio/src/connection.rs +++ b/rs/moq-tokio/src/connection.rs @@ -9,7 +9,6 @@ use std::time::Duration; use moq_net::Version; use moq_net::bandwidth::{Consumer as BandwidthConsumer, Producer as BandwidthProducer}; -use moq_net::kio; use moq_net::reconnect::{Action, Verdict}; use crate::abort::Detached; diff --git a/rs/moq-tokio/src/error.rs b/rs/moq-tokio/src/error.rs index 414df4572cd..d57c5caa204 100644 --- a/rs/moq-tokio/src/error.rs +++ b/rs/moq-tokio/src/error.rs @@ -255,6 +255,11 @@ pub enum Error { #[error(transparent)] Unix(Arc), + /// [`crate::watch::Files`] could not watch a file's directory. The string has the details. + #[cfg(feature = "watch")] + #[error("failed to watch files: {0}")] + Watch(String), + /// A qmux session refused the limits [`crate::server::Request::with_quic_limits`] set, /// such as a rate cap, which qmux cannot pace. #[cfg(feature = "qmux")] diff --git a/rs/moq-tokio/src/jemalloc.rs b/rs/moq-tokio/src/jemalloc.rs index abc4c5c605f..b2c17a34113 100644 --- a/rs/moq-tokio/src/jemalloc.rs +++ b/rs/moq-tokio/src/jemalloc.rs @@ -1,15 +1,44 @@ //! On-demand jemalloc heap profiling, for chasing leaks in a running process. //! -//! Spawn [`run`] to dump a profile whenever the process gets SIGUSR1. +//! Install [`Allocator`] as the `#[global_allocator]`, then spawn [`run`] to dump a profile +//! whenever the process gets SIGUSR1. //! //! Sampling does not have to be running for that to work. `MALLOC_CONF=prof:true` alone builds //! the profiling backend without sampling anything, and the first SIGUSR1 starts it. That keeps //! the steady-state cost off a process nobody is profiling: sampling accrues per-allocation //! metadata for as long as it runs, which on a busy process is hundreds of megabytes. +use std::alloc::{GlobalAlloc, Layout}; + use tikv_jemalloc_ctl::raw; +use tikv_jemallocator::Jemalloc; + +/// The jemalloc allocator [`run`] profiles, for a binary's `#[global_allocator]`. +#[derive(Clone, Copy, Debug, Default)] +pub struct Allocator; + +// Each method forwards to jemalloc's, under the same contract. +unsafe impl GlobalAlloc for Allocator { + #[inline] + unsafe fn alloc(&self, layout: Layout) -> *mut u8 { + unsafe { Jemalloc.alloc(layout) } + } + + #[inline] + unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 { + unsafe { Jemalloc.alloc_zeroed(layout) } + } + + #[inline] + unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { + unsafe { Jemalloc.dealloc(ptr, layout) } + } -pub use tikv_jemallocator; + #[inline] + unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 { + unsafe { Jemalloc.realloc(ptr, layout, new_size) } + } +} async fn blocking(work: impl FnOnce() -> T + Send + 'static) -> Result { tokio::task::spawn_blocking(work).await diff --git a/rs/moq-tokio/src/lib.rs b/rs/moq-tokio/src/lib.rs index ad080b66166..b6ba044fbb2 100644 --- a/rs/moq-tokio/src/lib.rs +++ b/rs/moq-tokio/src/lib.rs @@ -26,9 +26,6 @@ mod abort; pub mod accept; pub use moq_sock::bind; pub mod cli; -/// The congestion-controller traits, for a [`quic::Controller`] of the application's own. -#[cfg(feature = "driver")] -pub use moq_congestion as congestion; #[cfg(feature = "net")] pub mod client; #[cfg(feature = "net")] @@ -127,21 +124,6 @@ pub use server::{Listener, Server}; #[cfg(feature = "net")] pub use transport::Transport; -// Re-export these crates. -#[cfg(feature = "net")] -pub use moq_net; -pub use rustls; - -/// Re-exported because [`watch::Files`] surfaces `notify::Result`/`notify::Error` -/// in its API; a major `notify` bump is therefore a breaking change for this crate. -#[cfg(feature = "watch")] -pub use notify; - -/// Re-exported because [`tls::init_android`] takes a `jni::Env` handle; a major -/// `jni` bump is therefore a breaking change for this crate. -#[cfg(target_os = "android")] -pub use jni; - #[cfg(feature = "mdns")] pub mod mdns; diff --git a/rs/moq-tokio/src/quic.rs b/rs/moq-tokio/src/quic.rs index 4976a826cb0..56249f3f498 100644 --- a/rs/moq-tokio/src/quic.rs +++ b/rs/moq-tokio/src/quic.rs @@ -84,7 +84,7 @@ pub(crate) struct Forward { /// A congestion controller of the application's own, built fresh for each connection. /// -/// Implement [`crate::congestion::Factory`] and install it with [`Config::controller`]. +/// Implement [`moq_congestion::Factory`] and install it with [`Config::controller`]. #[cfg(feature = "driver")] #[derive(Clone)] pub struct Controller(pub std::sync::Arc); diff --git a/rs/moq-tokio/src/quic/backend.rs b/rs/moq-tokio/src/quic/backend.rs index 71030004f4b..60ef70370db 100644 --- a/rs/moq-tokio/src/quic/backend.rs +++ b/rs/moq-tokio/src/quic/backend.rs @@ -496,7 +496,7 @@ impl Client { let session = match url.scheme() { "https" => { - let mut request = web::proto::ConnectRequest::new(url.clone()); + let mut request = web_transport_proto::ConnectRequest::new(url.clone()); for protocol in versions.alpns() { request = request.with_protocol(protocol.to_string()); } @@ -589,9 +589,10 @@ fn map_client_error(err: web::Error) -> Error { /// it just burns the reconnect budget on a URL that will never work. fn client_status(err: &web::Error) -> Option { match err { - web::Error::Handshake(web::HandshakeError::Status(status)) => Some(status.as_u16()), + web::Error::Handshake(web::HandshakeError::Status(status)) => Some(*status), web::Error::Handshake(web::HandshakeError::Connect( - web::proto::ConnectError::ErrorStatus(status) | web::proto::ConnectError::WrongStatus(Some(status)), + web_transport_proto::ConnectError::ErrorStatus(status) + | web_transport_proto::ConnectError::WrongStatus(Some(status)), )) => Some(status.as_u16()), _ => None, } @@ -838,7 +839,7 @@ pub(crate) async fn accept( // The authority the client put in its CONNECT URL. let authority = request.url.host_str().filter(|h| !h.is_empty()).map(str::to_owned); - let mut response = web::proto::ConnectResponse::OK; + let mut response = web_transport_proto::ConnectResponse::OK; let mut link = link; if let Some(protocol) = request.protocols.iter().find(|p| alpns.contains(&p.as_str())) { response = response.with_protocol(protocol); diff --git a/rs/moq-tokio/src/quic/driver/connection.rs b/rs/moq-tokio/src/quic/driver/connection.rs index 3138fa4b741..d8e6069dc86 100644 --- a/rs/moq-tokio/src/quic/driver/connection.rs +++ b/rs/moq-tokio/src/quic/driver/connection.rs @@ -25,9 +25,9 @@ pub use moq_quic::connection::{Error, Stats}; use moq_quic::{ EndpointEvent, TransportError, TransportErrorCode, crypto, endpoint::ConnectionHandle, - rustls::pki_types::CertificateDer, stream::{Dir, Id as StreamId}, }; +use rustls::pki_types::CertificateDer; /// In-progress connection attempt future /// diff --git a/rs/moq-tokio/src/quic/web/connect.rs b/rs/moq-tokio/src/quic/web/connect.rs index cb7355b0155..022ce422a51 100644 --- a/rs/moq-tokio/src/quic/web/connect.rs +++ b/rs/moq-tokio/src/quic/web/connect.rs @@ -108,7 +108,7 @@ impl Connected { // Throw an error if we didn't get a 200 OK. if response.status != http::StatusCode::OK { - return Err(super::HandshakeError::Status(response.status).into()); + return Err(super::HandshakeError::Status(response.status.as_u16()).into()); } // Validate that the server's protocol was in our request. diff --git a/rs/moq-tokio/src/quic/web/error.rs b/rs/moq-tokio/src/quic/web/error.rs index 208125b34a2..40f2dce8c26 100644 --- a/rs/moq-tokio/src/quic/web/error.rs +++ b/rs/moq-tokio/src/quic/web/error.rs @@ -63,10 +63,11 @@ pub enum HandshakeError { #[error("connect: {0}")] Connect(#[from] web_transport_proto::ConnectError), - /// A status that does not fit the exchange: a client answered with anything but 200, or a - /// server asked to accept with a status other than 200, or to reject with one below 400. + /// An HTTP status that does not fit the exchange: a client answered with anything but 200, + /// or a server asked to accept with a status other than 200, or to reject with one outside + /// 400 to 599. #[error("http status: {0}")] - Status(http::StatusCode), + Status(u16), /// The CONNECT response selected a subprotocol the request did not offer. #[error("subprotocol not offered: {0}")] diff --git a/rs/moq-tokio/src/quic/web/mod.rs b/rs/moq-tokio/src/quic/web/mod.rs index f3fed2e49a6..46fd1fc8442 100644 --- a/rs/moq-tokio/src/quic/web/mod.rs +++ b/rs/moq-tokio/src/quic/web/mod.rs @@ -47,9 +47,3 @@ use settings::*; /// The HTTP/3 ALPN is required when negotiating a QUIC connection. pub const ALPN: &str = "h3"; - -/// Re-export the http crate because it's in the public API. -pub use http; - -/// Re-export the WebTransport protocol implementation. -pub use web_transport_proto as proto; diff --git a/rs/moq-tokio/src/quic/web/server.rs b/rs/moq-tokio/src/quic/web/server.rs index 22b2b8bde66..317acf19ec1 100644 --- a/rs/moq-tokio/src/quic/web/server.rs +++ b/rs/moq-tokio/src/quic/web/server.rs @@ -1,7 +1,6 @@ -use crate::quic::web::{ - Connecting, Error, HandshakeError, Session, Settings, - proto::{ConnectRequest, ConnectResponse}, -}; +use web_transport_proto::{ConnectRequest, ConnectResponse}; + +use crate::quic::web::{Connecting, Error, HandshakeError, Session, Settings}; /// A mostly complete WebTransport handshake, just awaiting the server's decision on whether to /// accept or reject the session based on the URL. @@ -39,18 +38,19 @@ impl Request { pub async fn respond(self, response: impl Into) -> Result { let response = response.into(); if response.status != http::StatusCode::OK { - return Err(HandshakeError::Status(response.status).into()); + return Err(HandshakeError::Status(response.status.as_u16()).into()); } let connect = self.connect.respond(response).await?; Ok(Session::new(self.conn, self.settings, connect)) } - /// Reject the session with a 4xx or 5xx status code. - pub async fn reject(self, status: http::StatusCode) -> Result<(), Error> { - if !status.is_client_error() && !status.is_server_error() { - return Err(HandshakeError::Status(status).into()); - } - self.connect.reject(status).await?; + /// Reject the session with a 4xx or 5xx HTTP status code. + pub async fn reject(self, status: u16) -> Result<(), Error> { + let code = http::StatusCode::from_u16(status) + .ok() + .filter(|code| code.is_client_error() || code.is_server_error()) + .ok_or(HandshakeError::Status(status))?; + self.connect.reject(code).await?; Ok(()) } diff --git a/rs/moq-tokio/src/quic/web/session.rs b/rs/moq-tokio/src/quic/web/session.rs index 70ea87e003c..50adf4d1c88 100644 --- a/rs/moq-tokio/src/quic/web/session.rs +++ b/rs/moq-tokio/src/quic/web/session.rs @@ -12,13 +12,12 @@ use bytes::{Buf, Bytes}; use futures::stream::{FuturesUnordered, StreamExt}; use kio::Waiter; +use web_transport_proto::{ConnectRequest, ConnectResponse, Frame, StreamUni, VarInt}; + use crate::quic::driver::send; use crate::quic::web::fan::Fan; use crate::quic::web::{ - CloseReason, Connected, Error, Settings, - proto::{ConnectRequest, ConnectResponse, Frame, StreamUni, VarInt}, - recv::Stream as RecvStream, - send::Stream as SendStream, + CloseReason, Connected, Error, Settings, recv::Stream as RecvStream, send::Stream as SendStream, }; /// An established WebTransport session, acting like a full QUIC connection. See @@ -1250,12 +1249,8 @@ mod tests { #[tokio::test] async fn a_rejection_refuses_non_error_statuses() { use futures::FutureExt; - for status in [ - http::StatusCode::CONTINUE, - http::StatusCode::OK, - http::StatusCode::NO_CONTENT, - http::StatusCode::FOUND, - ] { + // 600 parses as an HTTP status but is no error; 99 is no HTTP status at all. + for status in [100, 200, 204, 302, 600, 99] { let (client, server, _endpoints) = pair().await; let (client, ()) = tokio::join!( Session::connect(client, url::Url::parse("https://localhost/").unwrap()), diff --git a/rs/moq-tokio/src/quic/web/settings.rs b/rs/moq-tokio/src/quic/web/settings.rs index 40612ecff4f..88543d50f22 100644 --- a/rs/moq-tokio/src/quic/web/settings.rs +++ b/rs/moq-tokio/src/quic/web/settings.rs @@ -3,8 +3,8 @@ use std::pin::Pin; use futures::{StreamExt, stream::FuturesUnordered, try_join}; use tokio::io::AsyncReadExt; -use super::proto::StreamUni; use super::session::{PendingUni, log_header_error, read_uni_header}; +use web_transport_proto::StreamUni; pub struct Settings { #[allow( diff --git a/rs/moq-tokio/src/server.rs b/rs/moq-tokio/src/server.rs index cdcb51a9a6a..25148e45e04 100644 --- a/rs/moq-tokio/src/server.rs +++ b/rs/moq-tokio/src/server.rs @@ -2173,7 +2173,7 @@ mod tests { /// paused clock. #[cfg(feature = "websocket")] async fn session_pair() -> (qmux::Session, qmux::Session) { - use qmux::ws::tokio_tungstenite::{WebSocketStream, tungstenite::protocol::Role}; + use tokio_tungstenite::{WebSocketStream, tungstenite::protocol::Role}; const ALPN: &str = "qmux-01.moq-lite-06"; let (client, server) = tokio::io::duplex(64 * 1024); @@ -2191,7 +2191,7 @@ mod tests { #[tokio::test(start_paused = true)] async fn upgraded_websocket_preserves_request_metadata() { use moq_net::transport::poll::{SendOptions, SendStream as _, Session as _}; - use qmux::ws::tokio_tungstenite::{WebSocketStream, tungstenite::protocol::Role}; + use tokio_tungstenite::{WebSocketStream, tungstenite::protocol::Role}; let (client, server) = tokio::io::duplex(64 * 1024); let client = WebSocketStream::from_raw_socket(client, Role::Client, None).await; @@ -2235,7 +2235,7 @@ mod tests { #[tokio::test(start_paused = true)] async fn upgraded_websocket_refuses_setup_path_presence() { use moq_net::transport::poll::{SendOptions, SendStream as _, Session as _}; - use qmux::ws::tokio_tungstenite::{WebSocketStream, tungstenite::protocol::Role}; + use tokio_tungstenite::{WebSocketStream, tungstenite::protocol::Role}; for protocol in ["qmux-01.moq-lite-06", "qmux-01.moqt-18", "qmux-01.moqt-22"] { for path in ["", "/room?jwt=url-token", "/other?jwt=setup-token"] { diff --git a/rs/moq-tokio/src/watch.rs b/rs/moq-tokio/src/watch.rs index d361bd7c936..6cb12c7e388 100644 --- a/rs/moq-tokio/src/watch.rs +++ b/rs/moq-tokio/src/watch.rs @@ -28,14 +28,15 @@ impl Files { /// instance/watch limit is hit). `notify` already falls back to a built-in /// poll watcher on platforms without a native backend, so there's no manual /// polling here. - pub fn new(paths: &[PathBuf]) -> notify::Result { + pub fn new(paths: &[PathBuf]) -> crate::Result { // A capacity-1 channel of unit wakeups coalesces the burst of raw events // notify emits per change: a full buffer already has a pending wakeup, so // extra sends are dropped. let (tx, rx) = mpsc::channel(1); let watcher = callback(paths, move || { let _ = tx.try_send(()); - })?; + }) + .map_err(|err| crate::Error::Watch(crate::error::message(err)))?; Ok(Self { _watcher: watcher, @@ -199,7 +200,7 @@ mod tests { // watcher, so `new` must fall back to the current directory rather than error. #[test] fn bare_filename_watches_current_dir() { - match Files::new(&[PathBuf::from("cert.pem"), PathBuf::from("key.pem")]) { + match callback(&[PathBuf::from("cert.pem"), PathBuf::from("key.pem")], || {}) { Ok(_) => {} Err(err) if matches!(err.kind, notify::ErrorKind::MaxFilesWatch) => { eprintln!("skipping bare_filename_watches_current_dir: {err}"); diff --git a/rs/moq-tokio/src/websocket.rs b/rs/moq-tokio/src/websocket.rs index 1670aba1fb0..6f9e2d61f2a 100644 --- a/rs/moq-tokio/src/websocket.rs +++ b/rs/moq-tokio/src/websocket.rs @@ -7,11 +7,10 @@ //! accept it on a separate TCP port via [`Listener`], or pass an HTTP server's //! upgraded socket to [`accept`] before admitting the returned request. -use qmux::ws::tokio_tungstenite; -use qmux::ws::tokio_tungstenite::tungstenite::{self, client::IntoClientRequest, http}; use std::collections::HashSet; use std::sync::{Arc, LazyLock, Mutex}; use std::{net, time}; +use tokio_tungstenite::tungstenite::{self, client::IntoClientRequest, http}; use url::Url; use crate::cli::Duration as CliDuration; @@ -1207,7 +1206,7 @@ mod timeout_tests { peer = qmux::ws::Upgraded::new(peer, ALPN).connect() => crate::spawn_qmux(peer.unwrap()), result = accept.as_mut() => panic!("accepted before SETUP: {:?}", result.map(|_| ())), }; - let _stream = moq_net::kio::wait(|waiter| peer.poll_open_bi(waiter, Default::default())) + let _stream = kio::wait(|waiter| peer.poll_open_bi(waiter, Default::default())) .await .unwrap(); tokio::time::advance(timeout.unwrap_or(crate::listen::DEFAULT_TIMEOUT)).await; diff --git a/rs/moq-tokio/tests/integration/backend.rs b/rs/moq-tokio/tests/integration/backend.rs index 30ac910699c..29a00dc44ba 100644 --- a/rs/moq-tokio/tests/integration/backend.rs +++ b/rs/moq-tokio/tests/integration/backend.rs @@ -124,7 +124,7 @@ async fn connect_test(config: ConnectTest<'_>) { let mut group = track.append_group().expect("failed to append group"); group - .write_frame(moq_tokio::moq_net::Timestamp::ZERO, payload) + .write_frame(moq_net::Timestamp::ZERO, payload) .expect("failed to write frame"); group.finish().expect("failed to finish group"); @@ -158,7 +158,7 @@ async fn connect_test(config: ConnectTest<'_>) { // The client wired only a subscriber, so its advertised role reaches the server // over every transport, now that the SETUP is read before the caller authorizes // rather than deferred to `ok()`. - assert_eq!(request.role(), Some(moq_tokio::moq_net::setup::Role::Subscriber)); + assert_eq!(request.role(), Some(moq_net::setup::Role::Subscriber)); if let Some(expect_path) = expect_path { assert_eq!(request.path(), expect_path); } @@ -665,7 +665,7 @@ async fn quic_client_close_drains_finished_track() { } let mut group = track.append_group().expect("failed to append group"); group - .write_frame(moq_tokio::moq_net::Timestamp::ZERO, payload) + .write_frame(moq_net::Timestamp::ZERO, payload) .expect("failed to write frame"); group.finish().expect("failed to finish group"); track.finish().expect("failed to finish track"); @@ -807,7 +807,7 @@ async fn quic_client_close_drains_migrated_predecessor() { let mut group = track.append_group().expect("failed to append group"); group - .write_frame(moq_tokio::moq_net::Timestamp::ZERO, payload) + .write_frame(moq_net::Timestamp::ZERO, payload) .expect("failed to write frame"); group.finish().expect("failed to finish group"); track.finish().expect("failed to finish track"); @@ -862,10 +862,7 @@ async fn quic_client_close_drains_migrated_predecessor() { .expect("the subscription never reached the client") .expect("client thread panicked"); - first - .drain() - .send(moq_tokio::moq_net::goaway::Goaway::new()) - .expect("send goaway"); + first.drain().send(moq_net::goaway::Goaway::new()).expect("send goaway"); let request = kio::clock::timeout(TIMEOUT, server.accept()) .await .expect("the replacement never dialed") @@ -987,10 +984,7 @@ async fn quic_client_close_keeps_predecessor_handover() { .expect("the subscription never reached the client") .expect("client thread panicked"); - first - .drain() - .send(moq_tokio::moq_net::goaway::Goaway::new()) - .expect("send goaway"); + first.drain().send(moq_net::goaway::Goaway::new()).expect("send goaway"); let (err, elapsed) = tokio::task::spawn_blocking(move || client.join()) .await @@ -998,7 +992,7 @@ async fn quic_client_close_keeps_predecessor_handover() { .expect("client thread panicked"); // The one second close window would have ended it with a timeout instead. assert!( - !matches!(err, moq_tokio::Error::MoqNet(moq_tokio::moq_net::Error::Timeout)), + !matches!(err, moq_tokio::Error::MoqNet(moq_net::Error::Timeout)), "the handover deadline cuts the close short: {err:?}" ); // The window opened just before the status flipped, so most of it remains. Loose, diff --git a/rs/moq-tokio/tests/integration/broadcast.rs b/rs/moq-tokio/tests/integration/broadcast.rs index 5508bbfe111..d1c9335792b 100644 --- a/rs/moq-tokio/tests/integration/broadcast.rs +++ b/rs/moq-tokio/tests/integration/broadcast.rs @@ -8,7 +8,6 @@ //! This covers raw QUIC (moqt://) and WebTransport (https://) transports, //! exercising every protocol version the library supports. -use moq_tokio::moq_net; use std::time::Duration; /// A millisecond track with no publisher max age: the frames written here carry timestamps, @@ -43,7 +42,7 @@ async fn broadcast_test(scheme: &str, client_version: Option<&str>, server_versi // Write a group containing a single frame. let mut group = track.append_group().expect("failed to append group"); group - .write_frame(moq_tokio::moq_net::Timestamp::ZERO, b"hello".as_ref()) + .write_frame(moq_net::Timestamp::ZERO, b"hello".as_ref()) .expect("failed to write frame"); group.finish().expect("failed to finish group"); @@ -140,7 +139,7 @@ async fn broadcast_test(scheme: &str, client_version: Option<&str>, server_versi /// Lite05 publisher↔subscriber round-trip exercising the per-frame timestamp /// delta encoding, including negative deltas (B-frame ordering). async fn lite05_timestamp_roundtrip(scheme: &str) { - use moq_tokio::moq_net::{Timescale, Timestamp}; + use moq_net::{Timescale, Timestamp}; let pub_origin = moq_tokio::origin::spawn(); let broadcast = pub_origin @@ -258,7 +257,7 @@ async fn broadcast_moq_lite_05_timestamps_webtransport() { /// fetched frames are Deflate-compressed (matching TRACK_INFO) and inflated by the /// subscriber, exercising fetch/TRACK_INFO codec consistency. async fn lite05_fetch_roundtrip(scheme: &str) { - use moq_tokio::moq_net::{Timescale, Timestamp}; + use moq_net::{Timescale, Timestamp}; let pub_origin = moq_tokio::origin::spawn(); let broadcast = pub_origin @@ -490,7 +489,7 @@ async fn fetch_moq_transport_22() { /// subscription. Older relays served a subscription OR a fetch, never both, so /// this fetch would have hung. async fn lite05_fetch_during_subscribe(scheme: &str) { - use moq_tokio::moq_net::{Timescale, Timestamp}; + use moq_net::{Timescale, Timestamp}; let pub_origin = moq_tokio::origin::spawn(); let broadcast = pub_origin @@ -616,7 +615,7 @@ async fn broadcast_moq_lite_05_fetch_during_subscribe_webtransport() { /// `Some(ts)` at that scale. #[tokio::test] async fn broadcast_moq_lite_05_untimed_track() { - use moq_tokio::moq_net::Timescale; + use moq_net::Timescale; let pub_origin = moq_tokio::origin::spawn(); let broadcast = pub_origin @@ -1812,7 +1811,7 @@ async fn broadcast_websocket() { let mut group = track.append_group().expect("failed to append group"); group - .write_frame(moq_tokio::moq_net::Timestamp::ZERO, b"hello".as_ref()) + .write_frame(moq_net::Timestamp::ZERO, b"hello".as_ref()) .expect("failed to write frame"); group.finish().expect("failed to finish group"); @@ -1930,7 +1929,7 @@ async fn broadcast_websocket_fallback() { let mut group = track.append_group().expect("failed to append group"); group - .write_frame(moq_tokio::moq_net::Timestamp::ZERO, b"hello".as_ref()) + .write_frame(moq_net::Timestamp::ZERO, b"hello".as_ref()) .expect("failed to write frame"); group.finish().expect("failed to finish group"); @@ -2058,7 +2057,7 @@ async fn broadcast_websocket_uses_newest_version() { .expect("failed to create track"); let mut group = track.append_group().expect("failed to append group"); group - .write_frame(moq_tokio::moq_net::Timestamp::ZERO, b"hello".as_ref()) + .write_frame(moq_net::Timestamp::ZERO, b"hello".as_ref()) .expect("failed to write frame"); group.finish().expect("failed to finish group"); @@ -2138,7 +2137,7 @@ async fn quic_driver_task_inherits_connection_span() { .expect("failed to create track"); let mut group = track.append_group().expect("failed to append group"); group - .write_frame(moq_tokio::moq_net::Timestamp::ZERO, b"hello".as_ref()) + .write_frame(moq_net::Timestamp::ZERO, b"hello".as_ref()) .expect("failed to write frame"); group.finish().expect("failed to finish group"); @@ -2263,7 +2262,7 @@ async fn resubscribe_keeps_flowing_moq_lite_03() { let mut group0 = track.append_group().expect("append group 0"); group0 - .write_frame(moq_tokio::moq_net::Timestamp::ZERO, b"a".as_ref()) + .write_frame(moq_net::Timestamp::ZERO, b"a".as_ref()) .expect("write frame 0"); group0.finish().expect("finish group 0"); @@ -2340,7 +2339,7 @@ async fn resubscribe_keeps_flowing_moq_lite_03() { // A new group published after the resubscribe must reach the consumer. let mut group1 = track.append_group().expect("append group 1"); group1 - .write_frame(moq_tokio::moq_net::Timestamp::ZERO, b"b".as_ref()) + .write_frame(moq_net::Timestamp::ZERO, b"b".as_ref()) .expect("write frame 1"); group1.finish().expect("finish group 1"); @@ -2404,7 +2403,7 @@ async fn idle_subscription_releases_the_viewer_count() { let mut group = track.append_group().expect("append group"); group - .write_frame(moq_tokio::moq_net::Timestamp::ZERO, b"hello".as_ref()) + .write_frame(moq_net::Timestamp::ZERO, b"hello".as_ref()) .expect("write frame"); group.finish().expect("finish group"); @@ -2747,7 +2746,7 @@ async fn announce_interest_unauthorized_keeps_session_alive() { .expect("failed to create track"); let mut group = track.append_group().expect("failed to append group"); group - .write_frame(moq_tokio::moq_net::Timestamp::ZERO, b"hello".as_ref()) + .write_frame(moq_net::Timestamp::ZERO, b"hello".as_ref()) .expect("failed to write frame"); group.finish().expect("failed to finish group"); @@ -3050,7 +3049,7 @@ async fn publish_only_client_to_subscribe_only_server() { .expect("failed to create track"); let mut group = track.append_group().expect("failed to append group"); group - .write_frame(moq_tokio::moq_net::Timestamp::ZERO, b"hello".as_ref()) + .write_frame(moq_net::Timestamp::ZERO, b"hello".as_ref()) .expect("failed to write frame"); group.finish().expect("failed to finish group"); @@ -3218,13 +3217,13 @@ async fn goaway_test(scheme: &str, version: &str, expect_wire_timeout: bool) { // Trigger the drain and observe the GOAWAY. start_drain_tx.send(()).expect("send drain signal"); - let goaway = kio::clock::timeout(TIMEOUT, moq_net::kio::wait(|waiter| draining.poll(waiter))) + let goaway = kio::clock::timeout(TIMEOUT, kio::wait(|waiter| draining.poll(waiter))) .await .expect("goaway timed out") .expect("session closed before GOAWAY"); assert_eq!(goaway.uri(), "https://elsewhere.example/"); assert!(matches!( - draining.poll(&moq_net::kio::Waiter::noop()), + draining.poll(&kio::Waiter::noop()), std::task::Poll::Ready(Ok(_)) )); if expect_wire_timeout { @@ -3305,7 +3304,7 @@ async fn goaway_timeout_force_close_moq_transport_22_quic() { // Observe the GOAWAY but do NOT leave. let draining = connection.draining().expect("connected"); - let goaway = kio::clock::timeout(TIMEOUT, moq_net::kio::wait(|waiter| draining.poll(waiter))) + let goaway = kio::clock::timeout(TIMEOUT, kio::wait(|waiter| draining.poll(waiter))) .await .expect("goaway timed out") .expect("session closed before GOAWAY"); diff --git a/rs/moq-tokio/tests/integration/close_code.rs b/rs/moq-tokio/tests/integration/close_code.rs index 5887453c495..08016bcc581 100644 --- a/rs/moq-tokio/tests/integration/close_code.rs +++ b/rs/moq-tokio/tests/integration/close_code.rs @@ -7,8 +7,6 @@ use std::time::Duration; -use moq_tokio::moq_net; - const CODE: u16 = 4011; const RUNS: usize = 5; diff --git a/rs/moq-tokio/tests/integration/datagram_delivery.rs b/rs/moq-tokio/tests/integration/datagram_delivery.rs index a8a141c0c4d..d5b69e90f7e 100644 --- a/rs/moq-tokio/tests/integration/datagram_delivery.rs +++ b/rs/moq-tokio/tests/integration/datagram_delivery.rs @@ -11,7 +11,7 @@ use std::{sync::Arc, time::Duration}; use bytes::Bytes; -use moq_tokio::moq_net::{self, Timestamp}; +use moq_net::Timestamp; use moq_tokio::quic::{driver, web}; use crate::receive_credit::{dial, rand_seed}; diff --git a/rs/moq-tokio/tests/integration/fresh_port.rs b/rs/moq-tokio/tests/integration/fresh_port.rs index 9fe5a237ba2..48e6c7b7e0b 100644 --- a/rs/moq-tokio/tests/integration/fresh_port.rs +++ b/rs/moq-tokio/tests/integration/fresh_port.rs @@ -8,7 +8,7 @@ use std::{ time::Duration, }; -use moq_tokio::{Client, Connection, moq_net}; +use moq_tokio::{Client, Connection}; use tokio::{net::UdpSocket, sync::mpsc}; const DIAL: Duration = Duration::from_secs(1); diff --git a/rs/moq-tokio/tests/integration/keylog.rs b/rs/moq-tokio/tests/integration/keylog.rs index b9ff0c33ccd..a026da2b297 100644 --- a/rs/moq-tokio/tests/integration/keylog.rs +++ b/rs/moq-tokio/tests/integration/keylog.rs @@ -93,7 +93,7 @@ fn keylog_files_are_private_and_existing_permissions_are_not_changed() { /// Independently configured endpoints can append to the same destination without splitting lines. #[test] fn independent_keylog_writers_append_whole_records() { - use moq_tokio::rustls::KeyLog as _; + use rustls::KeyLog as _; let dir = tempfile::tempdir().unwrap(); let path = dir.path().join("keys.log"); let barrier = std::sync::Arc::new(std::sync::Barrier::new(8)); diff --git a/rs/moq-tokio/tests/integration/migrate.rs b/rs/moq-tokio/tests/integration/migrate.rs index aa53e31f36b..d7dbf6205c4 100644 --- a/rs/moq-tokio/tests/integration/migrate.rs +++ b/rs/moq-tokio/tests/integration/migrate.rs @@ -5,8 +5,6 @@ use std::time::Duration; -use moq_tokio::moq_net; - /// The only version whose routes carry the epoch that lets a subscription resume across /// the move. const LITE_07: &str = "moq-lite-07-wip"; diff --git a/rs/moq-tokio/tests/integration/receive_credit.rs b/rs/moq-tokio/tests/integration/receive_credit.rs index 307319cb151..f240f0ebfa6 100644 --- a/rs/moq-tokio/tests/integration/receive_credit.rs +++ b/rs/moq-tokio/tests/integration/receive_credit.rs @@ -15,8 +15,8 @@ use std::{process::Stdio, sync::Arc, time::Duration}; use bytes::Bytes; -use moq_tokio::moq_net::{ - self, Timestamp, frame, +use moq_net::{ + Timestamp, frame, track::{Delay, Subscription}, }; use moq_tokio::quic::{driver, web}; @@ -843,7 +843,7 @@ async fn javascript_partial_frame_gives_way(version: &str) { .expect("connect timeout") .expect("request"); let session = request - .respond(web::proto::ConnectResponse::OK.with_protocol(version.alpn())) + .respond(web_transport_proto::ConnectResponse::OK.with_protocol(version.alpn())) .await .expect("respond"); let origin = moq_tokio::origin::spawn(); diff --git a/rs/moq-tokio/tests/integration/reconnect.rs b/rs/moq-tokio/tests/integration/reconnect.rs index 3487d794152..9b1b3620cc3 100644 --- a/rs/moq-tokio/tests/integration/reconnect.rs +++ b/rs/moq-tokio/tests/integration/reconnect.rs @@ -7,8 +7,6 @@ use std::time::Duration; -use moq_tokio::moq_net; - /// A client whose reconnect loop escalates fast enough to assert on inside a test. fn client(backoff: moq_tokio::Backoff) -> moq_tokio::Client { let mut config = moq_tokio::connect::Config::default(); diff --git a/rs/moq-tokio/tests/integration/runtime.rs b/rs/moq-tokio/tests/integration/runtime.rs index 904287d710f..9b31ebc36c6 100644 --- a/rs/moq-tokio/tests/integration/runtime.rs +++ b/rs/moq-tokio/tests/integration/runtime.rs @@ -8,7 +8,6 @@ #![cfg(all(unix, feature = "quic", feature = "websocket", feature = "uds"))] use futures::executor::block_on; -use moq_tokio::moq_net; /// Serve one broadcast over every default transport and read it back over each. #[test] diff --git a/rs/moq-tokio/tests/integration/sim.rs b/rs/moq-tokio/tests/integration/sim.rs index 4d2989bce89..58f5f5a82d9 100644 --- a/rs/moq-tokio/tests/integration/sim.rs +++ b/rs/moq-tokio/tests/integration/sim.rs @@ -11,7 +11,7 @@ use std::{net::SocketAddr, sync::Arc, time::Duration}; use kio::clock::Instant; -use moq_tokio::moq_net::{self, Timescale, Timestamp, Version, origin, track}; +use moq_net::{Timescale, Timestamp, Version, origin, track}; use moq_tokio::quic::driver::{ self, sim::{Bottleneck, Link, Network, Path}, diff --git a/rs/moq-tokio/tests/integration/subscription_end_integrity.rs b/rs/moq-tokio/tests/integration/subscription_end_integrity.rs index e6e7268854d..69ca34cbd1e 100644 --- a/rs/moq-tokio/tests/integration/subscription_end_integrity.rs +++ b/rs/moq-tokio/tests/integration/subscription_end_integrity.rs @@ -26,8 +26,6 @@ use std::time::Duration; -use moq_tokio::moq_net; - /// A millisecond track: the frames written here carry timestamps. fn timed() -> moq_net::track::Info { moq_net::track::Info::default().with_timescale(moq_net::Timescale::MILLI) diff --git a/rs/moq-tokio/tests/integration/tokens.rs b/rs/moq-tokio/tests/integration/tokens.rs index 218df6d5ff8..81f0654e092 100644 --- a/rs/moq-tokio/tests/integration/tokens.rs +++ b/rs/moq-tokio/tests/integration/tokens.rs @@ -6,8 +6,6 @@ use std::{sync::Arc, time::Duration}; -use moq_tokio::moq_net; - /// What the server saw on one handshake. #[derive(Debug, PartialEq)] struct Seen { diff --git a/rs/moq-tokio/tests/integration/unannounce.rs b/rs/moq-tokio/tests/integration/unannounce.rs index 71c42e36635..23e6e111264 100644 --- a/rs/moq-tokio/tests/integration/unannounce.rs +++ b/rs/moq-tokio/tests/integration/unannounce.rs @@ -3,8 +3,6 @@ use std::time::Duration; -use moq_tokio::moq_net; - /// Subscribe to a published track, optionally unannounce (and let the origin /// process the retraction), then drop the subscriber and wait for the /// publisher's demand to go unused. diff --git a/rs/moq-uring/benches/echo_quic.rs b/rs/moq-uring/benches/echo_quic.rs index 66094f95dda..d67d5770e53 100644 --- a/rs/moq-uring/benches/echo_quic.rs +++ b/rs/moq-uring/benches/echo_quic.rs @@ -75,7 +75,7 @@ mod linux { .build() .expect("runtime"); runtime.block_on(async move { - let request = moq_tokio::quic::web::proto::ConnectRequest::new( + let request = web_transport_proto::ConnectRequest::new( url::Url::parse(&format!("https://{addr}/echo")).expect("url"), ); let session = super::support::web_connect(request, Default::default()) diff --git a/rs/moq-uring/src/lib.rs b/rs/moq-uring/src/lib.rs index 62ee4401793..db0ca71676f 100644 --- a/rs/moq-uring/src/lib.rs +++ b/rs/moq-uring/src/lib.rs @@ -59,9 +59,3 @@ mod worker; pub use error::Error; pub use timer::Timer; pub use worker::{Config, Handle, Worker}; - -/// The `url` crate, re-exported because -/// [`quic::web::proto::ConnectRequest::url`](crate::quic::web::proto::ConnectRequest::url) hands one back. -/// Naming that type otherwise means depending on a matching `url` version -/// directly, so a major bump here is a breaking change for this crate. -pub use url; diff --git a/rs/moq-uring/src/quic/web.rs b/rs/moq-uring/src/quic/web.rs index faccff8045e..8e53245b05b 100644 --- a/rs/moq-uring/src/quic/web.rs +++ b/rs/moq-uring/src/quic/web.rs @@ -23,10 +23,7 @@ use std::rc::Rc; use std::task::{Context, Poll, ready}; use bytes::{Buf, Bytes, BytesMut}; -/// HTTP types used when accepting or refusing a session. -pub use http; -/// The HTTP/3 and WebTransport wire types used by this API. -pub use web_transport_proto as proto; +use web_transport_proto as proto; /// The HTTP/3 ALPN used by WebTransport. pub const ALPN: &str = "h3"; @@ -240,7 +237,7 @@ impl Request { pub async fn respond(mut self, response: impl Into) -> Result { let response = response.into(); if response.status != http::StatusCode::OK { - return Err(HandshakeError::Status(response.status).into()); + return Err(HandshakeError::Status(response.status.as_u16()).into()); } if let Some(protocol) = &response.protocol && !self.request.protocols.contains(protocol) @@ -272,11 +269,12 @@ impl Request { /// ours) stay open until then: RFC 9114 makes closing one a connection /// error, so tearing them down here would show the peer an H3 failure /// instead of the status it was sent. - pub async fn reject(mut self, status: http::StatusCode) -> Result<(), Error> { - if !status.is_client_error() && !status.is_server_error() { - return Err(HandshakeError::Status(status).into()); - } - let response = proto::ConnectResponse::new(status); + pub async fn reject(mut self, status: u16) -> Result<(), Error> { + let code = http::StatusCode::from_u16(status) + .ok() + .filter(|code| code.is_client_error() || code.is_server_error()) + .ok_or(HandshakeError::Status(status))?; + let response = proto::ConnectResponse::new(code); let mut buf = Vec::new(); response.encode(&mut buf).map_err(HandshakeError::from)?; write_all(&mut self.send, &buf).await?; diff --git a/rs/moq-uring/src/quic/web/error.rs b/rs/moq-uring/src/quic/web/error.rs index 52a21579339..5b676d50a27 100644 --- a/rs/moq-uring/src/quic/web/error.rs +++ b/rs/moq-uring/src/quic/web/error.rs @@ -63,10 +63,10 @@ pub enum HandshakeError { #[error("connect: {0}")] Connect(#[from] web_transport_proto::ConnectError), - /// A status that does not fit the answer: accepting with anything but 200, or rejecting - /// with one below 400. + /// An HTTP status that does not fit the answer: accepting with anything but 200, or + /// rejecting with one outside 400 to 599. #[error("http status: {0}")] - Status(http::StatusCode), + Status(u16), /// The response selected a subprotocol the request did not offer. #[error("subprotocol not offered: {0}")] diff --git a/rs/moq-uring/tests/integration/echo.rs b/rs/moq-uring/tests/integration/echo.rs index e2f853946e6..454cebb46f6 100644 --- a/rs/moq-uring/tests/integration/echo.rs +++ b/rs/moq-uring/tests/integration/echo.rs @@ -75,7 +75,7 @@ fn echo_tokio_peer() { .build() .expect("runtime"); runtime.block_on(async move { - let request = moq_tokio::quic::web::proto::ConnectRequest::new( + let request = web_transport_proto::ConnectRequest::new( url::Url::parse(&format!("https://{addr}/echo")).expect("url"), ); let session = crate::support::web_connect(request, Default::default()) diff --git a/rs/moq-uring/tests/integration/local_addr.rs b/rs/moq-uring/tests/integration/local_addr.rs index a27e6a9ca8a..0421e663694 100644 --- a/rs/moq-uring/tests/integration/local_addr.rs +++ b/rs/moq-uring/tests/integration/local_addr.rs @@ -175,9 +175,8 @@ fn a_wildcard_endpoint_handshakes_on_a_secondary_address() { .build() .expect("runtime"); runtime.block_on(async move { - let request = moq_tokio::quic::web::proto::ConnectRequest::new( - url::Url::parse(&format!("https://{addr}/")).expect("url"), - ); + let request = + web_transport_proto::ConnectRequest::new(url::Url::parse(&format!("https://{addr}/")).expect("url")); kio::clock::timeout(TIMEOUT, crate::support::web_connect(request, Default::default())) .await .expect("handshake stalled") diff --git a/rs/moq-uring/tests/integration/receive_credit.rs b/rs/moq-uring/tests/integration/receive_credit.rs index 4706e6f91cb..8e67c32d350 100644 --- a/rs/moq-uring/tests/integration/receive_credit.rs +++ b/rs/moq-uring/tests/integration/receive_credit.rs @@ -291,7 +291,7 @@ fn javascript_partial_frame_gives_way() { .await .expect("handshake"); let session = request - .respond(quic::web::proto::ConnectResponse::OK.with_protocol(ALPN)) + .respond(web_transport_proto::ConnectResponse::OK.with_protocol(ALPN)) .await .expect("respond"); let (session, driver) = moq_net::Server::new() diff --git a/rs/moq-uring/tests/integration/support.rs b/rs/moq-uring/tests/integration/support.rs index b6067a151b2..09554c578ee 100644 --- a/rs/moq-uring/tests/integration/support.rs +++ b/rs/moq-uring/tests/integration/support.rs @@ -89,7 +89,7 @@ pub fn bundle() -> anyhow::Result { /// Open a WebTransport session to `request` from tokio, through the driver's /// own `connect`, trusting whatever certificate the server presents. pub async fn web_connect( - request: moq_tokio::quic::web::proto::ConnectRequest, + request: web_transport_proto::ConnectRequest, transport: moq_tokio::quic::driver::transport::Config, ) -> Result { use moq_tokio::quic::{driver, web}; diff --git a/rs/moq-uring/tests/integration/web.rs b/rs/moq-uring/tests/integration/web.rs index 2a668696515..26f86d20f79 100644 --- a/rs/moq-uring/tests/integration/web.rs +++ b/rs/moq-uring/tests/integration/web.rs @@ -64,8 +64,8 @@ fn tokio_client( .build() .expect("tokio runtime"); rt.block_on(async move { - let request = moq_tokio::quic::web::proto::ConnectRequest::new(url::Url::parse(&url).expect("url")) - .with_protocol(PROTO); + let request = + web_transport_proto::ConnectRequest::new(url::Url::parse(&url).expect("url")).with_protocol(PROTO); let session = crate::support::web_connect(request, Default::default()) .await .expect("connect"); @@ -164,7 +164,7 @@ fn webtransport_echo_end_to_end() { ); assert_eq!(request.protocols, [PROTO.to_string()]); let session = request - .respond(quic::web::proto::ConnectResponse::OK.with_protocol(PROTO)) + .respond(web_transport_proto::ConnectResponse::OK.with_protocol(PROTO)) .await .expect("respond"); assert_eq!(session.protocol(), Some(PROTO), "negotiated subprotocol"); @@ -231,7 +231,7 @@ fn webtransport_accepts_a_buffered_uni_after_the_peer_close() { let conn = endpoint.accept().await.expect("accept"); let request = quic::web::Request::accept(conn).await.expect("handshake"); let session = request - .respond(quic::web::proto::ConnectResponse::OK.with_protocol(PROTO)) + .respond(web_transport_proto::ConnectResponse::OK.with_protocol(PROTO)) .await .expect("respond"); kio::wait(|waiter| session.poll_closed(waiter)).await; @@ -267,7 +267,7 @@ fn a_clean_finish_closes_a_stream() { let conn = endpoint.accept().await.expect("accept"); let request = quic::web::Request::accept(conn).await.expect("handshake"); let session = request - .respond(quic::web::proto::ConnectResponse::OK.with_protocol(PROTO)) + .respond(web_transport_proto::ConnectResponse::OK.with_protocol(PROTO)) .await .expect("respond"); let mut recv = kio::wait(|waiter| session.poll_accept_uni(waiter)) @@ -318,7 +318,7 @@ fn a_stray_datagram_is_dropped() { let conn = endpoint.accept().await.expect("accept"); let request = quic::web::Request::accept(conn).await.expect("handshake"); let session = request - .respond(quic::web::proto::ConnectResponse::OK.with_protocol(PROTO)) + .respond(web_transport_proto::ConnectResponse::OK.with_protocol(PROTO)) .await .expect("respond"); let datagram = within( @@ -365,7 +365,7 @@ fn an_unread_lease_holds_the_close_watch_off() { let conn = endpoint.accept().await.expect("accept"); let request = quic::web::Request::accept(conn).await.expect("handshake"); let session = request - .respond(quic::web::proto::ConnectResponse::OK.with_protocol(PROTO)) + .respond(web_transport_proto::ConnectResponse::OK.with_protocol(PROTO)) .await .expect("respond"); let mut recv = kio::wait(|waiter| session.poll_accept_uni(waiter)) @@ -489,7 +489,7 @@ fn lite_session_over_webtransport() { let request = quic::web::Request::accept(conn).await.expect("handshake"); // The WebTransport equivalent of ALPN: pick the moq version. let protocol = request.protocols.iter().find(|p| *p == PROTO).cloned(); - let mut response = quic::web::proto::ConnectResponse::OK; + let mut response = web_transport_proto::ConnectResponse::OK; if let Some(protocol) = &protocol { response = response.with_protocol(protocol); } @@ -543,8 +543,8 @@ fn tokio_client_err(url: String) -> std::thread::JoinHandle Duration { .build() .expect("runtime"); runtime.block_on(async { - let request = moq_tokio::quic::web::proto::ConnectRequest::new( + let request = web_transport_proto::ConnectRequest::new( url::Url::parse(&format!("https://{address}/headers")).unwrap(), ); let session = support::web_connect(request, Default::default()) diff --git a/rs/moq-video/Cargo.toml b/rs/moq-video/Cargo.toml index 396372f3f5d..7b8346ec723 100644 --- a/rs/moq-video/Cargo.toml +++ b/rs/moq-video/Cargo.toml @@ -144,7 +144,7 @@ tracing = { workspace = true } # GPU rendering behind the `render` feature. `wgpu::hal` is re-exported by wgpu # itself, so the zero-copy import paths reach the platform handles without a # separate wgpu-hal dependency that could drift to a different version. -wgpu = { version = "30", optional = true } +wgpu = { workspace = true, optional = true } # RGBA -> I420 color conversion (replaces ffmpeg swscale). yuv = "0.8.14" diff --git a/rs/moq-video/examples/d3d11-resize-probe.rs b/rs/moq-video/examples/d3d11-resize-probe.rs index 7aa4f306b67..61e9a07a786 100644 --- a/rs/moq-video/examples/d3d11-resize-probe.rs +++ b/rs/moq-video/examples/d3d11-resize-probe.rs @@ -73,10 +73,11 @@ mod probe { use std::time::{Duration, Instant}; use anyhow::{Context, Result, anyhow, bail}; - use moq_video::windows::Win32::Foundation::{HMODULE, RECT}; - use moq_video::windows::Win32::Graphics::Direct3D::D3D_DRIVER_TYPE_HARDWARE; - use moq_video::windows::Win32::Graphics::Direct3D10::ID3D10Multithread; - use moq_video::windows::Win32::Graphics::Direct3D11::{ + use moq_video::{Frame, I420, Size, Surface}; + use windows::Win32::Foundation::{HMODULE, RECT}; + use windows::Win32::Graphics::Direct3D::D3D_DRIVER_TYPE_HARDWARE; + use windows::Win32::Graphics::Direct3D10::ID3D10Multithread; + use windows::Win32::Graphics::Direct3D11::{ D3D11_BIND_DECODER, D3D11_BIND_RENDER_TARGET, D3D11_BIND_SHADER_RESOURCE, D3D11_BIND_VIDEO_ENCODER, D3D11_BOX, D3D11_CPU_ACCESS_READ, D3D11_CREATE_DEVICE_BGRA_SUPPORT, D3D11_CREATE_DEVICE_DEBUG, D3D11_CREATE_DEVICE_VIDEO_SUPPORT, D3D11_MAP_READ, D3D11_MAPPED_SUBRESOURCE, D3D11_MESSAGE, D3D11_SDK_VERSION, @@ -90,8 +91,8 @@ mod probe { ID3D11VideoProcessor, ID3D11VideoProcessorEnumerator, ID3D11VideoProcessorInputView, ID3D11VideoProcessorOutputView, }; - use moq_video::windows::Win32::Graphics::Dxgi::Common::{DXGI_FORMAT_NV12, DXGI_RATIONAL, DXGI_SAMPLE_DESC}; - use moq_video::windows::Win32::Media::MediaFoundation::{ + use windows::Win32::Graphics::Dxgi::Common::{DXGI_FORMAT_NV12, DXGI_RATIONAL, DXGI_SAMPLE_DESC}; + use windows::Win32::Media::MediaFoundation::{ IMFActivate, IMFDXGIBuffer, IMFDXGIDeviceManager, IMFSample, IMFTransform, MF_E_NO_MORE_TYPES, MF_E_NOTACCEPTING, MF_E_TRANSFORM_NEED_MORE_INPUT, MF_E_TRANSFORM_STREAM_CHANGE, MF_LOW_LATENCY, MF_MT_FRAME_SIZE, MF_MT_MAJOR_TYPE, MF_MT_SUBTYPE, MF_VERSION, MFCreateDXGIDeviceManager, MFCreateMediaType, @@ -100,9 +101,8 @@ mod probe { MFT_MESSAGE_NOTIFY_BEGIN_STREAMING, MFT_MESSAGE_SET_D3D_MANAGER, MFT_OUTPUT_DATA_BUFFER, MFT_OUTPUT_STREAM_PROVIDES_SAMPLES, MFT_REGISTER_TYPE_INFO, MFTEnumEx, MFVideoFormat_H264, MFVideoFormat_NV12, }; - use moq_video::windows::Win32::System::Com::{COINIT_MULTITHREADED, CoInitializeEx, CoTaskMemFree, CoUninitialize}; - use moq_video::windows::core::Interface; - use moq_video::{Frame, I420, Size, Surface}; + use windows::Win32::System::Com::{COINIT_MULTITHREADED, CoInitializeEx, CoTaskMemFree, CoUninitialize}; + use windows::core::Interface; /// The source stream the probe decodes, and the size it scales down to. const SOURCE: Size = Size { diff --git a/rs/moq-video/src/lib.rs b/rs/moq-video/src/lib.rs index 21a7ed4cff2..f75f4e77f9f 100644 --- a/rs/moq-video/src/lib.rs +++ b/rs/moq-video/src/lib.rs @@ -116,27 +116,3 @@ pub use frame::{Frame, I420, Surface}; pub use frame_rate::{FrameRate, FrameRateError, MAX_FRAMES_PER_SECOND}; pub use output::Output; pub use size::Size; - -/// The NDK bindings [`frame::android::HardwareBuffer::buffer`] hands back, -/// re-exported for the same reason as the Apple and Windows ones: name the -/// exact version this crate links rather than guessing at a matching one, since a -/// hardware buffer from a different `ndk` build is a different type. A major bump -/// here is a breaking change for this crate. -#[cfg(all(target_os = "android", feature = "mediacodec"))] -pub use ndk; -/// The CoreFoundation bindings owning the handle [`Surface::into_pixel_buffer`] -/// returns, re-exported alongside [`objc2_core_video`] for the same reason. -#[cfg(apple)] -pub use objc2_core_foundation; -/// The CoreVideo bindings [`Surface::into_pixel_buffer`] hands back, -/// re-exported so you name the exact version this crate links rather than guessing -/// at a matching one. A major bump here is a breaking change for this crate. -#[cfg(apple)] -pub use objc2_core_video; -/// The Direct3D11 bindings [`frame::d3d11::Texture`] hands back, re-exported for -/// the same reason as the Apple ones above: name the exact version this crate -/// links rather than guessing at a matching one, since a device and a texture -/// from a different `windows` build are different types. A major bump here is a -/// breaking change for this crate. -#[cfg(target_os = "windows")] -pub use windows; diff --git a/rs/moq-video/src/render/mod.rs b/rs/moq-video/src/render/mod.rs index f9e56fc77cb..3106e7bf9e0 100644 --- a/rs/moq-video/src/render/mod.rs +++ b/rs/moq-video/src/render/mod.rs @@ -12,7 +12,7 @@ //! dependency. //! //! ```no_run -//! # fn example(device: &moq_video::render::wgpu::Device, queue: &moq_video::render::wgpu::Queue) -> Result<(), moq_video::Error> { +//! # fn example(device: &wgpu::Device, queue: &wgpu::Queue) -> Result<(), moq_video::Error> { //! use moq_video::render::{Config, Renderer}; //! //! let mut renderer = Renderer::new(device, queue, Config::new())?; @@ -70,14 +70,6 @@ mod metal; pub use device::request_device; pub use renderer::{Config, Renderer}; -/// The `wgpu` this renderer was built against, re-exported so you name the exact -/// version rather than guessing at a compatible one. -/// -/// [`Renderer::new`] takes this crate's `Device` and `Queue`, and -/// [`Renderer::render`] hands back its `Texture`, so a major bump here is a -/// breaking change for this crate. -pub use wgpu; - #[cfg(test)] mod tests { /// An application typically decodes on one task and draws on another, so diff --git a/rs/moq-webrtc/src/lib.rs b/rs/moq-webrtc/src/lib.rs index 4f3014534da..9f7d76ee2d6 100644 --- a/rs/moq-webrtc/src/lib.rs +++ b/rs/moq-webrtc/src/lib.rs @@ -59,19 +59,6 @@ mod session; // str0m, dimpl, `is`, and sctp-proto, vendored and trimmed; see the module docs. mod vendor; -/// Re-export of the HTTP router stack, so consumers can merge the [`axum::Router`] -/// returned by [`Server::publish_router`] / [`Server::subscribe_router`] into their -/// own app without adding their own axum dependency (and risking a version mismatch). A major axum bump is therefore -/// a breaking change for this crate. Only with the `server` feature. -#[cfg(feature = "server")] -pub use axum; - -/// Re-export of the URL type, so consumers can build the [`url::Url`] that -/// [`Client::subscribe`] / [`Client::publish`] dial without adding their own url -/// dependency (and risking a version mismatch). A major url bump is therefore a -/// breaking change for this crate. -pub use url; - pub use client::Client; pub use error::*; pub use server::{Response, Server, whep, whip}; diff --git a/rs/qmux/Cargo.toml b/rs/qmux/Cargo.toml index 92158349e78..b846a66f09e 100644 --- a/rs/qmux/Cargo.toml +++ b/rs/qmux/Cargo.toml @@ -34,7 +34,7 @@ rustls-native-certs = { workspace = true, optional = true } thiserror = { workspace = true } tokio = { workspace = true } tokio-rustls = { workspace = true, optional = true } -tokio-tungstenite = { version = "0.30", default-features = false, features = ["connect", "handshake"], optional = true } +tokio-tungstenite = { workspace = true, features = ["connect", "handshake"], optional = true } # `poll_read_buf`, which reads into a `BytesMut` without zeroing it first. tokio-util = { workspace = true, features = ["io"] } tracing = { workspace = true } diff --git a/rs/qmux/benches/receive.rs b/rs/qmux/benches/receive.rs index 29d0adb5c6b..aee4dfe477b 100644 --- a/rs/qmux/benches/receive.rs +++ b/rs/qmux/benches/receive.rs @@ -94,7 +94,8 @@ impl Receivers { for _ in 0..sessions { let (client, server) = tokio::io::duplex(64 << 10); let (client, server) = if websocket { - use qmux::ws::{Upgraded, tokio_tungstenite::WebSocketStream, tungstenite::protocol::Role}; + use qmux::ws::Upgraded; + use tokio_tungstenite::{WebSocketStream, tungstenite::protocol::Role}; let client = WebSocketStream::from_raw_socket(client, Role::Client, None).await; let server = WebSocketStream::from_raw_socket(server, Role::Server, None).await; let (client, server) = tokio::join!( diff --git a/rs/qmux/examples/bench.rs b/rs/qmux/examples/bench.rs index 3266cb0293c..26df9d26775 100644 --- a/rs/qmux/examples/bench.rs +++ b/rs/qmux/examples/bench.rs @@ -192,7 +192,7 @@ async fn connect(transport: Transport, tls: &Tls, addr: SocketAddr) -> anyhow::R ), Transport::Ws => spawn(qmux::ws::Client::new().connect(&format!("ws://{addr}")).await?), Transport::Wss => { - let connector = qmux::ws::tokio_tungstenite::Connector::Rustls(tls.client.clone()); + let connector = tokio_tungstenite::Connector::Rustls(tls.client.clone()); spawn( qmux::ws::Client::new() .with_connector(connector) diff --git a/rs/qmux/src/ws.rs b/rs/qmux/src/ws.rs index 6c243ee510b..4f4c11ecc88 100644 --- a/rs/qmux/src/ws.rs +++ b/rs/qmux/src/ws.rs @@ -6,25 +6,10 @@ use crate::protocol::validate_protocol; use crate::transport::WsTransport; use moq_net::transport::Address; use moq_quic::Side; -use tokio_tungstenite::{MaybeTlsStream, WebSocketStream}; +use tokio_tungstenite::{MaybeTlsStream, WebSocketStream, tungstenite}; use crate::{Config, Driver, Error, Session, Version, alpn}; -/// The `tokio-tungstenite` version this crate is built against. -/// -/// [`Client::with_connector`] and [`Upgraded`] take `tokio-tungstenite` types -/// directly, so use this re-export rather than a separately pinned dependency - -/// a different minor version is a distinct crate to the compiler and fails to -/// typecheck against these APIs. -pub use tokio_tungstenite; - -/// The `tungstenite` version this crate is built against, matching -/// [`tokio_tungstenite`]. -/// -/// [`Client::with_config`] and [`Upgraded`] name `tungstenite` types, and -/// [`Error::WebSocket`] wraps a `tungstenite::Error`. -pub use tokio_tungstenite::tungstenite; - /// The largest WebSocket message or frame a session under `config` reads. /// /// Each message carries one record, or one frame on draft-00, so cap a socket upgraded diff --git a/test/interop/clients/rust/catalog.rs b/test/interop/clients/rust/catalog.rs index 8376ea7e687..20bb6ea1efd 100644 --- a/test/interop/clients/rust/catalog.rs +++ b/test/interop/clients/rust/catalog.rs @@ -4,7 +4,6 @@ //! moq-lite-07 alone so the relay receives and stores the DEFLATE slices. Prints the catalog //! group's inflated size, which is what a relay serving plain readers must inflate exactly once. use anyhow::{Context, ensure}; -use moq_tokio::moq_net; use tokio::io::AsyncBufReadExt; /// Renditions enough for the catalog to compress, and for readers to check what they decoded. diff --git a/test/interop/clients/rust/control.rs b/test/interop/clients/rust/control.rs index a2ab1aa10a4..586f2b80c6d 100644 --- a/test/interop/clients/rust/control.rs +++ b/test/interop/clients/rust/control.rs @@ -1,6 +1,5 @@ //! Real Rust server for a JS TRACK_STATUS requester. use anyhow::{Context, ensure}; -use moq_tokio::moq_net; #[tokio::main(flavor = "current_thread")] async fn main() -> anyhow::Result<()> { diff --git a/test/interop/clients/rust/finish.rs b/test/interop/clients/rust/finish.rs index 43a58afa242..60051b406b6 100644 --- a/test/interop/clients/rust/finish.rs +++ b/test/interop/clients/rust/finish.rs @@ -4,7 +4,6 @@ use std::time::Duration; use anyhow::{Context, ensure}; use moq_mux::catalog::Stream; -use moq_tokio::moq_net; use tokio::io::{AsyncBufReadExt, AsyncReadExt}; /// How long the publisher keeps its finished broadcast up for the late readers. diff --git a/test/interop/clients/rust/goaway.rs b/test/interop/clients/rust/goaway.rs index b47fd39e609..3ec33ff4bf1 100644 --- a/test/interop/clients/rust/goaway.rs +++ b/test/interop/clients/rust/goaway.rs @@ -2,7 +2,6 @@ use std::process::Stdio; use anyhow::{Context, ensure}; -use moq_tokio::moq_net; use tokio::io::AsyncBufReadExt; async fn endpoint( diff --git a/test/interop/clients/rust/hls.rs b/test/interop/clients/rust/hls.rs index 6812db78f46..1491995c370 100644 --- a/test/interop/clients/rust/hls.rs +++ b/test/interop/clients/rust/hls.rs @@ -14,7 +14,6 @@ use anyhow::{Context, ensure}; use moq_mux::catalog::Stream; use moq_mux::catalog::hang::Container; use moq_mux::container::{Frame, Kind}; -use moq_tokio::moq_net; use tokio::io::AsyncBufReadExt; /// One frame: its pts in milliseconds and whether it opens a group. diff --git a/test/interop/clients/rust/socket-js.rs b/test/interop/clients/rust/socket-js.rs index b0817b19441..c0e9a19fed2 100644 --- a/test/interop/clients/rust/socket-js.rs +++ b/test/interop/clients/rust/socket-js.rs @@ -1,6 +1,5 @@ //! Socket convention interop through a relay, with a harness-owned drain acknowledgment. use anyhow::{Context, ensure}; -use moq_tokio::moq_net; use tokio::io::AsyncBufReadExt; #[tokio::main(flavor = "current_thread")] diff --git a/test/interop/clients/rust/socket.rs b/test/interop/clients/rust/socket.rs index 4f33ceae8ca..b1cf420eeb4 100644 --- a/test/interop/clients/rust/socket.rs +++ b/test/interop/clients/rust/socket.rs @@ -1,6 +1,6 @@ //! Socket interop peer; stdin acknowledges that the other process drained its half. use anyhow::{Context, ensure}; -use moq_tokio::moq_net::{self, socket::Endpoint}; +use moq_net::socket::Endpoint; use std::future::Future; use std::task::Poll; use tokio::io::AsyncBufReadExt; diff --git a/test/interop/clients/rust/tail.rs b/test/interop/clients/rust/tail.rs index 199aefa9e61..5213364870d 100644 --- a/test/interop/clients/rust/tail.rs +++ b/test/interop/clients/rust/tail.rs @@ -13,7 +13,6 @@ use std::time::Duration; use anyhow::{Context, ensure}; -use moq_tokio::moq_net; use tokio::io::AsyncBufReadExt; const GROUPS: u64 = 4; diff --git a/test/interop/compat.sh b/test/interop/compat.sh index 25c715557e8..ca18691d350 100755 --- a/test/interop/compat.sh +++ b/test/interop/compat.sh @@ -120,8 +120,9 @@ done for source in current released; do mkdir -p "$HARNESS_RUN/hang-$source/src" cp "$DIR/compat/container.rs" "$HARNESS_RUN/hang-$source/src/main.rs" + manifest="$HARNESS_RUN/hang-$source/Cargo.toml" if [[ "$source" == current ]]; then dependency="{ path = \"$WORKSPACE/rs/hang\" }"; else dependency="\"=$(value hang)\""; fi - cat >"$HARNESS_RUN/hang-$source/Cargo.toml" <"$manifest" <>"$manifest" + cargo build --manifest-path "$manifest" --target-dir "$TARGET/compat-hang-$source" harness_stage "hang-$source/compat-container" "$TARGET/compat-hang-$source/debug/compat-container" "$HARNESS_RUN/hang-$source/compat-container" encode "$HARNESS_RUN/$source.catalog" "$HARNESS_RUN/$source.frame" done diff --git a/test/interop/compat/container.rs b/test/interop/compat/container.rs index 146c1583063..adcc0d8ba4f 100644 --- a/test/interop/compat/container.rs +++ b/test/interop/compat/container.rs @@ -14,8 +14,8 @@ fn main() -> Result<(), Box> { match args[1].as_str() { "fetch-supported" => { // The library's own capability, so a failing FETCH cell is a failure, not a skip. - let supported = match args[2].parse::()? { - hang::moq_net::Version::Lite(version) => version.has_track_stream(), + let supported = match args[2].parse::()? { + moq_net::Version::Lite(version) => version.has_track_stream(), _ => return Err("the released comparison runs only moq-lite".into()), }; println!("{supported}"); From c1c2f265f4306e85cba1b9e4d6f19a48e3274d2f Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sat, 7 Nov 2026 21:50:12 -0800 Subject: [PATCH 3/4] quest: finish api-shape/reexports Co-Authored-By: Claude Opus 5.5 --- quest/m2/api-shape/README.md | 1 - quest/m2/api-shape/reexports.md | 95 ----------------------------- quest/m2/moq-quic-unused-surface.md | 5 +- quest/m4/perf/stream/README.md | 2 +- quest/m4/perf/stream/codec.md | 6 +- 5 files changed, 6 insertions(+), 103 deletions(-) delete mode 100644 quest/m2/api-shape/reexports.md diff --git a/quest/m2/api-shape/README.md b/quest/m2/api-shape/README.md index 41890acc694..1936e5df2c4 100644 --- a/quest/m2/api-shape/README.md +++ b/quest/m2/api-shape/README.md @@ -46,7 +46,6 @@ Rejected in planning: - [moq-net's small surface fixes](/quest/m2/api-shape/net.md) - one spelling per session, admission, compression, and priority surface, and no public wire codes - [Transports take shared types](/quest/m2/api-shape/transport.md) - moq-uring takes a congestion factory and rustls configs, and the tokio server request stops exposing its QUIC internals -- [Crates re-export no whole crate](/quest/m2/api-shape/reexports.md) - no moq crate re-exports a whole crate, moq's own included, so a dependency bump is no moq break, and moq-mux's container `Guard` gets a name - [Media crates' small surface fixes](/quest/m2/api-shape/media.md) - exporters, the container consumer, catalog color range, rate grant, moq-stats, JSON, and MSF each have one path and one name - [Native media's small surface fixes](/quest/m2/api-shape/native.md) - audio encode internals go private, `on_demand` has one meaning, and video and render setters fold into their constructors - [Apps' small surface fixes](/quest/m2/api-shape/apps.md) - the relay, gateways, moq-hls, moq-cli, and moq-boy drop dead or unreachable surface and gain role names diff --git a/quest/m2/api-shape/reexports.md b/quest/m2/api-shape/reexports.md deleted file mode 100644 index 721d3cb6f50..00000000000 --- a/quest/m2/api-shape/reexports.md +++ /dev/null @@ -1,95 +0,0 @@ -# [L] Crates re-export no whole crate - -## Goal - -moq's crates re-export no whole crate, moq's own included, so a breaking -release of a dependency is no longer a semver break of the crates that -re-export it: - -- hang: `pub use moq_net;` (`rs/hang/src/lib.rs`) -- moq-net: `pub use bytes;` and `pub use kio;` (`rs/moq-net/src/lib.rs`) -- moq-quic: `pub use rustls;` (`rs/moq-quic/src/lib.rs`) -- moq-rtmp: `pub use rustls;` (`rs/moq-rtmp/src/lib.rs`) -- moq-tokio: `moq_net`, `rustls`, `notify`, `jni`, and - `moq_congestion as congestion` (`rs/moq-tokio/src/lib.rs`), - `cli::usage_rs` (`rs/moq-tokio/src/cli.rs`), `jemalloc::tikv_jemallocator` - (`rs/moq-tokio/src/jemalloc.rs`), and `quic::web`'s `http` and - `web_transport_proto as proto` (`rs/moq-tokio/src/quic/web/mod.rs`) -- moq-uring: `url` (`rs/moq-uring/src/lib.rs`), and `quic::web`'s `http` and - `web_transport_proto as proto` (`rs/moq-uring/src/quic/web.rs`) -- moq-hls: `axum` (`rs/moq-hls/src/lib.rs`) -- moq-webrtc: `axum` and `url` (`rs/moq-webrtc/src/lib.rs`) -- moq-archive: `object_store` (`rs/moq-archive/src/lib.rs`) -- moq-video: `ndk`, `objc2_core_foundation`, `objc2_core_video`, and - `windows` (`rs/moq-video/src/lib.rs`), and `render::wgpu` - (`rs/moq-video/src/render/mod.rs`) -- moq-mux: `container::fmp4::mp4_atom`, unless - [media](/quest/m2/api-shape/media.md) has already dropped it, as - [moq-dev/moq#8214](https://github.com/moq-dev/moq/pull/8214) plans -- qmux: `ws`'s `tokio_tungstenite` and `tungstenite`, unless - [transport](/quest/m2/api-shape/transport.md) has already dropped them, as - #8214 plans - -No new one lands either: -[moq-quic-unused-surface](/quest/m2/moq-quic-unused-surface.md) names the -moq-quic items moq-tokio, moq-uring, and qmux need instead of adding -`pub use moq_quic;`. - -Where a signature names a third-party type only in passing, moq wraps it, -so the dependency leaves moq's public API altogether: `reject` takes moq's -own status instead of `http::StatusCode` (moq-tokio's `quic::web` server -and connect requests, moq-uring's), and `watch::Files::new` returns -moq-tokio's error instead of `notify::Result`. A dependency moq's -signatures are built on stays in them and its users name it as their own -dependency: moq-net's types throughout hang and moq-tokio, `bytes::Bytes` -throughout moq-net, kio's waiters and clock, and the rustls configs -moq-quic, moq-rtmp, and moq-tokio take and return. - -`moq_mux::container::producer::Guard`, which `container::Producer::modify` -returns, becomes nameable: `container` re-exports it beside `Producer`. - -Every caller in this repository (about 110 files naming paths such as -`hang::moq_net`, `moq_tokio::moq_net`, `moq_net::kio`, and -`moq_tokio::rustls`, in apps, bindings, and tests) names the crate -directly instead. The PR's Impact section says how to migrate: add the -dependency at the version moq's `Cargo.lock` uses. - -## Plan - -Decided 2026-11-07 (maintainer, rust2's -[export census](https://github.com/moq-dev/rust2/pull/655)): ✅ drop -whole-crate re-exports from moq, wrapping the few third-party types its -signatures need. A whole-crate re-export makes that crate's whole API part -of moq's, so any breaking release of it breaks moq's semver. rust2's -exporter refuses each one with a span at its `pub use` (rejected there: -skipping them silently, as rustdoc does; exporting their whole APIs). - -Decided 2026-11-07 (maintainer, -[moq-dev/moq#8233](https://github.com/moq-dev/moq/pull/8233)): ✅ every -whole-crate re-export goes, moq's own crates included, and -moq-quic-unused-surface adds no `pub use moq_quic;`. The semver reason -holds for any crate, and one rule needs no list. Rejected: only the ten -the census decision first listed; only third-party crates. Either would -need an exemption list in rust2's exporter, which is config. - -Each re-export's own comment says why it exists, usually that a signature -names the crate (`usage_rs` for `cli::Merge` and `answer`, `kio` for the -`poll_*` waiters, `tikv_jemallocator` for a caller's `#[global_allocator]`, -`tokio_tungstenite` for qmux's `Client::with_connector`). Those reasons -justify the dependency in the signature, not the re-export: a caller who -names the type adds the crate itself. Wrap a type only where that removes -the crate from moq's public API; a wrapper that mirrors most of a crate's -API (rustls's configs, `Bytes`, moq-net's session types) is not worth its -weight. Check `cli::Merge`, `answer`, moq-hls's and moq-webrtc's axum -routers, `url::Url`, moq-archive's object store, moq-video's platform -handles, and `jni` the same way, since some may be wrappable. - -`moq_quic::Side` is the other type rust2's census found unnameable, through -moq-tokio's `quic::driver` list naming `stream::Id` but not `Side`. Its -only uses there, `stream::Id::{new, initiator}`, go in -[moq-quic-unused-surface](/quest/m2/moq-quic-unused-surface.md), so this -quest leaves it. - -rust2's [whole-crate re-export wait](https://github.com/moq-dev/rust2/blob/main/quest/m1/ffi-export/refusals/moq-reexports.md) -and [unreachable types wait](https://github.com/moq-dev/rust2/blob/main/quest/m1/ffi-export/refusals/moq-unreachable.md) -bump rust2's moq pin once this lands. diff --git a/quest/m2/moq-quic-unused-surface.md b/quest/m2/moq-quic-unused-surface.md index 4e66d70c7a2..d2996a2350a 100644 --- a/quest/m2/moq-quic-unused-surface.md +++ b/quest/m2/moq-quic-unused-surface.md @@ -15,9 +15,8 @@ current defaults: `packet_threshold`, `time_threshold`, `retry_token_lifetime`, `incoming_buffer_size_total`, and `initial_rtt`. moq-tokio, moq-uring, and qmux each trim their lists of moq-quic names (20 in moq-tokio's `quic::driver`) to the items their own public signatures -use, and add no `pub use moq_quic;`, since -[reexports](/quest/m2/api-shape/reexports.md) drops every whole-crate -re-export. qmux keeps `Version`, its own wire concept. The PR's Impact section says how to +use, and add no `pub use moq_quic;`, since moq re-exports no whole crate. +qmux keeps `Version`, its own wire concept. The PR's Impact section says how to migrate; the release cut copies that into `MIGRATE.md`. ## Plan diff --git a/quest/m4/perf/stream/README.md b/quest/m4/perf/stream/README.md index 8e1dcb38003..140358191f6 100644 --- a/quest/m4/perf/stream/README.md +++ b/quest/m4/perf/stream/README.md @@ -25,7 +25,7 @@ Facts from the 2026-10-22 audit, so quests don't re-litigate them: - The relay's WebSocket path is axum (hyper, `axum-server`, tokio-rustls), then axum's tungstenite 0.29, converted zero-copy into qmux's tungstenite 0.30 (`rs/moq-relay/src/websocket.rs`). The relay therefore compiles two - tungstenite versions. qmux re-exports `tokio_tungstenite` and `tungstenite` + tungstenite versions. qmux names `tokio_tungstenite` and `tungstenite` types in its public API (`rs/qmux/src/ws.rs`). - tungstenite itself costs a zero-filled 128 KiB read buffer, a copy into its `out_buffer` on write, and a memmove after a partial write. The layers diff --git a/quest/m4/perf/stream/codec.md b/quest/m4/perf/stream/codec.md index 54f79ceb181..5c26c198b61 100644 --- a/quest/m4/perf/stream/codec.md +++ b/quest/m4/perf/stream/codec.md @@ -51,9 +51,9 @@ The subset to implement, from the 2026-10-22 audit: A maintained crate was weighed against this. The codec is small, sits on the hot path, and must write into the driver's buffers, so qmux owns it. -Public API: the `tokio_tungstenite` and `tungstenite` re-exports and the -`tungstenite` types in `Client::with_config`, `Client::with_connector`, -`Upgraded`, and `Error::WebSocket` go away. The Impact bullet says how to +Public API: the `tokio_tungstenite` and `tungstenite` types in +`Client::with_config`, `Client::with_connector`, `Upgraded`, and +`Error::WebSocket` go away. The Impact bullet says how to migrate in `qmux` and `moq-tokio`. The existing qmux interop tests (the `qmux06` dev-dependency) and the browser path in `js/qmux` must keep passing unchanged. From 56da6156d998ffb7feac839afa499ac26ba360d4 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sun, 8 Nov 2026 17:39:43 -0800 Subject: [PATCH 4/4] fix: one prefix on cert-watch errors; relay names its tungstenite features Co-Authored-By: Claude Opus 5.5 --- rs/moq-relay/Cargo.toml | 2 +- rs/moq-tokio/src/tls.rs | 2 +- rs/moq-tokio/src/watch.rs | 8 ++++++-- rs/moq-uring/tests/integration/web.rs | 4 ++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/rs/moq-relay/Cargo.toml b/rs/moq-relay/Cargo.toml index ad41e242f82..4628c94cbcf 100644 --- a/rs/moq-relay/Cargo.toml +++ b/rs/moq-relay/Cargo.toml @@ -93,7 +93,7 @@ thiserror = { workspace = true } tokio = { workspace = true, features = ["full"] } tokio-rustls = { workspace = true } # Reclaims the socket under a WebSocket upgrade as a WebSocket stream. -tokio-tungstenite = { workspace = true, optional = true } +tokio-tungstenite = { workspace = true, features = ["connect", "handshake"], optional = true } toml = { workspace = true } tower-service = "0.3" tracing = { workspace = true } diff --git a/rs/moq-tokio/src/tls.rs b/rs/moq-tokio/src/tls.rs index 01b20a9237a..ce64a285044 100644 --- a/rs/moq-tokio/src/tls.rs +++ b/rs/moq-tokio/src/tls.rs @@ -3869,7 +3869,7 @@ impl Reload { if paths.is_empty() { return Ok(Self { _task: None }); } - let watcher = crate::watch::Files::new(&paths).map_err(|err| Error::Watch(err.to_string()))?; + let watcher = crate::watch::Files::watch(&paths).map_err(|err| Error::Watch(err.to_string()))?; // The certificates were loaded before the watch existed, so anything that // landed in between produced no event and would sit unseen until the next diff --git a/rs/moq-tokio/src/watch.rs b/rs/moq-tokio/src/watch.rs index 6cb12c7e388..b94d72522f9 100644 --- a/rs/moq-tokio/src/watch.rs +++ b/rs/moq-tokio/src/watch.rs @@ -29,14 +29,18 @@ impl Files { /// poll watcher on platforms without a native backend, so there's no manual /// polling here. pub fn new(paths: &[PathBuf]) -> crate::Result { + Self::watch(paths).map_err(|err| crate::Error::Watch(crate::error::message(err))) + } + + /// [`Self::new`] with notify's own error, for callers that wrap it in theirs. + pub(crate) fn watch(paths: &[PathBuf]) -> notify::Result { // A capacity-1 channel of unit wakeups coalesces the burst of raw events // notify emits per change: a full buffer already has a pending wakeup, so // extra sends are dropped. let (tx, rx) = mpsc::channel(1); let watcher = callback(paths, move || { let _ = tx.try_send(()); - }) - .map_err(|err| crate::Error::Watch(crate::error::message(err)))?; + })?; Ok(Self { _watcher: watcher, diff --git a/rs/moq-uring/tests/integration/web.rs b/rs/moq-uring/tests/integration/web.rs index b58e0ef322c..fff6f13be99 100644 --- a/rs/moq-uring/tests/integration/web.rs +++ b/rs/moq-uring/tests/integration/web.rs @@ -309,8 +309,8 @@ fn an_open_waits_only_for_stream_credit() { .build() .expect("tokio runtime"); rt.block_on(async move { - let request = web_transport_proto::ConnectRequest::new(url::Url::parse(&url).expect("url")) - .with_protocol(PROTO); + let request = + web_transport_proto::ConnectRequest::new(url::Url::parse(&url).expect("url")).with_protocol(PROTO); let mut transport = moq_tokio::quic::driver::transport::Config::default(); transport.limits.receive_window = std::num::NonZeroU64::new(16 * 1024); let session = crate::support::web_connect(request, transport).await.expect("connect");