diff --git a/.claude/settings.json b/.claude/settings.json index 5317c116ba2..cba5a05a5b5 100644 --- a/.claude/settings.json +++ b/.claude/settings.json @@ -6,7 +6,7 @@ "Bash(cargo *)", "Bash(bun *)", "Bash(ffprobe:*)", - "Bash(rs/moq-c/build.sh:*)", + "Bash(rs/libmoq/build.sh:*)", "WebFetch(domain:www.ietf.org)", "WebFetch(domain:datatracker.ietf.org)", "WebFetch(domain:docs.rs)", diff --git a/.github/workflows/alert.yml b/.github/workflows/alert.yml index ef417e74de3..cb724444cbb 100644 --- a/.github/workflows/alert.yml +++ b/.github/workflows/alert.yml @@ -20,7 +20,7 @@ on: - Docker - GStreamer CI image - Interop - - moq-c + - libmoq - moq-cli - moq-gst - moq-relay diff --git a/.github/workflows/api-diff.yml b/.github/workflows/api-diff.yml index a318c46c9cd..4ca0762b3ec 100644 --- a/.github/workflows/api-diff.yml +++ b/.github/workflows/api-diff.yml @@ -65,7 +65,7 @@ jobs: run: nix develop --command just api-diff ${ARGS:+"$ARGS"} env: ARGS: ${{ steps.mode.outputs.args }} - # Lists and downloads the moq-c and moq-ffi release assets. + # Lists and downloads the libmoq and moq-ffi release assets. GH_TOKEN: ${{ github.token }} - name: Keep the report if: ${{ !cancelled() && steps.diff.outcome != 'skipped' }} diff --git a/.github/workflows/interop.yml b/.github/workflows/interop.yml index a66cab4b0a0..88ce27d5350 100644 --- a/.github/workflows/interop.yml +++ b/.github/workflows/interop.yml @@ -44,7 +44,7 @@ jobs: - uses: ./.github/actions/nix - # The relay, cli, moq-ffi, and moq-c all build from source. The nightly + # The relay, cli, moq-ffi, and libmoq all build from source. The nightly # run publishes them for the pull requests that touch the harness. - name: Rust cache id: rust-cache diff --git a/.github/workflows/moq-c.yml b/.github/workflows/libmoq.yml similarity index 89% rename from .github/workflows/moq-c.yml rename to .github/workflows/libmoq.yml index 69307e1e50d..33847cd6834 100644 --- a/.github/workflows/moq-c.yml +++ b/.github/workflows/libmoq.yml @@ -1,9 +1,9 @@ -name: moq-c +name: libmoq on: push: tags: - - "moq-c-v*" + - "libmoq-v*" # Dry-run: build everything, publish nothing. Nightly calls every release # workflow this way so a broken build surfaces before the tag is cut. workflow_call: @@ -55,7 +55,7 @@ jobs: - name: Parse version id: parse shell: bash - run: just gh release parse-version moq-c + run: just gh release parse-version libmoq - name: Build and package shell: bash @@ -63,7 +63,7 @@ jobs: TARGET: ${{ matrix.target }} VERSION: ${{ steps.parse.outputs.version }} run: | - just rs package-moq-c \ + just rs package-libmoq \ --target "$TARGET" \ --version "$VERSION" \ --output dist @@ -71,7 +71,7 @@ jobs: - name: Upload artifact uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7 with: - name: moq-c-${{ matrix.target }} + name: libmoq-${{ matrix.target }} path: dist/* release: @@ -92,11 +92,11 @@ jobs: - name: Parse version id: parse - run: just gh release parse-version moq-c + run: just gh release parse-version libmoq - name: Find previous tag id: prev_tag - run: just gh release prev-tag moq-c + run: just gh release prev-tag libmoq - name: Download artifacts uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8 @@ -108,7 +108,7 @@ jobs: env: GH_TOKEN: ${{ github.token }} RELEASE_TAG: ${{ github.ref_name }} - RELEASE_TITLE: "moq-c v${{ steps.parse.outputs.version }}" + RELEASE_TITLE: "libmoq v${{ steps.parse.outputs.version }}" RELEASE_PREV_TAG: ${{ steps.prev_tag.outputs.tag }} run: just gh release create artifacts diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index f2272c52e39..cdd317047c6 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -225,8 +225,8 @@ jobs: uncached: true artifact: js-coverage artifact-path: target/coverage/js - # OBS (over moq-ffi) and moq-c's C fixtures link a Rust staticlib from - # outside cargo, so a stale `rs/moq-c/native-libs/*.txt` breaks them and + # OBS (over moq-ffi) and libmoq's C fixtures link a Rust staticlib from + # outside cargo, so a stale `rs/libmoq/native-libs/*.txt` breaks them and # no cargo build. release-gate.yml's OBS filter can't list every such input; # this diff-independent run catches what it misses, a day late. - name: OBS @@ -237,7 +237,7 @@ jobs: # 60 to 90 s instead of about 8; the suite took 2 to 4.5 min locally. - name: OBS TSan recipe: obs test - - name: moq-c C fixtures + - name: libmoq C fixtures recipe: rs c-tests steps: @@ -717,9 +717,9 @@ jobs: contents: write id-token: write - release-moq-c: - name: moq-c - uses: ./.github/workflows/moq-c.yml + release-libmoq: + name: libmoq + uses: ./.github/workflows/libmoq.yml permissions: contents: write @@ -781,7 +781,7 @@ jobs: sizes: name: Shipping sizes # Measures what these release jobs upload rather than rebuilding it. - needs: [release-py-ffi, release-shared-ffi, release-moq-c, release-moq-relay, release-moq-cli] + needs: [release-py-ffi, release-shared-ffi, release-libmoq, release-moq-relay, release-moq-cli] runs-on: ubuntu-24.04-arm # Hosted `main` jobs write the Rust cache; see .github/actions/rust-cache. environment: ${{ github.ref == 'refs/heads/main' && 'cache-write' || '' }} diff --git a/.github/workflows/obs.yml b/.github/workflows/obs.yml index 3c882de5389..5e895fabfae 100644 --- a/.github/workflows/obs.yml +++ b/.github/workflows/obs.yml @@ -15,7 +15,7 @@ name: OBS # the moq-ffi API it is generated from, and the flake that supplies the # toolchain, including uniffi-bindgen-cpp. # -# moq-c's own C fixtures (`just rs c-tests`) run here too. They link libmoq.a +# libmoq's own C fixtures (`just rs c-tests`) run here too. They link libmoq.a # from outside cargo the same way the plugin links moq-ffi, which is too slow # for nextest's hang budget, so this job, which already does that kind of link, # is where they gate release PRs. They also compile the C doc samples, hence @@ -23,8 +23,8 @@ name: OBS # # The manifests and Cargo.lock are in there for the one way a crate the plugin # never names can break it: linking a Rust staticlib from outside cargo needs -# the native libraries in `rs/moq-c/native-libs/*.txt`, which moq-ffi and -# moq-c share and which are maintained by hand. A dependency that starts +# the native libraries in `rs/libmoq/native-libs/*.txt`, which moq-ffi and +# libmoq share and which are maintained by hand. A dependency that starts # pulling in a new one leaves that list stale, and every Rust gate stays green, # because cargo passes the flag itself and only this job links without it. # @@ -99,5 +99,5 @@ jobs: - name: Build run: nix develop .#obs --command just obs ci - - name: moq-c C fixtures + - name: libmoq C fixtures run: nix develop .#obs --command just rs c-tests diff --git a/.github/workflows/release-c.yml b/.github/workflows/release-c.yml index e7f7c164bcd..946755b8de8 100644 --- a/.github/workflows/release-c.yml +++ b/.github/workflows/release-c.yml @@ -1,8 +1,7 @@ name: Release C # Builds the moq C package (c/moq) for every target and publishes one archive per target to a -# c-v GitHub release. moq-c-v* tags belong to the hand-written rs/moq-c crate until it -# retires. +# c-v GitHub release. The hand-written rs/libmoq crate publishes under libmoq-v* tags. on: push: diff --git a/.github/workflows/release-gate.yml b/.github/workflows/release-gate.yml index f142bc20785..934a6a622bc 100644 --- a/.github/workflows/release-gate.yml +++ b/.github/workflows/release-gate.yml @@ -102,7 +102,7 @@ jobs: - "rs/moq-ffi/**" - ".cargo/config.toml" - "sh/c/**" - - "rs/moq-c/native-libs/**" + - "rs/libmoq/native-libs/**" - "cpp/moq/cmake/moq-ffi.cmake" - "Cargo.lock" - ".github/workflows/c.yml" @@ -113,7 +113,7 @@ jobs: - "rs/moq-ffi/**" - ".cargo/config.toml" - "sh/cpp/**" - - "rs/moq-c/native-libs/**" + - "rs/libmoq/native-libs/**" - "doc/lib/cpp/**" - "doc/lib/samples.sh" - "Cargo.lock" @@ -155,7 +155,7 @@ jobs: - "sh/obs/**" - "rs/moq-ffi/**" - ".cargo/config.toml" - - "rs/moq-c/**" + - "rs/libmoq/**" - "doc/lib/c/**" - "doc/lib/samples.sh" - "rs/**/Cargo.toml" diff --git a/.github/workflows/release-nix.yml b/.github/workflows/release-nix.yml index df678b9cc40..c505df99c9a 100644 --- a/.github/workflows/release-nix.yml +++ b/.github/workflows/release-nix.yml @@ -12,7 +12,7 @@ on: tags: - 'moq-relay-v*' - 'moq-cli-v*' - - 'moq-c-v*' + - 'libmoq-v*' - 'moq-gst-v*' jobs: @@ -45,7 +45,7 @@ jobs: env: REF_NAME: ${{ github.ref_name }} run: | - re='^(moq-relay|moq-cli|moq-c|moq-gst)-v([0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?)$' + re='^(moq-relay|moq-cli|libmoq|moq-gst)-v([0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?)$' if [[ ! "$REF_NAME" =~ $re ]]; then echo "Tag format not recognized: $REF_NAME" >&2 exit 1 diff --git a/.oss-scanner/threat_model.md b/.oss-scanner/threat_model.md index 839bad7e395..0a2e6b09533 100644 --- a/.oss-scanner/threat_model.md +++ b/.oss-scanner/threat_model.md @@ -39,7 +39,7 @@ Most important, in this order: `unsafe` is rare and worth reading closely where it appears: `rs/moq-quic`, `rs/moq-net/src/model`, `rs/moq-net/src/util/cell.rs`, `rs/moq-net/src/transport.rs`, and `rs/moq-relay/src/uring.rs`. -Out of scope: `js/` and the other language bindings (`py/`, `swift/`, `kt/`, `go/`, `dart/`, `cpp/`, `rs/moq-ffi`, `rs/moq-c`), capture and encode crates that read local devices (`moq-video`, `moq-v4l`, `moq-nvenc`, `moq-audio`, `moq-transcode`, `moq-gst`, `moq-boy`), `demo/`, `bench/`, `test/`, `infra/`, `doc/`, `drafts/`, and CI configuration. A flaw that lies wholly inside a dependency (quinn, rustls, aws-lc, tokio, hyper) belongs upstream unless our use of it makes it reachable. +Out of scope: `js/` and the other language bindings (`py/`, `swift/`, `kt/`, `go/`, `dart/`, `cpp/`, `rs/moq-ffi`, `rs/libmoq`), capture and encode crates that read local devices (`moq-video`, `moq-v4l`, `moq-nvenc`, `moq-audio`, `moq-transcode`, `moq-gst`, `moq-boy`), `demo/`, `bench/`, `test/`, `infra/`, `doc/`, `drafts/`, and CI configuration. A flaw that lies wholly inside a dependency (quinn, rustls, aws-lc, tokio, hyper) belongs upstream unless our use of it makes it reachable. ## How to exercise it diff --git a/.vscode/settings.json b/.vscode/settings.json index ae9bff02ba9..9b4563f0bc7 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,5 @@ { "css.lint.unknownAtRules": "ignore", "biome.lsp.bin": "./node_modules/.bin/biome", - "cmake.sourceDirectory": "./rs/moq-c" + "cmake.sourceDirectory": "./rs/libmoq" } diff --git a/Cargo.lock b/Cargo.lock index a6aa6c54b4d..6aa301c1251 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3925,8 +3925,27 @@ checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" [[package]] name = "libmoq" -version = "0.6.12" +version = "0.7.0" dependencies = [ + "anyhow", + "bytes", + "cbindgen", + "hang", + "kio", + "moq-audio", + "moq-json", + "moq-loc", + "moq-mux", + "moq-net", + "moq-tokio", + "moq-video", + "pollster", + "serde_json", + "test-env", + "thiserror 2.0.21", + "tokio", + "tracing", + "url", "workspace-hack", ] @@ -4329,32 +4348,6 @@ dependencies = [ "workspace-hack", ] -[[package]] -name = "moq-c" -version = "0.7.0" -dependencies = [ - "anyhow", - "bytes", - "cbindgen", - "hang", - "kio", - "moq-audio", - "moq-json", - "moq-loc", - "moq-mux", - "moq-net", - "moq-tokio", - "moq-video", - "pollster", - "serde_json", - "test-env", - "thiserror 2.0.21", - "tokio", - "tracing", - "url", - "workspace-hack", -] - [[package]] name = "moq-cli" version = "0.14.2" diff --git a/Cargo.toml b/Cargo.toml index f845e934194..34bee35020e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,7 @@ default-members = [ "rs/kio", "rs/kio/macros", "rs/hang", - # "rs/moq-c", # requires C toolchain + # "rs/libmoq", # requires C toolchain "rs/moq-congestion", "rs/moq-archive", "rs/moq-auth", @@ -180,7 +180,7 @@ moq-vaapi = { version = "0.2.1", path = "rs/moq-vaapi" } # cross-compiled Python, Swift, Kotlin, and Go builds have no use for: adding # `features = ["capture"]` to a consumer that ships in those bindings pulls the # whole device graph into every one of them. Codec features are independent of -# that argument, so moq-ffi and moq-c opt NVIDIA and VAAPI back in (OpenH264 +# that argument, so moq-ffi and libmoq opt NVIDIA and VAAPI back in (OpenH264 # through their own `openh264` feature, which release builds enable). moq-video = { version = "0.1.10", path = "rs/moq-video", default-features = false } moq-webrtc = { version = "0.3.12", path = "rs/moq-webrtc" } diff --git a/README.md b/README.md index 06b7d33cafa..f0a4a4fce8c 100644 --- a/README.md +++ b/README.md @@ -162,4 +162,4 @@ Licensed under either: - Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or https://www.apache.org/licenses/LICENSE-2.0) - MIT license ([LICENSE-MIT](LICENSE-MIT) or https://opensource.org/licenses/MIT) -**Exception:** the OBS plugin under [`cpp/obs/`](cpp/obs) is licensed under **GPL-2.0-or-later** (see [`cpp/obs/LICENSE`](cpp/obs/LICENSE)), because it links OBS Studio's `libobs`, which is GPL-2.0. This is a separately-distributable work; per GPLv2 its presence in this repository is mere aggregation and does not affect the MIT/Apache licensing of the rest of the project. `moq-c` and the other moq crates remain MIT/Apache. +**Exception:** the OBS plugin under [`cpp/obs/`](cpp/obs) is licensed under **GPL-2.0-or-later** (see [`cpp/obs/LICENSE`](cpp/obs/LICENSE)), because it links OBS Studio's `libobs`, which is GPL-2.0. This is a separately-distributable work; per GPLv2 its presence in this repository is mere aggregation and does not affect the MIT/Apache licensing of the rest of the project. `libmoq` and the other moq crates remain MIT/Apache. diff --git a/RELEASE.md b/RELEASE.md index ed8866b31a1..c9614406dce 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -5,7 +5,7 @@ After the `0.22.0` cut, which still waits on every break planned for it, each release cycle runs in three phases by kind of change, recorded as `phase` in `version.json`: `additive` work first, then `api` breaks, then `wire` changes. An API break is what a published consumer adapts to when it rebuilds: the public Rust, JS, or bindings API, CLI flags, config keys, and environment variables. A wire change is what a deployed peer adapts to without rebuilding: a frozen wire version, the hang catalog JSON, or a stored or exported container format. -The maintainer opens the next phase with a PR that changes `phase`. After the `0.22.0` cut, and after the wire cut that ends each cycle, a PR on `main` sets it to `additive` once the cut has merged into `release` and every package it bumps is published (crates.io, npm, and the `moq-c-v*`/`moq-ffi-v*` GitHub releases): the cut PR itself carries breaks, so its API diff must only report, and the API diff's baselines are those published versions, so an earlier reset fails Nightly's `--deny` on every break the cut shipped. +The maintainer opens the next phase with a PR that changes `phase`. After the `0.22.0` cut, and after the wire cut that ends each cycle, a PR on `main` sets it to `additive` once the cut has merged into `release` and every package it bumps is published (crates.io, npm, and the `libmoq-v*`/`moq-ffi-v*` GitHub releases): the cut PR itself carries breaks, so its API diff must only report, and the API diff's baselines are those published versions, so an earlier reset fails Nightly's `--deny` on every break the cut shipped. `main` can be cut on demand in the additive and API phases; in the wire phase it is cut only once its wire version is final, so wire work comes last and stays short. While `phase` is `additive`, Nightly runs `just api-diff --deny` on `main` and the cut PR's API diff denies too, so a break that lands early is reverted, or the maintainer opens the API phase. diff --git a/c/moq/MIGRATE.md b/c/moq/MIGRATE.md index 2ad00f40654..1d6b3e3695f 100644 --- a/c/moq/MIGRATE.md +++ b/c/moq/MIGRATE.md @@ -37,9 +37,9 @@ Viewer ceilings and PROBE target overrides are refused with the new `MOQ_ERROR_O Audio and video subscribe setup now reports `MOQ_ERROR_UNSUPPORTED_CONFIG` when the decoder refuses a codec, layout, or description, or when every video decoder for the codec reports that this device cannot decode the stream. Handle this variant to try another rendition instead of inspecting an audio/video error message or `Unsupported`. Decoder faults, such as a missing driver or no device, and later peer and decode failures keep their existing errors. Regenerate bindings and rebuild the matching native library together. -## moq-c 0.7, the hand-written ABI +## libmoq 0.6 -> 0.22 -The hand-written crate never published as moq-c: a libmoq 0.6 user applies these entries before moving to the generated API. +The hand-written API's last line, which ships as libmoq 0.22: a libmoq 0.6 user applies these entries before moving to the generated API. ### Announcements are a listing ([#7678](https://github.com/moq-dev/moq/pull/7678)) @@ -187,7 +187,7 @@ Set `moq_client_config::quic_keylog` or `moq_server_config::quic_keylog` as well ### OpenH264 is a build feature (#5771) The release archives and the CMake build still carry the software H.264 fallback. -A bare `cargo build -p moq-c` leaves it out; add `--features openh264` to keep it. +A bare `cargo build -p libmoq` leaves it out; add `--features openh264` to keep it. ### Subscriptions carry group ranges (#5732) @@ -218,19 +218,6 @@ Free each handle with `moq_consume_close` once its successor arrives. A frame write fails with a protocol error of kind `MOQ_PROTOCOL_KIND_TIMESTAMP_MISMATCH` when a group's first frame starts before a lower-sequence group's, or after a higher one's. A publisher whose timeline restarts publishes a new broadcast instead. -### libmoq is moq-c (#4288) - -The C bindings ship as the `moq-c` crate, starting at 0.7.0. -The header is still `moq.h` and the library is still `libmoq.a` / `moq.lib` (`-lmoq`); the C ABI did not change with the rename. -The CMake package, pkg-config name, release tags, and archives follow the new name. - -| Before | After | -| --- | --- | -| `find_package(moq)`, target `moq` | `find_package(moq-c)`, target `moq::c` | -| `pkg-config --libs moq` | `pkg-config --libs moq-c` | -| nix `.#libmoq` | nix `.#moq-c` | -| tags `libmoq-v*`, archives `libmoq--` | tags `moq-c-v*`, archives `moq-c--` | - ### Background panics are reported (#5562) A panic in a background task reports `MOQ_ERROR_PANIC`, and other handles keep running. diff --git a/cpp/moq/CMakeLists.txt b/cpp/moq/CMakeLists.txt index 44aa6c76909..93ef1bc6f2e 100644 --- a/cpp/moq/CMakeLists.txt +++ b/cpp/moq/CMakeLists.txt @@ -43,7 +43,7 @@ endif() # The bindings compile here at the including project's CMAKE_CXX_STANDARD (else the compiler's # default, at least C++17) and with its flags. Only a target that links them builds them: the # package ships the source, not this library. -# Named moq-cpp so an in-tree build can sit beside moq-c's `moq` target. +# Named moq-cpp so an in-tree build can sit beside libmoq's `moq` target. add_library(moq-cpp STATIC EXCLUDE_FROM_ALL src/moq.cpp) add_library(moq::cpp ALIAS moq-cpp) add_dependencies(moq-cpp moq_ffi) diff --git a/cpp/moq/cmake/moq-ffi.cmake b/cpp/moq/cmake/moq-ffi.cmake index 2e47fead240..17db76ac12d 100644 --- a/cpp/moq/cmake/moq-ffi.cmake +++ b/cpp/moq/cmake/moq-ffi.cmake @@ -172,8 +172,8 @@ else() VERBATIM ) endif() - # System libraries the staticlib needs from an external linker. moq-ffi and moq-c share one - # dependency tree, so they share rs/moq-c/native-libs/, which says how to regenerate it. + # System libraries the staticlib needs from an external linker. moq-ffi and libmoq share one + # dependency tree, so they share rs/libmoq/native-libs/, which says how to regenerate it. if(APPLE) set(_platform apple) elseif(WIN32) @@ -181,7 +181,7 @@ else() else() set(_platform linux) endif() - set(_native_libs "${_moq_workspace}/rs/moq-c/native-libs/${_platform}.txt") + set(_native_libs "${_moq_workspace}/rs/libmoq/native-libs/${_platform}.txt") endif() file(STRINGS "${_native_libs}" _lines) diff --git a/doc/lib/c/index.md b/doc/lib/c/index.md index e3d3e028144..fbb98cb8aa3 100644 --- a/doc/lib/c/index.md +++ b/doc/lib/c/index.md @@ -1,42 +1,44 @@ --- title: C -description: moq-c, the stable C ABI over the Rust core +description: libmoq, the hand-written C API over the Rust core --- # C -[![GitHub release](https://img.shields.io/github/v/release/moq-dev/moq?filter=moq-c-v*\&label=moq-c)](https://github.com/moq-dev/moq/releases?q=moq-c) +[![GitHub release](https://img.shields.io/github/v/release/moq-dev/moq?filter=libmoq-v*\&label=libmoq)](https://github.com/moq-dev/moq/releases?q=libmoq) -`moq-c` exposes MoQ to C and any language with a C FFI through a -stable ABI: a generated `moq.h`, a static `libmoq.a` that links the whole Rust -runtime in, and a pkg-config file for its native link dependencies. Releases -through 0.6 were named `libmoq`. C++ projects should prefer the +`libmoq` exposes MoQ to C and any language with a C FFI: a generated `moq.h`, +a static `libmoq.a` that links the whole Rust runtime in, and a pkg-config +file for its native link dependencies. C++ projects should prefer the [C++ package](/lib/cpp/) (`moq-cpp`): the same core as RAII objects and futures instead of handles and callbacks. +0.22 is libmoq's last minor, which takes fixes only. A generated C package, +`moq-c`, replaces it once published, with the API every other binding wraps. + ## Install -Each [`moq-c-v*` release](https://github.com/moq-dev/moq/releases?q=moq-c) -ships `moq-c--.tar.gz` with `include/moq.h`, `lib/libmoq.a`, and +Each [`libmoq-v*` release](https://github.com/moq-dev/moq/releases?q=libmoq) +ships `moq--.tar.gz` with `include/moq.h`, `lib/libmoq.a`, and a pkg-config file listing the system libraries the archive needs. They are a matched pair: compile against the header that came with the archive you link. Targets: Linux x86\_64 and aarch64, macOS arm64, Windows x64. ```bash -export PKG_CONFIG_PATH="moq-c-$ver-$target/lib/pkgconfig" -cc app.c $(pkg-config --cflags --libs --static moq-c) -o app +export PKG_CONFIG_PATH="moq-$ver-$target/lib/pkgconfig" +cc app.c $(pkg-config --cflags --libs --static moq) -o app ``` With CMake, point `CMAKE_PREFIX_PATH` at the extracted archive, then -`find_package(moq-c)` and link `moq::c`. +`find_package(moq)` and link `moq::moq`. -From source, `add_subdirectory(rs/moq-c)` in CMake gives the same `moq::c` -target, and `nix build .#moq-c` produces the release layout. A bare -`cargo build -p moq-c` leaves `moq.h` in a hashed `OUT_DIR`, writes no +From source, `add_subdirectory(rs/libmoq)` in CMake gives the same `moq::moq` +target, and `nix build .#libmoq` produces the release layout. A bare +`cargo build -p libmoq` leaves `moq.h` in a hashed `OUT_DIR`, writes no pkg-config file, and omits the OpenH264 software fallback unless given `--features openh264`. -`moq-c` and the C++ package each link in their own copy of the Rust core, so a +`libmoq` and the C++ package each link in their own copy of the Rust core, so a program links one of the two, never both. Encoded media callbacks from `moq_consume_audio` and `moq_consume_video` deliver read @@ -115,10 +117,10 @@ here, from media publish and consume to raw pixels and PCM with the codec inside. The header is the reference: each function carries a doc comment. [Layers](/lib/layers) maps each wrapped Rust layer to its function prefixes. -- **Handles and callbacks.** Every object is an integer handle, and every async result arrives on a `moq_status_callback` with your `void *user_data`. A status `> 0` is a live result, `0` a clean close, and `< 0` an error. The last two are terminal: moq-c never touches `user_data` again, so free it there. `*_close` and `*_cancel` only request shutdown; the terminal callback still fires. A session reports on a `moq_state_callback` instead: each `moq_connection_state` carries its `phase`, `connects`, and that phase's own `data`: the negative `failure` of the latest attempt while offline or migrating, and the live `version` while connected or migrating. The `MOQ_CONNECTION_PHASE_CLOSED` snapshot is terminal, delivered after the handle is released. `moq_session_close()` drains finished tracks for dialed and accepted sessions; wait for that terminal snapshot to learn the result. +- **Handles and callbacks.** Every object is an integer handle, and every async result arrives on a `moq_status_callback` with your `void *user_data`. A status `> 0` is a live result, `0` a clean close, and `< 0` an error. The last two are terminal: libmoq never touches `user_data` again, so free it there. `*_close` and `*_cancel` only request shutdown; the terminal callback still fires. A session reports on a `moq_state_callback` instead: each `moq_connection_state` carries its `phase`, `connects`, and that phase's own `data`: the negative `failure` of the latest attempt while offline or migrating, and the live `version` while connected or migrating. The `MOQ_CONNECTION_PHASE_CLOSED` snapshot is terminal, delivered after the handle is released. `moq_session_close()` drains finished tracks for dialed and accepted sessions; wait for that terminal snapshot to learn the result. - **Errors.** Negative return codes are named by `MOQ_ERROR_*`, and `moq_error()` gives the reason on the calling thread. Auth rejections have their own codes so you don't retry them. For the peer's protocol code use `moq_error_protocol()`; do not parse `moq_error()`. A panic in a binding background task reports `MOQ_ERROR_PANIC` through its terminal callback; unrelated objects keep running. A session closed because its credential expired has kind `MOQ_PROTOCOL_KIND_EXPIRED`, and a request refused for an expired token returns `MOQ_ERROR_EXPIRED`; refresh the token before retrying. Malformed credentials report `MOQ_PROTOCOL_KIND_MALFORMED_AUTH_TOKEN`; correct the token before reconnecting with it. A catalog that needs a newer moq-hang draft than this build reads returns `MOQ_ERROR_UNSUPPORTED_CATALOG`; upgrade the library to read it. A request-cap closure has kind `MOQ_PROTOCOL_KIND_TOO_MANY_REQUESTS`; reduce the workload or adjust the relay's [session limits](/bin/relay/config#session-and-peer) before reconnecting. - **Tokens.** Set `moq_client_config.tokens` instead of putting the credential in the URL. The first is the connection credential, sent in SETUP and, while an offered version can't carry it there (lite before 07), as the URL's `?jwt=`; each other token widens the grant over AUTH. A `?jwt=` already in the URL stays the connection credential, which is how to reach a relay older than this release. `moq_session_tokens_set()` replaces them before they expire: the next dial presents them, and a live AUTH session at once. A live session without AUTH (lite before 07, or moq-transport without the extension) keeps the old credential until it redials, and `moq_session_tokens_answered()` reports `MOQ_ERROR_UNSUPPORTED` for it. Otherwise that call reports the peer's verdict. Follow what the peer granted with `moq_session_grants()`. For a per-request token, `moq_session_credential()` presents it on the live session, or the next one while offline, and returns a credential handle at once: name it with `moq_route_set_auth()` or `moq_claim_set_auth()`, and setting a new one renews the announcement in place, without redialing. Only the session that minted it carries it, a dialed one across its reconnects; another session announcing the same route uses its own scope. `moq_credential_answered()` reports the peer's verdict: moq-transport accepts at once, since only the request carries it, moq-lite needs AUTH, where the grant joins the session's, and is `MOQ_ERROR_UNSUPPORTED` without it. `moq_credential_free()` withdraws the token once no route or claim names it, answered or not, and ends a wait still pending. -- **Threading.** Call any function from any thread. Callbacks run on moq-c's runtime thread; the callback and its `user_data` must be safe to use there. Synchronize access to data shared with other threads, and dispatch UI work to your UI thread. Raw publish calls block until the codec takes the frame, which paces a publisher. +- **Threading.** Call any function from any thread. Callbacks run on libmoq's runtime thread; the callback and its `user_data` must be safe to use there. Synchronize access to data shared with other threads, and dispatch UI work to your UI thread. Raw publish calls block until the codec takes the frame, which paces a publisher. - **Zeroed config is the default.** A zeroed `moq_client_config` means the default for every field, so new fields don't break callers. A field whose default isn't zero has a `has_*` flag: `backoff_timeout_us = 0` gives up at the first failure only with `has_backoff_timeout = true`, and without it the session never gives up. - **Subscription defaults.** A zeroed `moq_subscription`, a NULL pointer, and `moq_subscription_defaults()` all mean moq-net's defaults, whose zero `delay` starts at the newest group and skips a superseded one at once. Set `delay.max_unlimited` for no subscriber limit, and `delay.min_unstated` to leave the target latency unstated. - **Compressed tracks.** `moq_track_info.compression` set to `MOQ_COMPRESSION_DEFLATE` on a raw track sends each group DEFLATE-compressed to opt-in `moq-lite-07-wip` peers; other peers, and every reader here, get the original frames. @@ -128,7 +130,7 @@ inside. The header is the reference: each function carries a doc comment. - **Discovery.** Announcement captures are always a list of wildcard matches, empty when the filter has no wildcards. - **Ending cleanly.** When the input ends, finish every track, then call `moq_publish_catalog_finish()` to finish the catalog, which ends the content. The broadcast stays announced and keeps serving the finished tracks, so a subscriber still catching up can drain them, until `moq_publish_close()` or `moq_route_free()` takes it offline. How long to keep it up is yours to decide. A track still open at the close ends with `UNROUTABLE` (an internal error over moq-transport, which has no such code), and its handle is released. Readers follow a publisher's runs by announcement, not by that error: see [identity and recovery](/concept/identity). - **Timeline breaks.** On a seek or pause, call `moq_publish_media_discontinuity`, then keep timestamps moving forward and resume video on a keyframe. -- **Timestamps.** A `moq_timestamp` is exact: `value` units at `scale` units per second, so a 90 kHz tick survives a read and republish. Frames, datagrams, and JSON values point `timestamp` at theirs, valid as long as the payload. An untimed track has no scale, so there `has_scale` is false and `value` is the frame's group key (a datagram's sequence); every write and `moq_publish_track_group` takes one, with `moq_publish_group_start` naming a group's key. Stream tracks moq-c creates are timed, so their raw writes need one. Datagram tracks are separate and default to untimed; set their timescale when creating them to require timestamps. Stamp media frames and JSON writes from `moq_publish_catalog_now()`, the broadcast clock every track in the broadcast shares; media on a timeline of its own advertises the gap to the JSON tracks as catalog `delay`. JSON writes are converted to their track's milliseconds. A NULL timestamp on any write fails with `MOQ_ERROR_INVALID_POINTER`. A zero scale with `has_scale` set, or an out-of-range value, fails with `MOQ_ERROR_TIMESTAMP_OVERFLOW`. +- **Timestamps.** A `moq_timestamp` is exact: `value` units at `scale` units per second, so a 90 kHz tick survives a read and republish. Frames, datagrams, and JSON values point `timestamp` at theirs, valid as long as the payload. An untimed track has no scale, so there `has_scale` is false and `value` is the frame's group key (a datagram's sequence); every write and `moq_publish_track_group` takes one, with `moq_publish_group_start` naming a group's key. Stream tracks libmoq creates are timed, so their raw writes need one. Datagram tracks are separate and default to untimed; set their timescale when creating them to require timestamps. Stamp media frames and JSON writes from `moq_publish_catalog_now()`, the broadcast clock every track in the broadcast shares; media on a timeline of its own advertises the gap to the JSON tracks as catalog `delay`. JSON writes are converted to their track's milliseconds. A NULL timestamp on any write fails with `MOQ_ERROR_INVALID_POINTER`. A zero scale with `has_scale` set, or an out-of-range value, fails with `MOQ_ERROR_TIMESTAMP_OVERFLOW`. - **Catalog timing.** Each catalog snapshot from `moq_consume_catalog` takes effect at the media timestamp `moq_consume_catalog_timestamp` fills. A zero `delay_us` delivers only the newest catalog; a player that holds each update until its media reaches that time passes its playout delay instead, and receives in order every update it may still need. - **JSON values.** `moq_consume_json_value` fills `moq_json_value` with the document and its frame's timestamp. A snapshot consumer's callback fires for each state in order, but a group superseded before it is read is skipped. - **JSON windows.** `moq_publish_json_window` publishes a sliding run of records: `moq_publish_json_window_push` appends at the back, `moq_publish_json_window_pop` drops from the front, and `moq_publish_json_window_cut` closes the open group at a natural boundary. The catalog has no window mode, so a reader names the track. `moq_consume_json_window_event` fills `moq_json_window_event` with a push (the record at `start`, in `json`), a pop of `[start, end)`, or a skip of `[start, end)` that this reader joined too late to receive. Set `checkpoint_records` to bound what each new group restates for a window you never pop. @@ -140,5 +142,5 @@ inside. The header is the reference: each function carries a doc comment. ## Reference -- API source: [rs/moq-c/src](https://github.com/moq-dev/moq/tree/main/rs/moq-c/src) -- Source and a worked example: [`rs/moq-c`](https://github.com/moq-dev/moq/tree/main/rs/moq-c) +- API source: [rs/libmoq/src](https://github.com/moq-dev/moq/tree/main/rs/libmoq/src) +- Source and a worked example: [`rs/libmoq`](https://github.com/moq-dev/moq/tree/main/rs/libmoq) diff --git a/doc/lib/cpp/index.md b/doc/lib/cpp/index.md index 3acab9cb310..b52a06f4c8a 100644 --- a/doc/lib/cpp/index.md +++ b/doc/lib/cpp/index.md @@ -14,7 +14,7 @@ C++17 is the floor, and C++20 adds `co_await` on a future. The bindings are generated from the same [UniFFI](https://mozilla.github.io/uniffi-rs/) crate as the other wrappers, so a method means the same thing here as in Python or Go. For a plain C ABI, use -[moq-c](/lib/c/). +[libmoq](/lib/c/). ## Install @@ -51,7 +51,7 @@ an explicit directory, a release pin in `cpp/moq/FFI_VERSION` selects the defaul input; `just cpp package` fetches it with the checked-in SHA-256 hashes and fails if it cannot verify it. Direct CMake builds and `just cpp check` build the current checkout unless given an explicit native directory. The package is -`moq-cpp`. It and the C package, `moq-c`, each link in their own copy of the +`moq-cpp`. It and the C package, `libmoq`, each link in their own copy of the Rust core, so a program links one of the two, never both. ## Example diff --git a/doc/lib/index.md b/doc/lib/index.md index 67e976a144b..7b29ed3811d 100644 --- a/doc/lib/index.md +++ b/doc/lib/index.md @@ -18,7 +18,7 @@ protocol. A publisher in Python is consumable by a subscriber in Swift. | [Go](/lib/go/) | `moq.dev/moq` | Go services and tooling. | | [Dart](/lib/dart/) | `moq` on pub.dev | Flutter apps (experimental). | | [C++](/lib/cpp/) | `moq-cpp` via CMake or pkg-config | C++ apps, engines, and plugins. | -| [C](/lib/c/) | `moq-c` | The plain-C ABI, for C and any language with a C FFI; C++ should use the package above. | +| [C](/lib/c/) | `libmoq` | The plain-C ABI, for C and any language with a C FFI; C++ should use the package above. | ## Choose the layer @@ -40,8 +40,9 @@ Rust is the reference implementation; every server-side tool is built on it. TypeScript is a from-scratch browser implementation. The other seven wrap the Rust core: Python, Kotlin, Swift, Go, Dart, and C++ are generated from one [UniFFI](https://mozilla.github.io/uniffi-rs/) crate (`moq-ffi`) and then -wrapped in an idiomatic layer, while C gets a hand-written stable ABI -(`moq-c`). A feature added to the core lands in all of them together. +wrapped in an idiomatic layer, while C gets a hand-written API (`libmoq`). +A feature added to the core lands in all of them together, except `libmoq`: +its 0.22 line takes fixes only until a generated `moq-c` replaces it. [Layers](/lib/layers) shows where each layer they wrap lives in every binding. ## Performance diff --git a/doc/lib/layers.md b/doc/lib/layers.md index d57d49f0f58..c590cacde75 100644 --- a/doc/lib/layers.md +++ b/doc/lib/layers.md @@ -21,7 +21,7 @@ namespace tells them apart: `media.TrackConsumer` reads what Exceptions: - **C++** is one flat `moq::` namespace with the layer folded into the name (`moq::MediaTrackProducer`, `moq::JsonSnapshotProducer`). -- **C** is the hand-written moq-c ABI, grouped by direction (`moq_publish_*`, `moq_consume_*`) rather than by layer, so its rows name function prefixes. Its `moq_publish_video` and `moq_consume_video` move encoded frames (media); the codecs are `moq_encode_*` and `moq_decode_*`, which always publish to or subscribe from a broadcast, so C has no codec-only `Encoder`. +- **C** is the hand-written libmoq ABI, grouped by direction (`moq_publish_*`, `moq_consume_*`) rather than by layer, so its rows name function prefixes. Its `moq_publish_video` and `moq_consume_video` move encoded frames (media); the codecs are `moq_encode_*` and `moq_decode_*`, which always publish to or subscribe from a broadcast, so C has no codec-only `Encoder`. - **Dart** has no `audio` or `video` library, because its published binaries carry no codecs. - **TypeScript** is a separate implementation with its own [packages](/lib/js/), so it is not mapped here. diff --git a/doc/lib/rs/index.md b/doc/lib/rs/index.md index d2688128e14..9366e0abbc4 100644 --- a/doc/lib/rs/index.md +++ b/doc/lib/rs/index.md @@ -43,7 +43,7 @@ missing required CPU feature before starting transport cryptography. | [moq-stats](https://docs.rs/moq-stats) | Publish and consume relay traffic counters as tracks. | | [kio](/lib/rs/kio) | The async primitives everything polls through, and one clock for time and timers on tokio and a deterministic test simulator. | | [moq-hls](https://docs.rs/moq-hls), [moq-rtmp](https://docs.rs/moq-rtmp), [moq-srt](https://docs.rs/moq-srt), [moq-rtsp](https://github.com/moq-dev/moq/tree/main/rs/moq-rtsp), [moq-webrtc](https://github.com/moq-dev/moq/tree/main/rs/moq-webrtc) | The [gateways](/bin/), as libraries you can embed with your own auth. | -| [moq-ffi](https://docs.rs/moq-ffi), [moq-c](/lib/c/) | The UniFFI core behind the language bindings, and the C ABI. | +| [moq-ffi](https://docs.rs/moq-ffi), [libmoq](/lib/c/) | The UniFFI core behind the language bindings, and the C ABI. | | [moq-relay](/bin/relay/), [moq-cli](/bin/cli) | The binaries, also usable as crates. | | [web-transport](https://github.com/moq-dev/web-transport) | The WebTransport traits and the browser transport, in a sibling repository. | diff --git a/doc/setup/repository.md b/doc/setup/repository.md index e05a5f1400a..a7d5c3f887d 100644 --- a/doc/setup/repository.md +++ b/doc/setup/repository.md @@ -29,7 +29,7 @@ wrap the Rust core. [Layers](/lib/layers) maps the binding namespaces. | Browser reactive state and cleanup | [`js/signals`](https://github.com/moq-dev/moq/tree/main/js/signals) | [Signals](/lib/js/signals) | | Native capture, codecs, and rendering | [`rs/moq-audio`](https://github.com/moq-dev/moq/tree/main/rs/moq-audio), [`rs/moq-video`](https://github.com/moq-dev/moq/tree/main/rs/moq-video), [`rs/moq-transcode`](https://github.com/moq-dev/moq/tree/main/rs/moq-transcode) | [Audio](/lib/rs/moq-audio), [video](/lib/rs/moq-video) | | CLI commands and protocol gateways | [`rs/moq-cli`](https://github.com/moq-dev/moq/tree/main/rs/moq-cli), then the corresponding `rs/moq-{rtmp,srt,webrtc,rtsp,hls}` crate | [Applications](/bin/) | -| Language bindings | [`rs/moq-ffi`](https://github.com/moq-dev/moq/tree/main/rs/moq-ffi), [`rs/moq-c`](https://github.com/moq-dev/moq/tree/main/rs/moq-c), then `py/`, `swift/`, `kt/`, `go/`, `dart/`, or `cpp/moq/` | [Binding layers](/lib/layers) | +| Language bindings | [`rs/moq-ffi`](https://github.com/moq-dev/moq/tree/main/rs/moq-ffi), [`rs/libmoq`](https://github.com/moq-dev/moq/tree/main/rs/libmoq), then `py/`, `swift/`, `kt/`, `go/`, `dart/`, or `cpp/moq/` | [Binding layers](/lib/layers) | | Rooms, chat, and application data | [`js/room`](https://github.com/moq-dev/moq/tree/main/js/room), `rs/moq-json`, `js/json` | [Rooms](/lib/js/room), [JSON tracks](/lib/js/json) | | End-to-end encryption (unpublished, experimental) | [`rs/moq-e2ee`](https://github.com/moq-dev/moq/tree/main/rs/moq-e2ee), [`js/e2ee`](https://github.com/moq-dev/moq/tree/main/js/e2ee) | [E2EE draft](/draft/moq-e2ee) | | Async primitives and deterministic time | [`rs/kio`](https://github.com/moq-dev/moq/tree/main/rs/kio), [`js/clock`](https://github.com/moq-dev/moq/tree/main/js/clock) | [Rust conventions](/lib/rs/#conventions), [clock](/lib/js/clock) | diff --git a/doc/setup/upgrade.md b/doc/setup/upgrade.md index 04c3feec678..74e7603a253 100644 --- a/doc/setup/upgrade.md +++ b/doc/setup/upgrade.md @@ -26,7 +26,7 @@ replaces it. ## Migration guides - **Binaries:** [moq-relay](https://github.com/moq-dev/moq/blob/main/rs/moq-relay/MIGRATE.md), [moq-cli (`moq`)](https://github.com/moq-dev/moq/blob/main/rs/moq-cli/MIGRATE.md), [moq-gst](https://github.com/moq-dev/moq/blob/main/rs/moq-gst/MIGRATE.md), [obs-moq](https://github.com/moq-dev/moq/blob/main/cpp/obs/MIGRATE.md) -- **Bindings:** [moq-ffi (UniFFI)](https://github.com/moq-dev/moq/blob/main/rs/moq-ffi/MIGRATE.md), [moq-c (C)](https://github.com/moq-dev/moq/blob/main/rs/moq-c/MIGRATE.md), [Python](https://github.com/moq-dev/moq/blob/main/py/moq-rs/MIGRATE.md), [Go](https://github.com/moq-dev/moq/blob/main/go/wrapper/MIGRATE.md), [Swift](https://github.com/moq-dev/moq/blob/main/swift/MIGRATE.md), [Kotlin](https://github.com/moq-dev/moq/blob/main/kt/moq/MIGRATE.md), [Dart](https://github.com/moq-dev/moq/blob/main/dart/moq/MIGRATE.md), [C++](https://github.com/moq-dev/moq/blob/main/cpp/moq/MIGRATE.md) +- **Bindings:** [moq-ffi (UniFFI)](https://github.com/moq-dev/moq/blob/main/rs/moq-ffi/MIGRATE.md), [libmoq (C)](https://github.com/moq-dev/moq/blob/main/rs/libmoq/MIGRATE.md), [Python](https://github.com/moq-dev/moq/blob/main/py/moq-rs/MIGRATE.md), [Go](https://github.com/moq-dev/moq/blob/main/go/wrapper/MIGRATE.md), [Swift](https://github.com/moq-dev/moq/blob/main/swift/MIGRATE.md), [Kotlin](https://github.com/moq-dev/moq/blob/main/kt/moq/MIGRATE.md), [Dart](https://github.com/moq-dev/moq/blob/main/dart/moq/MIGRATE.md), [C++](https://github.com/moq-dev/moq/blob/main/cpp/moq/MIGRATE.md) - **Rust:** [hang](https://github.com/moq-dev/moq/blob/main/rs/hang/MIGRATE.md), [kio](https://github.com/moq-dev/moq/blob/main/rs/kio/MIGRATE.md), [kio-macros](https://github.com/moq-dev/moq/blob/main/rs/kio/macros/MIGRATE.md), [moq-archive](https://github.com/moq-dev/moq/blob/main/rs/moq-archive/MIGRATE.md), [moq-audio](https://github.com/moq-dev/moq/blob/main/rs/moq-audio/MIGRATE.md), [moq-auth](https://github.com/moq-dev/moq/blob/main/rs/moq-auth/MIGRATE.md), [moq-hls](https://github.com/moq-dev/moq/blob/main/rs/moq-hls/MIGRATE.md), [moq-json](https://github.com/moq-dev/moq/blob/main/rs/moq-json/MIGRATE.md), [moq-loc](https://github.com/moq-dev/moq/blob/main/rs/moq-loc/MIGRATE.md), [moq-msf](https://github.com/moq-dev/moq/blob/main/rs/moq-msf/MIGRATE.md), [moq-mux](https://github.com/moq-dev/moq/blob/main/rs/moq-mux/MIGRATE.md), [moq-net](https://github.com/moq-dev/moq/blob/main/rs/moq-net/MIGRATE.md), [moq-nvenc](https://github.com/moq-dev/moq/blob/main/rs/moq-nvenc/MIGRATE.md), [moq-pattern](https://github.com/moq-dev/moq/blob/main/rs/moq-pattern/MIGRATE.md), [moq-rtmp](https://github.com/moq-dev/moq/blob/main/rs/moq-rtmp/MIGRATE.md), [moq-sock](https://github.com/moq-dev/moq/blob/main/rs/moq-sock/MIGRATE.md), [moq-srt](https://github.com/moq-dev/moq/blob/main/rs/moq-srt/MIGRATE.md), [moq-stats](https://github.com/moq-dev/moq/blob/main/rs/moq-stats/MIGRATE.md), [moq-tokio](https://github.com/moq-dev/moq/blob/main/rs/moq-tokio/MIGRATE.md), [moq-transcode](https://github.com/moq-dev/moq/blob/main/rs/moq-transcode/MIGRATE.md), [moq-uring](https://github.com/moq-dev/moq/blob/main/rs/moq-uring/MIGRATE.md), [moq-v4l](https://github.com/moq-dev/moq/blob/main/rs/moq-v4l/MIGRATE.md), [moq-video](https://github.com/moq-dev/moq/blob/main/rs/moq-video/MIGRATE.md), [moq-webrtc (was moq-rtc)](https://github.com/moq-dev/moq/blob/main/rs/moq-webrtc/MIGRATE.md), [qmux](https://github.com/moq-dev/moq/blob/main/rs/qmux/MIGRATE.md) - **JavaScript:** [`@moq/auth`](https://github.com/moq-dev/moq/blob/main/js/auth/MIGRATE.md), [`@moq/clock`](https://github.com/moq-dev/moq/blob/main/js/clock/MIGRATE.md), [`@moq/hang`](https://github.com/moq-dev/moq/blob/main/js/hang/MIGRATE.md), [`@moq/json`](https://github.com/moq-dev/moq/blob/main/js/json/MIGRATE.md), [`@moq/loc`](https://github.com/moq-dev/moq/blob/main/js/loc/MIGRATE.md), [`@moq/msf`](https://github.com/moq-dev/moq/blob/main/js/msf/MIGRATE.md), [`@moq/net`](https://github.com/moq-dev/moq/blob/main/js/net/MIGRATE.md), [`@moq/pattern`](https://github.com/moq-dev/moq/blob/main/js/pattern/MIGRATE.md), [`@moq/publish`](https://github.com/moq-dev/moq/blob/main/js/publish/MIGRATE.md), [`@moq/qmux`](https://github.com/moq-dev/moq/blob/main/js/qmux/MIGRATE.md), [`@moq/room`](https://github.com/moq-dev/moq/blob/main/js/room/MIGRATE.md), [`@moq/signals`](https://github.com/moq-dev/moq/blob/main/js/signals/MIGRATE.md), [`@moq/video`](https://github.com/moq-dev/moq/blob/main/js/video/MIGRATE.md), [`@moq/watch`](https://github.com/moq-dev/moq/blob/main/js/watch/MIGRATE.md) diff --git a/flake.nix b/flake.nix index 91cdd86e518..bd602001bb1 100644 --- a/flake.nix +++ b/flake.nix @@ -571,7 +571,7 @@ moq-relay moq-bench moq-boy - moq-c + libmoq moq-gst ; diff --git a/go/ffi/moq/cgo.go b/go/ffi/moq/cgo.go index f78a0171a8e..50dc423b50e 100644 --- a/go/ffi/moq/cgo.go +++ b/go/ffi/moq/cgo.go @@ -14,7 +14,7 @@ package moq // A Rust staticlib does not carry the link options its dependencies declare, so // every system library has to be named here. The same list, for the same reason, -// lives in rs/moq-c/native-libs/ for C consumers of moq-c; keep the two in step +// lives in rs/libmoq/native-libs/ for C consumers of libmoq; keep the two in step // when moq-ffi gains a dependency. The moq-video / moq-audio entries cover // hardware H.264/H.265 encode and decode plus capture, and openh264 (the software // H.264 fallback) is C++. diff --git a/go/wrapper/reconnect_test.go b/go/wrapper/reconnect_test.go index 41e38063458..574678961d2 100644 --- a/go/wrapper/reconnect_test.go +++ b/go/wrapper/reconnect_test.go @@ -166,7 +166,7 @@ func TestListenKeylogRequiresSSLKEYLOGFILE(t *testing.T) { } } -// A Go worker survives a relay restart the way a moq-c worker does: the session +// A Go worker survives a relay restart the way a libmoq worker does: the session // redials with backoff, the publisher re-announces its broadcast to the fresh // relay, and the subscriber's subscription receives frames again. The connect count // pairs with Status so a worker can log each reconnect. diff --git a/infra/README.md b/infra/README.md index dce7f96a0d1..e5084c11ccf 100644 --- a/infra/README.md +++ b/infra/README.md @@ -324,7 +324,7 @@ done. "enforcement": "active", "conditions": {"ref_name": {"exclude": [], "include": [ "refs/tags/moq-relay-v*", "refs/tags/moq-cli-v*", - "refs/tags/moq-c-v*", "refs/tags/moq-gst-v*", + "refs/tags/libmoq-v*", "refs/tags/moq-gst-v*", "refs/tags/moq-ffi-v*", "refs/tags/moq-dart-v*" ]}}, "rules": [{"type": "creation"}, {"type": "update"}, {"type": "deletion"}], @@ -349,7 +349,7 @@ done. bootstrap created: ```bash - for tag in 'moq-relay-v*' 'moq-cli-v*' 'moq-c-v*' 'moq-gst-v*'; do + for tag in 'moq-relay-v*' 'moq-cli-v*' 'libmoq-v*' 'moq-gst-v*'; do gh api -X POST repos/moq-dev/moq/environments/cache-write/deployment-branch-policies \ -f name="$tag" -f type=tag done diff --git a/nix/Cargo.nix b/nix/Cargo.nix index 256244d679e..2d2144ffd48 100644 --- a/nix/Cargo.nix +++ b/nix/Cargo.nix @@ -150,16 +150,6 @@ rec { # File a bug if you depend on any for non-debug work! debug = internal.debugCrate { inherit packageId; }; }; - "moq-c" = rec { - packageId = "moq-c"; - build = internal.buildRustCrateWithFeatures { - packageId = "moq-c"; - }; - - # Debug support which might change between releases. - # File a bug if you depend on any for non-debug work! - debug = internal.debugCrate { inherit packageId; }; - }; "moq-cli" = rec { packageId = "moq-cli"; build = internal.buildRustCrateWithFeatures { @@ -16657,23 +16647,141 @@ rec { }; "libmoq" = rec { crateName = "libmoq"; - version = "0.6.12"; + version = "0.7.0"; edition = "2024"; src = lib.cleanSourceWith { filter = sourceFilter; src = ../rs/libmoq; }; + type = [ "staticlib" ]; authors = [ "Luke Curley " "Brian Medley " ]; + dependencies = [ + { + name = "anyhow"; + packageId = "anyhow"; + features = [ "backtrace" ]; + } + { + name = "bytes"; + packageId = "bytes"; + } + { + name = "hang"; + packageId = "hang"; + features = [ "async" ]; + } + { + name = "kio"; + packageId = "kio"; + features = [ "async" ]; + } + { + name = "moq-audio"; + packageId = "moq-audio"; + usesDefaultFeatures = false; + } + { + name = "moq-json"; + packageId = "moq-json"; + features = [ "async" ]; + } + { + name = "moq-mux"; + packageId = "moq-mux"; + features = [ "async" ]; + } + { + name = "moq-net"; + packageId = "moq-net"; + } + { + name = "moq-tokio"; + packageId = "moq-tokio"; + usesDefaultFeatures = false; + } + { + name = "moq-video"; + packageId = "moq-video"; + usesDefaultFeatures = false; + features = [ + "nvidia" + "vaapi" + ]; + } + { + name = "pollster"; + packageId = "pollster"; + } + { + name = "serde_json"; + packageId = "serde_json"; + } + { + name = "thiserror"; + packageId = "thiserror 2.0.21"; + } + { + name = "tokio"; + packageId = "tokio"; + features = [ "macros" ]; + } + { + name = "tracing"; + packageId = "tracing"; + } + { + name = "url"; + packageId = "url"; + } + ]; + buildDependencies = [ + { + name = "cbindgen"; + packageId = "cbindgen"; + } + ]; devDependencies = [ + { + name = "kio"; + packageId = "kio"; + features = [ "runtime" ]; + } + { + name = "moq-loc"; + packageId = "moq-loc"; + } + { + name = "moq-tokio"; + packageId = "moq-tokio"; + usesDefaultFeatures = false; + features = [ "test-support" ]; + } + { + name = "moq-video"; + packageId = "moq-video"; + features = [ "openh264" ]; + } + { + name = "test-env"; + packageId = "test-env"; + } + { + name = "tokio"; + packageId = "tokio"; + features = [ "test-util" ]; + } { name = "workspace-hack"; packageId = "workspace-hack"; } ]; - + features = { + "openh264" = [ "moq-video/openh264" ]; + }; + resolvedDefaultFeatures = [ "openh264" ]; }; "libredox" = rec { crateName = "libredox"; @@ -18440,144 +18548,6 @@ rec { "openh264" ]; }; - "moq-c" = rec { - crateName = "moq-c"; - version = "0.7.0"; - edition = "2024"; - src = lib.cleanSourceWith { - filter = sourceFilter; - src = ../rs/moq-c; - }; - type = [ "staticlib" ]; - authors = [ - "Luke Curley " - "Brian Medley " - ]; - dependencies = [ - { - name = "anyhow"; - packageId = "anyhow"; - features = [ "backtrace" ]; - } - { - name = "bytes"; - packageId = "bytes"; - } - { - name = "hang"; - packageId = "hang"; - features = [ "async" ]; - } - { - name = "kio"; - packageId = "kio"; - features = [ "async" ]; - } - { - name = "moq-audio"; - packageId = "moq-audio"; - usesDefaultFeatures = false; - } - { - name = "moq-json"; - packageId = "moq-json"; - features = [ "async" ]; - } - { - name = "moq-mux"; - packageId = "moq-mux"; - features = [ "async" ]; - } - { - name = "moq-net"; - packageId = "moq-net"; - } - { - name = "moq-tokio"; - packageId = "moq-tokio"; - usesDefaultFeatures = false; - } - { - name = "moq-video"; - packageId = "moq-video"; - usesDefaultFeatures = false; - features = [ - "nvidia" - "vaapi" - ]; - } - { - name = "pollster"; - packageId = "pollster"; - } - { - name = "serde_json"; - packageId = "serde_json"; - } - { - name = "thiserror"; - packageId = "thiserror 2.0.21"; - } - { - name = "tokio"; - packageId = "tokio"; - features = [ "macros" ]; - } - { - name = "tracing"; - packageId = "tracing"; - } - { - name = "url"; - packageId = "url"; - } - ]; - buildDependencies = [ - { - name = "cbindgen"; - packageId = "cbindgen"; - } - ]; - devDependencies = [ - { - name = "kio"; - packageId = "kio"; - features = [ "runtime" ]; - } - { - name = "moq-loc"; - packageId = "moq-loc"; - } - { - name = "moq-tokio"; - packageId = "moq-tokio"; - usesDefaultFeatures = false; - features = [ "test-support" ]; - } - { - name = "moq-video"; - packageId = "moq-video"; - features = [ "openh264" ]; - } - { - name = "test-env"; - packageId = "test-env"; - } - { - name = "tokio"; - packageId = "tokio"; - features = [ "test-util" ]; - } - { - name = "workspace-hack"; - packageId = "workspace-hack"; - } - ]; - features = { - "openh264" = [ "moq-video/openh264" ]; - }; - resolvedDefaultFeatures = [ "openh264" ]; - }; "moq-cli" = rec { crateName = "moq-cli"; version = "0.14.2"; diff --git a/nix/overlay.nix b/nix/overlay.nix index 6b8f6d5268e..bdb777dd094 100644 --- a/nix/overlay.nix +++ b/nix/overlay.nix @@ -24,12 +24,12 @@ let ''; # The native libraries an external linker must pass alongside libmoq.a. - # rs/moq-c/native-libs/ is the single source: rs/moq-c/CMakeLists.txt reads - # it for in-tree consumers, and moq-c below substitutes it into the moq-c.pc + # rs/libmoq/native-libs/ is the single source: rs/libmoq/CMakeLists.txt reads + # it for in-tree consumers, and libmoq below substitutes it into the moq.pc # and find_package templates directly rather than running CMake, so format # it the way each expects: `Libs.private` flags, and CMakeLists.txt's # MOQ_NATIVE_LIBS_QUOTED. - moqCNativeLibs = + libmoqNativeLibs = let platform = if final.stdenv.hostPlatform.isDarwin then @@ -38,7 +38,7 @@ let "windows" else "linux"; - lines = final.lib.splitString "\n" (builtins.readFile ../rs/moq-c/native-libs/${platform}.txt); + lines = final.lib.splitString "\n" (builtins.readFile ../rs/libmoq/native-libs/${platform}.txt); entries = builtins.filter (line: line != "" && !(final.lib.hasPrefix "#" line)) lines; framework = entry: "-framework ${final.lib.removePrefix "framework:" entry}"; isFramework = final.lib.hasPrefix "framework:"; @@ -53,11 +53,11 @@ let }; # Releases carry the OpenH264 software fallback, which is opt-in. - moqCCrate = crates.build { - root = "moq-c"; + libmoqCrate = crates.build { + root = "libmoq"; features = [ "openh264" ]; # Cargo.toml's `[lib] name`, which crate2nix drops for a staticlib-only - # crate, so the archive would be libmoq_c. + # crate, so the archive would be liblibmoq. rootAttrs.libName = "moq"; }; @@ -95,32 +95,32 @@ in }; # Lay out the artifact tree the way release tarballs and downstream - # `find_package(moq-c)` consumers already expect. - moq-c = final.stdenv.mkDerivation { - pname = "moq-c"; - inherit (moqCCrate) version; + # `find_package(moq)` consumers already expect. + libmoq = final.stdenv.mkDerivation { + pname = "libmoq"; + inherit (libmoqCrate) version; dontUnpack = true; nativeBuildInputs = [ final.pkg-config ]; - passthru = { inherit (moqCCrate) deps; }; + passthru = { inherit (libmoqCrate) deps; }; installPhase = '' runHook preInstall - mkdir -p $out/lib/pkgconfig $out/include $out/lib/cmake/moq-c + mkdir -p $out/lib/pkgconfig $out/include $out/lib/cmake/moq # buildRustCrate suffixes the archive with the crate's metadata hash, and # keeps build.rs's OUT_DIR, where it writes the header. - cp ${moqCCrate.lib}/lib/libmoq-*.a $out/lib/libmoq.a - cp ${moqCCrate.lib}/lib/moq-c.out/include/moq.h $out/include/ + cp ${libmoqCrate.lib}/lib/libmoq-*.a $out/lib/libmoq.a + cp ${libmoqCrate.lib}/lib/libmoq.out/include/moq.h $out/include/ # Rendered here rather than by build.rs: the template's paths are relative # to the .pc, which only holds once libmoq.a sits beside pkgconfig/. - pc=$out/lib/pkgconfig/moq-c.pc - substitute ${../rs/moq-c/moq-c.pc.in} "$pc" \ + pc=$out/lib/pkgconfig/moq.pc + substitute ${../rs/libmoq/moq.pc.in} "$pc" \ --subst-var-by VERSION "$version" \ - --subst-var-by LIBS_PRIVATE ${final.lib.escapeShellArg moqCNativeLibs.pc} + --subst-var-by LIBS_PRIVATE ${final.lib.escapeShellArg libmoqNativeLibs.pc} if grep -nE '@[A-Z_]+@' "$pc"; then - echo "unsubstituted placeholder in moq-c.pc (see above)" >&2 + echo "unsubstituted placeholder in moq.pc (see above)" >&2 exit 1 fi # Resolve the paths the way a consumer's pkg-config will, so a template @@ -128,20 +128,19 @@ in for check in libdir:libmoq.a includedir:moq.h; do dir=$(pkg-config --variable="''${check%%:*}" "$pc") if [ ! -f "$dir/''${check#*:}" ]; then - echo "moq-c.pc ''${check%%:*} $dir has no ''${check#*:}" >&2 + echo "moq.pc ''${check%%:*} $dir has no ''${check#*:}" >&2 exit 1 fi done - substitute ${../rs/moq-c/cmake/moq-c-config.cmake.in} \ - $out/lib/cmake/moq-c/moq-c-config.cmake \ + substitute ${../rs/libmoq/cmake/moq-config.cmake.in} \ + $out/lib/cmake/moq/moq-config.cmake \ --subst-var-by LIB_FILE libmoq.a \ --subst-var-by VERSION "$version" \ - --subst-var-by MOQ_NATIVE_LIBS_QUOTED ${final.lib.escapeShellArg moqCNativeLibs.cmake} - substitute ${../rs/moq-c/cmake/moq-c-config-version.cmake.in} \ - $out/lib/cmake/moq-c/moq-c-config-version.cmake \ - --subst-var-by VERSION "$version" \ - --subst-var-by MAJOR_VERSION "''${version%%.*}" + --subst-var-by MOQ_NATIVE_LIBS_QUOTED ${final.lib.escapeShellArg libmoqNativeLibs.cmake} + substitute ${../rs/libmoq/cmake/moq-config-version.cmake.in} \ + $out/lib/cmake/moq/moq-config-version.cmake \ + --subst-var-by VERSION "$version" runHook postInstall ''; diff --git a/quest/m0/ci/cachix-retire.md b/quest/m0/ci/cachix-retire.md index 0adb61aaeba..83653ffb253 100644 --- a/quest/m0/ci/cachix-retire.md +++ b/quest/m0/ci/cachix-retire.md @@ -40,8 +40,8 @@ otherwise have to move. push` would fail), any local action it uses, the deletion of `cachix.yml`, and `main`'s `cache.yml` in place of `release`'s, whose dispatch-only `warm` job still runs `cachix push kixelated` with - `CACHIX_AUTH_TOKEN` and would fail once the token is gone. Match `release`'s own tag patterns (it still cuts `libmoq-v*` - where `main` cuts `moq-c-v*`) and the flake attributes `release` builds; the + `CACHIX_AUTH_TOKEN` and would fail once the token is gone. Match `release`'s own tag patterns and the flake attributes `release` builds + (`main` cuts `libmoq-v*` like `release`); the `cache-write` Environment must admit those tags. - On the first `moq-relay-v*` or `moq-cli-v*` tag after the backport, record its `release-nix.yml` pushes from all three legs, then diff --git a/quest/m2/README.md b/quest/m2/README.md index f8832d690ed..e016b269b8f 100644 --- a/quest/m2/README.md +++ b/quest/m2/README.md @@ -50,7 +50,7 @@ removal, a rename, or a wire, catalog, or format change that is free until [the hole wait](/quest/m2/delay-hole-wait.md), and [upstream str0m](https://github.com/moq-dev/moq/pull/8963), which reverses the 2026-10-30 vendoring. -- **Bindings.** [The C API as `libmoq`](/quest/m2/libmoq-name.md), reversing 2026-10-25. +- **Bindings.** The C API as `libmoq` (done), reversing 2026-10-25. The bindings break twice by decision: at 0.22, and again at [the exporter switch](/quest/m3/ffi-exporter.md). diff --git a/quest/m2/libmoq-name.md b/quest/m2/libmoq-name.md deleted file mode 100644 index 9cb58f66765..00000000000 --- a/quest/m2/libmoq-name.md +++ /dev/null @@ -1,91 +0,0 @@ -# [M] The hand-written C API ships as libmoq, its final line - -## Goal - -The hand-written C API is published at the cut as `libmoq` 0.22, under the -package identity its users already have: the `libmoq` crate, the -`libmoq-v*` tag family and release archives, and the CMake and pkg-config -names `release` ships. A C user moves from 0.6 to 0.22 by following -`MIGRATE.md` for the API, with no package rename on top. 0.22 is that -line's last minor: afterwards it takes fixes only. - -`moq-c` and `moq::c` name only the generated package (`c/moq`), which stays -unpublished until it is ready. The code-free `rs/libmoq` stub is gone, and -the docs no longer call either C API a stable ABI. - -## Plan - -Decided 2026-11-16 (maintainer, /quest-plan of the pre-cut audit): ✅ ship -the hand-written API as `libmoq` 0.22 and keep `moq-c` unpublished for the -generated API (rejected: publishing it as `moq-c` and replacing that -package's whole API one minor later; shipping no C at 0.22). This reverses -the 2026-10-25 decision that the hand-written crate ships as `moq-c`, and -the rename in [moq-dev/moq#4288](https://github.com/moq-dev/moq/pull/4288). -C users were facing three names and two rewrites; this leaves one rename, -at the same moment as the API change that needs a rewrite anyway. - -Facts found by the audit: - -- Two packages in the tree claim one identity. `rs/moq-c` (hand-written): - `project(moq-c)` (`rs/moq-c/CMakeLists.txt:17`), `moq::c` (`:66`), - `moq-c.pc`, crate `moq-c` 0.7.0. `c/moq` (generated): `project(moq-c)` - (`c/moq/CMakeLists.txt:10`), `moq::c` (`:61`), `OUTPUT_NAME moq` (`:64`). -- `moq-c` has never been published in either form: there are 79 - `libmoq-v*` tags, newest `libmoq-v0.6.25`, and no `moq-c-v*` or `c-v*` - tag. `release` ships crate `libmoq` 0.6.26 with `project(moq)`, an - interface target `moq`, `moq.pc`, and `.github/workflows/libmoq.yml`. -- The generated line cannot ship at this cut: its type names and callback - contract change with [the exporter switch](/quest/m3/ffi-exporter.md). -- The plan this replaces published the hand-written crate as `moq-c` for - one minor and then gave the name to a total rewrite (CamelCase types, - `MoqError *` returns, task handles in place of `u32` ids), and no quest - planned the pointer release for the crate that would die. -- `doc/lib/index.md:43` and `doc/lib/c/index.md:3,11` call the hand-written - API a "stable ABI", though it is deleted once the generated one ships. -- `rs/libmoq` on `main` is a code-free stub at 0.6.12 whose description - reads "Renamed to moq-c". - -For the PR: - -- Replace the stub: `rs/moq-c` becomes `rs/libmoq`, crate `libmoq`, at a - version the cut's `just version` raises to the shared minor. Restore the - CMake project, target, and pkg-config names `release` has - (`git show origin/release:rs/libmoq/CMakeLists.txt`), and name the - workflow and tag family `libmoq` again. Diff the installed layout - (`include/`, `lib/`, `lib/cmake`, `lib/pkgconfig`) against a - `libmoq-v0.6.25` archive and explain every difference in the PR. -- Follow every reader: `.github/workflows/moq-c.yml`, `nix/overlay.nix` and - `flake.nix` (the `moq-c` package), `rs/justfile` (`package-moq-c`), - `sh/api-diff/ffi.sh` (it already accepts both tag families), - `sh/version.py`, `test/interop/clients/c`, `test/smoke/clients/c`, - `doc/lib/c`, and `RELEASE.md`'s `moq-c-v*` release family. -- `rs/moq-c/native-libs/` and `cpp/moq/cmake/moq-ffi.cmake` are read by the - generated package and C++ too; keep one source and repoint the readers - (`rg 'moq-c/native-libs|moq-ffi\.cmake'`). -- `MIGRATE.md`: the hand-written file's "Unreleased" section becomes - `libmoq` 0.6 to 0.22 and loses the package-rename steps. `c/moq/MIGRATE.md` - keeps the move to the generated API for when that publishes. -- The Nightly size report names four `moq-c-` archives, and - `sh/size/report.py` refuses a renamed series. Rename them in the report - and restart the history with the delete command in `sh/size/README.md`: - run it after the rename merges and before the next Nightly, since deleting - earlier lets a Nightly rewrite a history that still names the old series, and - merging without it fails every later Nightly. -- Docs: strike "stable ABI" from `doc/lib/index.md` and `doc/lib/c`, and say - what is true: `libmoq` 0.22 is the hand-written API's last minor, and a - generated `moq-c` replaces it. -- Recommended: say in `rs/libmoq/README.md` that the crate takes fixes only - after the cut, so new moq-ffi features stop being mirrored into its 261 - hand-written exports. That is AGENTS.md's bindings rule - ("a feature reaches the bindings when a binding user needs it") applied - to C. -- Verify with `just rs check` for the crate, its `c-tests`, the C doc - samples, and `just test interop --all`. - -Public API: none beyond what `main` already changed; the package identity -returns to `libmoq`, so the published name does not change. Wire: none. - -## Related - -- [Retire the hand-written C crate](/quest/m3/release/c-retire.md) - deletes this crate once the generated `moq-c` publishes -- [Generated C bindings](/quest/m3/c/README.md) - the package that takes the `moq-c` name diff --git a/quest/m2/libmoq-size-history.md b/quest/m2/libmoq-size-history.md new file mode 100644 index 00000000000..f6a470581e9 --- /dev/null +++ b/quest/m2/libmoq-size-history.md @@ -0,0 +1,23 @@ +# [XS] Restart the nightly size history after the libmoq rename + +## Goal + +Nightly's size report passes again once +[moq-dev/moq#8941](https://github.com/moq-dev/moq/pull/8941) merges. That PR +renames the hand-written C crate's four release archives from +`moq-c-` to `libmoq-` and stops matching the generated +package's `moq-c-generated-` uploads, so a retained history that names +the old keys makes `sh/size/report.py` refuse every report as "missing or +renamed" until the history restarts. + +## Plan + +After that PR merges, delete every retained `nightly-size-history` artifact +with the command in `sh/size/README.md`, as an agent with repository admin +access can, then confirm the next scheduled Nightly's `Collect and compare +sizes` step passes. The restart drops the 30-day baseline of every series, so +the first 30 days compare only against the previous night. + +## Waiting + +- moq-dev/moq: [moq-dev/moq#8941](https://github.com/moq-dev/moq/pull/8941) merges; check with `gh pr view 8941 --json state` diff --git a/quest/m2/video-producer.md b/quest/m2/video-producer.md index 17efcead050..857eb829cef 100644 --- a/quest/m2/video-producer.md +++ b/quest/m2/video-producer.md @@ -6,7 +6,7 @@ the uplink grant, as `moq_audio::encode::Producer` does for PCM. The type that publishes already encoded access units keeps working under a name that says what it takes (recommended: `encode::Publisher`). moq-boy, moq-ffi, and -moq-c publish video through the new producer, so the probe, catalog +libmoq publish video through the new producer, so the probe, catalog reservation, encode loop, and grant following exist once, in moq-video. ## Plan @@ -32,12 +32,12 @@ Facts found by the audit: the config, reserve a catalog slot with the effective join, build the producer, run the encode, receive, publish loop. `rs/moq-boy/src/video.rs:59-65` is the shortest witness; `rs/moq-ffi/src/video.rs` (2,129 lines) and - `rs/moq-c/src/video.rs` (1,820 lines) carry the rest. + `rs/libmoq/src/video.rs` (1,820 lines) carry the rest. - Grant following with rung disable, the part that is easy to get wrong, exists three times: private in the capture driver (`rs/moq-video/src/encode/producer.rs:718`, `:840`, `:940`), in moq-ffi - (`rs/moq-ffi/src/video.rs:370`, `:524`), and in moq-c - (`rs/moq-c/src/video.rs:286`, `:319`, `:363`). + (`rs/moq-ffi/src/video.rs:370`, `:524`), and in libmoq + (`rs/libmoq/src/video.rs:286`, `:319`, `:363`). - No quest owns it: [the grant getter](/quest/m3/video-publish-grant.md) only adds a getter to the capture handle, and [the mux wrap](/quest/m5/net-wrap/mux.md) only makes the producer generic. @@ -53,7 +53,7 @@ For the PR: Shape it after audio: an `Options` with `bandwidth`, `write(&Frame)`, and `finish(self) -> Result`, as the encoded publisher being renamed already has. -- Move moq-boy, moq-ffi, and moq-c onto it and delete their copies of the +- Move moq-boy, moq-ffi, and libmoq onto it and delete their copies of the grant follower. A binding option the lifted type cannot express (moq-ffi's `lower` rendition for the simulcast ladder, `rs/moq-ffi/src/video.rs:370`) becomes an option of the producer, not a reason to keep a copy. @@ -65,7 +65,7 @@ For the PR: and re-enables its rendition; `just test interop --all` for moq-ffi. Public API: moq-video breaks (`encode::Producer` changes meaning; the encoded -publisher is renamed). moq-ffi and moq-c keep their names. Wire: none. +publisher is renamed). moq-ffi and libmoq keep their names. Wire: none. ## Related diff --git a/quest/m3/c/README.md b/quest/m3/c/README.md index 5d9a7cacbb3..03221c1890b 100644 --- a/quest/m3/c/README.md +++ b/quest/m3/c/README.md @@ -40,8 +40,7 @@ Decided earlier, still standing: [Versions](/RELEASE.md#versions), [moq-dev/moq#7610](https://github.com/moq-dev/moq/pull/7610)). Amended 2026-11-16 (maintainer, /quest-plan of the pre-cut audit): the - hand-written API ships at 0.22 as `libmoq`, not `moq-c` - ([its name](/quest/m2/libmoq-name.md)), so the generated package takes + hand-written API ships at 0.22 as `libmoq`, not `moq-c`, so the generated package takes over no published name and C users rename once, when the API changes. - Docs change inline: the consumer quest rewrites `doc/lib/c`, and its Impact bullet carries the move for the package's `MIGRATE.md`. diff --git a/quest/m3/crates-trusted-publisher.md b/quest/m3/crates-trusted-publisher.md index fad19aae074..ddfc60364f5 100644 --- a/quest/m3/crates-trusted-publisher.md +++ b/quest/m3/crates-trusted-publisher.md @@ -11,8 +11,7 @@ Corrected 2026-11-12 (/quest-audit): moq-bench leaves the list, since it sets `publish = false`; seven crates remain. Corrected 2026-11-16 (/quest-plan of the pre-cut audit): moq-c leaves it too, since the hand-written C API ships as `libmoq`, which has a trusted publisher, and -`moq-c` stays unpublished for the generated API -([the C crate's name](/quest/m2/libmoq-name.md)); six remain. +`moq-c` stays unpublished for the generated API; six remain. ## Waiting diff --git a/quest/m3/release/c-publish.md b/quest/m3/release/c-publish.md index 15b83bbfd6f..48375c02609 100644 --- a/quest/m3/release/c-publish.md +++ b/quest/m3/release/c-publish.md @@ -15,8 +15,8 @@ and records the artifact versions and results. Decided 2026-11-16 (maintainer, /quest-plan of the pre-cut audit, replacing 2026-10-25's "the hand-written `moq-c` ships at the next cut"): the -hand-written API ships at the cut as `libmoq` 0.22, its final line -([the C crate's name](/quest/m2/libmoq-name.md)), and `moq-c` stays +hand-written API ships at the cut as `libmoq` 0.22, its final line, and +`moq-c` stays unpublished until this quest. So this is the first `moq-c` anyone can install: it supersedes no published `moq-c`, and the published package it replaces for C users is `libmoq`, whose source stays until diff --git a/quest/m3/release/c-retire.md b/quest/m3/release/c-retire.md index bdb6d645c72..77bfd0882f2 100644 --- a/quest/m3/release/c-retire.md +++ b/quest/m3/release/c-retire.md @@ -13,7 +13,7 @@ replaces them. - Decided 2026-11-16 (maintainer, /quest-plan of the pre-cut audit): the hand-written API ships at the cut as `libmoq` 0.22, its final line, and `moq-c` names only the generated package - ([the C crate's name](/quest/m2/libmoq-name.md)). This replaces the + (`c/moq`). This replaces the 2026-10-25 decision that it ships as `moq-c`, and with it the code-free `rs/libmoq` stub and its two quests: there is no stub at this cut. - So the crate this deletes is `rs/libmoq`. Before its source goes, publish @@ -39,6 +39,3 @@ replaces them. - [C consumers](/quest/m3/c/consumers.md) - the interop client and `doc/lib/c` samples no longer call the hand-written ABI -## Related - -- [The hand-written C API ships as libmoq](/quest/m2/libmoq-name.md) - the name this crate ships under until then diff --git a/quest/m3/release/cut.md b/quest/m3/release/cut.md index 754002ddd34..bf107b3deea 100644 --- a/quest/m3/release/cut.md +++ b/quest/m3/release/cut.md @@ -226,8 +226,8 @@ Decided 2026-11-16 (maintainer, /quest-plan of the pre-cut audit): `rs/moq-e2ee` at 0.0.25 and publishes it; once the cut merges `main` into `release`, its copy is `publish = false` at 0.0.26. Check that release-plz proposes nothing for `moq-e2ee`. -- ✅ The hand-written C API publishes as `libmoq` 0.22 - ([its final line](/quest/m2/libmoq-name.md)), reversing 2026-10-25, so the +- ✅ The hand-written C API publishes as `libmoq` 0.22, its final line, + reversing 2026-10-25, so the cut gate's "hand-written `moq-c`" below reads `libmoq`, and the two quests for a code-free `libmoq` stub were deleted. diff --git a/quest/m3/release/retired-names.md b/quest/m3/release/retired-names.md index 7395a8027d7..77cd639dfa0 100644 --- a/quest/m3/release/retired-names.md +++ b/quest/m3/release/retired-names.md @@ -20,9 +20,8 @@ doing nothing). [its finished format](/quest/m3/e2ee-format.md) publishes it, so it gets no pointer. crates.io keeps the full 0.0.25 (2026-11-11) as its newest until then; don't publish a stub over it. - - `libmoq` is the name the hand-written C API ships under at 0.22 - ([the C crate's name](/quest/m2/libmoq-name.md)), so it gets no pointer - at this cut. Its pointer at `moq-c` comes when the generated package + - `libmoq` is the name the hand-written C API ships under at 0.22, so it + gets no pointer at this cut. Its pointer at `moq-c` comes when the generated package publishes ([c-retire](/quest/m3/release/c-retire.md)). - Deprecate with a message: `moq-room` and `moq-native` ([moq-dev/moq#8450](https://github.com/moq-dev/moq/pull/8450)), diff --git a/rs/justfile b/rs/justfile index 995d4749849..c23a2e8185d 100644 --- a/rs/justfile +++ b/rs/justfile @@ -35,7 +35,7 @@ tamarin spec *args: # superset of it, and the two use different rustc wrappers, so running both # compiles the workspace twice. # -# A bare `just rs check` is default-members, which skips moq-c, moq-ffi, +# A bare `just rs check` is default-members, which skips libmoq, moq-ffi, # and moq-gst; pass `--workspace` for all of it. # Compile, lint, format-check, doc-check, and verify dependency hygiene. @@ -240,7 +240,7 @@ audit: # Outside nextest because the staticlib link alone outlasts its hang budget. -# Compile and run moq-c's C fixtures, and the C doc samples, against libmoq.a. Must run on Unix. +# Compile and run libmoq's C fixtures, and the C doc samples, against libmoq.a. Must run on Unix. c-tests: sh/rs/c-tests.sh @@ -542,10 +542,10 @@ package-nfpm *args: package-ffi *args: rs/moq-ffi/build.sh "$@" -# Build and package moq-c. +# Build and package libmoq. [positional-arguments] -package-moq-c *args: - rs/moq-c/build.sh "$@" +package-libmoq *args: + rs/libmoq/build.sh "$@" # Build and package the moq-gst GStreamer plugin. [positional-arguments] diff --git a/rs/moq-c/CHANGELOG.md b/rs/libmoq/CHANGELOG.md similarity index 100% rename from rs/moq-c/CHANGELOG.md rename to rs/libmoq/CHANGELOG.md diff --git a/rs/moq-c/CMakeLists.txt b/rs/libmoq/CMakeLists.txt similarity index 82% rename from rs/moq-c/CMakeLists.txt rename to rs/libmoq/CMakeLists.txt index c1dbb4b158f..83f30693746 100644 --- a/rs/moq-c/CMakeLists.txt +++ b/rs/libmoq/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.21) # release-plz owns the version and only ever bumps Cargo.toml, so read it from # there. A copy here goes stale the next release and stamps a wrong version into -# the installed find_package(moq-c) config, where it silently breaks version +# the installed find_package(moq) config, where it silently breaks version # constraints rather than failing the build. file(READ "${CMAKE_CURRENT_LIST_DIR}/Cargo.toml" _cargo_toml) string(REGEX MATCH "\nversion[ \t]*=[ \t]*\"([^\"]+)\"" _match "${_cargo_toml}") @@ -11,10 +11,10 @@ unset(_cargo_toml) unset(_match) if(NOT _version MATCHES "^[0-9]+\\.[0-9]+\\.[0-9]+$") - message(FATAL_ERROR "Unsupported version '${_version}' in rs/moq-c/Cargo.toml (project() takes a numeric x.y.z)") + message(FATAL_ERROR "Unsupported version '${_version}' in rs/libmoq/Cargo.toml (project() takes a numeric x.y.z)") endif() -project(moq-c VERSION ${_version} LANGUAGES C) +project(moq VERSION ${_version} LANGUAGES C) option(BUILD_RUST_LIB "Build the Rust library using cargo" ON) @@ -62,8 +62,8 @@ file(MAKE_DIRECTORY ${RUST_INCLUDE_DIR}) # Create interface library target that wraps the Rust static library add_library(moq INTERFACE) -# The name find_package(moq-c) exports, so a consumer links one target either way. -add_library(moq::c ALIAS moq) +# The name find_package(moq) exports, so a consumer links one target either way. +add_library(moq::moq ALIAS moq) target_include_directories(moq INTERFACE ${RUST_INCLUDE_DIR}) # Link the static library - must use target_link_libraries so it appears @@ -72,7 +72,7 @@ target_link_libraries(moq INTERFACE "${RUST_LIB}") # System libraries Rust std/deps pull in. When the staticlib is linked into a # C/C++ target by an external linker, cargo can't inject these itself. -# nix/overlay.nix reads the same files for moq-c.pc, so the two never drift. +# nix/overlay.nix reads the same files for moq.pc, so the two never drift. # # Reads native-libs/.txt into MOQ_NATIVE_LIBS: `framework:Foo` becomes # a linker framework flag, anything else a plain library name. @@ -108,7 +108,7 @@ endfunction() moq_read_native_libs(MOQ_NATIVE_LIBS) target_link_libraries(moq INTERFACE ${MOQ_NATIVE_LIBS}) -# Same list, quoted for substitution into cmake/moq-c-config.cmake.in below. +# Same list, quoted for substitution into cmake/moq-config.cmake.in below. # nix/overlay.nix substitutes that template itself and formats this identically. set(MOQ_NATIVE_LIBS_QUOTED "") foreach(_lib IN LISTS MOQ_NATIVE_LIBS) @@ -137,27 +137,27 @@ if(PROJECT_IS_TOP_LEVEL) # Generate and install CMake package config files include(CMakePackageConfigHelpers) - # The remaining placeholders in cmake/moq-c-config.cmake.in. rs/moq-c/build.sh + # The remaining placeholders in cmake/moq-config.cmake.in. rs/libmoq/build.sh # and nix/overlay.nix fill the same two in for the release artifacts. get_filename_component(LIB_FILE "${RUST_LIB}" NAME) set(VERSION "${PROJECT_VERSION}") configure_package_config_file( - ${CMAKE_CURRENT_SOURCE_DIR}/cmake/moq-c-config.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/moq-c-config.cmake - INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/moq-c + ${CMAKE_CURRENT_SOURCE_DIR}/cmake/moq-config.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/moq-config.cmake + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/moq PATH_VARS CMAKE_INSTALL_LIBDIR CMAKE_INSTALL_INCLUDEDIR ) write_basic_package_version_file( - ${CMAKE_CURRENT_BINARY_DIR}/moq-c-config-version.cmake + ${CMAKE_CURRENT_BINARY_DIR}/moq-config-version.cmake VERSION ${PROJECT_VERSION} - COMPATIBILITY SameMajorVersion + COMPATIBILITY SameMinorVersion ) install(FILES - ${CMAKE_CURRENT_BINARY_DIR}/moq-c-config.cmake - ${CMAKE_CURRENT_BINARY_DIR}/moq-c-config-version.cmake - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/moq-c + ${CMAKE_CURRENT_BINARY_DIR}/moq-config.cmake + ${CMAKE_CURRENT_BINARY_DIR}/moq-config-version.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/moq ) endif() diff --git a/rs/libmoq/Cargo.toml b/rs/libmoq/Cargo.toml index 81eb3d6825d..409207cefc7 100644 --- a/rs/libmoq/Cargo.toml +++ b/rs/libmoq/Cargo.toml @@ -1,18 +1,64 @@ [package] name = "libmoq" -description = "Renamed to moq-c: Media over QUIC, C bindings" +description = "Media over QUIC, C bindings" authors = ["Luke Curley ", "Brian Medley "] repository = "https://github.com/moq-dev/moq" license = "MIT OR Apache-2.0" -version = "0.6.12" +version = "0.7.0" edition = "2024" rust-version.workspace = true -keywords = ["quic", "media", "live"] -categories = ["multimedia", "network-programming"] +keywords = ["quic", "http3", "webtransport", "media", "live"] +categories = ["multimedia", "network-programming", "web-programming"] + +[lib] +name = "moq" +crate-type = ["staticlib"] + +[features] +# The OpenH264 software H.264 fallback (vendored C++). Off for development and +# linting; `build.sh`, the nix package, and CI's tests turn it on. +openh264 = ["moq-video/openh264"] + +[dependencies] +anyhow = { workspace = true, features = ["backtrace"] } +bytes = { workspace = true } +hang = { workspace = true, features = ["async"] } +kio = { workspace = true, features = ["async"] } +# Codecs only: OBS and the other C consumers do their own device I/O. +moq-audio = { workspace = true } +moq-json = { workspace = true, features = ["async"] } +moq-mux = { workspace = true, features = ["async"] } +moq-net = { workspace = true } +moq-tokio = { workspace = true } +# Select the NVIDIA and VAAPI hardware codecs explicitly because workspace +# defaults are off. The hardware backends dlopen their driver, so neither needs +# anything on the build host. The software fallback is `openh264`. +moq-video = { workspace = true, features = ["nvidia", "vaapi"] } +# Blocking on `encode::Sink` from the synchronous C entry points; see +# `video::block_on` for why not a tokio helper. +pollster = { workspace = true } +serde_json = { workspace = true } +thiserror = { workspace = true } +tokio = { workspace = true, features = ["macros"] } +tracing = { workspace = true } +url = { workspace = true } + +[build-dependencies] +cbindgen = "0.29" [dev-dependencies] +kio = { path = "../kio", features = ["runtime"] } +moq-loc = { path = "../moq-loc" } +# A peer without MoQ Solicit. +moq-tokio = { path = "../moq-tokio", default-features = false, features = ["test-support"] } +# The tests encode with OpenH264, the one encoder a GPU-less host has, so they +# turn it on without the `openh264` feature. +moq-video = { path = "../moq-video", features = ["openh264"] } +# Runs the tests that need a variable set or unset in a child process given it. +test-env = { path = "../test-env" } +tokio = { workspace = true, features = ["test-util"] } workspace-hack = { path = "../workspace-hack" } [lints] diff --git a/rs/moq-c/MIGRATE.md b/rs/libmoq/MIGRATE.md similarity index 97% rename from rs/moq-c/MIGRATE.md rename to rs/libmoq/MIGRATE.md index cbc75582521..d959d6e8bd8 100644 --- a/rs/moq-c/MIGRATE.md +++ b/rs/libmoq/MIGRATE.md @@ -1,8 +1,8 @@ -# Migrating moq-c +# Migrating libmoq How to update your code for each breaking change, newest first. -## Unreleased +## 0.6 -> 0.22 ### `moq_connection_stats` counts unrouted datagrams ([#7951](https://github.com/moq-dev/moq/pull/7951)) @@ -236,7 +236,7 @@ Set `moq_client_config::quic_keylog` or `moq_server_config::quic_keylog` as well ### OpenH264 is a build feature (#5771) The release archives and the CMake build still carry the software H.264 fallback. -A bare `cargo build -p moq-c` leaves it out; add `--features openh264` to keep it. +A bare `cargo build -p libmoq` leaves it out; add `--features openh264` to keep it. ### Subscriptions carry group ranges (#5732) @@ -267,19 +267,6 @@ Free each handle with `moq_consume_close` once its successor arrives. A frame write fails with a protocol error of kind `MOQ_PROTOCOL_KIND_TIMESTAMP_MISMATCH` when a group's first frame starts before a lower-sequence group's, or after a higher one's. A publisher whose timeline restarts publishes a new broadcast instead. -### libmoq is moq-c (#4288) - -The C bindings ship as the `moq-c` crate, starting at 0.7.0. -The header is still `moq.h` and the library is still `libmoq.a` / `moq.lib` (`-lmoq`); the C ABI did not change with the rename. -The CMake package, pkg-config name, release tags, and archives follow the new name. - -| Before | After | -| --- | --- | -| `find_package(moq)`, target `moq` | `find_package(moq-c)`, target `moq::c` | -| `pkg-config --libs moq` | `pkg-config --libs moq-c` | -| nix `.#libmoq` | nix `.#moq-c` | -| tags `libmoq-v*`, archives `libmoq--` | tags `moq-c-v*`, archives `moq-c--` | - ### Background panics are reported (#5562) A panic in a background task reports `MOQ_ERROR_PANIC`, and other handles keep running. @@ -329,7 +316,7 @@ To end its content first, call `moq_publish_catalog_finish`; the broadcast stays `moq_decode_video_frame` can return a conversion error for a single frame; it used to end the stream at the terminal callback. -## libmoq 0.5 -> 0.6 +## 0.5 -> 0.6 ### One client config diff --git a/rs/libmoq/README.md b/rs/libmoq/README.md index 3157249496a..ce1d5664966 100644 --- a/rs/libmoq/README.md +++ b/rs/libmoq/README.md @@ -1,10 +1,267 @@ # libmoq -`libmoq` is now [`moq-c`](https://crates.io/crates/moq-c), and this final -release contains no code. - -The C API is unchanged: the header is still `moq.h` and the library is still -`libmoq.a` (`moq.lib` on Windows). Switch the crate to `moq-c`, CMake to -`find_package(moq-c)` with the `moq::c` target, and pkg-config to `moq-c`. -Release archives are tagged `moq-c-v*` on -[GitHub](https://github.com/moq-dev/moq/releases?q=moq-c). +The hand-written C bindings for Media over QUIC. + +0.22 is this crate's last minor: after it, libmoq takes fixes only, and new +features land in the generated `moq-c` package (`c/moq`), which replaces it. + +## Building + +```bash +cargo build --release +``` + +This will: + +- Build the static library (`libmoq.a` on Unix-like systems, `moq.lib` on Windows) +- Generate the C header file at `$OUT_DIR/include/moq.h` + +`OUT_DIR` is the build script's hashed output directory, which +`cargo build --message-format=json` reports as `out_dir` on the +`build-script-executed` message for libmoq. +The pkg-config file (`moq.pc.in`) is rendered only when packaging (`nix build .#libmoq` +and the release tarballs), since its paths assume `lib/libmoq.a` beside `lib/pkgconfig/`. + +There's also a [CMakeLists.txt](CMakeLists.txt) file that can be used to import/build the library. + +## C API + +The library exposes the following C functions, see [api.rs](src/api.rs) for full details: + +```c +// Logging +int32_t moq_log_level(const char *level, uintptr_t level_len); + +// Session +int32_t moq_session_connect(const char *url, uintptr_t url_len, const moq_client_config *config, uint32_t origin_publish, uint32_t origin_consume, moq_state_callback on_state, void *user_data); +moq_client_config moq_client_defaults(void); +int32_t moq_session_close(uint32_t session); +int32_t moq_session_allocator(uint32_t session); +int32_t moq_allocator_reserve(uint32_t allocator, uint32_t track, uint64_t max_bps); +int32_t moq_allocator_close(uint32_t allocator); +int32_t moq_reservation_rate(uint32_t reservation, uint64_t *bps, bool *present); +int32_t moq_reservation_update(uint32_t reservation, uint64_t max_bps); +int32_t moq_reservation_close(uint32_t reservation); +int32_t moq_session_viewers(uint32_t session); +int32_t moq_viewers_watch(uint32_t viewers, uint64_t max_bps); +int32_t moq_viewers_set_target(uint32_t viewers, uint64_t target_bps, bool present); +int32_t moq_viewers_close(uint32_t viewers); +int32_t moq_viewer_rate(uint32_t viewer, uint64_t *bps, bool *present); +int32_t moq_viewer_update(uint32_t viewer, uint64_t max_bps); +int32_t moq_viewer_close(uint32_t viewer); + +// Session: Auth (a dialed session's tokens, and the grant the peer answers with) +int32_t moq_session_tokens_set(uint32_t session, const moq_string *tokens, uintptr_t tokens_len); +int32_t moq_session_tokens_answered(uint32_t session, moq_status_callback on_answer, void *user_data); +int32_t moq_session_grants(uint32_t session, moq_status_callback on_grant, void *user_data); +int32_t moq_session_grants_cancel(uint32_t watcher); +int32_t moq_grant_info(uint32_t grant, moq_grant *dst); +int32_t moq_grant_free(uint32_t grant); +int32_t moq_session_credential(uint32_t session, const uint8_t *token, uintptr_t token_len); +int32_t moq_credential_answered(uint32_t credential, moq_status_callback on_answer, void *user_data); +int32_t moq_credential_free(uint32_t credential); + +// Server +int32_t moq_server_listen(const moq_server_config *config, moq_status_callback on_request, void *user_data); +int32_t moq_server_addr(uint32_t server, moq_string *dst); +int32_t moq_server_fingerprints(uint32_t server, moq_string *dst, uintptr_t count); +int32_t moq_server_close(uint32_t server); +int32_t moq_session_request_path(uint32_t request, moq_string *dst); +int32_t moq_session_request_query(uint32_t request, moq_string *dst); +int32_t moq_session_request_accept(uint32_t request, uint32_t origin_publish, uint32_t origin_consume, moq_state_callback on_state, void *user_data); +int32_t moq_session_request_reject(uint32_t request, uint16_t code); +int32_t moq_session_request_free(uint32_t request); + +// Origin +int32_t moq_origin_create(void); +int32_t moq_origin_close(uint32_t origin); +int32_t moq_origin_request(uint32_t origin, const char *path, uintptr_t path_len, uint32_t instance, moq_status_callback on_broadcast, void *user_data); +int32_t moq_origin_request_cancel(uint32_t task); +int32_t moq_origin_follow(uint32_t origin, const char *path, uintptr_t path_len, uint32_t instance, moq_follow_callback on_follow, void *user_data); +int32_t moq_origin_follow_cancel(uint32_t task); +int32_t moq_origin_announced(uint32_t origin, const moq_announce_config *config, moq_status_callback on_announce, void *user_data); +int32_t moq_origin_announced_info(uint32_t announced, moq_announce_event *dst); +int32_t moq_origin_announced_free(uint32_t announced); +int32_t moq_origin_announced_cancel(uint32_t announced); +// config (NULL for everything): filter is relative to the literal prefix, or NULL for **. hidden also lists `.`-named paths. Updates stay relative to the origin. + +// Instances (0 means none: unpinned, or a fresh one in route options; a route's or claim's is the caller's to free, an announcement's lives with it) +int32_t moq_instance_parse(const char *text, uintptr_t text_len); +int32_t moq_instance_text(uint32_t instance, moq_string *dst); +int32_t moq_instance_minted(uint32_t instance); +int32_t moq_instance_equal(uint32_t a, uint32_t b); +int32_t moq_instance_free(uint32_t instance); + +// Publishing: Routes (freeing one retracts it; moq_publish_close on its broadcast ends both) +int32_t moq_origin_route(uint32_t origin, const char *path, uintptr_t path_len, const moq_route_options *options); +// options (NULL for the default): hidden until announced, a cost, and an optional stable instance with its epoch. Hops are the origin's to add. +int32_t moq_route_broadcast(uint32_t route); +int32_t moq_route_instance(uint32_t route); +int32_t moq_route_announce(uint32_t route); +int32_t moq_route_withdraw(uint32_t route); +int32_t moq_route_set_cost(uint32_t route, uint64_t cost); +int32_t moq_route_set_auth(uint32_t route, uint32_t credential); +int32_t moq_route_free(uint32_t route); + +// Publishing: Claims (a prefix answered on demand; freeing one retracts it) +int32_t moq_origin_claim(uint32_t origin, const char *prefix, uintptr_t prefix_len, const moq_route_options *options, moq_status_callback on_request, void *user_data); +int32_t moq_claim_instance(uint32_t claim); +int32_t moq_claim_announce(uint32_t claim); +int32_t moq_claim_withdraw(uint32_t claim); +int32_t moq_claim_set_cost(uint32_t claim, uint64_t cost); +int32_t moq_claim_set_auth(uint32_t claim, uint32_t credential); +int32_t moq_claim_free(uint32_t claim); +int32_t moq_broadcast_request_path(uint32_t request, moq_string *dst); +int32_t moq_broadcast_request_serve(uint32_t request, uint32_t broadcast); +int32_t moq_broadcast_request_route(uint32_t request, const moq_route_options *options); +int32_t moq_broadcast_request_reject(uint32_t request, uint16_t error_code); +int32_t moq_broadcast_request_free(uint32_t request); + +// Publishing +int32_t moq_publish_close(uint32_t broadcast); +int32_t moq_publish_audio(uint32_t broadcast, const moq_audio_init *config); +int32_t moq_publish_video(uint32_t broadcast, const moq_video_init *config); +int32_t moq_publish_container(uint32_t broadcast, const moq_container_init *config); +int32_t moq_publish_container_write(uint32_t container, const uint8_t *payload, uintptr_t payload_size); +int32_t moq_publish_container_finish(uint32_t container); +int32_t moq_publish_media_finish(uint32_t media); +int32_t moq_publish_media_frame(uint32_t media, const uint8_t *payload, uintptr_t payload_size, moq_timestamp timestamp); +int32_t moq_publish_track(uint32_t broadcast, const char *name, uintptr_t name_len, const moq_track_info *info); +int32_t moq_publish_track_group(uint32_t track, const moq_timestamp *start); +int32_t moq_publish_track_frame(uint32_t track, const uint8_t *payload, uintptr_t payload_size, const moq_timestamp *timestamp); +int32_t moq_publish_group_frame(uint32_t group, const uint8_t *payload, uintptr_t payload_size, const moq_timestamp *timestamp); +int32_t moq_publish_group_start(uint32_t group, uint64_t *dst); +int32_t moq_publish_group_finish(uint32_t group); +int32_t moq_publish_group_ready(uint32_t group, uint64_t size, moq_status_callback on_ready, void *user_data); +int32_t moq_publish_track_finish(uint32_t track); +int32_t moq_publish_track_largest(uint32_t track, uint64_t *group, uint64_t *frame, bool *present); +int32_t moq_publish_timebase(uint32_t broadcast); +int32_t moq_publish_timebase_free(uint32_t timebase); +// moq_container_init.timebase (0 for none) shares one source clock across containers. + +// Publishing: Demand +int32_t moq_publish_track_demand(uint32_t track, moq_status_callback on_demand, void *user_data); +int32_t moq_publish_media_demand(uint32_t media, moq_status_callback on_demand, void *user_data); +int32_t moq_encode_video_demand(uint32_t producer, moq_status_callback on_demand, void *user_data); +int32_t moq_encode_audio_demand(uint32_t producer, moq_status_callback on_demand, void *user_data); +int32_t moq_publish_demand_cancel(uint32_t watcher); +int32_t moq_publish_demand_wanted(uint32_t watcher, uint64_t *group, bool *present); + +// Publishing: Requests +int32_t moq_publish_requests(uint32_t broadcast, moq_status_callback on_request, void *user_data); +int32_t moq_publish_track_requests(uint32_t track, moq_status_callback on_group, void *user_data); +int32_t moq_track_request_requests(uint32_t request, moq_status_callback on_group, void *user_data); +int32_t moq_publish_requests_cancel(uint32_t dynamic); +int32_t moq_track_request_name(uint32_t request, moq_string *dst); +int32_t moq_track_request_accept(uint32_t request, const moq_track_info *info); +int32_t moq_track_request_video(uint32_t request, const moq_video_init *config); +int32_t moq_track_request_audio(uint32_t request, const moq_audio_init *config); +int32_t moq_track_request_abort(uint32_t request, uint16_t error_code); +int32_t moq_track_request_free(uint32_t request); +int32_t moq_group_request_start(uint32_t request, uint64_t *dst); +int32_t moq_group_request_priority(uint32_t request, int8_t *dst); +int32_t moq_group_request_frame_start(uint32_t request, uint64_t *dst); +int32_t moq_group_request_accept(uint32_t request); +int32_t moq_group_request_abort(uint32_t request, uint16_t error_code); +int32_t moq_group_request_free(uint32_t request); + +// Consuming +int32_t moq_consume_close(uint32_t consume); +int32_t moq_consume_closed(uint32_t broadcast, moq_status_callback on_closed, void *user_data); +int32_t moq_consume_closed_cancel(uint32_t watcher); + +// Consuming: Catalog +int32_t moq_consume_catalog(uint32_t broadcast, uint64_t delay_us, moq_status_callback on_catalog, void *user_data); +int32_t moq_consume_catalog_timestamp(uint32_t catalog, moq_timestamp *dst); +int32_t moq_consume_catalog_cancel(uint32_t catalog); +int32_t moq_consume_catalog_free(uint32_t catalog); +int32_t moq_consume_video_config(uint32_t catalog, uint32_t index, moq_video_config *dst); +int32_t moq_consume_video_enabled(uint32_t catalog, uint32_t index, bool *dst); +int32_t moq_consume_audio_config(uint32_t catalog, uint32_t index, moq_audio_config *dst); +int32_t moq_consume_audio_enabled(uint32_t catalog, uint32_t index, bool *dst); + +// Consuming: Video +int32_t moq_consume_video(uint32_t catalog, uint32_t index, const moq_delay *delay, moq_status_callback on_frame, void *user_data); +int32_t moq_consume_video_cancel(uint32_t track); + +// Consuming: Audio +int32_t moq_consume_audio(uint32_t catalog, uint32_t index, const moq_delay *delay, moq_status_callback on_frame, void *user_data); +int32_t moq_consume_audio_cancel(uint32_t track); + +// Consuming: Frames +int32_t moq_consume_read(uint32_t read, moq_media_read *dst); +int32_t moq_consume_read_free(uint32_t read); +moq_subscription moq_subscription_defaults(void); +int32_t moq_consume_track(uint32_t broadcast, const char *name, uintptr_t name_len, const moq_subscription *subscription, moq_status_callback on_frame, void *user_data); +int32_t moq_consume_track_frame(uint32_t frame, moq_frame *dst); +int32_t moq_consume_track_frame_free(uint32_t frame); +int32_t moq_consume_track_cancel(uint32_t track); + +// Codecs without a broadcast: encode, then publish or store the packets yourself +int32_t moq_audio_encoder_create(const moq_audio_encoder_output *output); +int32_t moq_audio_encoder_frame_size(uint32_t encoder); +int32_t moq_audio_encoder_init(uint32_t encoder, moq_audio_init *dst); +int32_t moq_audio_encoder_bitrate(uint32_t encoder, uint64_t bitrate); +int32_t moq_audio_encoder_encode(uint32_t encoder, const float *pcm, uintptr_t pcm_len); +int32_t moq_audio_encoder_receive(uint32_t encoder, moq_audio_packet *dst); +int32_t moq_audio_encoder_flush(uint32_t encoder); +int32_t moq_audio_encoder_finish(uint32_t encoder, const float *pcm, uintptr_t pcm_len, uint64_t *discard_padding); +int32_t moq_audio_encoder_packet(uint32_t encoder, uint32_t index, moq_audio_packet *dst); +int32_t moq_audio_encoder_free(uint32_t encoder); +int32_t moq_video_encoder_create(const moq_video_encoder_input *input, const moq_video_encoder_output *output); +int32_t moq_video_encoder_encode(uint32_t encoder, const moq_video_encoder_frame *frame); +int32_t moq_video_encoder_receive(uint32_t encoder, moq_frame *dst); +int32_t moq_video_encoder_cut(uint32_t encoder); +int32_t moq_video_encoder_bitrate(uint32_t encoder, uint64_t bitrate); +int32_t moq_video_encoder_flush(uint32_t encoder); +int32_t moq_video_encoder_free(uint32_t encoder); +``` + +Raw track frames use the same `moq_frame` record as media frames. Timestamps +are exact `moq_timestamp` records, `value` units at `scale` units per second. +A scale-less track has no time, so there `has_scale` is false and `value` is +the frame's group key (a datagram's sequence). Every write takes a non-NULL +timestamp: `moq_publish_track_frame` and `moq_publish_group_frame` convert +theirs to the track's timescale, a microsecond one unless +`moq_track_info.timescale` sets another with `timescale_present` true, and `moq_publish_group_start` reads +the key a scale-less group's frames carry. `moq_consume_track_frame` points +`moq_frame.timestamp` at the timestamp read, never NULL, valid until the frame +is freed. + +A zeroed `moq_track_info`, like a NULL one, advertises a zero max age, how long +a superseded group stays fresh, so only the live edge is served. Set +`max_age_us` for a longer age, or `max_age_unlimited` for no publisher limit, +which ignores `max_age_us`. Zero-initialize the struct +(`moq_track_info info = {0};`) before assigning members, so every flag starts +false. + +JSON window pushes and pops take a required `const moq_timestamp *timestamp`, +like snapshot updates and stream appends. It is when the edit occurred, +converted to the track's milliseconds; stamp it from `moq_publish_catalog_now`. +A NULL timestamp fails with `MOQ_ERROR_INVALID_POINTER`. + +```c +int32_t moq_publish_json_window_push(uint32_t window, const char *value, uintptr_t value_len, const moq_timestamp *timestamp); +int32_t moq_publish_json_window_pop(uint32_t window, uint64_t count, const moq_timestamp *timestamp); +``` + +### Pre-encoded simulcast + +Publish video renditions from lowest to highest, passing the next lower media +handle in `moq_video_init.lower` (0 for the lowest). This orders delivery so +higher renditions yield to lower ones. `moq_publish_media_set_enabled` updates +the catalog and marks a discontinuity when disabling; resume on a keyframe. +Audio importers do not support this toggle. + +Reserve each media track with `moq_allocator_reserve_media`. Create a +`moq_rate_control_create` handle bound to the reservation, with `moq_rate_policy.max_bps` and, for higher +rungs, `has_lower` and `lower_bps`. Read its initial `moq_rate_control_target`, +then call `moq_rate_control_update` on every frame, +including while disabled. It returns 0 or a negative error; `target.changed` +is true for a new target and false to hold the last one. Apply the target's `bitrate_bps` +to your encoder and `enabled` through `moq_publish_media_set_enabled`. +The shared controller drops immediately, ramps raises, ignores small changes, +and holds without an estimate. A rung disables only with a probing session, +which on native transports requires moq-quic with BBR3, so bandwidth can recover. +Close controls with `moq_rate_control_close` and reservations with +`moq_reservation_close`; neither owns or closes the media track. diff --git a/rs/moq-c/build.rs b/rs/libmoq/build.rs similarity index 97% rename from rs/moq-c/build.rs rename to rs/libmoq/build.rs index dead060ce94..f376d94ad03 100644 --- a/rs/moq-c/build.rs +++ b/rs/libmoq/build.rs @@ -27,7 +27,7 @@ fn main() { // The header lands in OUT_DIR: cargo forbids writing anywhere else, and a // build cache that replays this script (mbx) restores OUT_DIR and nothing // more. Consumers ask cargo for the path (`build-script-executed` in - // --message-format=json). moq-c.pc is not written here: its libdir has to name + // --message-format=json). moq.pc is not written here: its libdir has to name // the directory holding libmoq.a, which only exists once packaged (see // nix/overlay.nix), since cargo puts the staticlib outside OUT_DIR. let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); diff --git a/rs/moq-c/build.sh b/rs/libmoq/build.sh similarity index 79% rename from rs/moq-c/build.sh rename to rs/libmoq/build.sh index a3c8e4c7587..6ca80be7f5e 100755 --- a/rs/moq-c/build.sh +++ b/rs/libmoq/build.sh @@ -1,14 +1,14 @@ #!/usr/bin/env bash set -euo pipefail -# Build and package moq-c for release. +# Build and package libmoq for release. # Usage: ./build.sh [--target TARGET] [--version VERSION] [--output DIR] # # Examples: # ./build.sh # Build for host, detect version from Cargo.toml # ./build.sh --target aarch64-apple-darwin # Native build (run on matching runner) # -# On Linux and macOS this builds via `nix build .#moq-c` for reproducibility. +# On Linux and macOS this builds via `nix build .#libmoq` for reproducibility. # Windows targets fall back to a direct cargo build because Nix isn't # practical to install on the Windows GitHub runner image. @@ -55,7 +55,7 @@ if [[ -z "$TARGET" ]]; then echo "Detected target: $TARGET" fi -NAME="moq-c-${VERSION}-${TARGET}" +NAME="moq-${VERSION}-${TARGET}" PACKAGE_DIR="$OUTPUT_DIR/$NAME" echo "Packaging $NAME..." @@ -63,27 +63,26 @@ rm -rf "$PACKAGE_DIR" mkdir -p "$PACKAGE_DIR/include" "$PACKAGE_DIR/lib" if [[ "$TARGET" == *"-windows-"* ]]; then - echo "Building moq-c for $TARGET via cargo (Windows path)..." + echo "Building libmoq for $TARGET via cargo (Windows path)..." BUILD_LOG="$(mktemp)" trap 'rm -f "$BUILD_LOG"' EXIT # Releases carry the OpenH264 software fallback; nix/overlay.nix selects it # for the other platforms. - cargo build --locked --release --package moq-c --features openh264 --target "$TARGET" \ + cargo build --locked --release --package libmoq --features openh264 --target "$TARGET" \ --manifest-path "$WORKSPACE_DIR/Cargo.toml" --message-format=json-render-diagnostics >"$BUILD_LOG" TARGET_DIR="$WORKSPACE_DIR/target/$TARGET/release" LIB_FILE="moq.lib" cp "$TARGET_DIR/$LIB_FILE" "$PACKAGE_DIR/lib/" # build.rs writes the header into its OUT_DIR, which only cargo's JSON names. - GEN_DIR=$(jq -r 'select(.reason == "build-script-executed") | select(.package_id | test("/moq-c#")) | .out_dir' "$BUILD_LOG" | tail -1) + GEN_DIR=$(jq -r 'select(.reason == "build-script-executed") | select(.package_id | test("/libmoq#")) | .out_dir' "$BUILD_LOG" | tail -1) cp "$GEN_DIR/include/moq.h" "$PACKAGE_DIR/include/" # Generate CMake config files from templates (no pkg-config on Windows). - mkdir -p "$PACKAGE_DIR/lib/cmake/moq-c" - MAJOR_VERSION="${VERSION%%.*}" + mkdir -p "$PACKAGE_DIR/lib/cmake/moq" # The native libraries an external linker must pass alongside moq.lib, - # quoted the way rs/moq-c/CMakeLists.txt and nix/overlay.nix format them. + # quoted the way rs/libmoq/CMakeLists.txt and nix/overlay.nix format them. # Windows entries are all plain library names; `framework:` is Apple-only. NATIVE_LIBS_QUOTED=$(awk 'NF && $1 !~ /^#/ { printf "%s\"%s\"", sep, $1; sep = " " }' \ "$SCRIPT_DIR/native-libs/windows.txt") @@ -91,10 +90,9 @@ if [[ "$TARGET" == *"-windows-"* ]]; then sed -e "s|@LIB_FILE@|${LIB_FILE}|g" \ -e "s|@VERSION@|${VERSION}|g" \ -e "s|@MOQ_NATIVE_LIBS_QUOTED@|${NATIVE_LIBS_QUOTED}|g" \ - "$SCRIPT_DIR/cmake/moq-c-config.cmake.in" >"$PACKAGE_DIR/lib/cmake/moq-c/moq-c-config.cmake" + "$SCRIPT_DIR/cmake/moq-config.cmake.in" >"$PACKAGE_DIR/lib/cmake/moq/moq-config.cmake" sed -e "s|@VERSION@|${VERSION}|g" \ - -e "s|@MAJOR_VERSION@|${MAJOR_VERSION}|g" \ - "$SCRIPT_DIR/cmake/moq-c-config-version.cmake.in" >"$PACKAGE_DIR/lib/cmake/moq-c/moq-c-config-version.cmake" + "$SCRIPT_DIR/cmake/moq-config-version.cmake.in" >"$PACKAGE_DIR/lib/cmake/moq/moq-config-version.cmake" else # Release builds must match the host. A mismatch would silently mislabel # the archive, so reject it before building. @@ -104,11 +102,11 @@ else exit 1 fi - echo "Building moq-c for $TARGET via nix..." + echo "Building libmoq for $TARGET via nix..." BUILD_TMP="$(mktemp -d)" trap 'rm -rf "$BUILD_TMP"' EXIT RESULT_LINK="$BUILD_TMP/result" - nix build "$WORKSPACE_DIR#moq-c" --out-link "$RESULT_LINK" + nix build "$WORKSPACE_DIR#libmoq" --out-link "$RESULT_LINK" # The derivation lays out everything under $out/{lib,include}; copy it # verbatim so the release tarball matches what nix produced. @@ -118,11 +116,11 @@ else fi # A placeholder added to cmake/*.cmake.in but not to every substituter (the seds -# above, nix/overlay.nix) ships a config whose find_package(moq-c) hands the linker +# above, nix/overlay.nix) ships a config whose find_package(moq) hands the linker # a literal `@FOO@`, and the only thing that notices is a downstream build. Both # paths land the config here, so check them both. -for cmake_file in moq-c-config.cmake moq-c-config-version.cmake; do - CMAKE_CONFIG="$PACKAGE_DIR/lib/cmake/moq-c/$cmake_file" +for cmake_file in moq-config.cmake moq-config-version.cmake; do + CMAKE_CONFIG="$PACKAGE_DIR/lib/cmake/moq/$cmake_file" if [[ ! -f "$CMAKE_CONFIG" ]]; then echo "Error: $CMAKE_CONFIG missing from the package" >&2 exit 1 diff --git a/rs/moq-c/c-tests/abort-unwanted.c b/rs/libmoq/c-tests/abort-unwanted.c similarity index 99% rename from rs/moq-c/c-tests/abort-unwanted.c rename to rs/libmoq/c-tests/abort-unwanted.c index 17fe23eb30b..5f470650dc0 100644 --- a/rs/moq-c/c-tests/abort-unwanted.c +++ b/rs/libmoq/c-tests/abort-unwanted.c @@ -208,7 +208,7 @@ static int32_t join(uint32_t consume, const char *name, Queue *frames) { // The name of the first video rendition on `consume`'s catalog, once it has one. static void video_name(uint32_t consume, char *name, size_t size) { Queue *catalogs = queue_new(); - int32_t task = moq_consume_catalog(consume, on_code, catalogs); + int32_t task = moq_consume_catalog(consume, 0, on_code, catalogs); CHECK(task > 0); int32_t catalog = next(catalogs); CHECK(catalog > 0); diff --git a/rs/moq-c/c-tests/audio-decode-output.c b/rs/libmoq/c-tests/audio-decode-output.c similarity index 100% rename from rs/moq-c/c-tests/audio-decode-output.c rename to rs/libmoq/c-tests/audio-decode-output.c diff --git a/rs/moq-c/c-tests/decode-output.c b/rs/libmoq/c-tests/decode-output.c similarity index 99% rename from rs/moq-c/c-tests/decode-output.c rename to rs/libmoq/c-tests/decode-output.c index 19ce6607c30..01f3e1e2533 100644 --- a/rs/moq-c/c-tests/decode-output.c +++ b/rs/libmoq/c-tests/decode-output.c @@ -4,7 +4,7 @@ // // Compiled and run by `just rs c-tests` against this build's generated `moq.h` // and `libmoq.a`, linked from outside cargo the way an embedder does, so this -// file must only use the stable C ABI: +// file must only use the public C ABI: // // 1. Layout: compile-time asserts pin the struct fields and the pixel-format // discriminants the test below depends on. @@ -49,7 +49,7 @@ _Static_assert(MOQ_DECODE_READ_END == 2, "end read discriminant moved"); _Static_assert(MOQ_DECODE_START_OLDEST == 0, "oldest start discriminant moved"); _Static_assert(MOQ_DECODE_START_LATEST == 1, "latest start discriminant moved"); -// Numeric codes from rs/moq-c/src/error.rs. They are the contract a C caller +// Numeric codes from rs/libmoq/src/error.rs. They are the contract a C caller // matches on; if they drift, this fixture fails and the header is stale. #define MOQ_ERR_INVALID_POINTER -6 #define MOQ_ERR_INVALID_CODE -15 diff --git a/rs/moq-c/c-tests/doc-samples.h b/rs/libmoq/c-tests/doc-samples.h similarity index 100% rename from rs/moq-c/c-tests/doc-samples.h rename to rs/libmoq/c-tests/doc-samples.h diff --git a/rs/moq-c/c-tests/rate-control.c b/rs/libmoq/c-tests/rate-control.c similarity index 100% rename from rs/moq-c/c-tests/rate-control.c rename to rs/libmoq/c-tests/rate-control.c diff --git a/rs/moq-c/c-tests/timestamps.c b/rs/libmoq/c-tests/timestamps.c similarity index 99% rename from rs/moq-c/c-tests/timestamps.c rename to rs/libmoq/c-tests/timestamps.c index 4f5c2ea1cf9..b1703505f09 100644 --- a/rs/moq-c/c-tests/timestamps.c +++ b/rs/libmoq/c-tests/timestamps.c @@ -132,7 +132,7 @@ int main(void) { // Creating the datagram consumer joins its live cursor before this write. CHECK(moq_publish_datagrams_append((uint32_t)datagram_track, payload, sizeof(payload), &tick, NULL) == 0); WAIT_FOR(&c, c.datagram); - // JSON tracks moq-c creates count milliseconds. + // JSON tracks libmoq creates count milliseconds. const moq_timestamp stamped = {1500, 1000, true}; CHECK(moq_publish_json_stream_append((uint32_t)json, doc, strlen(doc), &stamped) == 0); WAIT_FOR(&c, c.value); diff --git a/rs/moq-c/cbindgen.toml b/rs/libmoq/cbindgen.toml similarity index 96% rename from rs/moq-c/cbindgen.toml rename to rs/libmoq/cbindgen.toml index 63baf9e2722..594533807c9 100644 --- a/rs/moq-c/cbindgen.toml +++ b/rs/libmoq/cbindgen.toml @@ -1,4 +1,4 @@ -# cbindgen configuration for moq-c. +# cbindgen configuration for libmoq. # # NOT loaded: build.rs drives cbindgen through `Builder::new()`, which never # discovers this file, and passes its own config. Of the settings below, only diff --git a/rs/moq-c/cmake/cargo-build.cmake b/rs/libmoq/cmake/cargo-build.cmake similarity index 71% rename from rs/moq-c/cmake/cargo-build.cmake rename to rs/libmoq/cmake/cargo-build.cmake index 0ea4cc6c1d6..0438af82ce0 100644 --- a/rs/moq-c/cmake/cargo-build.cmake +++ b/rs/libmoq/cmake/cargo-build.cmake @@ -1,6 +1,6 @@ -# Run with `cmake -DCARGO_BUILD_FLAG=... -DHEADER=... -P cargo-build.cmake` from rs/moq-c. +# Run with `cmake -DCARGO_BUILD_FLAG=... -DHEADER=... -P cargo-build.cmake` from rs/libmoq. # -# Builds moq-c with the OpenH264 software fallback the release archives carry, then copies moq.h to HEADER. build.rs writes the header into +# Builds libmoq with the OpenH264 software fallback the release archives carry, then copies moq.h to HEADER. build.rs writes the header into # its OUT_DIR, whose hashed path only cargo's JSON messages name. execute_process( COMMAND cargo build --locked --features openh264 ${CARGO_BUILD_FLAG} --message-format=json-render-diagnostics @@ -8,9 +8,9 @@ execute_process( COMMAND_ERROR_IS_FATAL ANY ) -string(REGEX MATCH "{\"reason\":\"build-script-executed\",\"package_id\":\"[^\"]*/moq-c#[^\n]*" _message "${_messages}") +string(REGEX MATCH "{\"reason\":\"build-script-executed\",\"package_id\":\"[^\"]*/libmoq#[^\n]*" _message "${_messages}") if(NOT _message) - message(FATAL_ERROR "cargo reported no build script output for moq-c") + message(FATAL_ERROR "cargo reported no build script output for libmoq") endif() string(JSON _out_dir GET "${_message}" out_dir) diff --git a/rs/libmoq/cmake/moq-config-version.cmake.in b/rs/libmoq/cmake/moq-config-version.cmake.in new file mode 100644 index 00000000000..c8cd6d0357e --- /dev/null +++ b/rs/libmoq/cmake/moq-config-version.cmake.in @@ -0,0 +1,33 @@ +# moq CMake version file + +set(PACKAGE_VERSION "@VERSION@") + +# libmoq is 0.x: a minor release may break the API (see MIGRATE.md), so only +# the same major.minor line is compatible, and only if it is at least as new as +# the request. This matches the SameMinorVersion policy that +# write_basic_package_version_file() applies to the source-built package. +if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) + set(PACKAGE_VERSION_COMPATIBLE FALSE) +else() + set(PACKAGE_VERSION_COMPATIBLE FALSE) + if(PACKAGE_VERSION MATCHES "^([0-9]+)\\.([0-9]+)") + if(PACKAGE_FIND_VERSION_MAJOR STREQUAL "${CMAKE_MATCH_1}" + AND PACKAGE_FIND_VERSION_MINOR STREQUAL "${CMAKE_MATCH_2}") + set(PACKAGE_VERSION_COMPATIBLE TRUE) + endif() + endif() + # find_package(moq 0.22...<0.23): PACKAGE_FIND_VERSION is the lower bound, + # so the upper one is checked here. + if(PACKAGE_VERSION_COMPATIBLE AND PACKAGE_FIND_VERSION_RANGE) + if(PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE") + if(PACKAGE_VERSION VERSION_GREATER PACKAGE_FIND_VERSION_MAX) + set(PACKAGE_VERSION_COMPATIBLE FALSE) + endif() + elseif(PACKAGE_VERSION VERSION_GREATER_EQUAL PACKAGE_FIND_VERSION_MAX) + set(PACKAGE_VERSION_COMPATIBLE FALSE) + endif() + endif() + if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) + set(PACKAGE_VERSION_EXACT TRUE) + endif() +endif() diff --git a/rs/moq-c/cmake/moq-c-config.cmake.in b/rs/libmoq/cmake/moq-config.cmake.in similarity index 70% rename from rs/moq-c/cmake/moq-c-config.cmake.in rename to rs/libmoq/cmake/moq-config.cmake.in index a1d740c2576..f4d0458f73b 100644 --- a/rs/moq-c/cmake/moq-c-config.cmake.in +++ b/rs/libmoq/cmake/moq-config.cmake.in @@ -1,5 +1,4 @@ -# find_package(moq-c): the C bindings as the moq::c target. The moq:: namespace is -# shared with moq-cpp (moq::cpp), so the two packages install side by side. +# find_package(moq): the libmoq C API as the moq::moq target. # Compute installation prefix relative to this file get_filename_component(_moq_prefix "${CMAKE_CURRENT_LIST_FILE}" PATH) @@ -15,19 +14,19 @@ set(_moq_libdir "${_moq_prefix}/lib") set(_moq_lib_name "@LIB_FILE@") # Create imported target -if(NOT TARGET moq::c) - add_library(moq::c STATIC IMPORTED) +if(NOT TARGET moq::moq) + add_library(moq::moq STATIC IMPORTED) - set_target_properties(moq::c PROPERTIES + set_target_properties(moq::moq PROPERTIES IMPORTED_LOCATION "${_moq_libdir}/${_moq_lib_name}" INTERFACE_INCLUDE_DIRECTORIES "${_moq_includedir}" ) # System libraries Rust std/deps pull in. An external linker consuming the # staticlib needs these spelled out; cargo can't inject them. Baked in at - # install time from rs/moq-c/native-libs/ for the platform this was built + # install time from rs/libmoq/native-libs/ for the platform this was built # for, which is the only platform the installed static library works on. - set_property(TARGET moq::c APPEND PROPERTY + set_property(TARGET moq::moq APPEND PROPERTY INTERFACE_LINK_LIBRARIES @MOQ_NATIVE_LIBS_QUOTED@ ) endif() @@ -39,5 +38,5 @@ unset(_moq_libdir) unset(_moq_lib_name) # Package metadata -set(moq-c_FOUND TRUE) -set(moq-c_VERSION "@VERSION@") +set(moq_FOUND TRUE) +set(moq_VERSION "@VERSION@") diff --git a/rs/moq-c/moq-c.pc.in b/rs/libmoq/moq.pc.in similarity index 95% rename from rs/moq-c/moq-c.pc.in rename to rs/libmoq/moq.pc.in index 007efff4259..bfa80e8c0b7 100644 --- a/rs/moq-c/moq-c.pc.in +++ b/rs/libmoq/moq.pc.in @@ -1,11 +1,11 @@ # Paths are relative to this .pc file, in the install layout the release -# tarballs and nix/overlay.nix ship: lib/{libmoq.a,pkgconfig/moq-c.pc} and +# tarballs and nix/overlay.nix ship: lib/{libmoq.a,pkgconfig/moq.pc} and # include/moq.h under one prefix. nix/overlay.nix renders it there, and checks # both paths resolve. libdir=${pcfiledir}/.. includedir=${pcfiledir}/../../include -Name: moq-c +Name: moq Description: Media over QUIC C Interface Version: @VERSION@ Libs: -L${libdir} -lmoq diff --git a/rs/moq-c/native-libs/apple.txt b/rs/libmoq/native-libs/apple.txt similarity index 81% rename from rs/moq-c/native-libs/apple.txt rename to rs/libmoq/native-libs/apple.txt index 2863b56e8bc..317fa94c2c0 100644 --- a/rs/moq-c/native-libs/apple.txt +++ b/rs/libmoq/native-libs/apple.txt @@ -2,8 +2,8 @@ # targets. Cargo injects these itself for Rust consumers, but a C/C++ toolchain # linking the staticlib has to spell them out. # -# Canonical list. nix/overlay.nix bakes it into moq-c.pc, CMakeLists.txt reads it for the -# moq::c target and the installed find_package config, test/interop/interop.sh +# Canonical list. nix/overlay.nix bakes it into moq.pc, CMakeLists.txt reads it for the +# moq::moq target and the installed find_package config, test/interop/interop.sh # links its C client with it, and cpp/moq/CMakeLists.txt reuses it for moq-ffi, # which has the same dependency tree. Keep the derived consumers reading this file rather # than repeating the list. @@ -12,7 +12,7 @@ # plain library name. `#` comments and blank lines are ignored. # # Regenerate after a dependency change with: -# cargo rustc -p moq-c --crate-type staticlib -- --print native-static-libs +# cargo rustc -p libmoq --crate-type staticlib -- --print native-static-libs # rustls / std framework:CoreFoundation diff --git a/rs/moq-c/native-libs/linux.txt b/rs/libmoq/native-libs/linux.txt similarity index 100% rename from rs/moq-c/native-libs/linux.txt rename to rs/libmoq/native-libs/linux.txt diff --git a/rs/moq-c/native-libs/windows.txt b/rs/libmoq/native-libs/windows.txt similarity index 100% rename from rs/moq-c/native-libs/windows.txt rename to rs/libmoq/native-libs/windows.txt diff --git a/rs/moq-c/src/api.rs b/rs/libmoq/src/api.rs similarity index 99% rename from rs/moq-c/src/api.rs rename to rs/libmoq/src/api.rs index 71b84a39c28..407baf96288 100644 --- a/rs/moq-c/src/api.rs +++ b/rs/libmoq/src/api.rs @@ -993,8 +993,8 @@ pub(crate) unsafe fn parse_subscription( /// A borrowed UTF-8 string slice, NOT NULL terminated. /// -/// Used in both directions. As an output (e.g. a JSON document moq-c hands back) the -/// pointer borrows moq-c's own storage and is only valid until the owning resource is +/// Used in both directions. As an output (e.g. a JSON document libmoq hands back) the +/// pointer borrows libmoq's own storage and is only valid until the owning resource is /// freed; see the function that fills it for the exact lifetime. As an input (e.g. a /// [moq_client_config] list) the pointer borrows the caller's storage and is only read /// during the call. @@ -1385,12 +1385,12 @@ pub unsafe extern "C" fn moq_log_level(level: *const c_char, level_len: usize) - /// Human-readable reason for the most recent failed call on the calling thread. /// -/// moq-c functions return only a negative code; this exposes the matching message +/// libmoq functions return only a negative code; this exposes the matching message /// (including detail the code can't carry, e.g. which URL failed to parse or why a /// decode failed). The string is only meaningful after a call returned a negative /// code; check the code first. /// -/// Returns a NUL-terminated, UTF-8 pointer valid until the next moq-c call **on the +/// Returns a NUL-terminated, UTF-8 pointer valid until the next libmoq call **on the /// same thread**, or NULL if no error has been recorded on this thread. Copy it if you /// need it to outlive the next call. Errors delivered through status callbacks carry /// their code directly; read this from inside the callback to get their reason. @@ -1407,7 +1407,7 @@ pub extern "C" fn moq_error() -> *const c_char { /// (transport, not-found, a bad handle, ...). Do not parse [moq_error] for this. /// /// The values are only meaningful after a call returned a negative code; check the -/// code first. Same lifetime as [moq_error]: overwritten by the next moq-c call on +/// code first. Same lifetime as [moq_error]: overwritten by the next libmoq call on /// this thread. Errors delivered through status callbacks are recorded before the /// callback runs, so read this from inside the callback. /// @@ -1634,7 +1634,7 @@ pub struct moq_client_config { pub quic_keylog: bool, /// Your own `name/version` product tokens, space-separated, advertised in SETUP - /// ahead of this library's (`my-app/1.0 moq-c/0.7.0 moq-net-rs/0.3.10`), or NULL for none. + /// ahead of this library's (`my-app/1.0 libmoq/0.7.0 moq-net-rs/0.3.10`), or NULL for none. pub implementation: *const c_char, /// The length in bytes of `implementation`. pub implementation_len: usize, @@ -2142,7 +2142,7 @@ pub unsafe extern "C" fn moq_session_request_query(request: u32, dst: *mut moq_s } /// The implementation the client advertised in its SETUP, such as -/// `moq-c/0.7.0 moq-net-rs/0.3.10`, or a NULL `data` if it advertised none. +/// `libmoq/0.7.0 moq-net-rs/0.3.10`, or a NULL `data` if it advertised none. /// /// Peer-controlled: use it for logs and rollout counts, never to authorize. The /// destination borrows the request's storage, like [moq_session_request_path]. diff --git a/rs/moq-c/src/audio.rs b/rs/libmoq/src/audio.rs similarity index 100% rename from rs/moq-c/src/audio.rs rename to rs/libmoq/src/audio.rs diff --git a/rs/moq-c/src/auth.rs b/rs/libmoq/src/auth.rs similarity index 100% rename from rs/moq-c/src/auth.rs rename to rs/libmoq/src/auth.rs diff --git a/rs/moq-c/src/bandwidth.rs b/rs/libmoq/src/bandwidth.rs similarity index 100% rename from rs/moq-c/src/bandwidth.rs rename to rs/libmoq/src/bandwidth.rs diff --git a/rs/moq-c/src/client.rs b/rs/libmoq/src/client.rs similarity index 98% rename from rs/moq-c/src/client.rs rename to rs/libmoq/src/client.rs index 9179a0206b3..6caf82dd33b 100644 --- a/rs/moq-c/src/client.rs +++ b/rs/libmoq/src/client.rs @@ -57,9 +57,9 @@ impl Quic<'_> { } /// What sessions opened through this library advertise in SETUP: the caller's `prefix`, -/// then moq-c, then its core. +/// then libmoq, then its core. pub fn implementation(prefix: Option<&str>) -> Result { - let core = format!("moq-c/{} {}", env!("CARGO_PKG_VERSION"), moq_net::IMPLEMENTATION); + let core = format!("libmoq/{} {}", env!("CARGO_PKG_VERSION"), moq_net::IMPLEMENTATION); let Some(prefix) = prefix else { return Ok(core); }; diff --git a/rs/moq-c/src/consume.rs b/rs/libmoq/src/consume.rs similarity index 100% rename from rs/moq-c/src/consume.rs rename to rs/libmoq/src/consume.rs diff --git a/rs/moq-c/src/datagram.rs b/rs/libmoq/src/datagram.rs similarity index 100% rename from rs/moq-c/src/datagram.rs rename to rs/libmoq/src/datagram.rs diff --git a/rs/moq-c/src/decode.rs b/rs/libmoq/src/decode.rs similarity index 100% rename from rs/moq-c/src/decode.rs rename to rs/libmoq/src/decode.rs diff --git a/rs/moq-c/src/encoder.rs b/rs/libmoq/src/encoder.rs similarity index 100% rename from rs/moq-c/src/encoder.rs rename to rs/libmoq/src/encoder.rs diff --git a/rs/moq-c/src/error.rs b/rs/libmoq/src/error.rs similarity index 100% rename from rs/moq-c/src/error.rs rename to rs/libmoq/src/error.rs diff --git a/rs/moq-c/src/ffi.rs b/rs/libmoq/src/ffi.rs similarity index 95% rename from rs/moq-c/src/ffi.rs rename to rs/libmoq/src/ffi.rs index a6f3a256e0c..29e1f9f2fe3 100644 --- a/rs/moq-c/src/ffi.rs +++ b/rs/libmoq/src/ffi.rs @@ -10,13 +10,13 @@ use crate::{Error, Id, moq_protocol_error}; /// A callback receiving a positive handle/value, zero on clean completion, or a negative error. /// -/// Runs on moq-c's runtime thread. The callback and `user_data` must be safe to use on that thread. +/// Runs on libmoq's runtime thread. The callback and `user_data` must be safe to use on that thread. #[expect(non_camel_case_types, reason = "C ABI type names match moq.h")] pub type moq_status_callback = Option; /// A callback receiving each session lifecycle change; the `MOQ_CONNECTION_PHASE_CLOSED` one is terminal. /// -/// Runs on moq-c's runtime thread. The callback and `user_data` must be safe to use on that thread. +/// Runs on libmoq's runtime thread. The callback and `user_data` must be safe to use on that thread. #[expect(non_camel_case_types, reason = "C ABI type names match moq.h")] pub type moq_state_callback = Option; @@ -26,7 +26,7 @@ pub type moq_state_callback = Option; @@ -38,7 +38,7 @@ pub static RUNTIME: LazyLock = LazyLock::new(|| { let handle = runtime.handle().clone(); std::thread::Builder::new() - .name("moq-c".into()) + .name("libmoq".into()) .spawn(move || { runtime.block_on(std::future::pending::<()>()); }) @@ -250,7 +250,7 @@ impl OnStatus { /// # Safety /// - The caller must ensure user_data remains valid for the callback's lifetime. /// - The callback function pointer must be valid if provided. - /// - The callback and `user_data` must be safe to use on moq-c's runtime thread. + /// - The callback and `user_data` must be safe to use on libmoq's runtime thread. pub unsafe fn new(user_data: *mut c_void, on_status: moq_status_callback) -> Result { Ok(Self { user_data, @@ -270,7 +270,7 @@ impl OnStatus { } // SAFETY: The constructor requires the callback and user_data to remain valid and -// safe to use on moq-c's runtime thread for the callback's lifetime. +// safe to use on libmoq's runtime thread for the callback's lifetime. unsafe impl Send for OnStatus {} /// A [moq_state_callback] and its user data. @@ -285,7 +285,7 @@ impl OnState { /// /// # Safety /// - The caller must keep `user_data` valid until the terminal callback. - /// - The callback and `user_data` must be safe to use on moq-c's runtime thread. + /// - The callback and `user_data` must be safe to use on libmoq's runtime thread. pub unsafe fn new(user_data: *mut c_void, on_state: moq_state_callback) -> Result { Ok(Self { user_data, @@ -304,7 +304,7 @@ impl OnState { } // SAFETY: The constructor requires the callback and user_data to remain valid and -// safe to use on moq-c's runtime thread until the terminal callback. +// safe to use on libmoq's runtime thread until the terminal callback. unsafe impl Send for OnState {} /// A [moq_follow_callback] and its user data. @@ -319,7 +319,7 @@ impl OnFollow { /// /// # Safety /// - The caller must keep `user_data` valid until the `MOQ_FOLLOW_EVENT_END` callback. - /// - The callback and `user_data` must be safe to use on moq-c's runtime thread. + /// - The callback and `user_data` must be safe to use on libmoq's runtime thread. pub unsafe fn new(user_data: *mut c_void, on_follow: moq_follow_callback) -> Result { Ok(Self { user_data, @@ -356,7 +356,7 @@ impl crate::task::Terminal for OnFollow { } // SAFETY: The constructor requires the callback and user_data to remain valid and -// safe to use on moq-c's runtime thread until the terminal callback. +// safe to use on libmoq's runtime thread until the terminal callback. unsafe impl Send for OnFollow {} /// Types that can be converted to C-compatible return codes. @@ -486,7 +486,7 @@ fn record(err: &Error) { /// Pointer to this thread's last error message, or null if none was recorded. /// -/// The pointer is valid until the next moq-c call on the same thread. +/// The pointer is valid until the next libmoq call on the same thread. pub fn last_error_ptr() -> *const c_char { LAST_ERROR.with(|cell| { cell.borrow() diff --git a/rs/moq-c/src/id.rs b/rs/libmoq/src/id.rs similarity index 100% rename from rs/moq-c/src/id.rs rename to rs/libmoq/src/id.rs diff --git a/rs/libmoq/src/lib.rs b/rs/libmoq/src/lib.rs index 7913c79d6bc..ec3126526d3 100644 --- a/rs/libmoq/src/lib.rs +++ b/rs/libmoq/src/lib.rs @@ -1 +1,62 @@ -#![doc = include_str!("../README.md")] +#![warn(missing_docs)] + +//! C bindings for [`moq_net`]. +//! +//! Provides a C-compatible API for real-time pub/sub over QUIC. +//! +//! ## Concepts +//! +//! - **Session**: Network connection to a MoQ relay, or one accepted by a server +//! - **Origin**: Collection of broadcasts +//! - **Broadcast**: Container for tracks +//! - **Track**: Named stream of groups +//! - **Group**: Collection of frames +//! - **Frame**: Sized payload with timestamp +//! +//! ## Error Handling +//! +//! All functions return negative error codes on failure or non-negative values on success. +//! Resources are managed through opaque integer handles that must be explicitly closed. + +mod api; +mod audio; +mod auth; +mod bandwidth; +mod client; +mod consume; +mod datagram; +mod decode; +mod encoder; +mod error; +mod ffi; +mod id; +mod origin; +mod publish; +mod server; +mod session; +mod state; +mod task; +mod video; + +pub use api::*; +pub use audio::*; +pub use auth::*; +pub use bandwidth::*; +pub use datagram::*; +pub use decode::{moq_decode_gap, moq_decode_read_kind, moq_decode_start}; +pub use encoder::*; +pub use error::*; +pub use ffi::{moq_follow_callback, moq_state_callback, moq_status_callback}; +pub use id::*; +pub use video::*; + +pub(crate) use client::*; +pub(crate) use consume::*; +pub(crate) use origin::*; +pub(crate) use publish::*; +pub(crate) use server::*; +pub(crate) use session::*; +pub(crate) use state::*; + +#[cfg(test)] +mod test; diff --git a/rs/moq-c/src/origin.rs b/rs/libmoq/src/origin.rs similarity index 99% rename from rs/moq-c/src/origin.rs rename to rs/libmoq/src/origin.rs index c134fc5e91b..aeefa05c8b0 100644 --- a/rs/moq-c/src/origin.rs +++ b/rs/libmoq/src/origin.rs @@ -179,7 +179,7 @@ struct ClaimEntry { impl Origin { pub fn create(&mut self) -> Result { // Every FFI entry point runs inside `RUNTIME.enter()`, so the driver - // lands on the dedicated moq-c runtime. + // lands on the dedicated libmoq runtime. let (producer, driver) = moq_net::origin::Producer::new(Default::default()); self.active.insert(Producer { producer, diff --git a/rs/moq-c/src/publish.rs b/rs/libmoq/src/publish.rs similarity index 99% rename from rs/moq-c/src/publish.rs rename to rs/libmoq/src/publish.rs index a93385f908d..d4bf6e8ab95 100644 --- a/rs/moq-c/src/publish.rs +++ b/rs/libmoq/src/publish.rs @@ -374,7 +374,7 @@ impl Publish { } /// Store an origin-created broadcast producer, attaching the catalog track - /// every moq-c broadcast carries. + /// every libmoq broadcast carries. pub fn create( &mut self, (mut broadcast, driver): (moq_net::broadcast::Producer, crate::ffi::Background), diff --git a/rs/moq-c/src/server.rs b/rs/libmoq/src/server.rs similarity index 100% rename from rs/moq-c/src/server.rs rename to rs/libmoq/src/server.rs diff --git a/rs/moq-c/src/session.rs b/rs/libmoq/src/session.rs similarity index 99% rename from rs/moq-c/src/session.rs rename to rs/libmoq/src/session.rs index 37b3358e52f..67707c2c5d7 100644 --- a/rs/moq-c/src/session.rs +++ b/rs/libmoq/src/session.rs @@ -21,7 +21,7 @@ pub(crate) struct Lifecycle { phase: Stage, } -/// A [`Lifecycle`]'s phase and its data, mirroring [`Phase`] with moq-c's errors. +/// A [`Lifecycle`]'s phase and its data, mirroring [`Phase`] with libmoq's errors. enum Stage { Connecting { failure: Option, @@ -438,7 +438,7 @@ impl Session { /// Deliver each lifecycle change until the connection stops, then return its result. /// /// Changes coalesce: a snapshot is the state when the callback runs, not every step - /// between. No lock is held, so the C callback is free to re-enter moq-c. + /// between. No lock is held, so the C callback is free to re-enter libmoq. async fn report( callback: ffi::OnState, connection: &moq_tokio::Connection, diff --git a/rs/moq-c/src/state.rs b/rs/libmoq/src/state.rs similarity index 100% rename from rs/moq-c/src/state.rs rename to rs/libmoq/src/state.rs diff --git a/rs/moq-c/src/task.rs b/rs/libmoq/src/task.rs similarity index 100% rename from rs/moq-c/src/task.rs rename to rs/libmoq/src/task.rs diff --git a/rs/moq-c/src/test.rs b/rs/libmoq/src/test.rs similarity index 99% rename from rs/moq-c/src/test.rs rename to rs/libmoq/src/test.rs index 11c47d145f3..efc93bc8954 100644 --- a/rs/moq-c/src/test.rs +++ b/rs/libmoq/src/test.rs @@ -3626,7 +3626,7 @@ fn a_holding_reader_reads_every_update_within_its_delay() { (999, vec![2_000, 3_000]), (1_001, vec![1_000, 2_000, 3_000]), ] { - // A raw broadcast, since a moq-c one stamps its own catalog from its clock. + // A raw broadcast, since a libmoq one stamps its own catalog from its clock. let broadcast = moq_net::broadcast::Info::new().produce(); let track = broadcast .create_track( @@ -6926,7 +6926,7 @@ fn publish_gray(producer: u32, rgba: &[u8]) -> i32 { } /// Regression: an encode is a round trip to the codec thread, and a wedged codec -/// never comes back from it. It used to run under both of moq-c's process-wide +/// never comes back from it. It used to run under both of libmoq's process-wide /// locks, the `State` mutex and one wrapping the runtime handle, so a single /// stalled producer parked every unrelated call in the process behind it: another /// broadcast's publish, a consumer's frame free, a session close. @@ -7604,7 +7604,7 @@ fn a_null_config_dials_with_the_defaults() { /// The caller's product tokens go ahead of the library's, and a malformed list fails the dial. #[test] fn implementation_prefixes_the_library() { - let core = format!("moq-c/{} {}", env!("CARGO_PKG_VERSION"), moq_net::IMPLEMENTATION); + let core = format!("libmoq/{} {}", env!("CARGO_PKG_VERSION"), moq_net::IMPLEMENTATION); assert_eq!(parsed(&client_config()).connect.implementation, Some(core.clone())); let mut config = client_config(); @@ -9433,7 +9433,7 @@ enum TokenSeen { /// Listen over TCP for one moq-transport `version` session as a base moq-transport peer, /// declining the Solicit extension so only requests carry tokens, and consuming -/// the peer's broadcasts into the moq-c origin `sink`. Returns the address and what happens +/// the peer's broadcasts into the libmoq origin `sink`. Returns the address and what happens /// to each non-empty token the session presents. fn base_moqt_server(version: &str, sink: u32) -> (String, mpsc::Receiver) { let version: moq_net::Version = version.parse().unwrap(); diff --git a/rs/moq-c/src/test/parity.rs b/rs/libmoq/src/test/parity.rs similarity index 99% rename from rs/moq-c/src/test/parity.rs rename to rs/libmoq/src/test/parity.rs index 9b6ec1247e5..dfe8bd86682 100644 --- a/rs/moq-c/src/test/parity.rs +++ b/rs/libmoq/src/test/parity.rs @@ -1,4 +1,4 @@ -//! The binding features moq-c gained to match moq-ffi for the cut. +//! The binding features libmoq gained to match moq-ffi for the cut. use std::sync::Arc; diff --git a/rs/moq-c/src/video.rs b/rs/libmoq/src/video.rs similarity index 100% rename from rs/moq-c/src/video.rs rename to rs/libmoq/src/video.rs diff --git a/rs/moq-c/Cargo.toml b/rs/moq-c/Cargo.toml deleted file mode 100644 index 7ac2ca1e371..00000000000 --- a/rs/moq-c/Cargo.toml +++ /dev/null @@ -1,65 +0,0 @@ -[package] -name = "moq-c" -description = "Media over QUIC, C bindings" -authors = ["Luke Curley ", "Brian Medley "] -repository = "https://github.com/moq-dev/moq" -license = "MIT OR Apache-2.0" - -version = "0.7.0" -edition = "2024" -rust-version.workspace = true - -keywords = ["quic", "http3", "webtransport", "media", "live"] -categories = ["multimedia", "network-programming", "web-programming"] - -[lib] -name = "moq" -crate-type = ["staticlib"] - -[features] -# The OpenH264 software H.264 fallback (vendored C++). Off for development and -# linting; `build.sh`, the nix package, and CI's tests turn it on. -openh264 = ["moq-video/openh264"] - -[dependencies] -anyhow = { workspace = true, features = ["backtrace"] } -bytes = { workspace = true } -hang = { workspace = true, features = ["async"] } -kio = { workspace = true, features = ["async"] } -# Codecs only: OBS and the other C consumers do their own device I/O. -moq-audio = { workspace = true } -moq-json = { workspace = true, features = ["async"] } -moq-mux = { workspace = true, features = ["async"] } -moq-net = { workspace = true } -moq-tokio = { workspace = true } -# Select the NVIDIA and VAAPI hardware codecs explicitly because workspace -# defaults are off. The hardware backends dlopen their driver, so neither needs -# anything on the build host. The software fallback is `openh264`. -moq-video = { workspace = true, features = ["nvidia", "vaapi"] } -# Blocking on `encode::Sink` from the synchronous C entry points; see -# `video::block_on` for why not a tokio helper. -pollster = { workspace = true } -serde_json = { workspace = true } -thiserror = { workspace = true } -tokio = { workspace = true, features = ["macros"] } -tracing = { workspace = true } -url = { workspace = true } - -[build-dependencies] -cbindgen = "0.29" - -[dev-dependencies] -kio = { path = "../kio", features = ["runtime"] } -moq-loc = { path = "../moq-loc" } -# A peer without MoQ Solicit. -moq-tokio = { path = "../moq-tokio", default-features = false, features = ["test-support"] } -# The tests encode with OpenH264, the one encoder a GPU-less host has, so they -# turn it on without the `openh264` feature. -moq-video = { path = "../moq-video", features = ["openh264"] } -# Runs the tests that need a variable set or unset in a child process given it. -test-env = { path = "../test-env" } -tokio = { workspace = true, features = ["test-util"] } -workspace-hack = { path = "../workspace-hack" } - -[lints] -workspace = true diff --git a/rs/moq-c/README.md b/rs/moq-c/README.md deleted file mode 100644 index 64639d38090..00000000000 --- a/rs/moq-c/README.md +++ /dev/null @@ -1,264 +0,0 @@ -# moq-c - -C bindings for Media over QUIC. - -## Building - -```bash -cargo build --release -``` - -This will: - -- Build the static library (`libmoq.a` on Unix-like systems, `moq.lib` on Windows) -- Generate the C header file at `$OUT_DIR/include/moq.h` - -`OUT_DIR` is the build script's hashed output directory, which -`cargo build --message-format=json` reports as `out_dir` on the -`build-script-executed` message for moq-c. -The pkg-config file (`moq-c.pc.in`) is rendered only when packaging (`nix build .#moq-c` -and the release tarballs), since its paths assume `lib/libmoq.a` beside `lib/pkgconfig/`. - -There's also a [CMakeLists.txt](CMakeLists.txt) file that can be used to import/build the library. - -## C API - -The library exposes the following C functions, see [api.rs](src/api.rs) for full details: - -```c -// Logging -int32_t moq_log_level(const char *level, uintptr_t level_len); - -// Session -int32_t moq_session_connect(const char *url, uintptr_t url_len, const moq_client_config *config, uint32_t origin_publish, uint32_t origin_consume, moq_state_callback on_state, void *user_data); -moq_client_config moq_client_defaults(void); -int32_t moq_session_close(uint32_t session); -int32_t moq_session_allocator(uint32_t session); -int32_t moq_allocator_reserve(uint32_t allocator, uint32_t track, uint64_t max_bps); -int32_t moq_allocator_close(uint32_t allocator); -int32_t moq_reservation_rate(uint32_t reservation, uint64_t *bps, bool *present); -int32_t moq_reservation_update(uint32_t reservation, uint64_t max_bps); -int32_t moq_reservation_close(uint32_t reservation); -int32_t moq_session_viewers(uint32_t session); -int32_t moq_viewers_watch(uint32_t viewers, uint64_t max_bps); -int32_t moq_viewers_set_target(uint32_t viewers, uint64_t target_bps, bool present); -int32_t moq_viewers_close(uint32_t viewers); -int32_t moq_viewer_rate(uint32_t viewer, uint64_t *bps, bool *present); -int32_t moq_viewer_update(uint32_t viewer, uint64_t max_bps); -int32_t moq_viewer_close(uint32_t viewer); - -// Session: Auth (a dialed session's tokens, and the grant the peer answers with) -int32_t moq_session_tokens_set(uint32_t session, const moq_string *tokens, uintptr_t tokens_len); -int32_t moq_session_tokens_answered(uint32_t session, moq_status_callback on_answer, void *user_data); -int32_t moq_session_grants(uint32_t session, moq_status_callback on_grant, void *user_data); -int32_t moq_session_grants_cancel(uint32_t watcher); -int32_t moq_grant_info(uint32_t grant, moq_grant *dst); -int32_t moq_grant_free(uint32_t grant); -int32_t moq_session_credential(uint32_t session, const uint8_t *token, uintptr_t token_len); -int32_t moq_credential_answered(uint32_t credential, moq_status_callback on_answer, void *user_data); -int32_t moq_credential_free(uint32_t credential); - -// Server -int32_t moq_server_listen(const moq_server_config *config, moq_status_callback on_request, void *user_data); -int32_t moq_server_addr(uint32_t server, moq_string *dst); -int32_t moq_server_fingerprints(uint32_t server, moq_string *dst, uintptr_t count); -int32_t moq_server_close(uint32_t server); -int32_t moq_session_request_path(uint32_t request, moq_string *dst); -int32_t moq_session_request_query(uint32_t request, moq_string *dst); -int32_t moq_session_request_accept(uint32_t request, uint32_t origin_publish, uint32_t origin_consume, moq_state_callback on_state, void *user_data); -int32_t moq_session_request_reject(uint32_t request, uint16_t code); -int32_t moq_session_request_free(uint32_t request); - -// Origin -int32_t moq_origin_create(void); -int32_t moq_origin_close(uint32_t origin); -int32_t moq_origin_request(uint32_t origin, const char *path, uintptr_t path_len, uint32_t instance, moq_status_callback on_broadcast, void *user_data); -int32_t moq_origin_request_cancel(uint32_t task); -int32_t moq_origin_follow(uint32_t origin, const char *path, uintptr_t path_len, uint32_t instance, moq_follow_callback on_follow, void *user_data); -int32_t moq_origin_follow_cancel(uint32_t task); -int32_t moq_origin_announced(uint32_t origin, const moq_announce_config *config, moq_status_callback on_announce, void *user_data); -int32_t moq_origin_announced_info(uint32_t announced, moq_announce_event *dst); -int32_t moq_origin_announced_free(uint32_t announced); -int32_t moq_origin_announced_cancel(uint32_t announced); -// config (NULL for everything): filter is relative to the literal prefix, or NULL for **. hidden also lists `.`-named paths. Updates stay relative to the origin. - -// Instances (0 means none: unpinned, or a fresh one in route options; a route's or claim's is the caller's to free, an announcement's lives with it) -int32_t moq_instance_parse(const char *text, uintptr_t text_len); -int32_t moq_instance_text(uint32_t instance, moq_string *dst); -int32_t moq_instance_minted(uint32_t instance); -int32_t moq_instance_equal(uint32_t a, uint32_t b); -int32_t moq_instance_free(uint32_t instance); - -// Publishing: Routes (freeing one retracts it; moq_publish_close on its broadcast ends both) -int32_t moq_origin_route(uint32_t origin, const char *path, uintptr_t path_len, const moq_route_options *options); -// options (NULL for the default): hidden until announced, a cost, and an optional stable instance with its epoch. Hops are the origin's to add. -int32_t moq_route_broadcast(uint32_t route); -int32_t moq_route_instance(uint32_t route); -int32_t moq_route_announce(uint32_t route); -int32_t moq_route_withdraw(uint32_t route); -int32_t moq_route_set_cost(uint32_t route, uint64_t cost); -int32_t moq_route_set_auth(uint32_t route, uint32_t credential); -int32_t moq_route_free(uint32_t route); - -// Publishing: Claims (a prefix answered on demand; freeing one retracts it) -int32_t moq_origin_claim(uint32_t origin, const char *prefix, uintptr_t prefix_len, const moq_route_options *options, moq_status_callback on_request, void *user_data); -int32_t moq_claim_instance(uint32_t claim); -int32_t moq_claim_announce(uint32_t claim); -int32_t moq_claim_withdraw(uint32_t claim); -int32_t moq_claim_set_cost(uint32_t claim, uint64_t cost); -int32_t moq_claim_set_auth(uint32_t claim, uint32_t credential); -int32_t moq_claim_free(uint32_t claim); -int32_t moq_broadcast_request_path(uint32_t request, moq_string *dst); -int32_t moq_broadcast_request_serve(uint32_t request, uint32_t broadcast); -int32_t moq_broadcast_request_route(uint32_t request, const moq_route_options *options); -int32_t moq_broadcast_request_reject(uint32_t request, uint16_t error_code); -int32_t moq_broadcast_request_free(uint32_t request); - -// Publishing -int32_t moq_publish_close(uint32_t broadcast); -int32_t moq_publish_audio(uint32_t broadcast, const moq_audio_init *config); -int32_t moq_publish_video(uint32_t broadcast, const moq_video_init *config); -int32_t moq_publish_container(uint32_t broadcast, const moq_container_init *config); -int32_t moq_publish_container_write(uint32_t container, const uint8_t *payload, uintptr_t payload_size); -int32_t moq_publish_container_finish(uint32_t container); -int32_t moq_publish_media_finish(uint32_t media); -int32_t moq_publish_media_frame(uint32_t media, const uint8_t *payload, uintptr_t payload_size, moq_timestamp timestamp); -int32_t moq_publish_track(uint32_t broadcast, const char *name, uintptr_t name_len, const moq_track_info *info); -int32_t moq_publish_track_group(uint32_t track, const moq_timestamp *start); -int32_t moq_publish_track_frame(uint32_t track, const uint8_t *payload, uintptr_t payload_size, const moq_timestamp *timestamp); -int32_t moq_publish_group_frame(uint32_t group, const uint8_t *payload, uintptr_t payload_size, const moq_timestamp *timestamp); -int32_t moq_publish_group_start(uint32_t group, uint64_t *dst); -int32_t moq_publish_group_finish(uint32_t group); -int32_t moq_publish_group_ready(uint32_t group, uint64_t size, moq_status_callback on_ready, void *user_data); -int32_t moq_publish_track_finish(uint32_t track); -int32_t moq_publish_track_largest(uint32_t track, uint64_t *group, uint64_t *frame, bool *present); -int32_t moq_publish_timebase(uint32_t broadcast); -int32_t moq_publish_timebase_free(uint32_t timebase); -// moq_container_init.timebase (0 for none) shares one source clock across containers. - -// Publishing: Demand -int32_t moq_publish_track_demand(uint32_t track, moq_status_callback on_demand, void *user_data); -int32_t moq_publish_media_demand(uint32_t media, moq_status_callback on_demand, void *user_data); -int32_t moq_encode_video_demand(uint32_t producer, moq_status_callback on_demand, void *user_data); -int32_t moq_encode_audio_demand(uint32_t producer, moq_status_callback on_demand, void *user_data); -int32_t moq_publish_demand_cancel(uint32_t watcher); -int32_t moq_publish_demand_wanted(uint32_t watcher, uint64_t *group, bool *present); - -// Publishing: Requests -int32_t moq_publish_requests(uint32_t broadcast, moq_status_callback on_request, void *user_data); -int32_t moq_publish_track_requests(uint32_t track, moq_status_callback on_group, void *user_data); -int32_t moq_track_request_requests(uint32_t request, moq_status_callback on_group, void *user_data); -int32_t moq_publish_requests_cancel(uint32_t dynamic); -int32_t moq_track_request_name(uint32_t request, moq_string *dst); -int32_t moq_track_request_accept(uint32_t request, const moq_track_info *info); -int32_t moq_track_request_video(uint32_t request, const moq_video_init *config); -int32_t moq_track_request_audio(uint32_t request, const moq_audio_init *config); -int32_t moq_track_request_abort(uint32_t request, uint16_t error_code); -int32_t moq_track_request_free(uint32_t request); -int32_t moq_group_request_start(uint32_t request, uint64_t *dst); -int32_t moq_group_request_priority(uint32_t request, int8_t *dst); -int32_t moq_group_request_frame_start(uint32_t request, uint64_t *dst); -int32_t moq_group_request_accept(uint32_t request); -int32_t moq_group_request_abort(uint32_t request, uint16_t error_code); -int32_t moq_group_request_free(uint32_t request); - -// Consuming -int32_t moq_consume_close(uint32_t consume); -int32_t moq_consume_closed(uint32_t broadcast, moq_status_callback on_closed, void *user_data); -int32_t moq_consume_closed_cancel(uint32_t watcher); - -// Consuming: Catalog -int32_t moq_consume_catalog(uint32_t broadcast, uint64_t delay_us, moq_status_callback on_catalog, void *user_data); -int32_t moq_consume_catalog_timestamp(uint32_t catalog, moq_timestamp *dst); -int32_t moq_consume_catalog_cancel(uint32_t catalog); -int32_t moq_consume_catalog_free(uint32_t catalog); -int32_t moq_consume_video_config(uint32_t catalog, uint32_t index, moq_video_config *dst); -int32_t moq_consume_video_enabled(uint32_t catalog, uint32_t index, bool *dst); -int32_t moq_consume_audio_config(uint32_t catalog, uint32_t index, moq_audio_config *dst); -int32_t moq_consume_audio_enabled(uint32_t catalog, uint32_t index, bool *dst); - -// Consuming: Video -int32_t moq_consume_video(uint32_t catalog, uint32_t index, const moq_delay *delay, moq_status_callback on_frame, void *user_data); -int32_t moq_consume_video_cancel(uint32_t track); - -// Consuming: Audio -int32_t moq_consume_audio(uint32_t catalog, uint32_t index, const moq_delay *delay, moq_status_callback on_frame, void *user_data); -int32_t moq_consume_audio_cancel(uint32_t track); - -// Consuming: Frames -int32_t moq_consume_read(uint32_t read, moq_media_read *dst); -int32_t moq_consume_read_free(uint32_t read); -moq_subscription moq_subscription_defaults(void); -int32_t moq_consume_track(uint32_t broadcast, const char *name, uintptr_t name_len, const moq_subscription *subscription, moq_status_callback on_frame, void *user_data); -int32_t moq_consume_track_frame(uint32_t frame, moq_frame *dst); -int32_t moq_consume_track_frame_free(uint32_t frame); -int32_t moq_consume_track_cancel(uint32_t track); - -// Codecs without a broadcast: encode, then publish or store the packets yourself -int32_t moq_audio_encoder_create(const moq_audio_encoder_output *output); -int32_t moq_audio_encoder_frame_size(uint32_t encoder); -int32_t moq_audio_encoder_init(uint32_t encoder, moq_audio_init *dst); -int32_t moq_audio_encoder_bitrate(uint32_t encoder, uint64_t bitrate); -int32_t moq_audio_encoder_encode(uint32_t encoder, const float *pcm, uintptr_t pcm_len); -int32_t moq_audio_encoder_receive(uint32_t encoder, moq_audio_packet *dst); -int32_t moq_audio_encoder_flush(uint32_t encoder); -int32_t moq_audio_encoder_finish(uint32_t encoder, const float *pcm, uintptr_t pcm_len, uint64_t *discard_padding); -int32_t moq_audio_encoder_packet(uint32_t encoder, uint32_t index, moq_audio_packet *dst); -int32_t moq_audio_encoder_free(uint32_t encoder); -int32_t moq_video_encoder_create(const moq_video_encoder_input *input, const moq_video_encoder_output *output); -int32_t moq_video_encoder_encode(uint32_t encoder, const moq_video_encoder_frame *frame); -int32_t moq_video_encoder_receive(uint32_t encoder, moq_frame *dst); -int32_t moq_video_encoder_cut(uint32_t encoder); -int32_t moq_video_encoder_bitrate(uint32_t encoder, uint64_t bitrate); -int32_t moq_video_encoder_flush(uint32_t encoder); -int32_t moq_video_encoder_free(uint32_t encoder); -``` - -Raw track frames use the same `moq_frame` record as media frames. Timestamps -are exact `moq_timestamp` records, `value` units at `scale` units per second. -A scale-less track has no time, so there `has_scale` is false and `value` is -the frame's group key (a datagram's sequence). Every write takes a non-NULL -timestamp: `moq_publish_track_frame` and `moq_publish_group_frame` convert -theirs to the track's timescale, a microsecond one unless -`moq_track_info.timescale` sets another, and `moq_publish_group_start` reads -the key a scale-less group's frames carry. `moq_consume_track_frame` points -`moq_frame.timestamp` at the timestamp read, never NULL, valid until the frame -is freed. - -A zeroed `moq_track_info`, like a NULL one, advertises a zero max age, how long -a superseded group stays fresh, so only the live edge is served. Set -`max_age_us` for a longer age, or `max_age_unlimited` for no publisher limit, -which ignores `max_age_us`. Zero-initialize the struct -(`moq_track_info info = {0};`) before assigning members, so every flag starts -false. - -JSON window pushes and pops take a required `const moq_timestamp *timestamp`, -like snapshot updates and stream appends. It is when the edit occurred, -converted to the track's milliseconds; stamp it from `moq_publish_catalog_now`. -A NULL timestamp fails with `MOQ_ERROR_INVALID_POINTER`. - -```c -int32_t moq_publish_json_window_push(uint32_t window, const char *value, uintptr_t value_len, const moq_timestamp *timestamp); -int32_t moq_publish_json_window_pop(uint32_t window, uint64_t count, const moq_timestamp *timestamp); -``` - -### Pre-encoded simulcast - -Publish video renditions from lowest to highest, passing the next lower media -handle in `moq_video_init.lower` (0 for the lowest). This orders delivery so -higher renditions yield to lower ones. `moq_publish_media_set_enabled` updates -the catalog and marks a discontinuity when disabling; resume on a keyframe. -Audio importers do not support this toggle. - -Reserve each media track with `moq_allocator_reserve_media`. Create a -`moq_rate_control_create` handle bound to the reservation, with `moq_rate_policy.max_bps` and, for higher -rungs, `has_lower` and `lower_bps`. Read its initial `moq_rate_control_target`, -then call `moq_rate_control_update` on every frame, -including while disabled. It returns 0 or a negative error; `target.changed` -is true for a new target and false to hold the last one. Apply the target's `bitrate_bps` -to your encoder and `enabled` through `moq_publish_media_set_enabled`. -The shared controller drops immediately, ramps raises, ignores small changes, -and holds without an estimate. A rung disables only with a probing session, -which on native transports requires moq-quic with BBR3, so bandwidth can recover. -Close controls with `moq_rate_control_close` and reservations with -`moq_reservation_close`; neither owns or closes the media track. diff --git a/rs/moq-c/cmake/moq-c-config-version.cmake.in b/rs/moq-c/cmake/moq-c-config-version.cmake.in deleted file mode 100644 index add17654b20..00000000000 --- a/rs/moq-c/cmake/moq-c-config-version.cmake.in +++ /dev/null @@ -1,20 +0,0 @@ -# moq-c CMake version file - -set(PACKAGE_VERSION "@VERSION@") - -# Check whether the requested version is compatible -if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) - set(PACKAGE_VERSION_COMPATIBLE FALSE) -else() - set(PACKAGE_VERSION_COMPATIBLE TRUE) - if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) - set(PACKAGE_VERSION_EXACT TRUE) - endif() -endif() - -# Check for same major version (SameMajorVersion compatibility) -if(PACKAGE_FIND_VERSION_MAJOR STREQUAL "@MAJOR_VERSION@") - set(PACKAGE_VERSION_COMPATIBLE TRUE) -else() - set(PACKAGE_VERSION_COMPATIBLE FALSE) -endif() diff --git a/rs/moq-c/src/lib.rs b/rs/moq-c/src/lib.rs deleted file mode 100644 index ec3126526d3..00000000000 --- a/rs/moq-c/src/lib.rs +++ /dev/null @@ -1,62 +0,0 @@ -#![warn(missing_docs)] - -//! C bindings for [`moq_net`]. -//! -//! Provides a C-compatible API for real-time pub/sub over QUIC. -//! -//! ## Concepts -//! -//! - **Session**: Network connection to a MoQ relay, or one accepted by a server -//! - **Origin**: Collection of broadcasts -//! - **Broadcast**: Container for tracks -//! - **Track**: Named stream of groups -//! - **Group**: Collection of frames -//! - **Frame**: Sized payload with timestamp -//! -//! ## Error Handling -//! -//! All functions return negative error codes on failure or non-negative values on success. -//! Resources are managed through opaque integer handles that must be explicitly closed. - -mod api; -mod audio; -mod auth; -mod bandwidth; -mod client; -mod consume; -mod datagram; -mod decode; -mod encoder; -mod error; -mod ffi; -mod id; -mod origin; -mod publish; -mod server; -mod session; -mod state; -mod task; -mod video; - -pub use api::*; -pub use audio::*; -pub use auth::*; -pub use bandwidth::*; -pub use datagram::*; -pub use decode::{moq_decode_gap, moq_decode_read_kind, moq_decode_start}; -pub use encoder::*; -pub use error::*; -pub use ffi::{moq_follow_callback, moq_state_callback, moq_status_callback}; -pub use id::*; -pub use video::*; - -pub(crate) use client::*; -pub(crate) use consume::*; -pub(crate) use origin::*; -pub(crate) use publish::*; -pub(crate) use server::*; -pub(crate) use session::*; -pub(crate) use state::*; - -#[cfg(test)] -mod test; diff --git a/rs/moq-cli/Cargo.toml b/rs/moq-cli/Cargo.toml index aaef371005d..d060ddb4c86 100644 --- a/rs/moq-cli/Cargo.toml +++ b/rs/moq-cli/Cargo.toml @@ -31,10 +31,10 @@ bin-dir = "{ bin }{ binary-ext }" [[bin]] name = "moq" path = "src/main.rs" -# `moq-c`'s staticlib is also named `moq`, so a `cargo doc` selecting both renders +# `libmoq`'s staticlib is also named `moq`, so a `cargo doc` selecting both renders # them to `target/doc/moq` and the two rustdoc processes race to clean it (#3094). # This binary's page is the one to give up: nothing links it, and a bin target has -# no public API to render, whereas docs.rs/moq-c is the published C API reference. +# no public API to render, whereas docs.rs/libmoq is the published C API reference. doc = false [features] diff --git a/rs/moq-ffi/Cargo.toml b/rs/moq-ffi/Cargo.toml index 662bc2b87d7..5720ac7cec6 100644 --- a/rs/moq-ffi/Cargo.toml +++ b/rs/moq-ffi/Cargo.toml @@ -36,7 +36,7 @@ moq-json = { workspace = true, features = ["async"] } moq-mux = { workspace = true, features = ["async"] } moq-net = { workspace = true } moq-tokio = { workspace = true } -# `nvidia` and `vaapi` back on, matching rs/moq-c: the workspace turns +# `nvidia` and `vaapi` back on, matching rs/libmoq: the workspace turns # moq-video's defaults off for `capture` (device code the bindings don't # expose), and the codecs are collateral rather than the goal. Nothing is paid for them off Linux, since # cudarc / moq-nvenc / libloading / moq-vaapi sit behind diff --git a/rs/moq-ffi/src/test.rs b/rs/moq-ffi/src/test.rs index f83607fa3e5..d4ac78e218e 100644 --- a/rs/moq-ffi/src/test.rs +++ b/rs/moq-ffi/src/test.rs @@ -3948,7 +3948,7 @@ async fn resolve_rejects_a_reference_without_an_origin() { consumer.resolve(referencing(Some(""), None)).await.unwrap(); assert!(consumer.resolve(referencing(Some("/"), None)).await.is_err()); - // Reported in normalized form, matching `EscapingBroadcast` and moq-c: it names what the + // Reported in normalized form, matching `EscapingBroadcast` and libmoq: it names what the // resolver actually tried to reach, not the caller's spelling of it. match consumer.resolve(referencing(Some("./source"), None)).await { Err(MoqError::UnresolvableBroadcast { reason: reference }) => assert_eq!(reference, "source"), diff --git a/rs/moq-video/src/decode/consumer.rs b/rs/moq-video/src/decode/consumer.rs index f4d2d373c05..810b1610d9c 100644 --- a/rs/moq-video/src/decode/consumer.rs +++ b/rs/moq-video/src/decode/consumer.rs @@ -144,7 +144,7 @@ type Item = (Read, Option); /// One subscription and the decoder it feeds. struct Reader { /// A [`Sink`] rather than a bare `Decoder`: the read loop below is held - /// across `.await` by every caller (moq-c's spawned task, moq-transcode), + /// across `.await` by every caller (libmoq's spawned task, moq-transcode), /// so the codec would otherwise migrate between executor workers and /// unbalance the per-thread COM apartment the Windows backend opens. decoder: Sink, diff --git a/rs/moq-video/src/decode/mod.rs b/rs/moq-video/src/decode/mod.rs index 313ba31a5d9..dd9e72f70a2 100644 --- a/rs/moq-video/src/decode/mod.rs +++ b/rs/moq-video/src/decode/mod.rs @@ -34,7 +34,7 @@ pub use sink::Sink; #[cfg(test)] mod tests { - /// Callers (moq-c, moq-transcode) hold these across `.await`s in spawned + /// Callers (libmoq, moq-transcode) hold these across `.await`s in spawned /// tasks and share frames via `Arc` (the transcode fanout), so both must /// stay `Send` and `Frame` also `Sync` even when a platform's frame wraps /// a GPU handle. Compile-time check; fails per-platform if a variant diff --git a/rs/moq-video/src/decode/sink.rs b/rs/moq-video/src/decode/sink.rs index 2f62e2b7805..714af4cbd68 100644 --- a/rs/moq-video/src/decode/sink.rs +++ b/rs/moq-video/src/decode/sink.rs @@ -294,7 +294,7 @@ mod tests { /// Regression: the Windows decoder opens a COM apartment on the thread that /// builds it and closes it on the thread that drops it. Every owner holds the /// codec across `.await` in a spawned task (`decode::Consumer`'s read loop, - /// which moq-c drives; moq-transcode's feed and fetch pipeline), so the + /// which libmoq drives; moq-transcode's feed and fetch pipeline), so the /// future migrates between executor workers and the apartment is opened on /// one and closed on another. #[test] diff --git a/sh/api-diff/ffi.sh b/sh/api-diff/ffi.sh index c39531d7ee0..9214c9ab58b 100755 --- a/sh/api-diff/ffi.sh +++ b/sh/api-diff/ffi.sh @@ -2,8 +2,8 @@ # Write the FFI interfaces of the last release and of this checkout as headers, # so sh/api-diff/run.sh can diff them. usage: sh/api-diff/ffi.sh # -# - moq.h: the C header, from the newest `moq-c-v*` (formerly `libmoq-v*`) -# release archive, and from moq-c's build script here. +# - moq.h: the C header, from the newest `libmoq-v*` release archive, and from +# libmoq's build script here. # - moq-ffi.hpp: the UniFFI surface every binding is generated from, rendered as # the C++ header uniffi-bindgen-cpp writes for it, which declares each exported # item with its full signature. The baseline comes from the newest `moq-ffi-v*` @@ -34,10 +34,10 @@ strip() { gcc -x "$1" -fpreprocessed -dD -E -P -w "$2" -o "$3" } -c_tag=$(latest '^(moq-c|libmoq)-v') +c_tag=$(latest '^libmoq-v') ffi_tag=$(latest '^moq-ffi-v') if [[ -z "$c_tag" || -z "$ffi_tag" ]]; then - echo "no moq-c or moq-ffi release found" >&2 + echo "no libmoq or moq-ffi release found" >&2 exit 1 fi @@ -46,11 +46,11 @@ gh release download "$c_tag" --repo moq-dev/moq --pattern '*-x86_64-unknown-linu tar -xzf "$work"/c/*.tar.gz -C "$work/c" --wildcards '*/include/moq.h' strip c "$work"/c/*/include/moq.h "$out/baseline/moq.h" -# moq-c's build script writes the header into its OUT_DIR, which `cargo check` runs. -c_out=$(cargo check --locked -p moq-c --message-format=json | - jq -r 'select(.reason == "build-script-executed") | select(.package_id | test("/moq-c#")) | .out_dir' | tail -1) +# libmoq's build script writes the header into its OUT_DIR, which `cargo check` runs. +c_out=$(cargo check --locked -p libmoq --message-format=json | + jq -r 'select(.reason == "build-script-executed") | select(.package_id | test("/libmoq#")) | .out_dir' | tail -1) if [[ -z "$c_out" || ! -f "$c_out/include/moq.h" ]]; then - echo "cargo check -p moq-c wrote no moq.h" >&2 + echo "cargo check -p libmoq wrote no moq.h" >&2 exit 1 fi strip c "$c_out/include/moq.h" "$out/current/moq.h" diff --git a/sh/api-diff/run.sh b/sh/api-diff/run.sh index 1bcc0d4e641..7acccff77db 100755 --- a/sh/api-diff/run.sh +++ b/sh/api-diff/run.sh @@ -127,7 +127,7 @@ rust() { jq -r '.packages[] | select(.publish != []) | "\(.name) \([.targets[].kind[]] | unique | join(",")) \([.targets[] | select(.kind | index("lib") or index("rlib")) | .name][0] // "-") \(.id)"') while read -r name kinds lib id; do - # A binary or a C library has no Rust API; moq-c and moq-ffi are diffed as FFI. + # A binary or a C library has no Rust API; libmoq and moq-ffi are diffed as FFI. [[ ",$kinds," == *,lib,* || ",$kinds," == *,rlib,* ]] || continue # The sparse index shards names by length: 3/k/kio, ha/ng/hang. case ${#name} in diff --git a/sh/cpp/ffi.py b/sh/cpp/ffi.py index 8e6ee5db316..1b8813cab5c 100644 --- a/sh/cpp/ffi.py +++ b/sh/cpp/ffi.py @@ -44,7 +44,7 @@ def stage(release, target, library, output): (output / "lib").mkdir() for filename in (static, metadata): shutil.copyfile(library / filename, output / "lib" / filename) - shutil.copyfile(ROOT / f"rs/moq-c/native-libs/{platform}.txt", output / "native-libs.txt") + shutil.copyfile(ROOT / f"rs/libmoq/native-libs/{platform}.txt", output / "native-libs.txt") (output / "manifest.json").write_text( json.dumps( { diff --git a/sh/dispatch-query.test.py b/sh/dispatch-query.test.py index 62a250cd375..5377c98141a 100644 --- a/sh/dispatch-query.test.py +++ b/sh/dispatch-query.test.py @@ -816,7 +816,7 @@ def test_flake_checks_follow_nix_inputs_instead_of_rust_source(self): (".cargo/config.toml", True), ("rs/moq-net/src/lib.rs", False), ("rs/moq-net/Cargo.toml", True), - ("rs/moq-c/native-libs/linux.txt", True), + ("rs/libmoq/native-libs/linux.txt", True), ("rs/moq-video/src/frame/nv12_resize.ptx", True), ("Cargo.toml", True), ("Cargo.lock", True), @@ -838,7 +838,7 @@ def test_cargo_nix_follows_what_crate2nix_reads(self): for path, expected in ( ("Cargo.lock", True), ("rs/moq-net/Cargo.toml", True), - ("rs/moq-c/build.rs", True), + ("rs/libmoq/build.rs", True), ("rs/moq-net/src/lib.rs", True), ("rs/moq-cli/src/main.rs", True), ("rs/moq-cli/src/bin/extra.rs", True), diff --git a/sh/dispatch.sh b/sh/dispatch.sh index e4f1dbb2b96..637af46c8a5 100755 --- a/sh/dispatch.sh +++ b/sh/dispatch.sh @@ -123,18 +123,18 @@ module rs '^(\.cargo/|nix/modules/moq-relay\.nix$|sh/local\.(sh|ts)$|rs/|test/in # from. The pinned crate2nix comes from flake.lock. module cargo_nix '((^|/)(Cargo\.(toml|lock)|build\.rs)$|^rs/.*/src/(lib\.rs|main\.rs|bin/)|^nix/(Cargo\.nix|crate-hashes\.json)$|^sh/rs/cargo-nix\.sh$|^flake\.lock$)' \ tools='nix nixfmt cargo' fix -# The C package links moq-c's native-libs lists, and the C++ package's FFI +# The C package links libmoq's native-libs lists, and the C++ package's FFI # pin. Both packages format with sh/clang-format.sh and OBS's style file. -module c '^(\.cargo/config\.toml$|c/|sh/c/|sh/clang-format\.sh$|cpp/obs/\.clang-format$|rs/moq-ffi/|rs/moq-c/native-libs/|cpp/moq/FFI_VERSION$|cpp/moq/cmake/moq-ffi\.cmake$)' \ +module c '^(\.cargo/config\.toml$|c/|sh/c/|sh/clang-format\.sh$|cpp/obs/\.clang-format$|rs/moq-ffi/|rs/libmoq/native-libs/|cpp/moq/FFI_VERSION$|cpp/moq/cmake/moq-ffi\.cmake$)' \ tools='cargo cmake cc c++ pkg-config uniffi-bindgen-cpp clang-format' compiles=check fix -# The package links moq-c's native-libs lists, and compiles its doc samples. +# The package links libmoq's native-libs lists, and compiles its doc samples. # It shares a lane with obs_compile because both build cpp/moq/build. -module cpp '^(\.cargo/config\.toml$|cpp/moq/|cpp/justfile$|sh/cpp/|sh/clang-format\.sh$|cpp/obs/\.clang-format$|rs/moq-ffi/|rs/moq-c/native-libs/|doc/lib/cpp/|doc/lib/samples\.sh$)' \ +module cpp '^(\.cargo/config\.toml$|cpp/moq/|cpp/justfile$|sh/cpp/|sh/clang-format\.sh$|cpp/obs/\.clang-format$|rs/moq-ffi/|rs/libmoq/native-libs/|doc/lib/cpp/|doc/lib/samples\.sh$)' \ tools='cargo cmake c++ uniffi-bindgen-cpp clang-format' compiles=check lane=cpp fix # The plugin and its tests call through the bindings generated from cpp/moq -# and moq-ffi and link through moq-c's native-libs lists, and flake.nix owns +# and moq-ffi and link through libmoq's native-libs lists, and flake.nix owns # the libobs headers it compiles against. -module obs_compile '^(\.cargo/config\.toml$|cpp/obs/|cpp/moq/|sh/obs/|rs/moq-ffi/|rs/moq-c/native-libs/|flake\.nix$)' \ +module obs_compile '^(\.cargo/config\.toml$|cpp/obs/|cpp/moq/|sh/obs/|rs/moq-ffi/|rs/libmoq/native-libs/|flake\.nix$)' \ tools='cargo cmake pkg-config uniffi-bindgen-cpp' compiles=check lane=cpp # The bun lane serializes fixers and JS builds that write shared outputs. # Dependency setup separately uses sh/js/install.py across every entry point. diff --git a/sh/gh/nightly.sh b/sh/gh/nightly.sh index 6073013f824..2249892b097 100755 --- a/sh/gh/nightly.sh +++ b/sh/gh/nightly.sh @@ -122,7 +122,7 @@ case "$1" in rust-test-apps) export NEXTEST_PROFILE=bench NEXTEST_TEST_THREADS=1 nextest just rs bench-tests --no-fail-fast --run-ignored only \ - -p moq-audio -p moq-mux -p moq-c -p moq-relay -p moq-cli -p moq-ffi \ + -p moq-audio -p moq-mux -p libmoq -p moq-relay -p moq-cli -p moq-ffi \ --features moq-audio/playback --lib --bin moq \ -E 'test(benchmark_mixer_callbacks) | test(benchmark_resampler) | test(benchmark_raw_audio) | test(benchmark_damage_pid_fanout) | test(benchmark_pes_staging) | test(benchmark_handles) | test(benchmark_stream_import) | test(benchmark_timebase_reservation_fanout)' ;; diff --git a/sh/gh/ts-paths.test.py b/sh/gh/ts-paths.test.py index 817b051c97d..4b6dbcd198a 100644 --- a/sh/gh/ts-paths.test.py +++ b/sh/gh/ts-paths.test.py @@ -57,7 +57,7 @@ def test_only_the_ts_entry(self): for line in ( " filters: |", " obs:", - ' - "rs/moq-c/**"', + ' - "rs/libmoq/**"', " ts:", ' - "test/ts/**"', " # A comment.", @@ -73,7 +73,7 @@ def test_only_the_ts_entry(self): def test_missing(self): with self.assertRaises(SystemExit): - module.ts_filter(' obs:\n - "rs/moq-c/**"\n') + module.ts_filter(' obs:\n - "rs/libmoq/**"\n') if __name__ == "__main__": diff --git a/sh/rs/c-tests.sh b/sh/rs/c-tests.sh index 461d874df8c..4aae24e28dc 100755 --- a/sh/rs/c-tests.sh +++ b/sh/rs/c-tests.sh @@ -1,8 +1,8 @@ #!/usr/bin/env bash -# Compile and run moq-c's C fixtures (`rs/moq-c/c-tests/*.c`), and the C doc +# Compile and run libmoq's C fixtures (`rs/libmoq/c-tests/*.c`), and the C doc # samples, against libmoq.a, linked the way an embedder does: an external `cc` # against the generated `moq.h`, plus the native libraries from -# `rs/moq-c/native-libs` that cargo can't inject into a link it doesn't drive. +# `rs/libmoq/native-libs` that cargo can't inject into a link it doesn't drive. # Unix only. set -euo pipefail @@ -18,33 +18,33 @@ if ! command -v "$cc" >/dev/null; then exit 1 fi -cargo build --locked -p moq-c --features openh264 +cargo build --locked -p libmoq --features openh264 # Ask cargo where it put the staticlib and the header rather than assuming # target/debug: CARGO_TARGET_DIR and a configured build target # (`target//debug`) both move them, and guessing wrong would link a # stale copy or nothing. Replays the build above from cache, so it costs a # process, not a compile. -log=$(cargo build --locked -p moq-c --features openh264 --message-format=json) +log=$(cargo build --locked -p libmoq --features openh264 --message-format=json) lib=$(jq -r 'select(.reason == "compiler-artifact") | .filenames[] | select(endswith("/libmoq.a"))' <<<"$log" | tail -1) if [ -z "$lib" ]; then - echo "cargo reported no libmoq.a for moq-c" >&2 + echo "cargo reported no libmoq.a for libmoq" >&2 exit 1 fi profile=$(dirname "$lib") -# rs/moq-c/build.rs writes the header into its OUT_DIR. -out_dir=$(jq -r 'select(.reason == "build-script-executed") | select(.package_id | test("/moq-c#")) | .out_dir' <<<"$log" | tail -1) +# rs/libmoq/build.rs writes the header into its OUT_DIR. +out_dir=$(jq -r 'select(.reason == "build-script-executed") | select(.package_id | test("/libmoq#")) | .out_dir' <<<"$log" | tail -1) include="$out_dir/include" if [ -z "$out_dir" ] || [ ! -f "$include/moq.h" ]; then - echo "$include/moq.h missing after 'cargo build --locked -p moq-c --features openh264'" >&2 + echo "$include/moq.h missing after 'cargo build --locked -p libmoq --features openh264'" >&2 exit 1 fi # Same list nix/overlay.nix (moq.pc), CMakeLists.txt, and test/interop/interop.sh read: # `framework:Foo` is a linker framework flag, anything else a plain library. case "$(uname -s)" in - Darwin) native_libs=rs/moq-c/native-libs/apple.txt ;; - *) native_libs=rs/moq-c/native-libs/linux.txt ;; + Darwin) native_libs=rs/libmoq/native-libs/apple.txt ;; + *) native_libs=rs/libmoq/native-libs/linux.txt ;; esac libs=() while read -r entry; do @@ -62,7 +62,7 @@ trap 'rm -rf "$out"' EXIT # doc-samples.h declares, and every name the prose cites. A `moq_decode_*` # wildcard ends in `_` and is skipped. bash doc/lib/samples.sh c doc/lib/c/index.md >"$out/doc-samples.c" -"$cc" -fsyntax-only -Werror=implicit-function-declaration -include rs/moq-c/c-tests/doc-samples.h -I"$include" "$out/doc-samples.c" +"$cc" -fsyntax-only -Werror=implicit-function-declaration -include rs/libmoq/c-tests/doc-samples.h -I"$include" "$out/doc-samples.c" grep -oE '\b(moq|MOQ)_[A-Za-z0-9_]*' doc/lib/c/index.md | grep -v '_$' | sort -u | while read -r name; do if ! grep -qw "$name" "$include/moq.h"; then echo "doc/lib/c/index.md cites $name, which moq.h does not declare" >&2 @@ -70,9 +70,32 @@ grep -oE '\b(moq|MOQ)_[A-Za-z0-9_]*' doc/lib/c/index.md | grep -v '_$' | sort -u fi done -for source in rs/moq-c/c-tests/*.c; do +for source in rs/libmoq/c-tests/*.c; do bin="$out/$(basename "$source" .c)" "$cc" "$source" -I"$include" -L"$profile" -lmoq "${libs[@]}" -o "$bin" echo "running $source" "$bin" done + +# find_package(moq ) takes the same 0.x line only, at least as new as +# the request: render the packed version file the way build.sh and +# nix/overlay.nix do, and ask CMake about each request. +if command -v cmake >/dev/null; then + pkg="$out/cmake-pkg" + mkdir -p "$pkg" "$out/cmake-probe" + sed 's/@VERSION@/0.22.1/' rs/libmoq/cmake/moq-config-version.cmake.in >"$pkg/moq-config-version.cmake" + echo 'set(moq_FOUND TRUE)' >"$pkg/moq-config.cmake" + # request:found + for case in ":1" "0.22:1" "0.22.1:1" "0.22.2:0" "0.23:0" "0.21:0" "0.6:0" "1.0:0" "0.22...0.22.1:1" "0.22...<0.22.1:0" "0.22...<0.23:1" "0.22...0.22.0:0" "0.22...<0.22.2:1"; do + request="${case%%:*}" + want="${case##*:}" + printf 'cmake_minimum_required(VERSION 3.21)\nproject(probe NONE)\nfind_package(moq %s QUIET CONFIG PATHS "%s" NO_DEFAULT_PATH)\nif(moq_FOUND)\n message(STATUS "found=1")\nelse()\n message(STATUS "found=0")\nendif()\n' \ + "$request" "$pkg" >"$out/cmake-probe/CMakeLists.txt" + got=$(cmake -S "$out/cmake-probe" -B "$out/cmake-probe/build" 2>&1 | sed -n 's/.*found=\([01]\).*/\1/p') + rm -rf "$out/cmake-probe/build" + if [ "$got" != "$want" ]; then + echo "find_package(moq $request) against 0.22.1: found=$got, want $want" >&2 + exit 1 + fi + done +fi diff --git a/sh/rs/select.test.py b/sh/rs/select.test.py index b8645392532..94a8e94f9fc 100644 --- a/sh/rs/select.test.py +++ b/sh/rs/select.test.py @@ -383,7 +383,7 @@ def test_c_artifact_and_header_selection_rejects_partial_json_streams(self): artifact = {"reason": "compiler-artifact", "filenames": [str(self.scratch / "libmoq.a")]} header = { "reason": "build-script-executed", - "package_id": "path+file:///rs/moq-c#1.0.0", + "package_id": "path+file:///rs/libmoq#1.0.0", "out_dir": str(self.scratch), } # Cargo emits a stream, not an array. Both selectors must reject an diff --git a/sh/size/release.py b/sh/size/release.py index c986620bc0a..179e907a711 100644 --- a/sh/size/release.py +++ b/sh/size/release.py @@ -10,7 +10,7 @@ # Keep the Go static-library history keys when the coordinator supplies them. # Android and iOS libraries are already measured inside Kotlin/Swift packages. GO_TARGETS = {"x86_64-unknown-linux-gnu", "aarch64-unknown-linux-gnu", "aarch64-apple-darwin", "x86_64-pc-windows-msvc"} -ARTIFACTS = ["go-lib-*", "moq-c-*", "moq-cli-*", "moq-relay-*", "python-*", "kotlin-package", "swift-ffi-package"] +ARTIFACTS = ["go-lib-*", "libmoq-*", "moq-cli-*", "moq-relay-*", "python-*", "kotlin-package", "swift-ffi-package"] # What a consumer downloads: archives, packages and the Go mirror's staticlibs. # Bare binaries, .deb and .rpm repeat the archives; Go's .so and .dll ship inside the packages. SHIPPING = (".tar.gz", ".zip", ".whl", ".aar", ".jar", ".a", ".lib") diff --git a/sh/size/release.test.py b/sh/size/release.test.py index 9d5be41f77f..976d7160684 100644 --- a/sh/size/release.test.py +++ b/sh/size/release.test.py @@ -12,7 +12,7 @@ def fixture(root, version): "go-lib-x86_64-unknown-linux-gnu/libmoq_ffi.a", "go-lib-x86_64-unknown-linux-gnu/libmoq_ffi.so", "go-lib-x86_64-pc-windows-msvc/moq_ffi.lib", - f"moq-c-aarch64-unknown-linux-gnu/moq-c-{version}-aarch64-unknown-linux-gnu.tar.gz", + f"libmoq-aarch64-unknown-linux-gnu/moq-{version}-aarch64-unknown-linux-gnu.tar.gz", f"moq-cli-x86_64-unknown-linux-gnu/moq-cli-v{version}-x86_64-unknown-linux-gnu.tar.gz", f"moq-cli-x86_64-unknown-linux-gnu/moq-cli-v{version}-x86_64-unknown-linux-gnu", f"moq-cli-x86_64-unknown-linux-gnu/moq_{version}_amd64.deb", @@ -43,7 +43,7 @@ def test_version_changes_keep_keys(self): "release/go-lib-x86_64-unknown-linux-gnu/libmoq_ffi.a", "release/kotlin-package/moq-ffi-android.aar", "release/kotlin-package/moq-ffi-jvm.jar", - "release/moq-c-aarch64-unknown-linux-gnu/moq-c-aarch64-unknown-linux-gnu.tar.gz", + "release/libmoq-aarch64-unknown-linux-gnu/moq-aarch64-unknown-linux-gnu.tar.gz", "release/moq-cli-x86_64-unknown-linux-gnu/moq-cli-x86_64-unknown-linux-gnu.tar.gz", "release/moq-relay-x86_64-pc-windows-msvc/moq-relay-x86_64-pc-windows-msvc.zip", "release/python-aarch64-unknown-linux-gnu/moq_ffi-py3-none-manylinux_2_28_aarch64.whl", diff --git a/swift/Package.swift b/swift/Package.swift index 1b4536cedc2..f700b8150ea 100644 --- a/swift/Package.swift +++ b/swift/Package.swift @@ -23,8 +23,8 @@ let package = Package( linkerSettings: [ // A Rust staticlib does not carry the link options its dependencies // declare, so an external linker has to name them. Mirrors - // rs/moq-c/native-libs/apple.txt, which solves the same problem for - // C consumers of moq-c. These cover moq-video / moq-audio: hardware + // rs/libmoq/native-libs/apple.txt, which solves the same problem for + // C consumers of libmoq. These cover moq-video / moq-audio: hardware // H.264/H.265 encode and decode on macOS and iOS, plus capture on macOS // only (AVFoundation, CoreGraphics, ScreenCaptureKit). .linkedFramework("AVFoundation", .when(platforms: [.macOS])), diff --git a/swift/ffi/Package.swift.template b/swift/ffi/Package.swift.template index b4b3393a079..3a5928d0fb5 100644 --- a/swift/ffi/Package.swift.template +++ b/swift/ffi/Package.swift.template @@ -23,8 +23,8 @@ let package = Package( linkerSettings: [ // A Rust staticlib does not carry the link options its dependencies // declare, so an external linker has to name them. Mirrors - // rs/moq-c/native-libs/apple.txt, which solves the same problem for - // C consumers of moq-c. These cover moq-video / moq-audio: hardware + // rs/libmoq/native-libs/apple.txt, which solves the same problem for + // C consumers of libmoq. These cover moq-video / moq-audio: hardware // H.264/H.265 encode and decode on macOS and iOS, plus capture on macOS // only (AVFoundation, CoreGraphics, ScreenCaptureKit). .linkedFramework("AVFoundation", .when(platforms: [.macOS])), diff --git a/test/interop/README.md b/test/interop/README.md index fe4be8bca7e..d3d72dc2ce8 100644 --- a/test/interop/README.md +++ b/test/interop/README.md @@ -33,7 +33,7 @@ C++ clients encode it through `moq-ffi` at a 2.5 ms frame duration, so the matrix covers the FFI audio path with a non-default codec config. Each subscriber decodes every audio rendition with what it already has: moq-audio for Rust (the `interop-audio` example, since the CLI has no PCM output), `moq-ffi` for Python, -Go, and C++, `moq-c` for C, `decodebin` on each `audio_N` pad for GStreamer, and +Go, and C++, `libmoq` for C, `decodebin` on each `audio_N` pad for GStreamer, and `@moq/hang`'s libav WebCodecs fallback under Node and Bun. Each writes the first 600 ms of PCM and frame timestamps of each rendition, named by its codec, for [`tone.py`](tone.py), which requires the @@ -144,7 +144,7 @@ player survive the publication lifecycle. See [Media QA](#media-qa). | C++ | `cpp/moq` (+ `rs/moq-ffi`, `find_package(moq-cpp)`) | `cmake` build + install of `cpp/moq` (uniffi-bindgen-cpp), then `cmake` for the client | publish (video + audio) + subscribe | | Browser | `js/watch` + `js/publish` | `vite build` + headless Chromium (Playwright) | publish (video + audio) + rendered playback | | Native JS | `js/net` + `js/hang` + the npm `@moq/web-transport` polyfill | `node` (tsx) and `bun` | subscribe | -| C | `rs/moq-c` | `cargo build -p moq-c` + `cc` | subscribe | +| C | `rs/libmoq` | `cargo build -p libmoq` + `cc` | subscribe | | GStreamer | `rs/moq-gst` (`moqsrc`) | `cargo build -p moq-gst` + `gst-launch-1.0` | subscribe | The browser, native JS, C, and GStreamer clients subscribe only by choice @@ -191,7 +191,7 @@ Clients that print the grant the relay sent back over AUTH, as an their token implies: the Rust CLI (a `moq_net::auth` debug log), the Python, Go, and C++ clients (read through moq-ffi before they start), and the native JS subscribers. A cell whose grant is missing or wrong fails even when media -flowed. moq-c's frozen ABI and GStreamer expose no grant, and the browser's +flowed. libmoq's frozen ABI and GStreamer expose no grant, and the browser's shared connection keeps its session private, so their cells check media alone. AUTH is only on the work-in-progress moq-lite-07, so the printing clients dial `moq-lite-07-wip` alone and a printing client that reports nothing never got its grant. The native JS subscribers dial @@ -609,7 +609,7 @@ clients/ js-native/subscribe.ts subscribe via @moq/net + @moq/hang + the WebTransport polyfill js-native/catalog.ts the compressed-catalog reader, pinned to one version js-native/hls.ts the HLS grid publisher via @moq/hang - c/subscribe.c subscribe via rs/moq-c + c/subscribe.c subscribe via rs/libmoq ``` ## CI diff --git a/test/interop/clients/c/subscribe.c b/test/interop/clients/c/subscribe.c index 21e38d5da2e..ddefc2b4169 100644 --- a/test/interop/clients/c/subscribe.c +++ b/test/interop/clients/c/subscribe.c @@ -1,7 +1,7 @@ // Subscribe-only cross-language interop client for the interop test, linked -// against the workspace moq-c (the C bindings, built by `cargo build -p moq-c`). +// against the workspace libmoq (the C bindings, built by `cargo build -p libmoq`). // -// moq-c is a handle + callback API: connect, consume a broadcast, get a +// libmoq is a handle + callback API: connect, consume a broadcast, get a // catalog snapshot via callback, start the video track and a decoder per audio // rendition, and a callback fires as each frame arrives. Once a non-empty video // frame has landed and --audio-ms of every audio rendition has been decoded to @@ -83,13 +83,13 @@ struct ctx { // One flag per registration handed &ctx, set by that registration's terminal // (<= 0) callback. main returns only once every registration is done: that terminal is - // moq-c's documented last touch of user_data, so it is what makes main's + // libmoq's documented last touch of user_data, so it is what makes main's // frame safe to destroy. int done_status, done_broadcast, done_catalog, done_frame; }; -// Callbacks run on moq-c's runtime thread; main waits on the condvar. ctx lives -// on main's stack and moq-c keeps the pointer until each registration's +// Callbacks run on libmoq's runtime thread; main waits on the condvar. ctx lives +// on main's stack and libmoq keeps the pointer until each registration's // terminal (<= 0) callback fires, so main must not return until every one of // them has. Closing the session ends its state registration alone; // moq_origin_follow, moq_consume_catalog and moq_consume_video each @@ -159,7 +159,7 @@ static void on_frame(void *ud, int32_t frame) { // Writes each decoded audio frame to its rendition's files for tone.py, until enough has arrived. // A gap or an encoder end before then fails the run, as the Rust client does. -// Runs on moq-c's runtime thread, the only writer, so the files need no lock. +// Runs on libmoq's runtime thread, the only writer, so the files need no lock. static void on_audio(void *ud, int32_t id) { audio_t *a = (audio_t *)ud; ctx_t *c = a->ctx; @@ -454,7 +454,7 @@ static void on_finish_health(void *ud, moq_follow_event event, int32_t broadcast // The context whose session a failure closes, once connected. static ctx_t *failing; -// Report a failure and exit 1, for the paths where moq-c still holds &ctx. +// Report a failure and exit 1, for the paths where libmoq still holds &ctx. // // _exit rather than a return: it leaves main's frame (and so ctx) intact for the // callbacks still pointing at it, which is what the failure paths want. Only the @@ -622,7 +622,7 @@ int main(int argc, char **argv) { return 1; } - // moq-c reads the config during the call alone. + // libmoq reads the config during the call alone. moq_client_config config; memset(&config, 0, sizeof(config)); moq_string versions[1]; @@ -724,7 +724,7 @@ int main(int argc, char **argv) { // The data path succeeded, which is all this interop client verifies. Returning // (rather than _exit) is the other half of what it verifies: an embedder that - // closes and drains gets a clean process exit, with moq-c's runtime thread + // closes and drains gets a clean process exit, with libmoq's runtime thread // still live behind its LazyLock. drain(&c); if (finish_mode) moq_consume_close((uint32_t)c.finish.health_broadcast); diff --git a/test/interop/interop.sh b/test/interop/interop.sh index 30b6af1260d..51d1b2c3499 100755 --- a/test/interop/interop.sh +++ b/test/interop/interop.sh @@ -5,7 +5,7 @@ # public registry to catch packaging breakage), this builds every client from # the workspace source. It proves the code in the tree interoperates across # implementations before anything is published: a relay built from rs/moq-relay, -# clients built from rs/moq-cli, py/, go/, cpp/moq, js/, and rs/moq-c, all +# clients built from rs/moq-cli, py/, go/, cpp/moq, js/, and rs/libmoq, all # talking to each other. There's no apt/brew/npm/PyPI here, just # cargo/bun/uv/go/cmake/cc. # @@ -83,7 +83,7 @@ FINISH_ONLY=0 VERSIONS="auto" IETF_VERSIONS="moq-transport-18,moq-transport-20,moq-transport-22" -# Cargo profile for the relay/cli/moq-c builds. Debug compiles faster, which is +# Cargo profile for the relay/cli/libmoq builds. Debug compiles faster, which is # what an interop test wants; the workload (320x240@30) is trivial either way. PROFILE="${INTEROP_PROFILE:-debug}" @@ -275,7 +275,7 @@ COMPAT=0 [[ -n "${INTEROP_VERSION:-}" ]] && COMPAT=1 # The clients that print the grant they received as an `auth granted` line. The -# Python, Go, and C++ clients read it through moq-ffi; moq-c's frozen ABI and +# Python, Go, and C++ clients read it through moq-ffi; libmoq's frozen ABI and # GStreamer expose none, and the browser's shared connection keeps its session private. # Grants are checked on $AUTH_VERSION, so only in the `auto` pass. prints_grant() { @@ -599,7 +599,7 @@ require_tools() { exit 1 fi # Resolve the cargo target dir once (honors a custom CARGO_TARGET_DIR, which - # the self-hosted CI runner sets), so the built binaries and moq-c's header + # the self-hosted CI runner sets), so the built binaries and libmoq's header # are found wherever cargo actually writes them. TARGET_BASE=$(cargo metadata --format-version 1 --manifest-path "$WORKSPACE/Cargo.toml" --no-deps | sed -n 's/.*"target_directory":"\([^"]*\)".*/\1/p') @@ -789,7 +789,7 @@ prepare_cpp() { CPP_INTEROP="$build/client/cpp-interop" } -# Build moq-c (the C staticlib + cbindgen header) and compile the C subscriber +# Build libmoq (the C staticlib + cbindgen header) and compile the C subscriber # against it. cargo writes libmoq.a to the profile dir, and build.rs writes # moq.h into its OUT_DIR, which only cargo's JSON messages name. prepare_c() { @@ -798,30 +798,30 @@ prepare_c() { mark_broken c "no C compiler ($cc) on PATH" return } - echo "building c client (workspace moq-c + cc)..." + echo "building c client (workspace libmoq + cc)..." local flag=() [[ "$PROFILE" == "release" ]] && flag=(--release) - if ! (cd "$WORKSPACE" && cargo build --locked ${flag[@]+"${flag[@]}"} -p moq-c --message-format=json-render-diagnostics) >"$HARNESS_RUN/c-build.json" 2>"$HARNESS_RUN/c-build.log"; then - mark_broken c "cargo build -p moq-c failed" + if ! (cd "$WORKSPACE" && cargo build --locked ${flag[@]+"${flag[@]}"} -p libmoq --message-format=json-render-diagnostics) >"$HARNESS_RUN/c-build.json" 2>"$HARNESS_RUN/c-build.log"; then + mark_broken c "cargo build -p libmoq failed" sed 's/^/ /' "$HARNESS_RUN/c-build.log" >&2 || true return fi - out_dir=$(grep '"reason":"build-script-executed"' "$HARNESS_RUN/c-build.json" | grep -F '/moq-c#' | + out_dir=$(grep '"reason":"build-script-executed"' "$HARNESS_RUN/c-build.json" | grep -F '/libmoq#' | sed -n 's/.*"out_dir":"\([^"]*\)".*/\1/p' | tail -1) || true header="$out_dir/include/moq.h" lib="$TARGET_BASE/$PROFILE/libmoq.a" [[ -f "$header" && -f "$lib" ]] || { - mark_broken c "moq-c artifacts missing ($header / $lib)" + mark_broken c "libmoq artifacts missing ($header / $lib)" return } harness_stage c/include/moq.h "$header" harness_stage c/libmoq.a "$lib" # cargo can't inject libmoq.a's native deps into an external link, so read - # them from the same list moq-c.pc and CMake use. + # them from the same list moq.pc and CMake use. local native_libs case "$(uname -s)" in - Darwin) native_libs="$WORKSPACE/rs/moq-c/native-libs/apple.txt" ;; - *) native_libs="$WORKSPACE/rs/moq-c/native-libs/linux.txt" ;; + Darwin) native_libs="$WORKSPACE/rs/libmoq/native-libs/apple.txt" ;; + *) native_libs="$WORKSPACE/rs/libmoq/native-libs/linux.txt" ;; esac os_libs=() while read -r entry; do diff --git a/test/interop/staging.test.py b/test/interop/staging.test.py index 6584924d921..d8188db06d7 100644 --- a/test/interop/staging.test.py +++ b/test/interop/staging.test.py @@ -57,8 +57,8 @@ def setUp(self): while [[ "$1" != --target-dir ]]; do shift; done mkdir -p "$2/debug" cp "$FIXTURE_TARGET/adapter" "$2/debug/compat-container" - elif [[ "$*" == *'-p moq-c'* ]]; then - printf '{"reason":"build-script-executed","package_id":"/moq-c#0.0.0","out_dir":"%s/header"}\n' \ + elif [[ "$*" == *'-p libmoq'* ]]; then + printf '{"reason":"build-script-executed","package_id":"/libmoq#0.0.0","out_dir":"%s/header"}\n' \ "$FIXTURE_TARGET" fi ;; diff --git a/test/justfile b/test/justfile index 1dfd24d35fc..d224aaafa58 100644 --- a/test/justfile +++ b/test/justfile @@ -60,7 +60,7 @@ harness: # relay and runs the publisher x subscriber matrix. Default: rust only (fast # sanity check). `interop --all` runs the full matrix: rust + python + go + # browser + C++ publish; everyone subscribes (incl. native node/bun JS, the -# moq-c C client, and the GStreamer moqsrc plugin). Other flags pass through, e.g. +# libmoq C client, and the GStreamer moqsrc plugin). Other flags pass through, e.g. # `just test interop --publishers rust,python --subscribers rust,c`. # Finite track tails run too; `--tail` selects just the CLI FETCH close and Rust/Node/Bun tail checks. # `--versions ietf` reruns them with every client pinned to each even moq-transport draft.