Build the robot's GStreamer plugins natively, from pinned sources

Two plugins the micro duck robot needs and no archive provides:
`libgstrockchipmpp.so` for hardware H.264 through Rockchip MPP, and
`libgstrswebrtc.so`/`libgstrsrtp.so` for webrtcsink. Debian ships no Rockchip
encoder in any suite, Radxa's prebuilt plugin is decode-only (measured on a
Zero 3W: mppvideodec and mppjpegdec, nothing else — 1.14.4 predates the
encoders), and gstreamer1.0-plugins-rs exists in no Debian suite at all.
`webrtcbin` is deliberately absent: Debian has it.

Native arm64 in a debian:trixie container, which is the point. The daemon
cross-compiles with cargo-zigbuild and its one C dependency is already the
documented cost of that; GStreamer would be a far larger second one, and both
routes — x86 multiarch or a sysroot with a meson cross file — link against an
approximation of the target rather than the target. Here nothing is
approximated.

Public because arm64 runners are free on public repositories, and more
importantly because a release asset is fetched by the updater's preinstall
hook, which runs with a cleared environment and no token. That is the same
arrangement the daemon already relies on for ONNX Runtime.

Pins are commits or tags, never branches, in one file both the build and the
release manifest read — a plugin whose version nobody can name is what makes a
media bug unreproducible, which is exactly what the third-party debs we
rejected could not answer. gst-plugins-rs is pinned at 0.15.3 rather than the
0.14.5 the reachy_mini SDK documents: 0.14.5 is the floor that matters, since
the tags below it miss a webrtcsink deadlock fix between remote description and
ICE handling, and both series declare a GStreamer v1_22 floor against a robot
running 1.26.2.

Two guards written from reading the trees rather than hoping.
`gst/rockchipmpp/meson.build` ends in `if not mpp_dep.found() → subdir_done()`,
so a missing librockchip-mpp-dev makes meson skip the plugin and *succeed*;
pkg-config is checked first and the .so checked for after. And the Radxa debs
are installed as one closure, because dpkg -i resolves nothing for direct
downloads — learning that one package at a time cost three rounds on a board.

Building also drops rkximage and kmssrc, the X11 and KMS sinks in the same
tree, which a headless robot has no use for and which are why the prebuilt deb
depends on libx11-6.

Assisted-by: Claude:claude-opus-5[1m] shellcheck
This commit is contained in:
Pierre Rouanet 2026-08-24 16:02:47 +02:00
commit 9cfd24e49f
6 changed files with 672 additions and 0 deletions

86
.github/workflows/release.yml vendored Normal file
View File

@ -0,0 +1,86 @@
# Build the plugins and attach them to a release.
#
# Runs on a **native arm64 runner inside a `debian:trixie` container**, which is the whole point
# of this repository. Both halves matter:
#
# - arm64, so nothing is cross-compiled. The alternative — multiarch on an x86 runner, or a
# sysroot plus a meson cross file — is the machinery this repo exists to avoid, and it links
# against an approximation of the target rather than the target.
# - debian:trixie, so the plugins link against the **exact** library versions the robot has.
# The runner's own Ubuntu userland has a different GStreamer, and a plugin built against it
# would work right up until it did not.
#
# arm64 runners are free on public repositories, which is why this repository is public. The other
# reason is more important: a release asset here is fetched by a robot's provisioning and by the
# updater's preinstall hook, and that hook runs with a cleared environment and no token. A private
# repository would break it.
name: release
on:
push:
tags: ['v*']
# So the build can be exercised without cutting a release — the failure mode of a workflow that
# only ever runs on a tag is discovering it is broken at the moment you need it.
workflow_dispatch:
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-24.04-arm
container:
image: debian:trixie
steps:
# `actions/checkout` needs git, and a bare trixie image has none. Installed before the
# checkout rather than in build.sh, which cannot run before the repository is there.
- name: Bootstrap the container
run: |
apt-get update -qq
apt-get install -y -qq --no-install-recommends git ca-certificates curl
- uses: actions/checkout@v4
- name: Build
run: sh scripts/build.sh both
# Named with the tag when there is one, so a downloaded artifact is identifiable after it
# leaves the browser. `github.ref_name` is the tag on a tag push and the branch otherwise.
- name: Package
id: package
run: |
ver="${{ github.ref_name }}"
name="microduck-gst-plugins-${ver}-aarch64"
mv dist "$name"
tar -czf "${name}.tar.gz" "$name"
sha256sum "${name}.tar.gz" > "${name}.tar.gz.sha256"
echo "name=${name}" >> "$GITHUB_OUTPUT"
echo "== contents =="
tar -tzf "${name}.tar.gz"
cat "${name}.tar.gz.sha256"
# Always uploaded, tag or not: a workflow_dispatch run is for looking at what came out.
- uses: actions/upload-artifact@v4
with:
name: ${{ steps.package.outputs.name }}
path: |
${{ steps.package.outputs.name }}.tar.gz
${{ steps.package.outputs.name }}.tar.gz.sha256
# The tarball plus its sha256 as separate assets: a consumer fetches both, verifies, then
# unpacks. One download and one integrity check, rather than one per plugin.
- name: Attach to the release
if: startsWith(github.ref, 'refs/tags/v')
env:
GH_TOKEN: ${{ github.token }}
run: |
apt-get install -y -qq --no-install-recommends gh
gh release create "${{ github.ref_name }}" \
--title "${{ github.ref_name }}" \
--notes-file "${{ steps.package.outputs.name }}/MANIFEST" \
--repo "${{ github.repository }}" \
|| echo "release already exists; uploading into it"
gh release upload "${{ github.ref_name }}" \
"${{ steps.package.outputs.name }}.tar.gz" \
"${{ steps.package.outputs.name }}.tar.gz.sha256" \
--clobber --repo "${{ github.repository }}"

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
dist/
.stage/
*.tar.gz
*.sha256

202
LICENSE Normal file
View File

@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

94
README.md Normal file
View File

@ -0,0 +1,94 @@
# microduck-gst-plugins
Prebuilt aarch64 GStreamer plugins for the micro duck robot, built in CI from pinned upstream
sources and attached to a release.
Two plugins, for two unrelated reasons. Neither is packaged anywhere we can install from.
| plugin | provides | why it is here |
|---|---|---|
| `libgstrockchipmpp.so` | `mpph264enc`, `mpph265enc`, `mppjpegenc`, `mppvp8enc`, `mppvideodec`, `mppjpegdec` | Debian ships no Rockchip encoder in any suite, and Radxa's `gstreamer1.0-rockchip1_1.14-4` is **decode-only** — measured on a Zero 3W: `mppvideodec` and `mppjpegdec`, nothing else. 1.14.4 predates the encoders. |
| `libgstrswebrtc.so`, `libgstrsrtp.so` | `webrtcsink`, `webrtcsrc`, `rsrtp*` | `gstreamer1.0-plugins-rs` does not exist in **any** Debian suite — not trixie, backports, sid or experimental. |
`webrtcbin` is **not** here: it comes from `gstreamer1.0-plugins-bad` in Debian and needs no
build.
## Why a repository of its own
The robot's daemon is cross-compiled from a developer's machine with `cargo-zigbuild`, and its one
C dependency is already the documented cost of doing that. GStreamer would be a much larger second
one — a cross sysroot or x86 multiarch, either of which links against an approximation of the
target.
So these are built **natively on an arm64 runner, in a `debian:trixie` container**, which is the
robot's own userland. Nothing is cross-compiled and nothing is approximated. arm64 runners are
free on public repositories, which is one reason this repository is public.
The other reason matters more: a release asset here is fetched by a robot during provisioning and
by the updater's `preinstall` hook, and that hook runs with a cleared environment and no token. A
private repository would break it. This is the same arrangement the daemon already relies on for
ONNX Runtime, which comes from a public `microsoft/onnxruntime` release.
Building rather than taking a third-party binary also buys one concrete thing beyond provenance:
`rkximage` and `kmssrc`, the X11 and KMS *sinks* in the same source tree, are **disabled**. A
headless robot has no use for either, and they are why the prebuilt Radxa deb depends on
`libx11-6`.
## Consuming a release
```
tar -xzf microduck-gst-plugins-<version>-aarch64.tar.gz
```
Put the `.so` files anywhere and point `GST_PLUGIN_PATH` at it — `/usr/local/lib/gstreamer-1.0`
on a robot, which is deliberately **not** the distro's plugin directory, so an `apt` operation can
never quietly replace or remove them.
```
GST_PLUGIN_PATH=/usr/local/lib/gstreamer-1.0 gst-inspect-1.0 mpph264enc
```
Verify the tarball against the `.sha256` beside it before unpacking. **Pin a version**; do not
follow "latest". Two provisioning runs a day apart that produce different plugins, with nothing
recording which, is an unreproducible media bug waiting to happen.
### Runtime dependencies
The plugins link against libraries a robot needs installed:
- `librockchip-mpp1` and `librga2` — from Radxa's pool, at the versions in
[`pins.env`](pins.env). Not in Debian.
- `libgstreamer1.0-0`, `libgstreamer-plugins-base1.0-0`, `libglib2.0-0`, `libdrm2` — Debian.
`mpph264enc` also needs **read/write access to `/dev/mpp_service`**, which arrives as `0600
root:root`. The failure that causes is silent in two different ways: `mpi_enc_test` writes an empty
file and exits 0, and this plugin registers its *decoders* while omitting the *encoders*, because
registration probes MPP. A non-root process needs a udev rule giving the node a group.
## Bumping a pin
Edit [`pins.env`](pins.env), commit, tag `vN`, push the tag. The release workflow builds and
attaches the tarball, with the manifest as the release notes so a release always says which
upstream commits it came from.
`workflow_dispatch` builds without cutting a release — worth using, because a workflow that only
ever runs on a tag is one you discover is broken at the moment you need it.
## Licences and source
These are binaries built from other people's source, so where that source is matters:
- **`gstreamer-rockchip`** is LGPL. Built from
[`JeffyCN/mirrors`](https://github.com/JeffyCN/mirrors) on the `gstreamer-rockchip` branch, at
the commit in `pins.env` and recorded in every release's `MANIFEST`.
`rockchip-linux/gstreamer-rockchip`, which every published deb names as its homepage, is a 404;
`JeffyCN/mirrors` is the live mirror under the same maintainer.
- **`gst-plugins-rs`** is MPL-2.0. Built from
[the upstream repository](https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs) at the tag in
`pins.env`.
Nothing here is modified — no patches, no forks. Each release's `MANIFEST` names the repository
and the exact ref per plugin, which is both the licence answer and the reason a media bug found on
a robot can be traced to a specific build.
This repository's own build scripts are Apache-2.0, matching the daemon.

41
pins.env Normal file
View File

@ -0,0 +1,41 @@
# What this repo builds, and from exactly where.
#
# One file, sourced by `scripts/build.sh` and read by the release workflow, so a bump is one
# commit and the manifest in a release can never disagree with what was built.
#
# Pins are commits or tags, never branches. A plugin whose version nobody can name is what makes
# a media bug unreproducible, and both of these upstreams move.
# ── Rockchip MPP: mpph264enc, mpph265enc, mppjpegenc, mppvp8enc, mppvideodec, mppjpegdec ──
#
# `rockchip-linux/gstreamer-rockchip` — the homepage both Radxa's and every third-party deb name
# — is a 404 now. `JeffyCN/mirrors` is the live mirror, same maintainer (Jeffy Chen).
#
# Why build it at all: Debian has no Rockchip encoder in any suite, and Radxa's
# `gstreamer1.0-rockchip1_1.14-4` is **decode-only** — measured on a Zero 3W, it provides
# `mppvideodec` and `mppjpegdec` and nothing else. 1.14.4 predates the encoders.
GST_ROCKCHIP_REPO=https://github.com/JeffyCN/mirrors.git
GST_ROCKCHIP_BRANCH=gstreamer-rockchip
GST_ROCKCHIP_REF=dcbcd6454ef892e385b3a782600369eb6c0719db
# ── gst-plugins-rs: webrtcsink, webrtcsrc, and the rtp sibling the same stack wants ──
#
# Why build it: `gstreamer1.0-plugins-rs` does not exist in **any** Debian suite — not trixie,
# not backports, not sid, not experimental.
#
# 0.15.3 rather than the 0.14.5 that Pollen's reachy_mini SDK documents. 0.14.5 is the floor that
# matters — the tags below it miss a `webrtcsink` deadlock fix between remote description and ICE
# handling, which presents as a client spinning forever on "connecting" — and 0.15.3 is simply
# newer than it. Both declare a GStreamer `v1_22` feature floor, and the robot runs 1.26.2, so
# the newer series costs nothing.
GST_PLUGINS_RS_REPO=https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
GST_PLUGINS_RS_REF=0.15.3
# ── Rockchip userspace, from Radxa's pool ──
#
# Not in Debian either. These are the *build* dependencies of the MPP plugin; the runtime halves
# of the same versions are what a robot installs. A header/library version mismatch here is a
# plugin that builds and then misbehaves, so both sides come from one place.
RADXA_POOL=https://radxa-repo.github.io/bullseye/pool/main
MPP_VERSION=1.5.0-1
RGA_VERSION=2.2.0-1

245
scripts/build.sh Executable file
View File

@ -0,0 +1,245 @@
#!/bin/sh
# Build the aarch64 GStreamer plugins the micro duck robot needs, from the pins in `pins.env`.
#
# Runs natively on aarch64 — in CI that is a `debian:trixie` container on an arm64 runner, which
# is what makes the output link against exactly the library versions the robot has rather than
# Ubuntu's or a cross sysroot's approximation of them. It also runs unchanged on a board, which
# is only useful for debugging: an RK3566 compiles the Rust half slowly enough that nobody should
# wait for it.
#
# sudo sh scripts/build.sh both plugins
# sudo sh scripts/build.sh rockchip just the MPP encoders
# sudo sh scripts/build.sh webrtc just webrtcsink/webrtcsrc
#
# Output lands in `dist/`: the .so files, SHA256SUMS, and MANIFEST recording which upstream commit
# each one came from. The manifest is not bookkeeping — it is the difference between a media bug
# somebody can reproduce and one they cannot, and it is what the third-party debs we rejected did
# not have.
set -eu
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
DIST="${ROOT}/dist"
# Debian's own plugin directory for this arch, which is where the .so wants to *end up* on a
# robot's GST_PLUGIN_PATH. Built here into a prefix we own so nothing is installed system-wide by
# a build.
STAGE="${ROOT}/.stage"
# shellcheck disable=SC1091 # sibling file, in this repository.
. "${ROOT}/pins.env"
say() { printf '\033[1m==>\033[0m %s\n' "$*"; }
warn() { printf '\033[33mwarning:\033[0m %s\n' "$*" >&2; }
die() { printf '\033[31merror:\033[0m %s\n' "$*" >&2; exit 1; }
WANT="${1:-both}"
case "$WANT" in
both|rockchip|webrtc) ;;
*) die "unknown target: ${WANT} (both, rockchip, webrtc)" ;;
esac
check_environment() {
[ "$(id -u)" = 0 ] || die "run as root — it installs build dependencies"
arch="$(uname -m)"
[ "$arch" = aarch64 ] \
|| die "this builds natively for aarch64 and this is ${arch}.
There is no cross-build here on purpose: linking against the robot's own Debian trixie
libraries is the reason CI uses an arm64 runner in a debian:trixie container."
command -v apt-get >/dev/null 2>&1 || die "expects a Debian userland"
}
apt_install() {
missing=""
for pkg in "$@"; do
dpkg -s "$pkg" >/dev/null 2>&1 || missing="$missing $pkg"
done
[ -n "$missing" ] || return 0
say "installing:$missing"
apt-get update -qq
# shellcheck disable=SC2086 # word-splitting the package list is the point
apt-get install -y -qq --no-install-recommends $missing \
|| die "apt failed installing:$missing"
}
# Rockchip's MPP and RGA, from Radxa's pool, runtime and headers together.
#
# `dpkg -i` resolves nothing here — these are direct downloads, not a configured apt source — so
# the full closure is named and installed in one call. Learning that one package at a time cost
# three rounds on a board: `rockchip-mpp-demos` needs `librockchip-vpu0` at an exact version, and
# the GStreamer plugin needs `librga2`.
install_rockchip_userspace() {
dpkg -s librockchip-mpp-dev >/dev/null 2>&1 && dpkg -s librga-dev >/dev/null 2>&1 && return 0
tmp="$(mktemp -d)"
# shellcheck disable=SC2064 # expand $tmp now, deliberately
trap "rm -rf '$tmp'" EXIT INT TERM
say "fetching Rockchip MPP ${MPP_VERSION} and RGA ${RGA_VERSION} from Radxa's pool"
for path in \
"m/mpp/librockchip-mpp1_${MPP_VERSION}_arm64.deb" \
"m/mpp/librockchip-vpu0_${MPP_VERSION}_arm64.deb" \
"m/mpp/librockchip-mpp-dev_${MPP_VERSION}_arm64.deb" \
"libr/librga/librga2_${RGA_VERSION}_arm64.deb" \
"libr/librga/librga-dev_${RGA_VERSION}_arm64.deb"
do
curl -fsSL -o "${tmp}/$(basename "$path")" "${RADXA_POOL}/${path}" \
|| die "cannot download ${RADXA_POOL}/${path}"
done
dpkg -i "${tmp}"/*.deb || die "dpkg -i failed on the Rockchip debs"
rm -rf "$tmp"
trap - EXIT INT TERM
}
build_rockchip() {
apt_install meson ninja-build build-essential pkg-config git curl ca-certificates \
libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libdrm-dev libglib2.0-dev
install_rockchip_userspace
# Verified, because meson's answer to a missing MPP is not an error:
# `gst/rockchipmpp/meson.build` ends in `if not mpp_dep.found() → subdir_done()`, so the whole
# plugin is *silently skipped* and the build succeeds having produced nothing.
for mod in rockchip_mpp librga; do
pkg-config --exists "$mod" \
|| die "pkg-config cannot find ${mod}. meson skips the plugin silently without it,
so this refuses here instead of shipping an empty release."
done
src="$(mktemp -d)"
say "gstreamer-rockchip @ ${GST_ROCKCHIP_REF}"
git clone -q --branch "$GST_ROCKCHIP_BRANCH" "$GST_ROCKCHIP_REPO" "${src}/s" \
|| die "cannot clone ${GST_ROCKCHIP_REPO}"
# Reset to the pin: `--depth 1` alone would take whatever the branch tip is today, which is
# the thing a pin exists to prevent.
git -C "${src}/s" checkout -q "$GST_ROCKCHIP_REF" \
|| die "${GST_ROCKCHIP_REF} is not on ${GST_ROCKCHIP_BRANCH}"
# `rkximage` and `kmssrc` are the X11 and KMS *sinks* in the same tree. A headless robot has
# no use for either, and they are why the prebuilt Radxa deb depends on libx11-6. Dropping
# them is the concrete thing building ourselves buys, beyond provenance.
say "configuring (rockchipmpp only; X11 and KMS sinks disabled)"
meson setup "${src}/b" "${src}/s" \
--prefix /usr --libdir lib --buildtype release \
-Drockchipmpp=enabled -Drga=enabled \
-Drkximage=disabled -Dkmssrc=disabled -Dvpxalphadec=disabled \
>"${src}/meson.log" 2>&1 || {
tail -40 "${src}/meson.log" >&2
die "meson setup failed; tail of its log above. The tree declares
meson_version >= 0.47 and was written against a far older meson, so a syntax rejection is the
failure to expect here. Installed: $(meson --version 2>/dev/null || echo unknown)."
}
ninja -C "${src}/b" >"${src}/ninja.log" 2>&1 || {
tail -40 "${src}/ninja.log" >&2
die "ninja failed; tail of its log above"
}
so="$(find "${src}/b" -name 'libgstrockchipmpp.so' -type f | head -1)"
[ -n "$so" ] || die "no libgstrockchipmpp.so was produced.
That is what a skipped subdir looks like rather than a compile error."
install -d "$DIST"
install -m 0644 "$so" "${DIST}/libgstrockchipmpp.so"
strip --strip-unneeded "${DIST}/libgstrockchipmpp.so"
printf 'libgstrockchipmpp.so %s %s\n' "$GST_ROCKCHIP_REPO" "$GST_ROCKCHIP_REF" \
>> "${DIST}/MANIFEST"
rm -rf "$src"
}
build_webrtc() {
# `libgstreamer-plugins-bad1.0-dev` is the load-bearing one: it carries
# `gstreamer-webrtc-1.0.pc` and `gstreamer-sdp-1.0.pc`, which is what the crate pkg-configs
# against. Everything else is what a Rust cdylib needs to link.
apt_install build-essential pkg-config git curl ca-certificates \
libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev \
libgstreamer-plugins-bad1.0-dev libssl-dev libglib2.0-dev
# rustup rather than Debian's rustc. gst-plugins-rs tracks a recent toolchain and a distro
# rustc that is a few months behind fails on an edition or a lint, months after anybody
# remembers this choice was made.
if ! command -v cargo >/dev/null 2>&1; then
say "installing a Rust toolchain"
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
| sh -s -- -y --profile minimal --default-toolchain stable >/dev/null \
|| die "rustup install failed"
fi
# shellcheck disable=SC1091 # written by rustup, just above.
[ -f "$HOME/.cargo/env" ] && . "$HOME/.cargo/env"
command -v cargo-cbuild >/dev/null 2>&1 || {
say "installing cargo-c"
cargo install cargo-c --locked >/dev/null || die "cargo install cargo-c failed"
}
src="$(mktemp -d)"
say "gst-plugins-rs @ ${GST_PLUGINS_RS_REF}"
git clone -q --depth 1 --branch "$GST_PLUGINS_RS_REF" "$GST_PLUGINS_RS_REPO" "${src}/s" \
|| die "cannot clone ${GST_PLUGINS_RS_REPO} at ${GST_PLUGINS_RS_REF}"
install -d "$DIST" "$STAGE"
# Two plugins, not one: Pollen's desktop app ships `libgstrswebrtc.so` *and*
# `libgstrsrtp.so`, and the same stack wants both.
for crate in gst-plugin-webrtc gst-plugin-rsrtp; do
say "cargo cinstall ${crate}"
( cd "${src}/s" && cargo cinstall -p "$crate" --prefix "$STAGE" --libdir lib --release ) \
>"${src}/${crate}.log" 2>&1 || {
tail -40 "${src}/${crate}.log" >&2
die "${crate} failed to build; tail of its log above"
}
done
found=0
for so in "${STAGE}"/lib/gstreamer-1.0/*.so; do
[ -e "$so" ] || continue
found=1
base="$(basename "$so")"
install -m 0644 "$so" "${DIST}/${base}"
strip --strip-unneeded "${DIST}/${base}"
printf '%s %s %s\n' "$base" "$GST_PLUGINS_RS_REPO" "$GST_PLUGINS_RS_REF" \
>> "${DIST}/MANIFEST"
done
[ "$found" = 1 ] || die "cargo cinstall produced no plugin under ${STAGE}/lib/gstreamer-1.0"
rm -rf "$src" "$STAGE"
}
# What was built, and enough to verify it independently.
finish() {
( cd "$DIST" && rm -f SHA256SUMS && sha256sum ./*.so > SHA256SUMS )
printf '\n'
say "dist/"
for f in "${DIST}"/*.so; do
printf ' %-28s %8s bytes\n' "$(basename "$f")" "$(stat -c '%s' "$f")"
done
printf '\n'
say "provenance"
sed 's/^/ /' "${DIST}/MANIFEST"
printf '\n'
say "elements"
# Loaded from dist/ exactly as a robot will load them, so this is the real question rather
# than a proxy. `mpph264enc` may be missing here even when built: registration probes MPP, and
# a container without /dev/mpp_service — or a robot whose node is still 0600 root:root —
# cannot answer. Absence in CI is expected; absence on a board with the udev rule is not.
for plug in rockchipmpp rswebrtc rsrtp; do
GST_PLUGIN_PATH="$DIST" gst-inspect-1.0 "$plug" 2>/dev/null \
| sed -n 's/^ \([a-z0-9]*\): / \1 /p' || true
done
[ -e /dev/mpp_service ] || warn "no /dev/mpp_service here, so the MPP encoders cannot register
in this environment. That is normal in CI: the .so still contains them, and a robot with the
udev rule will see them. Verify there, not here."
}
main() {
check_environment
rm -rf "$DIST" && install -d "$DIST"
: > "${DIST}/MANIFEST"
case "$WANT" in
rockchip) build_rockchip ;;
webrtc) build_webrtc ;;
both) build_rockchip; build_webrtc ;;
esac
apt_install gstreamer1.0-tools
finish
}
# Called on the last line so a truncated download defines functions and then does nothing, rather
# than running half a build.
main "$@"