Patch webrtcsink to put no converter in front of mpph264enc

`make_converter_for_video_caps` builds the chain webrtcsink inserts ahead of an
encoder it selected, special-casing hardware it knows — NVMM, D3D11, CUDA, GL,
VA, and on main also v4l2h264enc — and falling back to software
`videoconvert ! videoscale` for anything else. Rockchip's MPP encoder takes
NV12, I420, YUY2 and more directly and converts on the SoC's 2D accelerator, so
the fallback adds a full CPU pass over every frame to do work the hardware was
going to do anyway, on the four A55s robotd's 50 Hz loop shares.

The reason this matters more than CPU: the robot currently avoids the whole
question by pre-encoding and handing webrtcsink finished H.264. That works, and
it means webrtcsink cannot reach the encoder — so congestion control cannot
adapt the bitrate to the link, and a peer's PLI cannot produce a keyframe, which
leaves a viewer that lost one broken until the next periodic GOP. Letting
webrtcsink own the encoder fixes both. This patch is what makes that affordable.

**This repository is no longer patch-free, and says so.** MPL-2.0 asks that
modifications be identifiable, so the README states it, patches/README.md gives
each patch's reasoning, and build.sh records every applied patch in the release
MANIFEST beside the upstream ref. `git apply --check` runs first, so a patch that
stops applying fails the build naming itself rather than yielding a plugin
quietly missing the change it was carried for.

The trade-off is written down rather than glossed: without videoscale the bin
cannot resize, so the negotiated resolution must be one the source produces.
True on this robot, which pins its caps upstream of the tee — and the reason
upstream may want RGA-backed scaling instead of nothing before taking it. The
v4l2h264enc arm on main is the same shape for another hardware encoder, so the
precedent exists, and if it lands this file is deleted at the next bump.

Verified to apply cleanly against a real 0.15.3 checkout.

Assisted-by: Claude:claude-opus-5[1m] shellcheck
This commit is contained in:
Pierre Rouanet
2026-08-25 10:43:05 +02:00
parent fe51a2aa55
commit b81b50199a
4 changed files with 98 additions and 3 deletions
+15
View File
@@ -173,6 +173,21 @@ build_webrtc() {
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}"
# Our patches, applied in order and recorded in the MANIFEST. `--check` first so a patch that
# no longer applies stops the build here, naming itself, rather than producing a plugin that is
# quietly missing the change it was carried for.
for patch in "${ROOT}"/patches/*.patch; do
[ -e "$patch" ] || continue
name="$(basename "$patch")"
say "applying ${name}"
( cd "${src}/s" && git apply --check "$patch" ) \
|| die "${name} does not apply to ${GST_PLUGINS_RS_REF}.
It was written against a specific version of the file it touches. Re-cut it against this ref, or
drop it if upstream has taken the change — see patches/README.md."
( cd "${src}/s" && git apply "$patch" ) || die "${name} failed to apply"
printf 'patch %s\n' "$name" >> "${DIST}/MANIFEST"
done
install -d "$DIST" "$STAGE"
# Two crates, not one: the same stack wants `libgstrswebrtc.so` *and* `libgstrsrtp.so`.