diff --git a/.claude/settings.json b/.claude/settings.json index 29502e75533..6f57fddf56f 100644 --- a/.claude/settings.json +++ b/.claude/settings.json @@ -22,7 +22,7 @@ "Bash(cargo *)", "Bash(bun *)", "Bash(ffprobe:*)", - "Bash(rs/libmoq/build.sh:*)", + "Bash(rs/moq-c/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 4180d6bd844..21fb6e0f224 100644 --- a/.github/workflows/alert.yml +++ b/.github/workflows/alert.yml @@ -31,7 +31,7 @@ on: - Cachix - Docker - Interop - - libmoq + - moq-c - moq-cli - moq-gst - moq-relay diff --git a/.github/workflows/cachix.yml b/.github/workflows/cachix.yml index 7b54d5f2e74..0e029232464 100644 --- a/.github/workflows/cachix.yml +++ b/.github/workflows/cachix.yml @@ -6,7 +6,7 @@ on: - 'moq-relay-v*' - 'moq-cli-v*' - 'moq-boy-v*' - - 'libmoq-v*' + - 'moq-c-v*' - 'moq-gst-v*' jobs: @@ -43,7 +43,7 @@ jobs: env: REF_NAME: ${{ github.ref_name }} run: | - re='^(moq-relay|moq-cli|moq-boy|libmoq|moq-gst)-v([0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?)$' + re='^(moq-relay|moq-cli|moq-boy|moq-c|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/.github/workflows/interop.yml b/.github/workflows/interop.yml index 8fe97dd4f40..c39deacdee2 100644 --- a/.github/workflows/interop.yml +++ b/.github/workflows/interop.yml @@ -70,7 +70,7 @@ jobs: extra-trusted-public-keys = kixelated.cachix.org-1:CmFcV0lyM6KuVM2m9mih0q4SrAa0XyCsiM7GHrz3KKk= # Reuse ~/.cargo + ./target across nightly runs so only changed crates - # recompile (the relay, cli, moq-ffi, and libmoq all build from source). + # recompile (the relay, cli, moq-ffi, and moq-c all build from source). - name: Rust cache uses: Swatinem/rust-cache@f0d9c3887740aee45f6153b24b3a6b815192ec16 # v2 with: diff --git a/.github/workflows/libmoq.yml b/.github/workflows/moq-c.yml similarity index 84% rename from .github/workflows/libmoq.yml rename to .github/workflows/moq-c.yml index 7eb12759de1..c2cf06b6f90 100644 --- a/.github/workflows/libmoq.yml +++ b/.github/workflows/moq-c.yml @@ -1,9 +1,9 @@ -name: libmoq +name: moq-c on: push: tags: - - "libmoq-v*" + - "moq-c-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,12 +55,12 @@ jobs: - name: Parse version id: parse shell: bash - run: .github/scripts/release.sh parse-version libmoq + run: .github/scripts/release.sh parse-version moq-c - name: Build and package shell: bash run: | - ./rs/libmoq/build.sh \ + ./rs/moq-c/build.sh \ --target ${{ matrix.target }} \ --version ${{ steps.parse.outputs.version }} \ --output dist @@ -68,7 +68,7 @@ jobs: - name: Upload artifact uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 with: - name: libmoq-${{ matrix.target }} + name: moq-c-${{ matrix.target }} path: dist/* release: @@ -87,11 +87,11 @@ jobs: - name: Parse version id: parse - run: .github/scripts/release.sh parse-version libmoq + run: .github/scripts/release.sh parse-version moq-c - name: Find previous tag id: prev_tag - run: .github/scripts/release.sh prev-tag libmoq + run: .github/scripts/release.sh prev-tag moq-c - name: Download artifacts uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8 @@ -103,14 +103,14 @@ jobs: env: GH_TOKEN: ${{ github.token }} RELEASE_TAG: ${{ github.ref_name }} - RELEASE_TITLE: "libmoq v${{ steps.parse.outputs.version }}" + RELEASE_TITLE: "moq-c v${{ steps.parse.outputs.version }}" RELEASE_PREV_TAG: ${{ steps.prev_tag.outputs.tag }} run: .github/scripts/release.sh create artifacts - # The OBS plugin (cpp/obs) statically links libmoq, so it ships with every - # libmoq release: rebuild it against the release we just published (no + # The OBS plugin (cpp/obs) statically links moq-c, so it ships with every + # moq-c release: rebuild it against the release we just published (no # second cargo build, guaranteed-matching ABI) and cut a parallel - # obs-moq-v release. Runs after `release` so the libmoq archives + # obs-moq-v release. Runs after `release` so the moq-c archives # the plugin's CMake fetches are already live. obs-build: name: OBS plugin (${{ matrix.target }}) @@ -140,17 +140,17 @@ jobs: - name: Parse version id: parse shell: bash - run: .github/scripts/release.sh parse-version libmoq + run: .github/scripts/release.sh parse-version moq-c # Native Xcode / Visual Studio; libobs/Qt6/ffmpeg come from the obs-deps - # bundle and libmoq from the release we just published (--libmoq-release). + # bundle and moq-c from the release we just published (--moq-c-release). - name: Build and package shell: bash env: TARGET: ${{ matrix.target }} VERSION: ${{ steps.parse.outputs.version }} run: | - ./cpp/obs/build.sh --target "$TARGET" --libmoq-release "$VERSION" --output dist + ./cpp/obs/build.sh --target "$TARGET" --moq-c-release "$VERSION" --output dist - name: Upload artifact uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 @@ -173,10 +173,10 @@ jobs: - name: Parse version id: parse - run: .github/scripts/release.sh parse-version libmoq + run: .github/scripts/release.sh parse-version moq-c - # Only the obs-moq archives: the libmoq-* artifacts from the build job - # belong to the libmoq release, not this one. + # Only the obs-moq archives: the moq-c-* artifacts from the build job + # belong to the moq-c release, not this one. - name: Download artifacts uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8 with: @@ -185,7 +185,7 @@ jobs: merge-multiple: true # release.sh prev-tag keys off the current tag, but the trigger here is a - # libmoq-v* tag, so it can't find the previous obs-moq tag. Take the + # moq-c-v* tag, so it can't find the previous obs-moq tag. Take the # newest existing obs-moq tag (excluding this version, for safe re-runs) # so the release notes span only since the last obs-moq release. - name: Find previous obs-moq tag diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index d15d3ff9141..74a28f48858 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -90,8 +90,8 @@ jobs: if: ${{ !cancelled() }} run: nix develop --command just rs audit - # The OBS plugin and libmoq's C fixtures are the only things that link - # libmoq.a from outside cargo, so a stale `rs/libmoq/native-libs/*.txt` + # The OBS plugin and moq-c's C fixtures are the only things that link + # libmoq.a from outside cargo, so a stale `rs/moq-c/native-libs/*.txt` # breaks them and nothing else. obs.yml lists the inputs that can do that, # but a list of paths can't be complete: a build script emitting # `cargo::rustc-link-lib` needs no manifest change, and widening that @@ -102,7 +102,7 @@ jobs: if: ${{ !cancelled() }} run: nix develop --command just obs ci - - name: libmoq C fixtures + - name: moq-c C fixtures if: ${{ !cancelled() }} run: nix develop --command just rs c-tests @@ -190,9 +190,9 @@ jobs: contents: write id-token: write - release-libmoq: - name: libmoq - uses: ./.github/workflows/libmoq.yml + release-moq-c: + name: moq-c + uses: ./.github/workflows/moq-c.yml permissions: contents: write @@ -308,8 +308,8 @@ jobs: # encode/decode and its ScreenCaptureKit / AVFoundation capture, plus # moq-audio's ScreenCaptureKit system audio and its TCC permission pre-check. # The Linux gate skips all of it. moq-video has a release-time backstop, since - # libmoq's `libmoq-v*` tag build compiles it on Apple Silicon, but moq-audio - # has none: libmoq and moq-ffi take it codecs-only, so no release build ever + # moq-c's `moq-c-v*` tag build compiles it on Apple Silicon, but moq-audio + # has none: moq-c and moq-ffi take it codecs-only, so no release build ever # compiles its capture backend. # # Same shape as `windows` and for the same reasons: a separate job because it diff --git a/.github/workflows/obs.yml b/.github/workflows/obs.yml index 4433d39ec8e..33fe97214fe 100644 --- a/.github/workflows/obs.yml +++ b/.github/workflows/obs.yml @@ -6,13 +6,13 @@ name: OBS # # Linux is the platform that needs no bundle at all -- nixpkgs has obs-studio, # Qt6 and ffmpeg, so the dev shell is the whole dependency set. The plugin is -# platform-independent C++ over libmoq's C ABI, so a Linux compile catches the +# platform-independent C++ over moq-c's C ABI, so a Linux compile catches the # breakage a macOS developer would otherwise ship uncompiled. # -# Narrow trigger, like swift.yml: the plugin's own sources, the libmoq header +# Narrow trigger, like swift.yml: the plugin's own sources, the moq-c header # they call through, and the flake that supplies the toolchain. # -# libmoq's own C fixtures (`just rs c-tests`) run here too. They link libmoq.a +# moq-c's own C fixtures (`just rs c-tests`) run here too. They link libmoq.a # from outside cargo the same way, which is too slow for nextest's hang budget # and needs the debug staticlib this job has just built, so this is the one # PR gate that already has everything they need. They also compile the C doc @@ -20,13 +20,13 @@ name: OBS # # The manifests and Cargo.lock are in there for the one way a crate the plugin # never names can break it: linking libmoq.a from outside cargo needs the native -# libraries in `rs/libmoq/native-libs/*.txt`, which are maintained by hand. A +# libraries in `rs/moq-c/native-libs/*.txt`, 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. # # Manifests and build scripts rather than Cargo.lock alone, because neither a -# feature toggle nor a build script has to touch the lockfile. libmoq takes +# feature toggle nor a build script has to touch the lockfile. moq-c takes # moq-native with default features, so flipping one of those defaults on # (`jemalloc` gates `dep:tikv-jemallocator`) changes what libmoq.a needs at link # time while Cargo.lock stays byte-identical, since moq-relay already put that @@ -49,7 +49,7 @@ on: types: [opened, synchronize, reopened, closed] paths: - "cpp/obs/**" - - "rs/libmoq/**" + - "rs/moq-c/**" - "doc/lib/c/**" - "doc/lib/samples.sh" - "rs/**/Cargo.toml" @@ -94,7 +94,7 @@ jobs: # cache.yml warms the default-branch store on `main`. Pull requests restore # it; the action refuses to publish from a pull request. It holds - # dev-profile artifacts, which is why `just obs ci` builds libmoq in debug + # dev-profile artifacts, which is why `just obs ci` builds moq-c in debug # rather than the preset's release. - name: Rust cache uses: ./.github/actions/rust-cache @@ -106,5 +106,5 @@ jobs: # The plugin build above already produced the debug libmoq.a, so the # cargo step inside is a no-op and this is just a cc and a run. - - name: libmoq C fixtures + - name: moq-c C fixtures run: nix develop --command just rs c-tests diff --git a/.vscode/settings.json b/.vscode/settings.json index 9b4563f0bc7..ae9bff02ba9 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/libmoq" + "cmake.sourceDirectory": "./rs/moq-c" } diff --git a/AGENTS.md b/AGENTS.md index 494dbdaa8fb..b0a5fd95f8c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -93,7 +93,7 @@ These diff the branch against its base and only run the affected packages. | Change in | Also update | |---|---| -| `rs/moq-ffi` | `rs/libmoq`, `{py,swift,kt,dart}/`, `go/wrapper/moq/*.go` (the `go/ffi` and `dart/moq_ffi` bindings regenerate automatically, but a new method needs a hand-written wrapper too, like `py/moq-rs` or `dart/moq`), `doc/lib/{py,swift,kt,go,dart,c}` | +| `rs/moq-ffi` | `rs/moq-c`, `{py,swift,kt,dart}/`, `go/wrapper/moq/*.go` (the `go/ffi` and `dart/moq_ffi` bindings regenerate automatically, but a new method needs a hand-written wrapper too, like `py/moq-rs` or `dart/moq`), `doc/lib/{py,swift,kt,go,dart,c}` | | `rs/moq-net` wire/API | `js/net`, `doc/concept`, `drafts/draft-lcurley-moq-lite.md` (if the wire spec changes) | | `rs/hang` catalog/container | `js/hang`, `doc/concept`, `drafts/draft-lcurley-moq-hang.md` (if the format spec changes) | | `rs/moq-token` | `js/token` | @@ -102,7 +102,7 @@ These diff the branch against its base and only run the affected packages. | `rs/moq-cli` | `doc/bin/cli.md` | | `rs/moq-token-cli` | `doc/bin/relay/auth.md`, `doc/lib/rs/moq-token.md`, `doc/lib/rs/index.md` | | `rs/moq-gst` | `doc/bin/gstreamer.md` | -| `rs/libmoq` C ABI (`moq.h`) | `cpp/obs/src`, `doc/bin/obs.md` | +| `rs/moq-c` C ABI (`moq.h`) | `cpp/obs/src`, `doc/bin/obs.md` | | `js/{watch,publish}` UI/API | `demo/web` if it consumes the API | | a kramdown-rfc construct new to `drafts/` | `doc/.vitepress/drafts.ts`, which translates the drafts into `/draft/` site pages | diff --git a/Cargo.lock b/Cargo.lock index 9956f06f49c..baa24b6ed32 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3885,26 +3885,6 @@ checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" [[package]] name = "libmoq" version = "0.6.6" -dependencies = [ - "anyhow", - "bytes", - "cbindgen", - "hang", - "kio 0.6.0", - "moq-audio", - "moq-json", - "moq-loc", - "moq-mux", - "moq-net", - "moq-tokio", - "moq-video", - "pollster", - "serde_json", - "thiserror 2.0.21", - "tokio", - "tracing", - "url", -] [[package]] name = "libredox" @@ -4281,6 +4261,30 @@ dependencies = [ "usage-rs", ] +[[package]] +name = "moq-c" +version = "0.7.0" +dependencies = [ + "anyhow", + "bytes", + "cbindgen", + "hang", + "kio 0.6.0", + "moq-audio", + "moq-json", + "moq-loc", + "moq-mux", + "moq-net", + "moq-tokio", + "moq-video", + "pollster", + "serde_json", + "thiserror 2.0.21", + "tokio", + "tracing", + "url", +] + [[package]] name = "moq-cli" version = "0.12.6" diff --git a/Cargo.toml b/Cargo.toml index 5f9dcd44315..1a38ee49ca7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,7 @@ members = [ "rs/moq-bench", "rs/moq-binary", "rs/moq-boy", + "rs/moq-c", "rs/moq-cli", "rs/moq-e2ee", "rs/moq-ffi", @@ -44,7 +45,7 @@ members = [ default-members = [ "rs/kio", "rs/hang", - # "rs/libmoq", # requires C toolchain + # "rs/moq-c", # requires C toolchain "rs/moq-archive", "rs/moq-auth", "rs/moq-boy", @@ -186,7 +187,7 @@ moq-vaapi = "0.1.0" # 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 libmoq opt NVIDIA, OpenH264, and VAAPI back in. +# that argument, so moq-ffi and moq-c opt NVIDIA, OpenH264, and VAAPI back in. moq-video = { version = "0.1.5", path = "rs/moq-video", default-features = false } nix = { version = "0.31.3", features = ["net", "socket", "uio"] } # Upstream noq-proto, only for iroh's controller factory types. diff --git a/README.md b/README.md index 1da6f968779..44a44fc2da8 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ This repository provides both [Rust](rs) and [TypeScript](js) libraries with sim | [moq-relay](rs/moq-relay) | A clusterable relay server. This relay performs fan-out connecting multiple clients and servers together. | | | [moq-auth](rs/moq-auth) | The authorization contract `moq-relay` speaks: requests, grants, leases, and the JWT that rides them. `moq auth` is the CLI. | [![docs.rs](https://docs.rs/moq-auth/badge.svg)](https://docs.rs/moq-auth) | | [moq-tokio](rs/moq-tokio) | Opinionated helpers to configure a Quinn QUIC endpoint. It's harder than it should be. | [![docs.rs](https://docs.rs/moq-tokio/badge.svg)](https://docs.rs/moq-tokio) | -| [libmoq](rs/libmoq) | C bindings for `moq-net`. | [![docs.rs](https://docs.rs/libmoq/badge.svg)](https://docs.rs/libmoq) | +| [moq-c](rs/moq-c) | C bindings for `moq-net`. | [![docs.rs](https://docs.rs/moq-c/badge.svg)](https://docs.rs/moq-c) | | [hang](rs/hang) | Media-specific encoding/streaming layered on top of `moq-net`. Can be used as a library. | [![docs.rs](https://docs.rs/hang/badge.svg)](https://docs.rs/hang) | | [moq-cli](rs/moq-cli) | A CLI for publishing media to MoQ relays. | | | [moq-mux](rs/moq-mux) | Media muxers and demuxers (fMP4/CMAF, HLS) for importing content into MoQ broadcasts. | [![docs.rs](https://docs.rs/moq-mux/badge.svg)](https://docs.rs/moq-mux) | @@ -144,4 +144,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. `libmoq` 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. `moq-c` and the other moq crates remain MIT/Apache. diff --git a/cpp/obs/CMakeLists.txt b/cpp/obs/CMakeLists.txt index 636b2ea81af..b24656608b2 100644 --- a/cpp/obs/CMakeLists.txt +++ b/cpp/obs/CMakeLists.txt @@ -1,20 +1,20 @@ cmake_minimum_required(VERSION 3.28) -# Build the in-tree libmoq by default. Release-only builds clear MOQ_LOCAL and +# Build the in-tree moq-c by default. Release-only builds clear MOQ_LOCAL and # must select the published archive explicitly, so this never silently drifts # to an old static version. -set(MOQ_LOCAL "${CMAKE_CURRENT_SOURCE_DIR}/../.." CACHE PATH "Path to the moq repo (builds rs/libmoq in-tree)") -set(MOQ_VERSION "" CACHE STRING "Published libmoq version (required without MOQ_LOCAL)") +set(MOQ_LOCAL "${CMAKE_CURRENT_SOURCE_DIR}/../.." CACHE PATH "Path to the moq repo (builds rs/moq-c in-tree)") +set(MOQ_VERSION "" CACHE STRING "Published moq-c version (required without MOQ_LOCAL)") # One predicate for both the version derivation here and the link/fetch choice # below, so the two can't drift apart. set(_moq_local_build FALSE) -if(MOQ_LOCAL AND EXISTS "${MOQ_LOCAL}/rs/libmoq/CMakeLists.txt") +if(MOQ_LOCAL AND EXISTS "${MOQ_LOCAL}/rs/moq-c/CMakeLists.txt") set(_moq_local_build TRUE) endif() if(_moq_local_build) - set(_moq_manifest "${MOQ_LOCAL}/rs/libmoq/Cargo.toml") + set(_moq_manifest "${MOQ_LOCAL}/rs/moq-c/Cargo.toml") file(STRINGS "${_moq_manifest}" _moq_version_lines REGEX "^version = \"[^\"]+\"$") list(LENGTH _moq_version_lines _moq_version_count) if(NOT _moq_version_count EQUAL 1) @@ -24,7 +24,7 @@ if(_moq_local_build) string(REGEX REPLACE "^version = \"([^\"]+)\"$" "\\1" _moq_link_version "${_moq_version_line}") else() if(NOT MOQ_VERSION) - message(FATAL_ERROR "MOQ_VERSION is required when MOQ_LOCAL does not contain rs/libmoq") + message(FATAL_ERROR "MOQ_VERSION is required when MOQ_LOCAL does not contain rs/moq-c") endif() set(_moq_link_version "${MOQ_VERSION}") endif() @@ -67,28 +67,28 @@ endif() target_link_libraries(obs-moq PRIVATE OBS::libobs) if(_moq_local_build) - add_subdirectory("${MOQ_LOCAL}/rs/libmoq" moq) - target_link_libraries(obs-moq PRIVATE moq) + add_subdirectory("${MOQ_LOCAL}/rs/moq-c" moq) + target_link_libraries(obs-moq PRIVATE moq::c) else() include(FetchContent) FetchContent_Declare( moq URL - https://github.com/moq-dev/moq/releases/download/libmoq-v${_moq_link_version}/moq-${_moq_link_version}-${MOQ_TARGET}.${MOQ_ARCHIVE} + https://github.com/moq-dev/moq/releases/download/moq-c-v${_moq_link_version}/moq-c-${_moq_link_version}-${MOQ_TARGET}.${MOQ_ARCHIVE} ) FetchContent_MakeAvailable(moq) - find_package(moq REQUIRED PATHS ${moq_SOURCE_DIR} NO_DEFAULT_PATH) - target_link_libraries(obs-moq PRIVATE moq::moq) + find_package(moq-c REQUIRED PATHS ${moq_SOURCE_DIR} NO_DEFAULT_PATH) + target_link_libraries(obs-moq PRIVATE moq::c) endif() -# libmoq is a Rust static library; its std runtime pulls in symbols from Windows +# moq-c is a Rust static library; its std runtime pulls in symbols from Windows # system libraries (e.g. NtCreateNamedPipeFile from ntdll) that MSVC does not # auto-resolve when the archive is linked into this module. These are the OS # import libraries reported by `rustc --print native-static-libs` that aren't # linked by default; they resolve by name from the Windows SDK (no hard-coded -# paths). The libmoq package config also declares these, but linking them here -# keeps the plugin buildable against any libmoq (local dev tree or prebuilt +# paths). The moq-c package config also declares these, but linking them here +# keeps the plugin buildable against any moq-c (local dev tree or prebuilt # release) whose config may predate that declaration. Duplicate links are # harmless. if(WIN32) diff --git a/cpp/obs/README.md b/cpp/obs/README.md index 2c16160fec6..e5aff1fd1b7 100644 --- a/cpp/obs/README.md +++ b/cpp/obs/README.md @@ -3,7 +3,7 @@ An OBS Studio plugin for publishing to and subscribing from MoQ relays. It loads into a stock OBS Studio install (no OBS source build required) and links -`libmoq`, built from the in-tree [`rs/libmoq`](../../rs/libmoq) crate. +`moq-c`, built from the in-tree [`rs/moq-c`](../../rs/moq-c) crate. Build instructions for each platform live in [`doc/bin/obs.md`](../../doc/bin/obs.md). In short, from the repo root: diff --git a/cpp/obs/build.sh b/cpp/obs/build.sh index dfa153c6de9..64a5f0baa85 100755 --- a/cpp/obs/build.sh +++ b/cpp/obs/build.sh @@ -36,16 +36,16 @@ while [[ $# -gt 0 ]]; do OUTPUT_DIR="$2" shift 2 ;; - --libmoq-release) - # Link a published libmoq release of this version instead of - # building rs/libmoq from source. CMake fetches the matching - # moq-- archive from the GitHub release and the - # plugin is versioned to match. Used by CI on a libmoq-v* tag. + --moq-c-release) + # Link a published moq-c release of this version instead of + # building rs/moq-c from source. CMake fetches the matching + # moq-c-- archive from the GitHub release and the + # plugin is versioned to match. Used by CI on a moq-c-v* tag. MOQ_RELEASE="$2" shift 2 ;; -h | --help) - echo "Usage: $0 [--target TARGET] [--version VERSION] [--output DIR] [--libmoq-release VERSION]" + echo "Usage: $0 [--target TARGET] [--version VERSION] [--output DIR] [--moq-c-release VERSION]" exit 0 ;; *) @@ -55,7 +55,7 @@ while [[ $# -gt 0 ]]; do esac done -# In libmoq-release mode the plugin version tracks the libmoq version. +# In moq-c-release mode the plugin version tracks the moq-c version. if [[ -n "$MOQ_RELEASE" ]]; then VERSION="$MOQ_RELEASE" fi @@ -112,7 +112,7 @@ if [[ -n "$MOQ_RELEASE" ]]; then # Empty MOQ_LOCAL forces CMake's release-download branch; MOQ_VERSION and # MOQ_TARGET steer it at this target's archive. MOQ_ARCHIVE is correct per # preset already. - echo "Linking libmoq release v$MOQ_RELEASE ($TARGET)" + echo "Linking moq-c release v$MOQ_RELEASE ($TARGET)" CONFIGURE_ARGS+=(-DMOQ_LOCAL= "-DMOQ_VERSION=$MOQ_RELEASE" "-DMOQ_TARGET=$TARGET") fi cmake --preset "$PRESET" ${CONFIGURE_ARGS[@]+"${CONFIGURE_ARGS[@]}"} diff --git a/cpp/obs/cmake/common/bootstrap.cmake b/cpp/obs/cmake/common/bootstrap.cmake index c38b7d029a8..4420dbbb8e4 100644 --- a/cpp/obs/cmake/common/bootstrap.cmake +++ b/cpp/obs/cmake/common/bootstrap.cmake @@ -52,8 +52,8 @@ string(JSON _email GET ${buildspec} email) string(JSON _version GET ${buildspec} version) string(JSON _bundleId GET ${buildspec} platformConfig macos bundleId) -# Release CI builds the plugin against a specific libmoq release and versions it -# to match (see build.sh --libmoq-release), so allow overriding the buildspec +# Release CI builds the plugin against a specific moq-c release and versions it +# to match (see build.sh --moq-c-release), so allow overriding the buildspec # version. Everything below derives PLUGIN_VERSION_* from _version. if(DEFINED PLUGIN_VERSION_OVERRIDE AND NOT PLUGIN_VERSION_OVERRIDE STREQUAL "") set(_version "${PLUGIN_VERSION_OVERRIDE}") diff --git a/cpp/obs/justfile b/cpp/obs/justfile index 1c1f59ed108..91259c32052 100644 --- a/cpp/obs/justfile +++ b/cpp/obs/justfile @@ -10,7 +10,7 @@ # libobs/Qt6/ffmpeg via buildspec.json (obs-deps). # Windows: needs Visual Studio 2022; same buildspec download (run from Git Bash). # -# libmoq is built from the in-tree crate (rs/libmoq) via cargo. MOQ_LOCAL points +# moq-c is built from the in-tree crate (rs/moq-c) via cargo. MOQ_LOCAL points # CMake at the repo root by default, so there's no prebuilt release to download. set quiet @@ -20,7 +20,7 @@ default: just --list # Configure via CMake presets. MOQ_LOCAL defaults to the repo root inside -# CMakeLists.txt (so libmoq builds from rs/libmoq); pass `path=/some/moq` to +# CMakeLists.txt (so moq-c builds from rs/moq-c); pass `path=/some/moq` to # override. We deliberately don't compute the path here: `justfile_directory()` # resolves to the root justfile when this runs as `just obs setup`, so the @@ -75,7 +75,7 @@ run: # ENABLE_QT and ENABLE_FRONTEND_API are on, so the definitions they gate on are # set here to match. # -# test/ is in scope because each test file defines the libmoq entry points the +# test/ is in scope because each test file defines the moq-c entry points the # plugin calls, so a signature that drifts from the generated moq.h is a # conflicting C declaration. Catching that needs only headers, which is why it # belongs here: `just obs ci` finds the same drift, but only where obs.yml's @@ -110,7 +110,7 @@ compile: ffmpeg=$(pkg-config --cflags libavcodec libavutil libswscale libswresample) # MOQ_VERSION_STRING only reaches a label in the dock, so any value - # type-checks the same; CMake stamps the real libmoq version. + # type-checks the same; CMake stamps the real moq-c version. status=0 for source in src/*.cpp test/*.cpp; do # shellcheck disable=SC2086 @@ -137,7 +137,7 @@ compile: # gates a merge. # # CMAKE_BUILD_TYPE overrides the preset's RelWithDebInfo because the Rust cache -# CI restores holds dev-profile artifacts. A release build of libmoq would +# CI restores holds dev-profile artifacts. A release build of moq-c would # rebuild its whole dependency tree on every run, and the gate is about whether # the plugin compiles, which the profile doesn't change. ci preset="": @@ -148,11 +148,11 @@ ci preset="": cmake --build --preset "$PRESET" just _unit -# Print the -I flags for libobs and libmoq, shared by `compile` and `_unit`. +# Print the -I flags for libobs and moq-c, shared by `compile` and `_unit`. # -# moq.h is generated by cbindgen from rs/libmoq/src, so regenerate rather than +# moq.h is generated by cbindgen from rs/moq-c/src, so regenerate rather than # just locating it: a stale header is how a plugin call to a since-changed -# libmoq function type-checks anyway. +# moq-c function type-checks anyway. [private] _includes: #!/usr/bin/env bash @@ -198,21 +198,21 @@ _includes: exit 1 fi - (cd ../.. && cargo check --locked --quiet -p libmoq) + (cd ../.. && cargo check --locked --quiet -p moq-c) - # rs/libmoq/build.rs writes the header into its OUT_DIR, so ask cargo where + # rs/moq-c/build.rs writes the header into its OUT_DIR, so ask cargo where # that is. Replays the check above from cache, so it costs a process rather # than a compile. - out_dir=$(cd ../.. && cargo check --locked -p libmoq --message-format=json | - jq -r 'select(.reason == "build-script-executed") | select(.package_id | tostring | test("libmoq")) | .out_dir' | + out_dir=$(cd ../.. && cargo check --locked -p moq-c --message-format=json | + jq -r 'select(.reason == "build-script-executed") | select(.package_id | tostring | test("/moq-c#")) | .out_dir' | tail -1) if [ -z "$out_dir" ]; then - echo "cargo reported no build script output for libmoq" >&2 + echo "cargo reported no build script output for moq-c" >&2 exit 1 fi moq_include="$out_dir/include" if [ ! -f "$moq_include/moq.h" ]; then - echo "$moq_include/moq.h missing after 'cargo check --locked -p libmoq'" >&2 + echo "$moq_include/moq.h missing after 'cargo check --locked -p moq-c'" >&2 exit 1 fi @@ -220,7 +220,7 @@ _includes: # arguments without splitting on the spaces in a path. printf -- '-I%s\n' src "$obs_include" "$simde_include" "$moq_include" -# Unit-test the plugin sources against stubbed libobs/libmoq/ffmpeg, under +# Unit-test the plugin sources against stubbed libobs/moq-c/ffmpeg, under # ThreadSanitizer. # # Manual, like `just rs macos` and `just rs windows`, because ThreadSanitizer @@ -295,7 +295,7 @@ _unit mode="plain": trap 'rm -rf "$out"' EXIT # One binary per source under test: each test file defines its own libobs and - # libmoq stubs, so two of them can't share a link. Header-only helpers + # moq-c stubs, so two of them can't share a link. Header-only helpers # (quality defaults) build as a third binary with no plugin source. for name in moq-output moq-source; do # shellcheck disable=SC2086 @@ -366,7 +366,7 @@ check: echo "CMake accepted a release build without MOQ_VERSION" >&2 exit 1 fi - if ! grep -Fq "MOQ_VERSION is required when MOQ_LOCAL does not contain rs/libmoq" "$build_dir/configure.log"; then + if ! grep -Fq "MOQ_VERSION is required when MOQ_LOCAL does not contain rs/moq-c" "$build_dir/configure.log"; then cat "$build_dir/configure.log" >&2 exit 1 fi diff --git a/doc/bin/obs.md b/doc/bin/obs.md index a9733f27d1e..bab4d65b729 100644 --- a/doc/bin/obs.md +++ b/doc/bin/obs.md @@ -30,10 +30,10 @@ OBS Studio install. video codec, encoder, and audio codec choices. **Stats** shows the active encoding, negotiated draft, dial scheme, and one minute of RTT, estimated send/receive bandwidth, packet loss, and bytes sent. - **About** lists plugin and libmoq versions, documentation links, and available + **About** lists plugin and moq-c versions, documentation links, and available video encoders. -OBS reports each locally encoded packet's handoff to libmoq against the shared +OBS reports each locally encoded packet's handoff to moq-c against the shared broadcast media clock. Each track's catalog `jitter` is the largest measured delay above that track's own recent minimum, and its `delay` is how far that minimum trails the earliest track, both rounded up to milliseconds. @@ -85,5 +85,5 @@ BBR or loss-based CUBIC), stream limits and timeouts, qlog traces for diagnosing stalls, and the WebSocket fallback race. A rejected value stops the stream with the reason in the log rather than silently using a default. -The plugin is C++ over [libmoq](/lib/c/)'s C ABI and ships with every libmoq +The plugin is C++ over [moq-c](/lib/c/)'s C ABI and ships with every moq-c release. diff --git a/doc/index.md b/doc/index.md index 99cad74bd59..675de42ab2f 100644 --- a/doc/index.md +++ b/doc/index.md @@ -145,7 +145,7 @@ Some highlights: FFI bindings around the Rust core, with idiomatic APIs in each language: -- [C](/lib/c/) - `libmoq` static + shared library with an auto-generated header. +- [C](/lib/c/) - `moq-c` static + shared library with an auto-generated header. - [Python](/lib/py/) - `asyncio`-friendly bindings, published to PyPI. - [Kotlin](/lib/kt/) - Coroutines and `Flow` for Android and the JVM. - [Swift](/lib/swift/) - Async sequences for iOS, iPadOS, and macOS. diff --git a/doc/lib/c/index.md b/doc/lib/c/index.md index ad5702c4718..55295af3544 100644 --- a/doc/lib/c/index.md +++ b/doc/lib/c/index.md @@ -1,40 +1,44 @@ --- title: C -description: libmoq, the stable C ABI over the Rust core +description: moq-c, the stable C ABI over the Rust core --- # 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) +[![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) -`libmoq` exposes MoQ to C, C++, and any language with a C FFI through a +`moq-c` exposes MoQ to C, 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. The -[OBS plugin](/bin/obs) is built on it. +[OBS plugin](/bin/obs) is built on it. It was published as `libmoq` through +0.6; the header and library file names did not change. ## Install -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 +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 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-$ver-$target/lib/pkgconfig" -cc app.c $(pkg-config --cflags --libs --static moq) -o app +export PKG_CONFIG_PATH="moq-c-$ver-$target/lib/pkgconfig" +cc app.c $(pkg-config --cflags --libs --static moq-c) -o app ``` -From source, `add_subdirectory(rs/libmoq)` in CMake gives a `moq` target to -link. A bare `cargo build --release -p libmoq` writes `target/release/libmoq.a`, -and `moq.h` plus `moq.pc` land in the build script's `OUT_DIR` under `include/` +With CMake, point `CMAKE_PREFIX_PATH` at the extracted archive, then +`find_package(moq-c)` and link `moq::c`. + +From source, `add_subdirectory(rs/moq-c)` in CMake gives the same `moq::c` +target. A bare `cargo build --release -p moq-c` writes `target/release/libmoq.a`, +and `moq.h` plus `moq-c.pc` land in the build script's `OUT_DIR` under `include/` and `lib/pkgconfig/`, a hashed path that `--message-format=json` reports as -`out_dir`. That `moq.pc` expects the install layout, with `libmoq.a` in `lib/` +`out_dir`. That `moq-c.pc` expects the install layout, with `libmoq.a` in `lib/` beside `pkgconfig/`. ## Shape of the API -- **Handles and callbacks.** Every object is an integer handle; every async result arrives on a required `moq_status_callback` with a `void *user_data`. A status `> 0` is a live result, `0` a clean close, `< 0` an error, and the last two are terminal: libmoq never touches `user_data` again, so free it there. `*_cancel` only requests shutdown; the terminal callback still fires. +- **Handles and callbacks.** Every object is an integer handle; every async result arrives on a required `moq_status_callback` with a `void *user_data`. A status `> 0` is a live result, `0` a clean close, `< 0` an error, and the last two are terminal: moq-c never touches `user_data` again, so free it there. `*_cancel` only requests shutdown; the terminal callback still fires. - **Errors.** Negative return codes named by `MOQ_ERROR_*` in `moq.h`, with `moq_error()` giving the reason for the last failure on the calling thread. Auth rejections (401, 403) have their own codes so you don't retry them. A protocol failure also fills `moq_error_protocol()` with the session or stream scope, the verbatim wire code, and a known kind; do not parse `moq_error()` for that. - **Threading.** Any function from any thread. Raw publish calls block until the codec takes the frame, which paces a publisher. - **Connection health.** `moq_session_stats()` reports available metrics with per-field validity flags. `moq_session_snapshot()` samples those metrics and the negotiated draft name together from the same connection. Its protocol string is backed by static storage. Both return an offline error between reconnects and leave the destination untouched. `moq_session_bandwidth()` mints an allocator over the send estimate; `moq_bandwidth_reserve` claims a share for an app-owned track, and `moq_encode_video` / `moq_encode_audio` take the same handle so the built-in video encoder follows the grant. @@ -62,7 +66,7 @@ if (session < 0) return fail(moq_error()); ``` -For a locally encoded media track, call `moq_publish_media_flush(media, timestamp_us)` after `moq_publish_media_frame` with the same broadcast-clock PTS. The monotonic handoff time is sampled inside libmoq. Do not call it for file, pipe, or network imports; those remain clock-free. Invalid handles and unrepresentable timestamps return a negative error code. +For a locally encoded media track, call `moq_publish_media_flush(media, timestamp_us)` after `moq_publish_media_frame` with the same broadcast-clock PTS. The monotonic handoff time is sampled inside moq-c. Do not call it for file, pipe, or network imports; those remain clock-free. Invalid handles and unrepresentable timestamps return a negative error code. Call `moq_publish_media_discontinuity(media)` when the source seeks, pauses, or changes its time base. It publishes a timeline marker and restarts handoff measurement without lowering advertised jitter. Resume with timestamps that continue forward on the broadcast media clock; this does not permit timestamp rewinds. @@ -86,7 +90,7 @@ reports few or none. | `packets_lost` | datagrams | Total datagrams detected as lost. | The header is the reference; each function carries a doc comment. Source and -a worked example: [`rs/libmoq`](https://github.com/moq-dev/moq/tree/main/rs/libmoq), -API docs on [docs.rs/libmoq](https://docs.rs/libmoq). +a worked example: [`rs/moq-c`](https://github.com/moq-dev/moq/tree/main/rs/moq-c), +API docs on [docs.rs/moq-c](https://docs.rs/moq-c). Raw track publisher metadata has an optional maximum age. Omitting it imposes no publisher age limit; zero keeps the live edge. Local cache limits still apply, and media imports explicitly retain 30 seconds. See [publisher retention](/concept/moq-lite). diff --git a/doc/lib/index.md b/doc/lib/index.md index 27eaf5edd18..d6107028574 100644 --- a/doc/lib/index.md +++ b/doc/lib/index.md @@ -17,7 +17,7 @@ protocol. A publisher in Python is consumable by a subscriber in Swift. | [Python](/lib/py/) | `moq-rs` on PyPI | Scripts, ML pipelines, voice agents. | | [Go](/lib/go/) | `moq.dev/moq` | Go services and tooling. | | [Dart](/lib/dart/) | `moq` on pub.dev | Flutter apps. | -| [C](/lib/c/) | `libmoq` | C/C++ and any language with a C FFI. | +| [C](/lib/c/) | `moq-c` | C/C++ and any language with a C FFI. | ## How they relate @@ -26,7 +26,7 @@ TypeScript is a from-scratch browser implementation. The other six wrap the Rust core: Python, Kotlin, Swift, Go, and Dart 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 -(`libmoq`). A feature added to the core lands in all of them together. +(`moq-c`). A feature added to the core lands in all of them together. ## What every binding can do diff --git a/doc/lib/rs/index.md b/doc/lib/rs/index.md index 3740a3fe736..2a00ac67139 100644 --- a/doc/lib/rs/index.md +++ b/doc/lib/rs/index.md @@ -33,7 +33,7 @@ The reference implementation. Every crate is on | [moq-loc](https://docs.rs/moq-loc), [moq-msf](https://docs.rs/moq-msf) | The IETF LOC container and MSF catalog. | | [moq-stats](https://docs.rs/moq-stats) | Publish and consume relay traffic counters as tracks. | | [moq-hls](https://docs.rs/moq-hls), [moq-rtmp](https://docs.rs/moq-rtmp), [moq-srt](https://docs.rs/moq-srt), [moq-rtc](https://docs.rs/moq-rtc) | The [gateways](/bin/), as libraries you can embed with your own auth. | -| [moq-ffi](https://docs.rs/moq-ffi), [libmoq](/lib/c/) | The UniFFI core behind the language bindings, and the C ABI. | +| [moq-ffi](https://docs.rs/moq-ffi), [moq-c](/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 QUIC/WebTransport/qmux transports, in a sibling repository. | diff --git a/flake.nix b/flake.nix index 028422fd1b9..0efc9eea824 100644 --- a/flake.nix +++ b/flake.nix @@ -440,7 +440,7 @@ moq-relay moq-bench moq-boy - libmoq + moq-c moq-gst ; @@ -537,12 +537,12 @@ checks = { package-source-assets = pkgs.runCommand "package-source-assets" { } '' for asset in \ - rs/libmoq/moq.pc.in \ - rs/libmoq/native-libs/apple.txt \ - rs/libmoq/native-libs/linux.txt \ - rs/libmoq/native-libs/windows.txt + rs/moq-c/moq-c.pc.in \ + rs/moq-c/native-libs/apple.txt \ + rs/moq-c/native-libs/linux.txt \ + rs/moq-c/native-libs/windows.txt do - test -f "${overlayPkgs.libmoq.src}/$asset" + test -f "${overlayPkgs.moq-c.src}/$asset" done test -f "${overlayPkgs.moq-boy.src}/rs/moq-video/src/frame/nv12_resize.ptx" touch "$out" diff --git a/go/ffi/moq/cgo.go b/go/ffi/moq/cgo.go index 8be6f790a68..64ed11c447a 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/libmoq/native-libs/ for C consumers of libmoq; keep the two in step +// lives in rs/moq-c/native-libs/ for C consumers of moq-c; 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 762a46c38d8..871770099f6 100644 --- a/go/wrapper/reconnect_test.go +++ b/go/wrapper/reconnect_test.go @@ -146,7 +146,7 @@ func TestServerCloseReleasesPort(t *testing.T) { defer func() { _ = second.Close() }() } -// A Go worker survives a relay restart the way a libmoq worker does: the session +// A Go worker survives a relay restart the way a moq-c 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 epoch // pairs with Status so a worker can log each reconnect. diff --git a/justfile b/justfile index 9d8af7a6636..d0e8439b254 100644 --- a/justfile +++ b/justfile @@ -456,7 +456,7 @@ _tools $FILES="": # cargo to regenerate moq.h and pkg-config to locate Qt6 and ffmpeg. Every # platform: the plugin type-checks against headers, and the dev shell ships # those even on Darwin, where obs-studio can't build. - scoped '^(cpp/obs/|rs/libmoq/|flake\.nix$)' && tools+=(pkg-config cargo) + scoped '^(cpp/obs/|rs/moq-c/|flake\.nix$)' && tools+=(pkg-config cargo) # `just obs check` lints with clang-format and gersemi, validates the CMake # release configuration, and compares the three OBS pins, one of which moves # on a flake.lock bump alone. @@ -575,13 +575,13 @@ _check $BASE $TEST: just go check "$files" just dart check "$files" # Type-checking the plugin and its unit tests needs only headers, so it - # runs here rather than waiting for obs.yml to link them on Linux. libmoq + # runs here rather than waiting for obs.yml to link them on Linux. moq-c # is in scope because the plugin calls through its generated C header, and # the tests restate those entry points as stubs, so an ABI change breaks # both. flake.nix because it owns the libobs headers this compiles # against -- obs.yml links against nixpkgs' obs-studio instead, so nothing # else would notice that package going bad. - if echo "$files" | grep -qE '^(cpp/obs/|rs/libmoq/|flake\.nix$)'; then + if echo "$files" | grep -qE '^(cpp/obs/|rs/moq-c/|flake\.nix$)'; then just obs compile fi # flake.nix is in scope because `just obs check` is what compares the OBS diff --git a/nix/overlay.nix b/nix/overlay.nix index 961f1e72d67..d82a12f5522 100644 --- a/nix/overlay.nix +++ b/nix/overlay.nix @@ -98,14 +98,14 @@ let cargoExtraArgs = "-p moq-bench"; }; - libmoqInfo = crateInfo ../rs/libmoq/Cargo.toml; + moqCInfo = crateInfo ../rs/moq-c/Cargo.toml; # The native libraries an external linker must pass alongside libmoq.a. - # rs/libmoq/native-libs/ is the single source: build.rs bakes it into moq.pc - # and rs/libmoq/CMakeLists.txt reads it for in-tree consumers. This installPhase + # rs/moq-c/native-libs/ is the single source: build.rs bakes it into moq-c.pc + # and rs/moq-c/CMakeLists.txt reads it for in-tree consumers. This installPhase # substitutes the find_package template directly rather than running CMake, so # format the same list here, matching CMakeLists.txt's MOQ_NATIVE_LIBS_QUOTED. - libmoqNativeLibs = + moqCNativeLibs = let platform = if final.stdenv.hostPlatform.isDarwin then @@ -114,7 +114,7 @@ let "windows" else "linux"; - lines = final.lib.splitString "\n" (builtins.readFile ../rs/libmoq/native-libs/${platform}.txt); + lines = final.lib.splitString "\n" (builtins.readFile ../rs/moq-c/native-libs/${platform}.txt); entries = builtins.filter (line: line != "" && !(final.lib.hasPrefix "#" line)) lines; quote = entry: @@ -125,26 +125,26 @@ let in final.lib.concatMapStringsSep " " quote entries; - libmoqArgs = libmoqInfo // { - # libmoq's build.rs reads moq.pc.in and native-libs/*.txt at compile time to + moqCArgs = moqCInfo // { + # moq-c's build.rs reads moq-c.pc.in and native-libs/*.txt at compile time to # generate the pkgconfig file. craneLib.cleanCargoSource's default filter # drops both, which makes build.rs skip pkgconfig generation (see the - # `if let Ok(template)` in rs/libmoq/build.rs) or fail reading the lib list, - # and the installPhase's `cp .../moq.pc` then fails. + # `if let Ok(template)` in rs/moq-c/build.rs) or fail reading the lib list, + # and the installPhase's `cp .../moq-c.pc` then fails. src = final.lib.cleanSourceWith { src = ../.; name = "source"; filter = path: type: (final.lib.hasSuffix ".pc.in" path) - || (final.lib.hasInfix "/rs/libmoq/native-libs/" path) + || (final.lib.hasInfix "/rs/moq-c/native-libs/" path) || (filterCargoSources path type); }; - cargoExtraArgs = "-p libmoq"; + cargoExtraArgs = "-p moq-c"; doCheck = false; nativeBuildInputs = with final; [ pkg-config - # libmoq is the only nix-built package that pulls moq-video, and its `vaapi` + # moq-c is the only nix-built package that pulls moq-video, and its `vaapi` # feature brings moq-vaapi, whose build.rs runs bindgen over its vendored # libva headers. Sets LIBCLANG_PATH + BINDGEN_EXTRA_CLANG_ARGS so it finds # libclang and the libc headers, same as the devShell in flake.nix. @@ -155,37 +155,37 @@ let # ~75 MB+. Thin LTO with a single codegen unit dead-strips the unused # monomorphizations Rust bakes into a staticlib, halving the artifact # with no source or ABI change, which keeps the release tarball and - # brew download small. Mirrors rs/libmoq/build.sh's Windows cargo path. + # brew download small. Mirrors rs/moq-c/build.sh's Windows cargo path. CARGO_PROFILE_RELEASE_LTO = "thin"; CARGO_PROFILE_RELEASE_CODEGEN_UNITS = "1"; - # libmoq is a staticlib; crane's default install phase only handles + # moq-c is a staticlib; crane's default install phase only handles # binaries. Lay out the artifact tree the way release tarballs and - # downstream `find_package(moq)` consumers already expect. + # downstream `find_package(moq-c)` consumers already expect. installPhase = '' runHook preInstall - mkdir -p $out/lib/pkgconfig $out/include $out/lib/cmake/moq + mkdir -p $out/lib/pkgconfig $out/include $out/lib/cmake/moq-c # Ask cargo's build log where it put things instead of reconstructing the # paths, which a cross --target build moves. build.rs lays out its # OUT_DIR like this prefix, minus the staticlib. jq=${final.lib.getExe final.jq} lib=$($jq -r 'select(.reason == "compiler-artifact") | .filenames[] | select(endswith("/libmoq.a"))' "$cargoBuildLog") - gen=$($jq -r 'select(.reason == "build-script-executed") | select(.package_id | test("libmoq")) | .out_dir' "$cargoBuildLog") + gen=$($jq -r 'select(.reason == "build-script-executed") | select(.package_id | test("/moq-c#")) | .out_dir' "$cargoBuildLog") cp "$lib" $out/lib/ cp "$gen/include/moq.h" $out/include/ - cp "$gen/lib/pkgconfig/moq.pc" $out/lib/pkgconfig/ + cp "$gen/lib/pkgconfig/moq-c.pc" $out/lib/pkgconfig/ - major_version="$(echo "${libmoqInfo.version}" | cut -d. -f1)" - substitute ${../rs/libmoq/cmake/moq-config.cmake.in} \ - $out/lib/cmake/moq/moq-config.cmake \ + major_version="$(echo "${moqCInfo.version}" | cut -d. -f1)" + substitute ${../rs/moq-c/cmake/moq-c-config.cmake.in} \ + $out/lib/cmake/moq-c/moq-c-config.cmake \ --subst-var-by LIB_FILE libmoq.a \ - --subst-var-by VERSION "${libmoqInfo.version}" \ - --subst-var-by MOQ_NATIVE_LIBS_QUOTED ${final.lib.escapeShellArg libmoqNativeLibs} - substitute ${../rs/libmoq/cmake/moq-config-version.cmake.in} \ - $out/lib/cmake/moq/moq-config-version.cmake \ - --subst-var-by VERSION "${libmoqInfo.version}" \ + --subst-var-by VERSION "${moqCInfo.version}" \ + --subst-var-by MOQ_NATIVE_LIBS_QUOTED ${final.lib.escapeShellArg moqCNativeLibs} + 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 "${moqCInfo.version}" \ --subst-var-by MAJOR_VERSION "$major_version" runHook postInstall @@ -300,7 +300,7 @@ in } ); - libmoq = buildPackage libmoqArgs; + moq-c = buildPackage moqCArgs; moq-gst-plugin = buildPackage moqGstPluginArgs; diff --git a/quest/m0/README.md b/quest/m0/README.md index a37d03ba033..da75fd356d6 100644 --- a/quest/m0/README.md +++ b/quest/m0/README.md @@ -62,7 +62,7 @@ Their package boundaries are explicit: - `moq-nvenc` narrows its safe facade around owned resources and completion, while loading and incompatibility become fallible public errors. - Published `moq-mux` gains only the additive shared `rate` namespace. Published - `moq-ffi`, `libmoq`, and language-binding signatures, layouts, and sentinel + `moq-ffi`, `moq-c`, and language-binding signatures, layouts, and sentinel behavior remain unchanged while their internals adapt. The agreed media direction is small, honest APIs: typed PCM layouts, rational diff --git a/quest/m1/README.md b/quest/m1/README.md index fd5463199c6..b682f06727a 100644 --- a/quest/m1/README.md +++ b/quest/m1/README.md @@ -24,13 +24,13 @@ transport, benchmark tooling); worktrees isolate commits, not semantics. - [Track tail interop](/quest/m1/track-tail-interop.md) - a Rust publisher ending a track with a group in flight is read to its end by the JS subscriber, and the reverse, in `just test interop` - [Origin mount](/quest/m1/origin-mount.md) - a session sees a granted subtree from outside its root under a path inside it, read-only - [Interop flakes](/quest/m1/interop-flakes.md) - the interop harness passes with other runs sharing the machine -- [Binding audio delay](/quest/m1/binding-surface.md) - moq-ffi, libmoq, and every wrapper configure and observe audio playout delay +- [Binding audio delay](/quest/m1/binding-surface.md) - moq-ffi, moq-c, and every wrapper configure and observe audio playout delay - [FFI shape](/quest/m1/ffi-shape/README.md) - the bindings mirror Rust's layers: net at the root, then media, json, audio, and video namespaces built from the handle below - [Track demand](/quest/m1/track-demand.md) - Rust and JS watch a track's subscribers through `demand()` alone - [Session close](/quest/m1/session-close.md) - a graceful session end withdraws announces and waits one second for the ack - [Close codes](/quest/m1/close-codes.md) - a client sees the peer's application close code over WebSocket and raw QUIC, like WebTransport - [JS caught up](/quest/m1/js-announce-caught-up.md) - @moq/net's announce consumer says when the initial set has landed, like Rust -- [Bindings caught up](/quest/m1/announce-live-bindings.md) - moq-ffi, libmoq, and every wrapper yield the same flat announce event, `Live` included +- [Bindings caught up](/quest/m1/announce-live-bindings.md) - moq-ffi, moq-c, and every wrapper yield the same flat announce event, `Live` included - [IETF announce count](/quest/m1/ietf-announce-count.md) - an opt-in moq-transport extension carries the replay count, so IETF announce consumers go live without a timer - [Publish delay](/quest/m1/publish-delay.md) - js/publish encoders advertise `delay` behind the earliest rendition, like moq-mux @@ -45,7 +45,7 @@ transport, benchmark tooling); worktrees isolate commits, not semantics. - [In-band auth](/quest/m1/auth/README.md) - a session tells its peer what it may publish and subscribe to, unions tokens presented in band, and fails loud on an out-of-scope publish - [Tests under load](/quest/m1/test-flakes.md) - three tests that time out or run out of file descriptors under `just check` are fixed at the cause - [C++ through moq-ffi](/quest/m1/cpp/README.md) - generated C++ over moq-ffi with futures and expected-style errors, shipped as a tarball, vcpkg, and Conan, and adopted by the OBS plugin -- [moq-c](/quest/m1/moq-c.md) - libmoq ships as `moq-c`, beside `moq-cpp`, with its C header and library unchanged +- [Retire libmoq](/quest/m1/libmoq-retire.md) - the published `libmoq` crate stops after its final release points users at `moq-c` - [OBS native codecs](/quest/m1/obs-moq-video/README.md) - remove FFmpeg decoding dependencies, deliver GPU frames, and use native audio/video encoders - [Opus concealment](/quest/m1/opus-conceal.md) - a lost Opus packet conceals the last packet's length, not 120 ms - [Audio codecs](/quest/m1/audio-codecs/README.md) - platform audio codecs, explicit unsupported cases, and channel layouts up to 7.1 @@ -123,11 +123,11 @@ transport, benchmark tooling); worktrees isolate commits, not semantics. - [FLV script tags](/quest/m1/flv-script.md) - onMetaData and AMF data messages survive RTMP and FLV import - [Release size](/quest/m1/release-size.md) - the release scripts' LTO exports become the workspace release profile, and a nightly report shows what each moq-ffi build ships - [Dart on iOS](/quest/m1/dart-ios.md) - prove the shipped iOS native asset actually loads on a device, which no CI can -- [libmoq shutdown](/quest/m1/libmoq-shutdown.md) - OBS exits cleanly with the plugin loaded: a C ABI `moq_shutdown` stops the libmoq thread before the module is unloaded +- [moq-c shutdown](/quest/m1/libmoq-shutdown.md) - OBS exits cleanly with the plugin loaded: a C ABI `moq_shutdown` stops the moq-c thread before the module is unloaded - [Kotlin JVM exit](/quest/m1/kt-jvm-exit.md) - a Kotlin/JVM program exits cleanly whatever the moq-ffi runtime thread is doing, like Python does since #3766 - [Dart publish](/quest/m1/dart-publish.md) - the packages are built and dry-run clean but exist nowhere consumers can install from - [Dart codec parity](/quest/m1/dart-codecs.md) - Dart is the one binding that cannot originate media -- [libmoq fetch](/quest/m1/libmoq-fetch.md) - libmoq gains an additive cached-group fetch entry point +- [moq-c fetch](/quest/m1/libmoq-fetch.md) - moq-c gains an additive cached-group fetch entry point - [moq-mux on wasm32](/quest/m1/mux-wasm-target.md) - the crate's two wasm blockers are fixed and the target stays in the clippy lane - [#2850](/quest/m1/2850-js-net-give-reader-a-synchronous-decode-so-the-publisher.md) - js/net: decode messages synchronously from buffered bytes and delete the publisher read-ahead queue - [Install moq](/quest/m1/moq-installer.md) - one command installs or upgrades the released CLI on macOS and Linux diff --git a/quest/m1/announce-live-bindings.md b/quest/m1/announce-live-bindings.md index a4823ceee81..36959c05ef3 100644 --- a/quest/m1/announce-live-bindings.md +++ b/quest/m1/announce-live-bindings.md @@ -2,7 +2,7 @@ ## Goal -moq-ffi, libmoq, and every wrapper (`py`, `swift`, `kt`, `go`, `dart`) yield +moq-ffi, moq-c, and every wrapper (`py`, `swift`, `kt`, `go`, `dart`) yield the same flat announce event Rust does: `Announced`, `Updated`, or `Retracted` carrying the announce, or `Live` once every route live at subscribe time has been delivered. A binding app can list what is live and stop, with no timer. @@ -14,13 +14,13 @@ Mirror moq-net's `announce::Event` one to one: - moq-ffi: `MoqAnnounceConsumer::next` returns `MoqAnnounceEvent`, a uniffi enum with the four variants, replacing `MoqAnnounceUpdate::active()`. Stop filtering `Live` in `rs/moq-ffi/src/origin.rs`. -- libmoq: the `on_announce` handle's `moq_announce_update.kind` gains a LIVE +- moq-c: the `on_announce` handle's `moq_announce_update.kind` gains a LIVE value with no route fields, replacing the active flag. Stop skipping - `Event::Live` in `rs/libmoq/src/origin.rs`. + `Event::Live` in `rs/moq-c/src/origin.rs`. - Hand-written wrappers and `doc/lib/{py,swift,kt,go,dart,c}` follow, with a test per binding that an empty origin still yields `Live`. -Public API: breaking in moq-ffi, libmoq's C ABI, and every wrapper, so it +Public API: breaking in moq-ffi, moq-c's C ABI, and every wrapper, so it retargets to `dev` with the Rust break. Wire: none. ## Related diff --git a/quest/m1/audio-codecs/encode-backend.md b/quest/m1/audio-codecs/encode-backend.md index 5c6dbc10738..20cb723a954 100644 --- a/quest/m1/audio-codecs/encode-backend.md +++ b/quest/m1/audio-codecs/encode-backend.md @@ -16,7 +16,7 @@ and selection contract settled in main. Opus and PCM retain their behavior. This quest adds AAC through platform encoders; no software AAC dependency is selected. - `encode::Codec` gains `Aac`, meaning `mp4a.40.2`, and `as_str` / `FromStr` - accept `"aac"`, which is what libmoq's codec string carries. moq-ffi's + accept `"aac"`, which is what moq-c's codec string carries. moq-ffi's immutable codec object gains an `aac()` constructor and conversion; do not reintroduce a closed binding enum. The generated bindings, hand-written wrappers, and docs follow the Cross-Package Sync table. diff --git a/quest/m1/audio-codecs/layout.md b/quest/m1/audio-codecs/layout.md index 2df431c95cd..07b184f5f2f 100644 --- a/quest/m1/audio-codecs/layout.md +++ b/quest/m1/audio-codecs/layout.md @@ -4,7 +4,7 @@ `moq-audio` carries up to 7.1 end to end. A decoded frame says which layout it is in, the playback mixer downmixes it to whatever the device opened, a raw -PCM consumer can ask for a layout, and the FFI and libmoq expose the same. +PCM consumer can ask for a layout, and the FFI and moq-c expose the same. Proven with multichannel PCM, the one codec that needs no new decoder. ## Plan @@ -29,7 +29,7 @@ positions from an arbitrary channel count. device chooser prefers the widest well-known layout the device offers (a 5.1 HDMI sink opens at six channels, a headset at two), and each `Sink` remixes into the bus. Today's "silence past the front pair" fan-out goes. -- moq-ffi and libmoq keep `channels` as a count, and the count means the +- moq-ffi and moq-c keep `channels` as a count, and the count means the default layout for that count (the WAVE convention: 3 is 2.1, 4 is quad, 6 is 5.1, 8 is 7.1), delivered or accepted in the canonical order. No record, `repr(C)` struct, or binding changes, so this stays on `main`; only the diff --git a/quest/m1/auth/README.md b/quest/m1/auth/README.md index 6ec02ba9d11..9696c7b9ced 100644 --- a/quest/m1/auth/README.md +++ b/quest/m1/auth/README.md @@ -107,7 +107,7 @@ existing lite-06 ALPN. - [moq-transport](/quest/m1/auth/moq-transport.md) - the same exchange as a setup-option extension on draft-17+, specified in a new draft - [Bindings](/quest/m1/auth/bindings.md) - grants and tokens reach every - binding through moq-ffi and libmoq + binding through moq-ffi and moq-c - [Token in band](/quest/m1/auth/token-in-band.md) - the credential can leave the URL: a session starts on what the URL carried and its AUTH streams add the rest, with the URL kept for peers below lite-06 diff --git a/quest/m1/auth/bindings.md b/quest/m1/auth/bindings.md index 6bd1a36ab27..7f652ef27ba 100644 --- a/quest/m1/auth/bindings.md +++ b/quest/m1/auth/bindings.md @@ -3,7 +3,7 @@ ## Goal Every binding can read a session's grant and present more tokens: moq-ffi and -libmoq expose it, and the hand-written Python, Swift, Kotlin, Go, and Dart +moq-c expose it, and the hand-written Python, Swift, Kotlin, Go, and Dart wrappers and their docs carry it. An OBS user whose token is about to expire mid-stream can be handed a new one without the plugin reconnecting. @@ -19,9 +19,9 @@ mid-stream can be handed a new one without the plugin reconnecting. moq-ffi already maps on refusal. `MoqClient` sessions reached through the reconnecting connection use the accessor [Relay tokens](/quest/m1/auth/relay-refresh.md) adds. -- libmoq: `moq_session_auth_grant`, `moq_session_auth_add`, and +- moq-c: `moq_session_auth_grant`, `moq_session_auth_add`, and `moq_auth_token_close` with the terminal-status callback contract the other - async calls use, in `rs/libmoq/src/api.rs` and the session table; + async calls use, in `rs/moq-c/src/api.rs` and the session table; regenerate `moq.h`, and update `cpp/obs/src` only if the plugin surfaces a token field, otherwise leave it. - Interop: the Python, Go, and C interop clients print their grant and join diff --git a/quest/m1/auth/token-in-band.md b/quest/m1/auth/token-in-band.md index 2c38ad03456..a5e45dacb41 100644 --- a/quest/m1/auth/token-in-band.md +++ b/quest/m1/auth/token-in-band.md @@ -24,7 +24,7 @@ AUTH can carry the full grant once the pattern-interest prerequisite lands. the client makes. A `?jwt=` in the URL stays a member of the union, which is how cluster dial targets keep their per-peer credential, and per-dial extras use the session's `auth().add()` once connected. moq-ffi - `MoqClient::set_tokens`, libmoq `moq_client_set_tokens` (mirrored in the + `MoqClient::set_tokens`, moq-c `moq_client_set_tokens` (mirrored in the wrappers and `cpp/obs/src`), and `js/net`'s `connect` options field follow. - Credential refresh belongs with token presentation. Resolve the configured credential source before each dial. After an authorization refusal, resolve diff --git a/quest/m1/auth/unauthorized.md b/quest/m1/auth/unauthorized.md index cbd1c255e2c..f52c1e110f5 100644 --- a/quest/m1/auth/unauthorized.md +++ b/quest/m1/auth/unauthorized.md @@ -16,7 +16,7 @@ error, so the addition is compatible. Add the matching `StreamError` variant (the enum is non-exhaustive) in Rust and JS, send it from every revocation path the lite stream added, and cover it in the Rust and JS tests. Map it to the existing `Unauthorized` protocol kind in -`stream_kind` in `rs/moq-ffi/src/error.rs` and `rs/libmoq/src/error.rs`, +`stream_kind` in `rs/moq-ffi/src/error.rs` and `rs/moq-c/src/error.rs`, whose wildcard arms would otherwise report `Unknown`, with a test for each. Update `drafts/draft-lcurley-moq-lite.md` and run `just drafts check`. diff --git a/quest/m1/binding-surface.md b/quest/m1/binding-surface.md index e789e327109..c5041402fda 100644 --- a/quest/m1/binding-surface.md +++ b/quest/m1/binding-surface.md @@ -2,7 +2,7 @@ ## Goal -moq-ffi, libmoq, and every wrapper (Python, Go, Swift, Kotlin, Dart) expose +moq-ffi, moq-c, and every wrapper (Python, Go, Swift, Kotlin, Dart) expose `decode::Options::delay` and `decode::Consumer::delay()` so applications can configure and observe audio playout delay. @@ -11,7 +11,7 @@ configure and observe audio playout delay. - One PR, each wrapper touched once, in its own idiom: durations as the language's duration type where the wrapper already uses one, handles over flat methods where a surface has more than one call. -- Add the libmoq implementation and tests in `rs/libmoq`, then regenerate +- Add the moq-c implementation and tests in `rs/moq-c`, then regenerate `moq.h`. Keep the additions compatible with the published C ABI. - Update `doc/lib/{py,swift,kt,go,dart,c}` in the same PR. - Test configuration and observed delay in every wrapper that has tests. diff --git a/quest/m1/broadcast-epoch/README.md b/quest/m1/broadcast-epoch/README.md index a0a9551ecc8..587a892f852 100644 --- a/quest/m1/broadcast-epoch/README.md +++ b/quest/m1/broadcast-epoch/README.md @@ -60,7 +60,7 @@ This README owns: - [Origin](/quest/m1/broadcast-epoch/origin.md) - moq-net publish mints an epoch, consumers follow the newest live one, and bare requests resolve to it on every version - [Apps](/quest/m1/broadcast-epoch/apps.md) - moq-cli, the browser publish and watch components, and demo/web publish under epochs and play bare names - [Gateways](/quest/m1/broadcast-epoch/gateways.md) - RTMP, SRT, and WHIP ingest mint an epoch per incoming connection, so an encoder reconnect is a clean takeover -- [Bindings](/quest/m1/broadcast-epoch/bindings.md) - moq-ffi, libmoq, and every wrapper expose the epoch and inherit the default +- [Bindings](/quest/m1/broadcast-epoch/bindings.md) - moq-ffi, moq-c, and every wrapper expose the epoch and inherit the default - [GStreamer and OBS](/quest/m1/broadcast-epoch/gst-obs.md) - moqsink and the OBS plugin publish each run under a fresh epoch ## Required diff --git a/quest/m1/broadcast-epoch/bindings.md b/quest/m1/broadcast-epoch/bindings.md index ed5567ef691..7db6c064677 100644 --- a/quest/m1/broadcast-epoch/bindings.md +++ b/quest/m1/broadcast-epoch/bindings.md @@ -2,7 +2,7 @@ ## Goal -`moq-ffi`, `libmoq`, and the py, swift, kt, go, and dart wrappers publish under +`moq-ffi`, `moq-c`, and the py, swift, kt, go, and dart wrappers publish under the default epoch and follow bare names like Rust. The epoch of a published or consumed broadcast is readable, and a caller can pass an explicit one. The reconnect counter `session.epoch()` is renamed so "epoch" has one meaning. diff --git a/quest/m1/broadcast-epoch/gst-obs.md b/quest/m1/broadcast-epoch/gst-obs.md index 5ae7824177d..c00cf203e31 100644 --- a/quest/m1/broadcast-epoch/gst-obs.md +++ b/quest/m1/broadcast-epoch/gst-obs.md @@ -10,9 +10,9 @@ restarted pipeline or a stop and start in OBS is a clean takeover for viewers. `moqsink` takes the origin default per session. When [#3115](/quest/m2/3115-moqsink-the-publication-has-no-generation-so-a-flush.md) lands, each of its publication generations is a new epoch. OBS gets it -through libmoq. Update `doc/bin/gstreamer.md` and `doc/bin/obs.md` if they +through moq-c. Update `doc/bin/gstreamer.md` and `doc/bin/obs.md` if they show paths. ## Required -- [Bindings](/quest/m1/broadcast-epoch/bindings.md) - OBS publishes through libmoq +- [Bindings](/quest/m1/broadcast-epoch/bindings.md) - OBS publishes through moq-c diff --git a/quest/m1/cpp/README.md b/quest/m1/cpp/README.md index 3faa892c8f5..4e37724aca6 100644 --- a/quest/m1/cpp/README.md +++ b/quest/m1/cpp/README.md @@ -9,7 +9,7 @@ cancellable futures, with no `user_data` plumbing, no handle integers, and no thread of their own to babysit. The OBS plugin is the in-tree consumer that proves the shape; external SDK users are the audience. -Non-goals: libmoq stays as the plain-C ABI, keeps its own release, and keeps +Non-goals: moq-c stays as the plain-C ABI, keeps its own release, and keeps following the Cross-Package Sync table like every other wrapper; no second hand-written C++ surface (ergonomics are fixed in moq-ffi where every binding benefits); no wire or public Rust API change. @@ -42,7 +42,7 @@ on a future under `__cpp_impl_coroutine`, `std::expected` under `__cpp_lib_expected`. Never a second library per standard. Distribution is all of: a release tarball with a CMake package config and -pkg-config file (mirroring `libmoq.yml`), a vcpkg registry we own, and a Conan +pkg-config file (mirroring `moq-c.yml`), a vcpkg registry we own, and a Conan remote we own, the latter two fetching the prebuilt tarball so consumers never need a Rust toolchain or the bindgen fork. vcpkg lands first; the Conan recipe reads the same release manifest so a release bumps both. @@ -51,7 +51,7 @@ reads the same release manifest so a release bumps both. - [Generator](/quest/m1/cpp/generator.md) - the uniffi 0.32 C++ generator with futures and expected-style errors, pinned and generating `cpp/ffi` in CI - [Package](/quest/m1/cpp/package.md) - the `cpp/moq` wrapper, CMake package, release tarball, interop client, and docs -- [OBS migration](/quest/m1/cpp/obs.md) - the OBS plugin moves from libmoq handles and trampolines to the generated C++ +- [OBS migration](/quest/m1/cpp/obs.md) - the OBS plugin moves from moq-c handles and trampolines to the generated C++ ## Related diff --git a/quest/m1/cpp/obs.md b/quest/m1/cpp/obs.md index 475e1206cc1..6c9a4574bf6 100644 --- a/quest/m1/cpp/obs.md +++ b/quest/m1/cpp/obs.md @@ -2,11 +2,11 @@ ## Goal -`cpp/obs` links `cpp/moq` instead of libmoq. The output and source hold +`cpp/obs` links `cpp/moq` instead of moq-c. The output and source hold `moq::` objects instead of `int` handles, async work is a future with a continuation on OBS's own executor, and the generation counters, condvars, `SessionRef`/`callback_state` heap trampolines, and "never take signal_mutex -inside a libmoq call" lock-order rules that exist only to survive libmoq's +inside a moq-c call" lock-order rules that exist only to survive moq-c's single callback thread are deleted. Behavior visible to OBS users is unchanged: same settings, same dock, same reconnect and teardown timing. @@ -26,13 +26,13 @@ unchanged: same settings, same dock, same reconnect and teardown timing. object, not a `free` call. FFmpeg decode stays as is; the native decode replacement is the OBS native codecs questline and now starts from this code. -- Tests: `cpp/obs/test/*-test.cpp` currently stub libmoq's C symbols to race +- Tests: `cpp/obs/test/*-test.cpp` currently stub moq-c's C symbols to race the OBS and runtime threads. Rewrite them against `moq::` interfaces with a fake executor; keep the scenarios (stop during connect, late terminal, superseded attempt). - Build and release: `cpp/obs/CMakeLists.txt` consumes the package (in-tree `cpp/` for `MOQ_LOCAL`, the release tarball otherwise); `obs.yml` - rides `release-cpp.yml` instead of `libmoq.yml`. `doc/bin/obs.md` says the + rides `release-cpp.yml` instead of `moq-c.yml`. `doc/bin/obs.md` says the plugin is C++ over the generated bindings. - Shutdown: define `obs_module_unload` and call `moq_ffi_shutdown` there, after OBS has destroyed the outputs and sources, so the runtime thread is diff --git a/quest/m1/cpp/package.md b/quest/m1/cpp/package.md index fa546c0e9cf..abad2c9221b 100644 --- a/quest/m1/cpp/package.md +++ b/quest/m1/cpp/package.md @@ -25,18 +25,18 @@ A `test/interop/clients/cpp` client joins `just test interop --all`, and continuations must not block on the moq-ffi runtime thread. - Build: `cpp/CMakeLists.txt` builds `libmoq_ffi` (staticlib, features `video`+`audio`) with the same `cargo build` custom command and - `BUILD_RUST_LIB` switch `rs/libmoq/CMakeLists.txt` uses (no Corrosion, so + `BUILD_RUST_LIB` switch `rs/moq-c/CMakeLists.txt` uses (no Corrosion, so the two CMake entry points stay alike), compiles `cpp/ffi`, installs headers, `moqConfig.cmake`, and `moq.pc`. Windows MSVC, - macOS, and Linux, both architectures, matching `libmoq.yml`'s matrix. -- Release: `release-cpp.yml` mirrors `libmoq.yml` (tag `cpp-v*`, nightly + macOS, and Linux, both architectures, matching `moq-c.yml`'s matrix. +- Release: `release-cpp.yml` mirrors `moq-c.yml` (tag `cpp-v*`, nightly dry-run through the `workflow_call` chain), producing one tarball per target containing the static library, generated sources, wrapper headers, and the CMake package. The registries quest consumes these artifacts. - Interop: `test/interop/clients/cpp` subscribes and publishes like the Go client; - the C client stays, since libmoq stays. + the C client stays, since moq-c stays. - Docs: `doc/lib/cpp/index.md` (install via tarball, then the registries once they exist; the future, expected, executor, and coroutine rules) and a row in - `doc/lib/index.md`. The C row now says libmoq is the plain-C ABI and points + `doc/lib/index.md`. The C row now says moq-c is the plain-C ABI and points C++ readers at the new package. ## Required diff --git a/quest/m1/ffi-shape/README.md b/quest/m1/ffi-shape/README.md index 6c0fabddbdf..4fde8fa024f 100644 --- a/quest/m1/ffi-shape/README.md +++ b/quest/m1/ffi-shape/README.md @@ -32,10 +32,10 @@ Settled shape: namespaces. - `demand()` is the one way to watch subscribers; producers drop their `name`/`is_used`/`used`/`unused` duplicates. -- libmoq renames its C symbols to the same groups (`moq_json_*`, +- moq-c renames its C symbols to the same groups (`moq_json_*`, `moq_media_*`), with `cpp/obs` adapting. -Each child reshapes one group end to end: moq-ffi, all five wrappers, libmoq, +Each child reshapes one group end to end: moq-ffi, all five wrappers, moq-c, and the `doc/lib` samples, per the cross-package table. This README owns the work no child does: diff --git a/quest/m1/ffi-shape/codec.md b/quest/m1/ffi-shape/codec.md index 1f72300318b..5c23fb60523 100644 --- a/quest/m1/ffi-shape/codec.md +++ b/quest/m1/ffi-shape/codec.md @@ -17,9 +17,9 @@ key apart from its rendition; pick one convention for both. Go's through `demand()` only. Both groups stay behind their cargo features and off wasm. -libmoq's codec symbols follow. +moq-c's codec symbols follow. -Public API: breaking in every binding and libmoq. Wire: none. +Public API: breaking in every binding and moq-c. Wire: none. ## Required diff --git a/quest/m1/ffi-shape/json.md b/quest/m1/ffi-shape/json.md index 0ff6f352275..d417b786adb 100644 --- a/quest/m1/ffi-shape/json.md +++ b/quest/m1/ffi-shape/json.md @@ -25,9 +25,9 @@ keep doing so, and the rest may follow. Watch for Go import cycles: a subpackage takes the root's broadcast handle, so the root must not import it back. -libmoq's JSON symbols move to `moq_json_*`. +moq-c's JSON symbols move to `moq_json_*`. -Public API: breaking in every binding and libmoq. Wire: none. +Public API: breaking in every binding and moq-c. Wire: none. ## Required diff --git a/quest/m1/ffi-shape/media.md b/quest/m1/ffi-shape/media.md index e936b296682..d00840050be 100644 --- a/quest/m1/ffi-shape/media.md +++ b/quest/m1/ffi-shape/media.md @@ -24,9 +24,9 @@ once the shape is in front of you, and prefer one path. Go's `FetchMediaGroup` takes an options struct. Media producers watch subscribers through `demand()` only. -libmoq's media symbols move to `moq_media_*`, and `cpp/obs` adapts. +moq-c's media symbols move to `moq_media_*`, and `cpp/obs` adapts. -Public API: breaking in every binding and libmoq. Wire: none. +Public API: breaking in every binding and moq-c. Wire: none. ## Required diff --git a/quest/m1/ffi-shape/net.md b/quest/m1/ffi-shape/net.md index b91d2770ace..0b2d0a254b9 100644 --- a/quest/m1/ffi-shape/net.md +++ b/quest/m1/ffi-shape/net.md @@ -36,9 +36,9 @@ are renamed. this line removes, but dropping it costs every quick-start a hop (raised in #3959). -libmoq's affected symbols follow. +moq-c's affected symbols follow. -Public API: breaking in every binding and libmoq. Wire: none. +Public API: breaking in every binding and moq-c. Wire: none. ## Required diff --git a/quest/m1/kt-jvm-exit.md b/quest/m1/kt-jvm-exit.md index b1ccffb892f..229659840f3 100644 --- a/quest/m1/kt-jvm-exit.md +++ b/quest/m1/kt-jvm-exit.md @@ -37,4 +37,4 @@ Public API: none; the hook is internal to the binding. Wire: none. ## Related -- [libmoq shutdown](/quest/m1/libmoq-shutdown.md) - the same hazard class for the C ABI and the OBS plugin +- [moq-c shutdown](/quest/m1/libmoq-shutdown.md) - the same hazard class for the C ABI and the OBS plugin diff --git a/quest/m1/libmoq-fetch.md b/quest/m1/libmoq-fetch.md index 15710672158..c2d47b411ad 100644 --- a/quest/m1/libmoq-fetch.md +++ b/quest/m1/libmoq-fetch.md @@ -1,4 +1,4 @@ -# [S] libmoq: fetch one cached group +# [S] moq-c: fetch one cached group ## Goal @@ -8,11 +8,11 @@ handle, and terminal-status conventions. The new entry point is additive. ## Plan Mirror `MoqTrackConsumer::fetch_group` from `rs/moq-ffi/src/consumer.rs` in -`rs/libmoq`, supporting raw and container-decoded delivery as the FFI does. +`rs/moq-c`, supporting raw and container-decoded delivery as the FFI does. Specify ownership, cancellation, cache misses, and terminal delivery using the existing consume contracts. Test a hit, miss, and cancelled fetch from a C caller. Regenerate `moq.h` and update `doc/lib/c/index.md`, whose capability list already claims group fetch. Decoder output configuration landed separately on the dev line. -The `moq_group_request_*` tests in `rs/libmoq/src/test.rs` fetch from Rust for +The `moq_group_request_*` tests in `rs/moq-c/src/test.rs` fetch from Rust for lack of this entry point; switch them to it. diff --git a/quest/m1/libmoq-retire.md b/quest/m1/libmoq-retire.md new file mode 100644 index 00000000000..90717f5c66b --- /dev/null +++ b/quest/m1/libmoq-retire.md @@ -0,0 +1,18 @@ +# [XS] Retire the libmoq stub + +## Goal + +`rs/libmoq` is gone and the `libmoq` crate is no longer published. Its last +release, a code-free crate whose README points at `moq-c`, stays on crates.io +for anyone still resolving the old name. + +## Plan + +- Delete `rs/libmoq` and its workspace member once that release is on + crates.io, so release-plz never publishes it again. +- Grep for any remaining `libmoq` that names the crate rather than the + `libmoq.a` file. + +## Required + +- The final `libmoq` release, built from the `rs/libmoq` stub, is on crates.io diff --git a/quest/m1/libmoq-shutdown.md b/quest/m1/libmoq-shutdown.md index a9d65aaf763..c50435b5b4e 100644 --- a/quest/m1/libmoq-shutdown.md +++ b/quest/m1/libmoq-shutdown.md @@ -1,17 +1,17 @@ -# [M] libmoq can be stopped before its host unloads it +# [M] moq-c can be stopped before its host unloads it ## Goal OBS exits without a crash whether a moq output is running, was just stopped, -or a source still has terminal callbacks outstanding. libmoq parks a -process-wide `libmoq` thread in `block_on` on first use and has no way to +or a source still has terminal callbacks outstanding. moq-c parks a +process-wide `moq-c` thread in `block_on` on first use and has no way to stop it, while OBS `dlclose`s each plugin at shutdown; the plugin links -libmoq statically, so the thread's code is unmapped under it. Any host that +moq-c statically, so the thread's code is unmapped under it. Any host that unloads the library has the same exposure. ## Plan -Starts on `main`; libmoq's runtime (`rs/libmoq/src/ffi.rs`) is the same on +Starts on `main`; moq-c's runtime (`rs/moq-c/src/ffi.rs`) is the same on both branches and the change is additive. - Reproduce first: exit OBS with the plugin loaded and an output running, @@ -19,22 +19,22 @@ both branches and the change is additive. `moq_source_destroy` hit its two-second backstop. Record which of these crashes, and how, in the PR before changing anything. - Add `moq_shutdown()` to the C ABI, mirroring `moq_ffi_shutdown` in - `rs/moq-ffi`: it stops and joins the `libmoq` thread. Pending calls resolve + `rs/moq-ffi`: it stops and joins the `moq-c` thread. Pending calls resolve as cancelled, the terminal callback for every still-open handle fires with a cancelled status before it returns, and any later call returns an error code rather than restarting the runtime. It is idempotent and must be - called from a host thread, never from a libmoq callback. Native codec and + called from a host thread, never from a moq-c callback. Native codec and capture threads belong to their handles and end with them; this call does not reach into them. - The OBS wiring (`obs_module_unload` calling the shutdown after the outputs and sources are destroyed) belongs to [OBS migration](/quest/m1/cpp/obs.md), where the plugin reaches moq-ffi through the generated C++ and calls `moq_ffi_shutdown`; this quest gives the plain-C ABI the same call for the - hosts that stay on libmoq. -- Regression tests: a `rs/libmoq/c-tests` fixture that builds libmoq as a + hosts that stay on moq-c. +- Regression tests: a `rs/moq-c/c-tests` fixture that builds moq-c as a cdylib, `dlopen`s it, opens a session, and `dlclose`s once without `moq_shutdown` (must fail, proving the hazard) and once with it (clean - exit, thread gone); a `rs/libmoq` unit test that pending and later calls + exit, thread gone); a `rs/moq-c` unit test that pending and later calls resolve cancelled and open handles close without panicking afterwards (mirror `rs/moq-ffi/src/test.rs::shutdown_cancels_and_drops_cleanly`, in a child process since the stop is process-wide). Wire the new fixture @@ -45,7 +45,7 @@ both branches and the change is additive. wrapper: `os.Exit` ends the process without tearing a host runtime down under the thread. -Public API: additive on the libmoq C ABI (`moq_shutdown`). Wire: none. +Public API: additive on the moq-c C ABI (`moq_shutdown`). Wire: none. ## Related diff --git a/quest/m1/moq-c.md b/quest/m1/moq-c.md deleted file mode 100644 index ba182621253..00000000000 --- a/quest/m1/moq-c.md +++ /dev/null @@ -1,33 +0,0 @@ -# [M] libmoq becomes moq-c - -## Goal - -The C bindings ship as `moq-c`, matching `moq-cpp` and the other bindings: the -crate, its directory, release tags, CMake package, and pkg-config file all use -the name. C code and link lines do not change: the header stays `moq.h` and the -library file keeps its current name. The published `libmoq` crate gets one last -release that points users at `moq-c`. - -## Plan - -- Rename the crate `libmoq` to `moq-c` (`rs/libmoq` to `rs/moq-c`), its release - tags from `libmoq-v*` to `moq-c-v*`, and its workflow. The CMake package - becomes `find_package(moq-c)` and the pkg-config file `moq-c.pc`. The C++ - package is already `moq-cpp` (#4187), so the two install side by side. -- Keep the `[lib] name` so the library file and `moq.h` are unchanged. -- A published package rename is a break, so this lands on `dev`. Release - tooling (release-plz, alert and nightly workflows, cachix) must follow the - new name and tag; check every workflow that names libmoq. -- Update every consumer and reference: `cpp/obs` (`find_package`), interop - clients, `doc/lib/c`, `doc/bin/obs.md`, the root `AGENTS.md` Cross-Package - Sync table, and quests that name libmoq. Grep the whole repository. -- Publish a final `libmoq` release whose README and description point at - `moq-c`, then stop publishing it. The maintainer cuts releases; the PR only - prepares it. - -Public API: the C ABI is unchanged; the crate, package, and tag names change. -Wire: none. - -## Related - -- [C++ through moq-ffi](/quest/m1/cpp/README.md) - the `moq-cpp` package this name mirrors diff --git a/quest/m1/obs-moq-video/README.md b/quest/m1/obs-moq-video/README.md index 9a90fa83298..5711201d50b 100644 --- a/quest/m1/obs-moq-video/README.md +++ b/quest/m1/obs-moq-video/README.md @@ -33,7 +33,7 @@ The quests separate portable decoding, platform GPU delivery, audio, and publish ## Related -- [OBS migration](/quest/m1/cpp/obs.md) - every quest here starts from the plugin on the generated C++, so codec surface is designed in moq-ffi and reaches libmoq and the other wrappers through the Cross-Package Sync table, not as OBS-only C symbols +- [OBS migration](/quest/m1/cpp/obs.md) - every quest here starts from the plugin on the generated C++, so codec surface is designed in moq-ffi and reaches moq-c and the other wrappers through the Cross-Package Sync table, not as OBS-only C symbols - [Linux GPU input](/quest/m2/obs-linux-gpu.md) - allocation-export feasibility and its dependent implementation are deferred - [VAAPI encode and decode](/quest/m4/video-vaapi.md) - owns Linux backend decode/import capabilities; reconcile its older dependency assumptions against current code - [Video hardware validation](/quest/m3/video-hardware.md) - physical hardware evidence is required for each claimed GPU path diff --git a/quest/m1/obs-moq-video/linux-bundle.md b/quest/m1/obs-moq-video/linux-bundle.md index fb55f31b515..099aeb43236 100644 --- a/quest/m1/obs-moq-video/linux-bundle.md +++ b/quest/m1/obs-moq-video/linux-bundle.md @@ -6,7 +6,7 @@ Every `obs-moq-v*` release attaches a Linux x86_64 tarball that loads into a sto ## Plan -- The only reason `obs-build` in `.github/workflows/libmoq.yml` skips Linux is FFmpeg: the source links nix/distro libavcodec, which is not portable. The FFmpeg removal is the blocker; once the plugin is C++ over libmoq plus libobs and Qt6, a Linux build has no extra runtime dependency that OBS itself does not already carry. +- The only reason `obs-build` in `.github/workflows/moq-c.yml` skips Linux is FFmpeg: the source links nix/distro libavcodec, which is not portable. The FFmpeg removal is the blocker; once the plugin is C++ over moq-c plus libobs and Qt6, a Linux build has no extra runtime dependency that OBS itself does not already carry. - Build on `ubuntu-24.04` (glibc 2.39, the floor OBS's own Linux packages target) against the libobs and Qt6 headers OBS's plugin template uses; the template's `.deb` recipe is the reference. Ship the plain archive layout the other platforms use (`obs-moq-*-x86_64-unknown-linux-gnu.tar.gz` with `bin/64bit/obs-moq.so` and `data/`), extractable into `~/.config/obs-studio/plugins/obs-moq/`. A `.deb` is optional and separate. - Flatpak OBS cannot load a plugin from the host filesystem. Verify a real Flatpak install and support it only if the sandbox's runtime ABI matches, documenting the `~/.var/app/com.obsproject.Studio/config/obs-studio/plugins/` path. Otherwise, state plainly that Flatpak is unsupported. - `cpp/obs/build.sh --target x86_64-unknown-linux-gnu` produces the tarball, and the matrix in `obs-build` gains the row; nothing else in the release pipeline changes. Keep the nightly `just obs ci` compile as the PR gate. diff --git a/quest/m1/obs-moq-video/rate-control.md b/quest/m1/obs-moq-video/rate-control.md index c4a8aeda4d8..81c8aea0ab1 100644 --- a/quest/m1/obs-moq-video/rate-control.md +++ b/quest/m1/obs-moq-video/rate-control.md @@ -12,7 +12,7 @@ configured rate. ## Plan -Uses the reservation surface from libmoq (`moq_session_bandwidth`, +Uses the reservation surface from moq-c (`moq_session_bandwidth`, `moq_bandwidth_reserve`, `moq_reservation_grant`). Apply grants through the shape `moq_mux::rate::Control` uses (drops at once, raises ramp, hysteresis) rather than pushing every change into `obs_encoder_update`; whether diff --git a/quest/m1/release-size.md b/quest/m1/release-size.md index 8d0fb4868bf..e6634930982 100644 --- a/quest/m1/release-size.md +++ b/quest/m1/release-size.md @@ -2,9 +2,9 @@ ## Goal -The shipped moq-ffi and libmoq artifacts already build with thin LTO and one +The shipped moq-ffi and moq-c artifacts already build with thin LTO and one codegen unit, but through `CARGO_PROFILE_RELEASE_*` exports in three places -(`rs/moq-ffi/build.sh`, `rs/libmoq/build.sh`, `nix/overlay.nix`), so the +(`rs/moq-ffi/build.sh`, `rs/moq-c/build.sh`, `nix/overlay.nix`), so the Python wheel (maturin), `moq`, `moq-relay`, and every `cargo build --release` by a self-builder get none of it, and a plain release build measures nothing a user receives. After this quest `[profile.release]` in the workspace @@ -37,11 +37,11 @@ both still produce symbolized captures. Thin LTO is the known-good starting point. Try `lto = "fat"` and `strip = "symbols"` on top and keep each only if the table earns it: thin LTO bought 5% on the dylib, so fat is not assumed to buy much, and `strip` must not break the crash reports C ABI users read -(libmoq ships a symbols file if it does). Link time on the release matrix +(moq-c ships a symbols file if it does). Link time on the release matrix goes in the same table as the sizes. Then the nightly job: a `size` recipe under `sh/` that builds both moq-ffi -configurations and `libmoq` with the release profile, prints stripped sizes +configurations and `moq-c` with the release profile, prints stripped sizes and `cargo bloat --crates -n 30` per build, and posts the result to the job summary. `cargo bloat` reads the symbol table, so if `strip` lands the recipe builds with `CARGO_PROFILE_RELEASE_STRIP=none` for the bloat pass and strips diff --git a/quest/m1/track-demand.md b/quest/m1/track-demand.md index 40ed2806079..de9fc5ea86c 100644 --- a/quest/m1/track-demand.md +++ b/quest/m1/track-demand.md @@ -11,7 +11,7 @@ built on a track (moq-json, moq-mux import, moq-audio, moq-binary) exposes ## Plan About 150 call sites move, across moq-net, moq-mux, moq-json, moq-audio, -moq-binary, moq-relay, moq-transcode, moq-stats, and libmoq. Both waits +moq-binary, moq-relay, moq-transcode, moq-stats, and moq-c. Both waits already surface the track's abort reason, so callers keep their errors. Keep `abort_unused` if its race still needs an owner. JS mirrors the Rust shape in `js/net`. diff --git a/quest/m2/cs/package.md b/quest/m2/cs/package.md index 5b5eadd73c4..d5472a13d05 100644 --- a/quest/m2/cs/package.md +++ b/quest/m2/cs/package.md @@ -16,7 +16,7 @@ interop --all` and `doc/lib/cs` documents the package. over the consumer `next()` loops, `IAsyncDisposable` on handles. Nothing re-implements a method. - Package: one NuGet with managed code plus native `libmoq_ffi` per RID - (win-x64, osx-arm64, linux-x64, linux-arm64, matching `libmoq.yml`), built by + (win-x64, osx-arm64, linux-x64, linux-arm64, matching `moq-c.yml`), built by `release-cs.yml` on the nightly dry-run chain and published on a `cs-v*` tag. - Interop: `test/interop/clients/cs` publishes and subscribes like the Go client. diff --git a/quest/m2/flate/README.md b/quest/m2/flate/README.md index 6bbb52e9681..063f0f37c72 100644 --- a/quest/m2/flate/README.md +++ b/quest/m2/flate/README.md @@ -28,4 +28,4 @@ a compressed track is announced, routed, and cached like any other. ## Quests - [Track wrapper](/quest/m2/flate/track.md) - `moq-flate` and `@moq/flate` wrap a track so each group is one compression window without caller bookkeeping -- [Bindings](/quest/m2/flate/bindings.md) - moq-ffi and libmoq publish and subscribe compressed tracks, mirrored through every wrapper +- [Bindings](/quest/m2/flate/bindings.md) - moq-ffi and moq-c publish and subscribe compressed tracks, mirrored through every wrapper diff --git a/quest/m2/flate/bindings.md b/quest/m2/flate/bindings.md index c83c3df2141..fae37cd2174 100644 --- a/quest/m2/flate/bindings.md +++ b/quest/m2/flate/bindings.md @@ -2,7 +2,7 @@ ## Goal -moq-ffi and libmoq publish and subscribe a compressed track of opaque frames, +moq-ffi and moq-c publish and subscribe a compressed track of opaque frames, and every wrapper (Python, Swift, Kotlin, Go, Dart, C) reaches it. A track written from C decodes in the browser with `@moq/flate` and vice versa. @@ -29,7 +29,7 @@ track API; only the payload is compressed. Explicit groups rather than a flat `a at the boundary and the caller chooses where that is; a helper that rolls groups on a size or count budget can follow if a consumer asks. -libmoq mirrors `moq_publish_json_*` and `moq_consume_json_*`: +moq-c mirrors `moq_publish_json_*` and `moq_consume_json_*`: `moq_publish_flate`, `moq_publish_flate_group`, `moq_publish_flate_frame`, `moq_publish_flate_group_finish`, `moq_publish_flate_finish`, `moq_consume_flate`, `moq_consume_flate_group`, `moq_consume_flate_frame`, @@ -43,12 +43,12 @@ Wrappers per the Cross-Package Sync table: the uniffi bindings regenerate; re-exports and `Flows.kt` extensions, and `dart/moq` each gain a hand-written sibling. Document in `doc/lib/{c,py,swift,kt,go,dart}` beside the JSON entry. -Tests: a moq-ffi round trip next to `json_snapshot_roundtrip`, a libmoq C +Tests: a moq-ffi round trip next to `json_snapshot_roundtrip`, a moq-c C round trip in `src/test.rs`, and one cross-language check that a C-published group decodes with the shared vector from the track quest. Run `just test interop --all`. -Public API impact: additive on moq-ffi, libmoq, and every wrapper; `main`. +Public API impact: additive on moq-ffi, moq-c, and every wrapper; `main`. Wire impact: none. ## Required diff --git a/quest/m2/intra-refresh/README.md b/quest/m2/intra-refresh/README.md index 8a87f4724a3..15219af33b7 100644 --- a/quest/m2/intra-refresh/README.md +++ b/quest/m2/intra-refresh/README.md @@ -44,7 +44,7 @@ Decisions the quests share: - [Encode config](/quest/m2/intra-refresh/encode-config.md) - refresh mode extends the settled GOP contract; the producer cuts groups per sweep and publishes `warmup` - [NVENC refresh](/quest/m2/intra-refresh/nvenc-refresh.md) - the NVENC backend encodes refresh mode for H.264 and HEVC - [V4L2 refresh](/quest/m2/intra-refresh/v4l2-refresh.md) - the V4L2 backend encodes refresh mode -- [Bindings](/quest/m2/intra-refresh/bindings.md) - ffi, libmoq, and every wrapper expose the `Gop` enum +- [Bindings](/quest/m2/intra-refresh/bindings.md) - ffi, moq-c, and every wrapper expose the `Gop` enum - [Export sync flags](/quest/m2/intra-refresh/export-sync-flags.md) - fmp4, MKV, and HLS stop advertising a refresh group start as a sync sample ## Related diff --git a/quest/m2/intra-refresh/bindings.md b/quest/m2/intra-refresh/bindings.md index 880327b1a81..a9ee7698980 100644 --- a/quest/m2/intra-refresh/bindings.md +++ b/quest/m2/intra-refresh/bindings.md @@ -3,17 +3,17 @@ ## Goal Every binding names the group structure the way the core does: the ffi record, -the libmoq C struct, and the Python, Swift, Kotlin, Dart, and Go wrappers take +the moq-c C struct, and the Python, Swift, Kotlin, Dart, and Go wrappers take a keyframe interval or a refresh cycle and nothing else, and `cut()` keeps its meaning in both modes. This replaces the published `gop` integer in moq-ffi -and changes the libmoq C struct layout, so it targets `dev`. +and changes the moq-c C struct layout, so it targets `dev`. ## Plan - `rs/moq-ffi/src/video.rs`: `MoqVideoEncoderOutput.gop: Option` becomes a `MoqVideoGop` enum record mirroring `Gop`, defaulting to keyframes at two seconds. `MoqVideoProducer::cut()` already has the right name. -- `rs/libmoq/src/video.rs`: `moq_video_encoder_output` gains a +- `rs/moq-c/src/video.rs`: `moq_video_encoder_output` gains a `moq_video_gop` discriminant beside `gop`, zero meaning keyframes, and `moq.h` is regenerated (build.rs does not do it on source-only changes). `cpp/obs/src` follows the header. diff --git a/rs/AGENTS.md b/rs/AGENTS.md index d2ba893ae8b..2d1908d4421 100644 --- a/rs/AGENTS.md +++ b/rs/AGENTS.md @@ -2,7 +2,7 @@ The `/rs` Cargo workspace. Extends the root `AGENTS.md`. # Crates -One crate per component from the root list, named `moq-` (`hang` and `libmoq` are the exceptions). Keep them modular; a crate does one thing. Beyond that list: +One crate per component from the root list, named `moq-` (`hang` is the exception). Keep them modular; a crate does one thing. Beyond that list: - `kio`: "easy async" primitives everything else polls through. - `moq-tokio`: configures the QUIC backends (Quinn/Quiche/Noq/Iroh) and the fallback transports for native binaries, on tokio. `moq-sock` holds the socket plumbing it shares with `moq-uring`, the experimental thread-per-core io\_uring runtime. diff --git a/rs/justfile b/rs/justfile index 93d4114d2ee..1412a9e4475 100644 --- a/rs/justfile +++ b/rs/justfile @@ -29,7 +29,7 @@ default: # No `cargo check` pass: clippy is a superset of it, and the two use different # rustc wrappers, so running both means compiling the workspace twice. # -# A bare `just rs check` is default-members, which skips libmoq, moq-ffi, +# A bare `just rs check` is default-members, which skips moq-c, moq-ffi, # moq-gst, and moq-wasm (they need cbindgen, a uniffi build, GStreamer, and a # wasm32 target respectively, so they stay out of a casual local check). Every # recipe that means "all of it" therefore passes `--workspace` explicitly, since @@ -206,12 +206,12 @@ _select $FILES: seeds=$(sed -n 's|^rs/\([^/]*\)/.*|\1|p' <<< "$FILES" | sort -u) # Every workspace member, not just the default ones. `--no-deps` already - # limits this to the workspace. The non-default members (libmoq, moq-ffi, + # limits this to the workspace. The non-default members (moq-c, moq-ffi, # moq-gst, moq-wasm) have to participate as both seeds and dependents: they # used to drop out here because `check` matched a bare `cargo check`, but # `check` is the only gate now, and the `cargo clippy --workspace` in the # deleted `just rs ci` is what used to cover them. Without them, a PR - # touching only rs/libmoq selects nothing and compiles nothing. + # touching only rs/moq-c selects nothing and compiles nothing. edges=$(jq -r ' .packages[] | .name as $name @@ -624,8 +624,8 @@ uring-check *args: # # Same trade as `windows`: nightly.yml runs this once a day rather than gating a # merge on a Mac runner. The moq-video half also has a release-time backstop, -# since libmoq's `libmoq-v*` tag build compiles it on Apple Silicon. The -# moq-audio half has none: libmoq and moq-ffi take it codecs-only, so no release +# since moq-c's `moq-c-v*` tag build compiles it on Apple Silicon. The +# moq-audio half has none: moq-c and moq-ffi take it codecs-only, so no release # build compiles its capture backend and this recipe is the only thing that does. # # Scoped to those two crates instead of the workspace, because they hold all @@ -722,23 +722,23 @@ audit: relay-minimal: cargo nextest run --locked -p moq-relay --no-default-features --lib -E 'test(workers_require_a_quic_backend)' -# libmoq's C fixtures (`rs/libmoq/c-tests/*.c`) link `libmoq.a` the way an +# moq-c's C fixtures (`rs/moq-c/c-tests/*.c`) link `libmoq.a` the way an # embedder does: an external `cc` against the generated `moq.h`, plus the native -# libraries from `rs/libmoq/native-libs` that cargo can't inject into a link it +# libraries from `rs/moq-c/native-libs` that cargo can't inject into a link it # doesn't drive. Each fixture pins part of the C ABI at compile time and # exercises it at runtime, so it has to run, not just compile. # # Outside nextest on purpose. The staticlib link alone takes ~2 minutes, past the # hang budget in `.config/nextest.toml` once the rest of the workspace builds # beside it, and `rs/AGENTS.md` says to make a slow test fast, not to raise the -# ceiling. obs.yml runs this on every PR that touches rs/libmoq, right after it +# ceiling. obs.yml runs this on every PR that touches rs/moq-c, right after it # has built the same debug libmoq.a for the plugin, and nightly.yml covers the # paths that filter misses. # # Unix only: linking a Rust staticlib from MSVC spells the flags and the # archive (`moq.lib`) differently, and this recipe doesn't model that. -# Compile and run libmoq's C fixtures, and the C doc samples, against libmoq.a. Must run on Unix. +# Compile and run moq-c's C fixtures, and the C doc samples, against libmoq.a. Must run on Unix. c-tests: #!/usr/bin/env bash set -euo pipefail @@ -748,33 +748,33 @@ c-tests: exit 1 fi - cargo build --locked -p libmoq + cargo build --locked -p moq-c # 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 libmoq --message-format=json) + log=$(cargo build --locked -p moq-c --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 libmoq" >&2 + echo "cargo reported no libmoq.a for moq-c" >&2 exit 1 fi profile=$(dirname "$lib") - # 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) + # 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) include="$out_dir/include" if [ -z "$out_dir" ] || [ ! -f "$include/moq.h" ]; then - echo "$include/moq.h missing after 'cargo build --locked -p libmoq'" >&2 + echo "$include/moq.h missing after 'cargo build --locked -p moq-c'" >&2 exit 1 fi - # Same list build.rs (moq.pc), CMakeLists.txt, and test/interop/interop.sh read: + # Same list build.rs (moq-c.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/libmoq/native-libs/apple.txt ;; - *) native_libs=rs/libmoq/native-libs/linux.txt ;; + Darwin) native_libs=rs/moq-c/native-libs/apple.txt ;; + *) native_libs=rs/moq-c/native-libs/linux.txt ;; esac libs=() while read -r entry; do @@ -792,7 +792,7 @@ c-tests: # 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/libmoq/c-tests/doc-samples.h -I"$include" "$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" for name in $(grep -oE '\b(moq|MOQ)_[A-Za-z0-9_]*' doc/lib/c/index.md | grep -v '_$' | sort -u); do if ! grep -qw "$name" "$include/moq.h"; then echo "doc/lib/c/index.md cites $name, which moq.h does not declare" >&2 @@ -800,7 +800,7 @@ c-tests: fi done - for source in rs/libmoq/c-tests/*.c; do + for source in rs/moq-c/c-tests/*.c; do bin="$out/$(basename "$source" .c)" "$cc" "$source" -I"$include" -L"$profile" -lmoq "${libs[@]}" -o "$bin" echo "running $source" diff --git a/rs/libmoq/Cargo.toml b/rs/libmoq/Cargo.toml index 13331998983..bdf227ecb20 100644 --- a/rs/libmoq/Cargo.toml +++ b/rs/libmoq/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "libmoq" -description = "Media over QUIC, C bindings" +description = "Renamed to moq-c: Media over QUIC, C bindings" authors = ["Luke Curley ", "Brian Medley "] repository = "https://github.com/moq-dev/moq" license = "MIT OR Apache-2.0" @@ -9,39 +9,5 @@ version = "0.6.6" edition = "2024" rust-version.workspace = true -keywords = ["quic", "http3", "webtransport", "media", "live"] -categories = ["multimedia", "network-programming", "web-programming"] - -[lib] -name = "moq" -crate-type = ["staticlib"] - -[dependencies] -anyhow = { workspace = true, features = ["backtrace"] } -bytes = { workspace = true } -hang = { workspace = true } -kio = { workspace = true } -# Codecs only: OBS and the other C consumers do their own device I/O. -moq-audio = { workspace = true, features = ["aac"] } -moq-json = { workspace = true } -moq-mux = { workspace = true } -moq-net = { workspace = true } -moq-tokio = { workspace = true, features = ["noq", "aws-lc-rs", "websocket", "tcp", "uds"] } -# Select the OpenH264 fallback plus NVIDIA and VAAPI hardware codecs explicitly -# because workspace defaults are off. The hardware backends dlopen their driver; -# `vaapi` also runs bindgen, so Linux builds need libclang. -moq-video = { workspace = true, features = ["nvidia", "openh264", "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] -moq-loc = { path = "../moq-loc" } +keywords = ["quic", "media", "live"] +categories = ["multimedia", "network-programming"] diff --git a/rs/libmoq/README.md b/rs/libmoq/README.md index 3892cd8d6b4..3157249496a 100644 --- a/rs/libmoq/README.md +++ b/rs/libmoq/README.md @@ -1,145 +1,10 @@ # libmoq -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` -- Generate the pkg-config file at `$OUT_DIR/lib/pkgconfig/moq.pc` - -`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. -`moq.pc` assumes the install layout (`lib/libmoq.a` beside `lib/pkgconfig/`), so -copy the staticlib into `$OUT_DIR/lib/` or a prefix before using it. - -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_status_callback on_status, void *user_data); -moq_client_config moq_client_defaults(void); -int32_t moq_session_close(uint32_t session); -int32_t moq_session_bandwidth(uint32_t session); -int32_t moq_bandwidth_reserve(uint32_t bandwidth, uint32_t track, uint64_t max_bps); -int32_t moq_bandwidth_close(uint32_t bandwidth); -int32_t moq_reservation_grant(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); - -// 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_status_callback on_status, 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_create_broadcast(uint32_t origin, const char *path, uintptr_t path_len); -int32_t moq_origin_request(uint32_t origin, const char *path, uintptr_t path_len, moq_status_callback on_broadcast, void *user_data); -int32_t moq_origin_request_cancel(uint32_t task); -int32_t moq_origin_announced_broadcast(uint32_t origin, const char *path, uintptr_t path_len, moq_status_callback on_broadcast, void *user_data); -int32_t moq_origin_announced_broadcast_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_update *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. - -// Publishing -int32_t moq_publish_announce(uint32_t broadcast, const moq_route *route); -int32_t moq_publish_unannounce(uint32_t broadcast); -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, uint64_t timestamp_us); -int32_t moq_publish_media_flush(uint32_t media, uint64_t timestamp_us); -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); -int32_t moq_publish_track_frame(uint32_t track, const uint8_t *payload, uintptr_t payload_size, uint64_t timestamp_us); -int32_t moq_publish_group_frame(uint32_t group, const uint8_t *payload, uintptr_t payload_size, uint64_t timestamp_us); -int32_t moq_publish_group_finish(uint32_t group); -int32_t moq_publish_track_finish(uint32_t track); - -// 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); - -// Publishing: Requests -int32_t moq_publish_dynamic(uint32_t broadcast, moq_status_callback on_request, void *user_data); -int32_t moq_publish_track_dynamic(uint32_t track, moq_status_callback on_group, void *user_data); -int32_t moq_track_request_dynamic(uint32_t request, moq_status_callback on_group, void *user_data); -int32_t moq_publish_dynamic_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_sequence(uint32_t request, uint64_t *dst); -int32_t moq_group_request_priority(uint32_t request, uint8_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); - -// Consuming: Catalog -int32_t moq_consume_catalog(uint32_t broadcast, moq_status_callback on_catalog, void *user_data); -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_stalled(uint32_t catalog, uint32_t index, bool *dst); -int32_t moq_consume_audio_config(uint32_t catalog, uint32_t index, moq_audio_config *dst); - -// Consuming: Video -int32_t moq_consume_video(uint32_t catalog, uint32_t index, uint64_t max_age_us, 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, uint64_t max_age_us, moq_status_callback on_frame, void *user_data); -int32_t moq_consume_audio_cancel(uint32_t track); - -// Consuming: Frames -int32_t moq_consume_frame(uint32_t frame, moq_frame *dst); -int32_t moq_consume_frame_free(uint32_t frame); -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); -``` - -Raw track frames use the same `moq_frame` record as media frames. Use -`moq_publish_track_frame` or `moq_publish_group_frame` to provide microsecond -presentation timestamps; `moq_consume_track_frame` returns that timestamp in -`moq_frame.timestamp_us`. libmoq creates raw tracks with a microsecond -timescale, matching the C ABI's timestamp units. +`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). diff --git a/rs/libmoq/src/lib.rs b/rs/libmoq/src/lib.rs index 560dde71ed4..7913c79d6bc 100644 --- a/rs/libmoq/src/lib.rs +++ b/rs/libmoq/src/lib.rs @@ -1,51 +1 @@ -//! 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 bandwidth; -mod client; -mod consume; -mod error; -mod ffi; -mod id; -mod origin; -mod publish; -mod server; -mod session; -mod state; -mod video; - -pub use api::*; -pub use audio::*; -pub use bandwidth::*; -pub use error::*; -pub use ffi::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; +#![doc = include_str!("../README.md")] diff --git a/rs/libmoq/CHANGELOG.md b/rs/moq-c/CHANGELOG.md similarity index 100% rename from rs/libmoq/CHANGELOG.md rename to rs/moq-c/CHANGELOG.md diff --git a/rs/libmoq/CMakeLists.txt b/rs/moq-c/CMakeLists.txt similarity index 83% rename from rs/libmoq/CMakeLists.txt rename to rs/moq-c/CMakeLists.txt index 9c14c080ad1..6f604d7af85 100644 --- a/rs/libmoq/CMakeLists.txt +++ b/rs/moq-c/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) config, where it silently breaks version +# the installed find_package(moq-c) 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/libmoq/Cargo.toml (project() takes a numeric x.y.z)") + message(FATAL_ERROR "Unsupported version '${_version}' in rs/moq-c/Cargo.toml (project() takes a numeric x.y.z)") endif() -project(moq VERSION ${_version} LANGUAGES C) +project(moq-c VERSION ${_version} LANGUAGES C) option(BUILD_RUST_LIB "Build the Rust library using cargo" ON) @@ -62,6 +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) target_include_directories(moq INTERFACE ${RUST_INCLUDE_DIR}) # Link the static library - must use target_link_libraries so it appears @@ -70,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. build.rs -# reads the same files for moq.pc, so the two never drift. +# reads the same files for moq-c.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. @@ -106,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-config.cmake.in below. +# Same list, quoted for substitution into cmake/moq-c-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) @@ -135,27 +137,27 @@ if(PROJECT_IS_TOP_LEVEL) # Generate and install CMake package config files include(CMakePackageConfigHelpers) - # The remaining placeholders in cmake/moq-config.cmake.in. rs/libmoq/build.sh + # The remaining placeholders in cmake/moq-c-config.cmake.in. rs/moq-c/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-config.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/moq-config.cmake - INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/moq + ${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 PATH_VARS CMAKE_INSTALL_LIBDIR CMAKE_INSTALL_INCLUDEDIR ) write_basic_package_version_file( - ${CMAKE_CURRENT_BINARY_DIR}/moq-config-version.cmake + ${CMAKE_CURRENT_BINARY_DIR}/moq-c-config-version.cmake VERSION ${PROJECT_VERSION} COMPATIBILITY SameMajorVersion ) install(FILES - ${CMAKE_CURRENT_BINARY_DIR}/moq-config.cmake - ${CMAKE_CURRENT_BINARY_DIR}/moq-config-version.cmake - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/moq + ${CMAKE_CURRENT_BINARY_DIR}/moq-c-config.cmake + ${CMAKE_CURRENT_BINARY_DIR}/moq-c-config-version.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/moq-c ) endif() diff --git a/rs/moq-c/Cargo.toml b/rs/moq-c/Cargo.toml new file mode 100644 index 00000000000..c7564df3878 --- /dev/null +++ b/rs/moq-c/Cargo.toml @@ -0,0 +1,47 @@ +[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"] + +[dependencies] +anyhow = { workspace = true, features = ["backtrace"] } +bytes = { workspace = true } +hang = { workspace = true } +kio = { workspace = true } +# Codecs only: OBS and the other C consumers do their own device I/O. +moq-audio = { workspace = true, features = ["aac"] } +moq-json = { workspace = true } +moq-mux = { workspace = true } +moq-net = { workspace = true } +moq-tokio = { workspace = true, features = ["noq", "aws-lc-rs", "websocket", "tcp", "uds"] } +# Select the OpenH264 fallback plus NVIDIA and VAAPI hardware codecs explicitly +# because workspace defaults are off. The hardware backends dlopen their driver; +# `vaapi` also runs bindgen, so Linux builds need libclang. +moq-video = { workspace = true, features = ["nvidia", "openh264", "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] +moq-loc = { path = "../moq-loc" } diff --git a/rs/moq-c/README.md b/rs/moq-c/README.md new file mode 100644 index 00000000000..7ac62ae0330 --- /dev/null +++ b/rs/moq-c/README.md @@ -0,0 +1,145 @@ +# 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` +- Generate the pkg-config file at `$OUT_DIR/lib/pkgconfig/moq-c.pc` + +`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. +`moq-c.pc` assumes the install layout (`lib/libmoq.a` beside `lib/pkgconfig/`), so +copy the staticlib into `$OUT_DIR/lib/` or a prefix before using it. + +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_status_callback on_status, void *user_data); +moq_client_config moq_client_defaults(void); +int32_t moq_session_close(uint32_t session); +int32_t moq_session_bandwidth(uint32_t session); +int32_t moq_bandwidth_reserve(uint32_t bandwidth, uint32_t track, uint64_t max_bps); +int32_t moq_bandwidth_close(uint32_t bandwidth); +int32_t moq_reservation_grant(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); + +// 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_status_callback on_status, 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_create_broadcast(uint32_t origin, const char *path, uintptr_t path_len); +int32_t moq_origin_request(uint32_t origin, const char *path, uintptr_t path_len, moq_status_callback on_broadcast, void *user_data); +int32_t moq_origin_request_cancel(uint32_t task); +int32_t moq_origin_announced_broadcast(uint32_t origin, const char *path, uintptr_t path_len, moq_status_callback on_broadcast, void *user_data); +int32_t moq_origin_announced_broadcast_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_update *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. + +// Publishing +int32_t moq_publish_announce(uint32_t broadcast, const moq_route *route); +int32_t moq_publish_unannounce(uint32_t broadcast); +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, uint64_t timestamp_us); +int32_t moq_publish_media_flush(uint32_t media, uint64_t timestamp_us); +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); +int32_t moq_publish_track_frame(uint32_t track, const uint8_t *payload, uintptr_t payload_size, uint64_t timestamp_us); +int32_t moq_publish_group_frame(uint32_t group, const uint8_t *payload, uintptr_t payload_size, uint64_t timestamp_us); +int32_t moq_publish_group_finish(uint32_t group); +int32_t moq_publish_track_finish(uint32_t track); + +// 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); + +// Publishing: Requests +int32_t moq_publish_dynamic(uint32_t broadcast, moq_status_callback on_request, void *user_data); +int32_t moq_publish_track_dynamic(uint32_t track, moq_status_callback on_group, void *user_data); +int32_t moq_track_request_dynamic(uint32_t request, moq_status_callback on_group, void *user_data); +int32_t moq_publish_dynamic_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_sequence(uint32_t request, uint64_t *dst); +int32_t moq_group_request_priority(uint32_t request, uint8_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); + +// Consuming: Catalog +int32_t moq_consume_catalog(uint32_t broadcast, moq_status_callback on_catalog, void *user_data); +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_stalled(uint32_t catalog, uint32_t index, bool *dst); +int32_t moq_consume_audio_config(uint32_t catalog, uint32_t index, moq_audio_config *dst); + +// Consuming: Video +int32_t moq_consume_video(uint32_t catalog, uint32_t index, uint64_t max_age_us, 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, uint64_t max_age_us, moq_status_callback on_frame, void *user_data); +int32_t moq_consume_audio_cancel(uint32_t track); + +// Consuming: Frames +int32_t moq_consume_frame(uint32_t frame, moq_frame *dst); +int32_t moq_consume_frame_free(uint32_t frame); +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); +``` + +Raw track frames use the same `moq_frame` record as media frames. Use +`moq_publish_track_frame` or `moq_publish_group_frame` to provide microsecond +presentation timestamps; `moq_consume_track_frame` returns that timestamp in +`moq_frame.timestamp_us`. moq-c creates raw tracks with a microsecond +timescale, matching the C ABI's timestamp units. diff --git a/rs/libmoq/build.rs b/rs/moq-c/build.rs similarity index 96% rename from rs/libmoq/build.rs rename to rs/moq-c/build.rs index 3ba1a40b7f2..52dfbb43ce1 100644 --- a/rs/libmoq/build.rs +++ b/rs/moq-c/build.rs @@ -60,10 +60,10 @@ fn main() { .expect("Unable to generate bindings") .write_to_file(&header); - let pc_in = PathBuf::from(&crate_dir).join(format!("{}.pc.in", LIB_NAME)); + let pc_in = PathBuf::from(&crate_dir).join("moq-c.pc.in"); let pkgconfig_dir = out_dir.join("lib").join("pkgconfig"); fs::create_dir_all(&pkgconfig_dir).expect("Failed to create pkgconfig directory"); - let pc_out = pkgconfig_dir.join(format!("{}.pc", LIB_NAME)); + let pc_out = pkgconfig_dir.join("moq-c.pc"); if let Ok(template) = fs::read_to_string(&pc_in) { let target = env::var("TARGET").unwrap(); let libs_private = native_libs(&crate_dir, &target); diff --git a/rs/libmoq/build.sh b/rs/moq-c/build.sh similarity index 81% rename from rs/libmoq/build.sh rename to rs/moq-c/build.sh index 7eb7ff5ba3f..e07690b8fd2 100755 --- a/rs/libmoq/build.sh +++ b/rs/moq-c/build.sh @@ -1,14 +1,14 @@ #!/usr/bin/env bash set -euo pipefail -# Build and package libmoq for release. +# Build and package moq-c 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 .#libmoq` for reproducibility. +# On Linux and macOS this builds via `nix build .#moq-c` for reproducibility. # Windows targets fall back to a direct cargo build because Nix isn't # practical to install on the Windows GitHub runner image. @@ -17,7 +17,7 @@ RS_DIR="$(cd "$SCRIPT_DIR/.." && pwd)" WORKSPACE_DIR="$(cd "$RS_DIR/.." && pwd)" # Shrink the release staticlib. libmoq.a carries the same heavy dep tree as -# moq-ffi, so an unstripped build is ~75 MB+. libmoq ships as a release +# moq-ffi, so an unstripped build is ~75 MB+. moq-c ships as a release # tarball (not a git mirror, so no hard 100 MB limit like moq-go), but thin # LTO with a single codegen unit dead-strips the unused monomorphizations Rust # bakes into a staticlib, halving the artifact with no source or ABI changes. @@ -66,7 +66,7 @@ if [[ -z "$TARGET" ]]; then echo "Detected target: $TARGET" fi -NAME="moq-${VERSION}-${TARGET}" +NAME="moq-c-${VERSION}-${TARGET}" PACKAGE_DIR="$OUTPUT_DIR/$NAME" echo "Packaging $NAME..." @@ -74,25 +74,25 @@ rm -rf "$PACKAGE_DIR" mkdir -p "$PACKAGE_DIR/include" "$PACKAGE_DIR/lib" if [[ "$TARGET" == *"-windows-"* ]]; then - echo "Building libmoq for $TARGET via cargo (Windows path)..." + echo "Building moq-c for $TARGET via cargo (Windows path)..." BUILD_LOG="$(mktemp)" trap 'rm -f "$BUILD_LOG"' EXIT - cargo build --locked --release --package libmoq --target "$TARGET" --manifest-path "$WORKSPACE_DIR/Cargo.toml" \ + cargo build --locked --release --package moq-c --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("libmoq")) | .out_dir' "$BUILD_LOG" | tail -1) + GEN_DIR=$(jq -r 'select(.reason == "build-script-executed") | select(.package_id | test("/moq-c#")) | .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" + mkdir -p "$PACKAGE_DIR/lib/cmake/moq-c" MAJOR_VERSION="${VERSION%%.*}" # The native libraries an external linker must pass alongside moq.lib, - # quoted the way rs/libmoq/CMakeLists.txt and nix/overlay.nix format them. + # quoted the way rs/moq-c/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") @@ -100,10 +100,10 @@ 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-config.cmake.in" >"$PACKAGE_DIR/lib/cmake/moq/moq-config.cmake" + "$SCRIPT_DIR/cmake/moq-c-config.cmake.in" >"$PACKAGE_DIR/lib/cmake/moq-c/moq-c-config.cmake" sed -e "s|@VERSION@|${VERSION}|g" \ -e "s|@MAJOR_VERSION@|${MAJOR_VERSION}|g" \ - "$SCRIPT_DIR/cmake/moq-config-version.cmake.in" >"$PACKAGE_DIR/lib/cmake/moq/moq-config-version.cmake" + "$SCRIPT_DIR/cmake/moq-c-config-version.cmake.in" >"$PACKAGE_DIR/lib/cmake/moq-c/moq-c-config-version.cmake" else # Release builds must match the host. A mismatch would silently mislabel # the archive, so reject it before building. @@ -113,11 +113,11 @@ else exit 1 fi - echo "Building libmoq for $TARGET via nix..." + echo "Building moq-c for $TARGET via nix..." BUILD_TMP="$(mktemp -d)" trap 'rm -rf "$BUILD_TMP"' EXIT RESULT_LINK="$BUILD_TMP/result" - nix build "$WORKSPACE_DIR#libmoq" --out-link "$RESULT_LINK" + nix build "$WORKSPACE_DIR#moq-c" --out-link "$RESULT_LINK" # The derivation lays out everything under $out/{lib,include}; copy it # verbatim so the release tarball matches what nix produced. @@ -127,11 +127,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) hands the linker +# above, nix/overlay.nix) ships a config whose find_package(moq-c) 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-config.cmake moq-config-version.cmake; do - CMAKE_CONFIG="$PACKAGE_DIR/lib/cmake/moq/$cmake_file" +for cmake_file in moq-c-config.cmake moq-c-config-version.cmake; do + CMAKE_CONFIG="$PACKAGE_DIR/lib/cmake/moq-c/$cmake_file" if [[ ! -f "$CMAKE_CONFIG" ]]; then echo "Error: $CMAKE_CONFIG missing from the package" >&2 exit 1 diff --git a/rs/libmoq/c-tests/decode-output.c b/rs/moq-c/c-tests/decode-output.c similarity index 99% rename from rs/libmoq/c-tests/decode-output.c rename to rs/moq-c/c-tests/decode-output.c index 057f33e62d9..663907df4c0 100644 --- a/rs/libmoq/c-tests/decode-output.c +++ b/rs/moq-c/c-tests/decode-output.c @@ -37,7 +37,7 @@ _Static_assert(offsetof(moq_video_decoder_output, width) == 12, "width moved"); _Static_assert(offsetof(moq_video_decoder_output, height) == 16, "height moved"); _Static_assert(sizeof(moq_video_decoder_output) == 24, "decoder output size changed"); -// Numeric codes from rs/libmoq/src/error.rs. They are the contract a C caller +// Numeric codes from rs/moq-c/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/libmoq/c-tests/doc-samples.h b/rs/moq-c/c-tests/doc-samples.h similarity index 100% rename from rs/libmoq/c-tests/doc-samples.h rename to rs/moq-c/c-tests/doc-samples.h diff --git a/rs/libmoq/cbindgen.toml b/rs/moq-c/cbindgen.toml similarity index 96% rename from rs/libmoq/cbindgen.toml rename to rs/moq-c/cbindgen.toml index d23798a319f..af1058b39b7 100644 --- a/rs/libmoq/cbindgen.toml +++ b/rs/moq-c/cbindgen.toml @@ -1,4 +1,4 @@ -# cbindgen configuration for libmoq. +# cbindgen configuration for moq-c. # # NOT loaded: build.rs drives cbindgen through `Builder::new()`, which never # discovers this file, and passes its own config. The generated moq.h therefore diff --git a/rs/libmoq/cmake/cargo-build.cmake b/rs/moq-c/cmake/cargo-build.cmake similarity index 76% rename from rs/libmoq/cmake/cargo-build.cmake rename to rs/moq-c/cmake/cargo-build.cmake index 4a0316a31f5..b2ab5553c83 100644 --- a/rs/libmoq/cmake/cargo-build.cmake +++ b/rs/moq-c/cmake/cargo-build.cmake @@ -1,6 +1,6 @@ -# Run with `cmake -DCARGO_BUILD_FLAG=... -DHEADER=... -P cargo-build.cmake` from rs/libmoq. +# Run with `cmake -DCARGO_BUILD_FLAG=... -DHEADER=... -P cargo-build.cmake` from rs/moq-c. # -# Builds libmoq, then copies moq.h to HEADER. build.rs writes the header into +# Builds moq-c, 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 ${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\":\"[^\"]*/libmoq#[^\n]*" _message "${_messages}") +string(REGEX MATCH "{\"reason\":\"build-script-executed\",\"package_id\":\"[^\"]*/moq-c#[^\n]*" _message "${_messages}") if(NOT _message) - message(FATAL_ERROR "cargo reported no build script output for libmoq") + message(FATAL_ERROR "cargo reported no build script output for moq-c") endif() string(JSON _out_dir GET "${_message}" out_dir) diff --git a/rs/libmoq/cmake/moq-config-version.cmake.in b/rs/moq-c/cmake/moq-c-config-version.cmake.in similarity index 95% rename from rs/libmoq/cmake/moq-config-version.cmake.in rename to rs/moq-c/cmake/moq-c-config-version.cmake.in index 990a3ccc887..add17654b20 100644 --- a/rs/libmoq/cmake/moq-config-version.cmake.in +++ b/rs/moq-c/cmake/moq-c-config-version.cmake.in @@ -1,4 +1,4 @@ -# moq CMake version file +# moq-c CMake version file set(PACKAGE_VERSION "@VERSION@") diff --git a/rs/libmoq/cmake/moq-config.cmake.in b/rs/moq-c/cmake/moq-c-config.cmake.in similarity index 70% rename from rs/libmoq/cmake/moq-config.cmake.in rename to rs/moq-c/cmake/moq-c-config.cmake.in index 41a1012d875..a1d740c2576 100644 --- a/rs/libmoq/cmake/moq-config.cmake.in +++ b/rs/moq-c/cmake/moq-c-config.cmake.in @@ -1,4 +1,5 @@ -# moq CMake configuration file +# 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. # Compute installation prefix relative to this file get_filename_component(_moq_prefix "${CMAKE_CURRENT_LIST_FILE}" PATH) @@ -14,19 +15,19 @@ set(_moq_libdir "${_moq_prefix}/lib") set(_moq_lib_name "@LIB_FILE@") # Create imported target -if(NOT TARGET moq::moq) - add_library(moq::moq STATIC IMPORTED) +if(NOT TARGET moq::c) + add_library(moq::c STATIC IMPORTED) - set_target_properties(moq::moq PROPERTIES + set_target_properties(moq::c 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/libmoq/native-libs/ for the platform this was built + # install time from rs/moq-c/native-libs/ for the platform this was built # for, which is the only platform the installed static library works on. - set_property(TARGET moq::moq APPEND PROPERTY + set_property(TARGET moq::c APPEND PROPERTY INTERFACE_LINK_LIBRARIES @MOQ_NATIVE_LIBS_QUOTED@ ) endif() @@ -38,5 +39,5 @@ unset(_moq_libdir) unset(_moq_lib_name) # Package metadata -set(moq_FOUND TRUE) -set(moq_VERSION "@VERSION@") +set(moq-c_FOUND TRUE) +set(moq-c_VERSION "@VERSION@") diff --git a/rs/libmoq/moq.pc.in b/rs/moq-c/moq-c.pc.in similarity index 94% rename from rs/libmoq/moq.pc.in rename to rs/moq-c/moq-c.pc.in index fc21229333e..298baaf0c54 100644 --- a/rs/libmoq/moq.pc.in +++ b/rs/moq-c/moq-c.pc.in @@ -1,10 +1,10 @@ # Paths are relative to this .pc file, in the install layout the release -# tarballs and nix/overlay.nix ship: lib/{libmoq.a,pkgconfig/moq.pc} and +# tarballs and nix/overlay.nix ship: lib/{libmoq.a,pkgconfig/moq-c.pc} and # include/moq.h under one prefix. libdir=${pcfiledir}/.. includedir=${pcfiledir}/../../include -Name: moq +Name: moq-c Description: Media over QUIC C Interface Version: @VERSION@ Libs: -L${libdir} -lmoq diff --git a/rs/libmoq/native-libs/apple.txt b/rs/moq-c/native-libs/apple.txt similarity index 80% rename from rs/libmoq/native-libs/apple.txt rename to rs/moq-c/native-libs/apple.txt index a4315b87488..498703d637f 100644 --- a/rs/libmoq/native-libs/apple.txt +++ b/rs/moq-c/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. build.rs bakes it into moq.pc, CMakeLists.txt reads it for the -# moq::moq target and the installed find_package config, and test/interop/interop.sh +# Canonical list. build.rs bakes it into moq-c.pc, CMakeLists.txt reads it for the +# moq::c target and the installed find_package config, and test/interop/interop.sh # links its C client with it. Keep the derived consumers reading this file rather # than repeating the list. # @@ -11,7 +11,7 @@ # plain library name. `#` comments and blank lines are ignored. # # Regenerate after a dependency change with: -# cargo rustc -p libmoq --crate-type staticlib -- --print native-static-libs +# cargo rustc -p moq-c --crate-type staticlib -- --print native-static-libs # rustls / std framework:CoreFoundation diff --git a/rs/libmoq/native-libs/linux.txt b/rs/moq-c/native-libs/linux.txt similarity index 100% rename from rs/libmoq/native-libs/linux.txt rename to rs/moq-c/native-libs/linux.txt diff --git a/rs/libmoq/native-libs/windows.txt b/rs/moq-c/native-libs/windows.txt similarity index 100% rename from rs/libmoq/native-libs/windows.txt rename to rs/moq-c/native-libs/windows.txt diff --git a/rs/libmoq/src/api.rs b/rs/moq-c/src/api.rs similarity index 99% rename from rs/libmoq/src/api.rs rename to rs/moq-c/src/api.rs index 0c3f6e2418b..740efa2c756 100644 --- a/rs/libmoq/src/api.rs +++ b/rs/moq-c/src/api.rs @@ -590,8 +590,8 @@ impl From<&moq_subscription> for moq_net::track::Subscription { /// A borrowed UTF-8 string slice, NOT NULL terminated. /// -/// 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 +/// 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 /// 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. @@ -857,12 +857,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. /// -/// libmoq functions return only a negative code; this exposes the matching message +/// moq-c 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 libmoq call **on the +/// Returns a NUL-terminated, UTF-8 pointer valid until the next moq-c 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. @@ -879,7 +879,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 libmoq call on +/// code first. Same lifetime as [moq_error]: overwritten by the next moq-c call on /// this thread. Errors delivered through status callbacks are recorded before the /// callback runs, so read this from inside the callback. /// diff --git a/rs/libmoq/src/audio.rs b/rs/moq-c/src/audio.rs similarity index 100% rename from rs/libmoq/src/audio.rs rename to rs/moq-c/src/audio.rs diff --git a/rs/libmoq/src/bandwidth.rs b/rs/moq-c/src/bandwidth.rs similarity index 100% rename from rs/libmoq/src/bandwidth.rs rename to rs/moq-c/src/bandwidth.rs diff --git a/rs/libmoq/src/client.rs b/rs/moq-c/src/client.rs similarity index 100% rename from rs/libmoq/src/client.rs rename to rs/moq-c/src/client.rs diff --git a/rs/libmoq/src/consume.rs b/rs/moq-c/src/consume.rs similarity index 100% rename from rs/libmoq/src/consume.rs rename to rs/moq-c/src/consume.rs diff --git a/rs/libmoq/src/error.rs b/rs/moq-c/src/error.rs similarity index 100% rename from rs/libmoq/src/error.rs rename to rs/moq-c/src/error.rs diff --git a/rs/libmoq/src/ffi.rs b/rs/moq-c/src/ffi.rs similarity index 98% rename from rs/libmoq/src/ffi.rs rename to rs/moq-c/src/ffi.rs index c081700c98d..b66c3d610ee 100644 --- a/rs/libmoq/src/ffi.rs +++ b/rs/moq-c/src/ffi.rs @@ -20,7 +20,7 @@ pub static RUNTIME: LazyLock = LazyLock::new(|| { let handle = runtime.handle().clone(); std::thread::Builder::new() - .name("libmoq".into()) + .name("moq-c".into()) .spawn(move || { runtime.block_on(std::future::pending::<()>()); }) @@ -209,7 +209,7 @@ fn record_error(ret: &C) { /// Pointer to this thread's last error message, or null if none was recorded. /// -/// The pointer is valid until the next libmoq call on the same thread. +/// The pointer is valid until the next moq-c call on the same thread. pub fn last_error_ptr() -> *const c_char { LAST_ERROR.with(|cell| { cell.borrow() diff --git a/rs/libmoq/src/id.rs b/rs/moq-c/src/id.rs similarity index 100% rename from rs/libmoq/src/id.rs rename to rs/moq-c/src/id.rs diff --git a/rs/moq-c/src/lib.rs b/rs/moq-c/src/lib.rs new file mode 100644 index 00000000000..560dde71ed4 --- /dev/null +++ b/rs/moq-c/src/lib.rs @@ -0,0 +1,51 @@ +//! 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 bandwidth; +mod client; +mod consume; +mod error; +mod ffi; +mod id; +mod origin; +mod publish; +mod server; +mod session; +mod state; +mod video; + +pub use api::*; +pub use audio::*; +pub use bandwidth::*; +pub use error::*; +pub use ffi::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/libmoq/src/origin.rs b/rs/moq-c/src/origin.rs similarity index 99% rename from rs/libmoq/src/origin.rs rename to rs/moq-c/src/origin.rs index 1695b0e705c..5fb0cfc99c9 100644 --- a/rs/libmoq/src/origin.rs +++ b/rs/moq-c/src/origin.rs @@ -89,7 +89,7 @@ struct DynamicEntry { impl Origin { pub fn create(&mut self) -> Result { // Every FFI entry point runs inside `RUNTIME.enter()`, so the driver - // lands on the dedicated libmoq runtime. + // lands on the dedicated moq-c runtime. self.active.insert(moq_tokio::origin::spawn()) } diff --git a/rs/libmoq/src/publish.rs b/rs/moq-c/src/publish.rs similarity index 99% rename from rs/libmoq/src/publish.rs rename to rs/moq-c/src/publish.rs index 27b3d054573..5cdc78f2f8b 100644 --- a/rs/libmoq/src/publish.rs +++ b/rs/moq-c/src/publish.rs @@ -99,7 +99,7 @@ pub struct Publish { impl Publish { /// Store an origin-created broadcast producer, attaching the catalog track - /// every libmoq broadcast carries. + /// every moq-c broadcast carries. pub fn create(&mut self, mut broadcast: moq_net::broadcast::Producer) -> Result { let config = moq_mux::catalog::Config::default() .with_catalog(moq_mux::catalog::hang::Catalog::::default()); diff --git a/rs/libmoq/src/server.rs b/rs/moq-c/src/server.rs similarity index 100% rename from rs/libmoq/src/server.rs rename to rs/moq-c/src/server.rs diff --git a/rs/libmoq/src/session.rs b/rs/moq-c/src/session.rs similarity index 99% rename from rs/libmoq/src/session.rs rename to rs/moq-c/src/session.rs index 26819a833c4..ca443927179 100644 --- a/rs/libmoq/src/session.rs +++ b/rs/moq-c/src/session.rs @@ -259,7 +259,7 @@ impl Session { connects += 1; // Positive status carries the connection epoch, so callers can tell a // reconnect (>1) from the first connect (1). No lock is held, so the C - // callback is free to re-enter libmoq. + // callback is free to re-enter moq-c. let code = i32::try_from(connects) .context("connection epoch exceeded i32::MAX") .map_err(|err| Error::Connect(Arc::new(err)))?; diff --git a/rs/libmoq/src/state.rs b/rs/moq-c/src/state.rs similarity index 100% rename from rs/libmoq/src/state.rs rename to rs/moq-c/src/state.rs diff --git a/rs/libmoq/src/test.rs b/rs/moq-c/src/test.rs similarity index 99% rename from rs/libmoq/src/test.rs rename to rs/moq-c/src/test.rs index a4820f11306..c57997ed39f 100644 --- a/rs/libmoq/src/test.rs +++ b/rs/moq-c/src/test.rs @@ -3630,7 +3630,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 libmoq's process-wide +/// never comes back from it. It used to run under both of moq-c'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. @@ -4907,7 +4907,7 @@ fn read_raw_frames(consume: u32, name: &[u8], count: usize) -> Vec> { assert_eq!(moq_consume_track_frame_free(frame_id), 0); } assert_eq!(moq_consume_track_cancel(track), 0); - // The callback context must outlive libmoq's last call into it: wait for the terminal. + // The callback context must outlive moq-c's last call into it: wait for the terminal. assert_eq!(frame_cb.recv_terminal(), 0, "clean cancel delivers terminal 0"); payloads } diff --git a/rs/libmoq/src/video.rs b/rs/moq-c/src/video.rs similarity index 100% rename from rs/libmoq/src/video.rs rename to rs/moq-c/src/video.rs diff --git a/rs/moq-cli/Cargo.toml b/rs/moq-cli/Cargo.toml index 6065077ddd6..a9dc666f9d6 100644 --- a/rs/moq-cli/Cargo.toml +++ b/rs/moq-cli/Cargo.toml @@ -19,10 +19,10 @@ categories = ["multimedia", "network-programming", "web-programming"] [[bin]] name = "moq" path = "src/main.rs" -# `libmoq`'s staticlib is also named `moq`, so a `cargo doc` selecting both renders +# `moq-c`'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/libmoq is the published C API reference. +# no public API to render, whereas docs.rs/moq-c is the published C API reference. doc = false [features] diff --git a/rs/moq-ffi/AGENTS.md b/rs/moq-ffi/AGENTS.md index 67972929dd7..7d3a51b5e7a 100644 --- a/rs/moq-ffi/AGENTS.md +++ b/rs/moq-ffi/AGENTS.md @@ -4,7 +4,7 @@ The UniFFI core every non-Rust binding is generated from. Proc-macro based (`#[u Mirror every change in the same PR: -- `rs/libmoq`: the C staticlib (`cbindgen` emits `moq.h`). If the C ABI moved, also `cpp/obs`. +- `rs/moq-c`: the C staticlib (`cbindgen` emits `moq.h`). If the C ABI moved, also `cpp/obs`. - Hand-written wrappers: `py/moq-rs`, `go/wrapper/moq`, `dart/moq`, `swift/Sources`, `kt/moq`. The `go/ffi` and `dart/moq_ffi` layers regenerate, but a new method still needs its ergonomic wrapper. - Docs under `doc/lib/{py,go,dart,swift,kt,c}`. - Then `just test interop --all` for the interop matrix. diff --git a/rs/moq-ffi/Cargo.toml b/rs/moq-ffi/Cargo.toml index 7b822275cc0..b9e8f8c5ef4 100644 --- a/rs/moq-ffi/Cargo.toml +++ b/rs/moq-ffi/Cargo.toml @@ -50,7 +50,7 @@ url = { workspace = true } # Codecs only: the language wrappers do their own device I/O. moq-audio = { workspace = true, optional = true, features = ["aac"] } moq-tokio = { workspace = true, default-features = true } -# `openh264`, `nvidia`, and `vaapi` back on, matching rs/libmoq: the workspace turns +# `openh264`, `nvidia`, and `vaapi` back on, matching rs/moq-c: 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 95944688ead..aff41c41bfa 100644 --- a/rs/moq-ffi/src/test.rs +++ b/rs/moq-ffi/src/test.rs @@ -1692,7 +1692,7 @@ async fn resolve_rejects_a_reference_without_an_origin() { consumer.resolve(Some(String::new())).await.unwrap(); consumer.resolve(Some("/".into())).await.unwrap(); - // Reported in normalized form, matching `EscapingBroadcast` and libmoq: it names what the + // Reported in normalized form, matching `EscapingBroadcast` and moq-c: it names what the // resolver actually tried to reach, not the caller's spelling of it. match consumer.resolve(Some("./source".into())).await { Err(MoqError::UnresolvableBroadcast(reference)) => assert_eq!(reference, "source"), diff --git a/rs/moq-video/src/decode/consumer.rs b/rs/moq-video/src/decode/consumer.rs index 96df15c11c9..bb976c34338 100644 --- a/rs/moq-video/src/decode/consumer.rs +++ b/rs/moq-video/src/decode/consumer.rs @@ -74,7 +74,7 @@ impl Options { /// `moq_audio::decode::Consumer`. pub struct Consumer { /// A [`Sink`] rather than a bare `Decoder`: the read loop below is held - /// across `.await` by every caller (libmoq's spawned task, moq-transcode), + /// across `.await` by every caller (moq-c'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 1bfece02bf7..bb3ddd3ccb1 100644 --- a/rs/moq-video/src/decode/mod.rs +++ b/rs/moq-video/src/decode/mod.rs @@ -30,7 +30,7 @@ pub use sink::Sink; #[cfg(test)] mod tests { - /// Callers (libmoq, moq-transcode) hold these across `.await`s in spawned + /// Callers (moq-c, 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 3bd15bea291..1f4784de086 100644 --- a/rs/moq-video/src/decode/sink.rs +++ b/rs/moq-video/src/decode/sink.rs @@ -262,7 +262,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 libmoq drives; moq-transcode's feed and fetch pipeline), so the + /// which moq-c 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/swift/Package.swift b/swift/Package.swift index 97256a74c93..42825605688 100644 --- a/swift/Package.swift +++ b/swift/Package.swift @@ -22,8 +22,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/libmoq/native-libs/apple.txt, which solves the same problem for - // C consumers of libmoq. These cover moq-video / moq-audio: hardware + // 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 // H.264/H.265 encode and decode, plus capture. All macOS-only, since // those backends are `cfg(target_os = "macos")`. .linkedFramework("AVFoundation", .when(platforms: [.macOS])), diff --git a/swift/ffi/Package.swift.template b/swift/ffi/Package.swift.template index d66fb3d01b6..1288ec6d677 100644 --- a/swift/ffi/Package.swift.template +++ b/swift/ffi/Package.swift.template @@ -22,8 +22,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/libmoq/native-libs/apple.txt, which solves the same problem for - // C consumers of libmoq. These cover moq-video / moq-audio: hardware + // 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 // H.264/H.265 encode and decode, plus capture. All macOS-only, since // those backends are `cfg(target_os = "macos")`. .linkedFramework("AVFoundation", .when(platforms: [.macOS])), diff --git a/test/interop/README.md b/test/interop/README.md index ab969fc1a03..9f645062b92 100644 --- a/test/interop/README.md +++ b/test/interop/README.md @@ -32,7 +32,7 @@ player survive the publication lifecycle. See [Media QA](#media-qa). | Go | `go/wrapper` (+ `rs/moq-ffi`, import `moq-go/moq`) | `go/scripts/stage.sh` (uniffi-bindgen-go) + `go build` | 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/libmoq` | `cargo build -p libmoq` + `cc` | subscribe | +| C | `rs/moq-c` | `cargo build -p moq-c` + `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 @@ -178,7 +178,7 @@ clients/ src/probe.ts subscriber-side measurement, taken at the sinks src/instrument.ts live counts of the platform resources the page holds js-native/subscribe.ts subscribe via @moq/net + @moq/hang + the WebTransport polyfill - c/subscribe.c subscribe via rs/libmoq + c/subscribe.c subscribe via rs/moq-c ``` ## CI diff --git a/test/interop/clients/c/subscribe.c b/test/interop/clients/c/subscribe.c index 5d5e60aabee..d960dc01acf 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 libmoq (the C bindings, built by `cargo build -p libmoq`). +// against the workspace moq-c (the C bindings, built by `cargo build -p moq-c`). // -// libmoq is a handle + callback API: connect, consume a broadcast, get a +// moq-c is a handle + callback API: connect, consume a broadcast, get a // catalog snapshot via callback, start the video track, and a frame callback // fires as frames arrive. Once a non-empty frame lands we close and drain every // registration, then return 0; a timeout exits 1. Publishing isn't wired up: the @@ -33,13 +33,13 @@ typedef struct { // One flag per registration handed &ctx, set by that registration's terminal // (<= 0) callback. main returns only once all four are set: that terminal is - // libmoq's documented last touch of user_data, so it is what makes main's + // moq-c'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; } ctx_t; -// 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 +// 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 // terminal (<= 0) callback fires, so main must not return until every one of // them has. Closing the session ends its status registration alone; // moq_origin_announced_broadcast, moq_consume_catalog and moq_consume_video each @@ -118,7 +118,7 @@ static void on_catalog(void *ud, int32_t catalog) { moq_consume_catalog_free((uint32_t)catalog); } -// Report a failure and exit 1, for the paths where libmoq still holds &ctx. +// Report a failure and exit 1, for the paths where moq-c 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. Draining @@ -250,7 +250,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 libmoq's runtime thread + // closes and drains gets a clean process exit, with moq-c's runtime thread // still live behind its LazyLock. drain(&c); moq_consume_close((uint32_t)bc); diff --git a/test/interop/interop.sh b/test/interop/interop.sh index 5400c55be44..f098b42a564 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/, js/, and rs/libmoq, all talking to each +# clients built from rs/moq-cli, py/, js/, and rs/moq-c, all talking to each # other. There's no apt/brew/npm/PyPI here, just cargo/bun/uv/cc. # # It stands up a moq-relay, then for each publisher language publishes an H.264 @@ -37,7 +37,7 @@ URL="" NEGATIVE=0 MEDIA=0 -# Cargo profile for the relay/cli/libmoq builds. Debug compiles faster, which is +# Cargo profile for the relay/cli/moq-c builds. Debug compiles faster, which is # what an interop test wants; the workload (320x240@30) is trivial either way. PROFILE="${INTEROP_PROFILE:-debug}" @@ -161,7 +161,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 libmoq's header + # the self-hosted CI runner sets), so the built binaries and moq-c'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') @@ -280,7 +280,7 @@ prepare_go() { fi } -# Build libmoq (the C staticlib + cbindgen header) and compile the C subscriber +# Build moq-c (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() { @@ -289,28 +289,28 @@ prepare_c() { mark_broken c "no C compiler ($cc) on PATH" return } - echo "building c client (workspace libmoq + cc)..." + echo "building c client (workspace moq-c + cc)..." local flag=() [[ "$PROFILE" == "release" ]] && flag=(--release) - 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" + 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" sed 's/^/ /' "$HARNESS_RUN/c-build.log" >&2 || true return fi - out_dir=$(grep '"reason":"build-script-executed"' "$HARNESS_RUN/c-build.json" | grep libmoq | + out_dir=$(grep '"reason":"build-script-executed"' "$HARNESS_RUN/c-build.json" | grep -F '/moq-c#' | 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 "libmoq artifacts missing ($header / $lib)" + mark_broken c "moq-c artifacts missing ($header / $lib)" return } # cargo can't inject libmoq.a's native deps into an external link, so read # them from the same list build.rs and CMake use. local native_libs case "$(uname -s)" in - Darwin) native_libs="$WORKSPACE/rs/libmoq/native-libs/apple.txt" ;; - *) native_libs="$WORKSPACE/rs/libmoq/native-libs/linux.txt" ;; + Darwin) native_libs="$WORKSPACE/rs/moq-c/native-libs/apple.txt" ;; + *) native_libs="$WORKSPACE/rs/moq-c/native-libs/linux.txt" ;; esac os_libs=() while read -r entry; do diff --git a/test/justfile b/test/justfile index af90bcd7ed0..080e6841925 100644 --- a/test/justfile +++ b/test/justfile @@ -25,7 +25,7 @@ default: # Cross-language media interop test, built from this checkout. Stands up a # relay and runs the publisher x subscriber matrix. Default: rust only (fast # sanity check). `interop --all` runs the full matrix: rust + python + go + -# browser publish; everyone subscribes (incl. native node/bun JS, the C libmoq +# browser publish; everyone subscribes (incl. native node/bun JS, the moq-c C # client, and the GStreamer moqsrc plugin). --timeout 30 gives headless Chromium # cold-start headroom. Other flags pass through, e.g. # `just test interop --publishers rust,python --subscribers rust,c`.