Skip to content

Rebase Pexip patches onto latest upstream GStreamer main (8d08c320ce) + upstreaming plan - #79

Draft
havardgraff with Copilot wants to merge 3242 commits into
mainfrom
copilot/rebase-gstreamer-fork
Draft

havardgraff with Copilot wants to merge 3242 commits into
mainfrom
copilot/rebase-gstreamer-fork

Conversation

Copilot AI commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

What this is

The 422 fork-only commits (linear, on top of upstream 3cd20010e0, 2025-11-01) replayed in their original order, one by one onto upstream main = 8d08c320ce (2026-10-06, 1.29.2.1, 2,828 commits ahead). Every replayed commit carries a (cherry picked from commit <old-sha>) trailer, so the old→new mapping is recoverable.

count
fork commits 422
applied cleanly 367
applied after resolving conflicts 37
dropped (already upstream / obsolete / empty) 18
adaptation commit on top 1

Branch shape: first parent of the tip commit 854f49ea39 is the clean linear series (499491c948, upstream main + patches). The second parent is the old fork main (34adb59d78) and exists only so this branch fast-forwards the current history and can be pushed without force. Recommendation: instead of merging this PR, force-push 499491c948 as the new main and archive the old tip as rebase/34adb59d78 (fork convention). To review only our patches: git range-diff 3cd20010e0..34adb59d78 8d08c320ce..499491c948.

Verification done

  • One-shot reference: git merge-tree upstream/main fork/main vs. this tree: only 41 files differ, all in conflicted files or deliberate adaptations (checked every non-conflict hunk, listed below).
  • Linux build of core, base, good (rtp, rtpmanager, flv, isomp4, udp, vpx), bad (sctp incl. dcsctp C++, pcapparse, videoparsers, netsim, insertbin) + tests: 1489/1490 targets built; the one failure is the vpx ISA variant (see known issues, pre-existing).
  • Tests run: rtpssrcdemux, rtpbin, rtpjitterbuffer, rtprtx, rtpfunnel pass; rtpsession 179/180 (see known issues). Core, videorate, videodecoder, pcapparse, netsim, vpx, flv/qtdemux tests were not run (time).
  • Apple, Android, Windows code could not be compiled here: review-only.

Dropped patches (already upstream / obsolete)

#55, #56 (vtdec iOS errors = 3e26f3b), #59, #171 (flvdemux no-more-pads-threshold = f16074c), #225, #244, #261, #285 (avfdeviceprovider monitoring/screens), #288/#289 (avfvideosrc unique-id = 7c28143), #391-#393, #399, #401, #402 (h264parse/qtdemux hardening), #400 (pcapparse = 3833dd7), #407 (amcvideodec crop init = 941362b), and the vpcC byte-writer leak (code rewritten upstream), jni codec impl (removed upstream, 575317c).

Notable conflict resolutions / adaptations

  • rtpmanager: fork TWCC rework (#331) removes upstream's rtx-ssrc-map property; kept upstream's rtx-percentage, max-csrcs, max-sources, is_rtx; fork's timedout_ssrcs logic moved into upstream's new remove_source() helper; test helper generate_test_buffer_full merges both signatures.
  • sctp: usrsctp replaced by dcsctp (#299); upstream's pad-task strong-ref change and GMutex fix adapted.
  • videorate (#339): fork's old implementation kept verbatim + upstream's static-features/untrusted-aware additions (upstream fixes 90f0425, 68e2c9f intentionally lost).
  • vulkan/MoltenVK (#313): upstream's moltenvk subproject supersedes VK_SDK_PATH logic; only extra frameworks kept.
  • osxaudio device provider (#384): fork rewrite taken, upstream leak fix (gst_caps_unref) ported.
  • flvdemux: upstream's uint64 property is used; adaptation commit sets default to G_MAXUINT64 - 1 ("never signal", Pexip is live-only) since -1 is out of range and would break class_init.
  • sctp adaptation: gst_pad_start_task now gets a strong ref (upstream MR 11489).
  • qtdemux max-audio-samples merged with upstream max-atom-size (single get/set pair); alsa double free, gstamc log-level downgrades re-applied on the new duplicated sites.

Known issues / follow-ups (not done)

  1. elements_rtpsession: test_twcc_stats_rtx_recover_not_lost_stuff fails (bitrate-recv 285182 vs 1129244). Not yet checked whether it fails on the old fork tip; suspects: upstream RTX throttling/is_rtx or TWCC stats merge.
  2. vpx ISA variants (vpx-avx/-neon, pexhack) hard-code vpx_args without -DHAVE_VPX_1_8, so gstvpxdec.c fails with libvpx >= 1.8 (also on the old fork tip).
  3. timedout_ssrcs (#123) can now grow unbounded via upstream's LRU eviction: add a bound.
  4. Move base-class hash table teardown from dispose() to finalize() #62 leaves a dead twcc_stats member that only #331 removes (intermediate commits Move base-class hash table teardown from dispose() to finalize() #62..#330 do not compile in rtpmanager; final tree is fine).
  5. Tulio/mediafoundation #29 pad-revert hack (needs pmxdatachannel tests, re-evaluate vs upstream sticky-event resend); TWCC stats: fix DoD stat and add non-recovery-bitrate stats #48 netsim task needs strong ref; #313 has an Apple-only meson bug (cocoa_dep.found() guards iokit_dep; required: get_option('vulkan') should be vulkan_opt); ext/sctp/meson.build uses sctp_sources before definition (picks up gst-libs one, docs only).
  6. App-side compat: flvdemux property is now guint64 (no -1); avfvideosrc property device-unique-id → unique-id; rtx-ssrc-map removed from RTPSession by the fork; device-index deprecation.

Upstreaming plan (summary)

Rules: GitLab MRs to gstreamer/gstreamer main; <= ~10 commits per MR, each building and tested; squash fixup!/FIXUP and add+revert pairs (#335, #349); keep [pexhack]/PEXHACK/PEXIP_MODIFICATION patches downstream; bump Since: to 1.30, regenerate docs cache, run gst-indent/gitlint.

topic patches proposal
rtpmanager 112 split into ~8 MRs: (1) race/UAF/leak fixes (ssrcdemux pad state, NACK hash table, rtprtxsend, funnel dedupe, jitterbuffer latency, TWCC bounds/socket_ts), (2) buffer-list support (rtpsession/rtprtxreceive/rtpstorage/ssrcdemux), (3) rtprtxsend padding/RTX, (4) TWCC stats (rtptwccstats) + config (base-seqnum, feedback interval, packet event), (5) FEC recovery pct + GstRTPRepairMeta (new public API, own MR with docs), (6) tests
core (gst/) 56 independent fixes first (bin add/remove, hash teardown in finalize, pad last_flowret atomic, flowcombiner, testclock/harness races), then basetransform buffer lists; pad-revert hack stays downstream
other / v4l2/alsa/misc 59 one-off fixes, 1 MR per element
android / apple / windows 72 review on device first; small fixes (log levels, AVC levels, dequeue errors, vtenc leak/restart) as separate MRs
rtp libs / video+audio libs 46 after the core fixes; repair meta with rtp lib
vpx 16 properties (tile-columns/rows, direct-rendering, ROI) upstreamable; ISA variants/pexip_modification downstream
sctp/dcsctp 12 large import: propose as optional sctp-internal-dcsctp replacing usrsctp, upstream last
rtmp, pcapparse, netsim, build/ci, core tests 49 small independent MRs; ci/build stays downstream

Suggested order: (0) already-upstream drops, (1) small fixes, (2) core buffer-list + rtp repair meta, (3) rtpmanager features, (4) codecs/platform, (5) dcsctp.

havardgraff and others added 30 commits October 11, 2026 14:28
Don't send a segment event if we haven't produced data and set the
output caps yet. Doing so causes a g_warning about sticky event
misordering.

https://bugzilla.gnome.org/show_bug.cgi?id=773510
(cherry picked from commit fd1d9ed)
This is a Pexip specific change since we are only interested in using
gstflvdemux live.

(cherry picked from commit 337a635)
This happens all the time for us, so no point warning about it.

(cherry picked from commit 4150aec)
(cherry picked from commit c08372b)
Multiple SIMD-ified vpx plugins will be built if available. These
plugins will be put in a separate plugin directory which can be
linked to if configuring with --enable-simd-symlink=avx etc.

(cherry picked from commit dea5dd3)
Hard code limit to 1500 ms between each generated key frame. This
should ideally be a property and set to a value derived from RTT.

This avoids generating bursts of keyframes when receiving many
PLIs/NACKs in close succession.

1500ms is quite large, but with 500ms and lots of packetloss, the
frequent keyframe generation will more then double the bitrate from
the libvpx encoder (configured at 1mbps, producing over 2mbps),
potentially making an already bad situation much worse. By adding
another second we only see about 1,4mbps, which is more acceptable.

(cherry picked from commit 00bcaf7)
Adds property that can be used to disable direct rendering.

(cherry picked from commit a6fb741)
When buffer is pushed downstream, we should not hold the buffer mapped
with write access. Doing so would often lead to unneccesary memcpy
later.

For instance, gst_buffer_make_writable() in
gst_video_decoder_finish_frame() will cause a memcpy because of
_memory_get_exclusive_reference().

(cherry picked from commit 34e53cb)
Can't have a mix of GstValueArray and GValueArray here.

(cherry picked from commit e9c8812)
...it crashes our libvpx...

(cherry picked from commit f2d0b2c)
These made one of our vpx test fail.
GST_DEBUG=*vp*:LOG GST_CHECKS=vpx_enc_rate_limit_key_frames python3 /pexip/external/meson/meson.py test vpx -vv

Look into why and how more closely!

(cherry picked from commit c0aa078)
(cherry picked from commit c58172b)
(cherry picked from commit 21c3443)
Controls weather or not we would want to parse the bitstream in order to
extract partition information, which is currently only used if no custom
meta is present.

(cherry picked from commit fedfc3a)
(cherry picked from commit ad0559b)
regression from 63005d

(cherry picked from commit eb702a5)
(cherry picked from commit cce2364)
havardgraff and others added 14 commits October 11, 2026 14:44
This is both nicer in code, but also avoids locking to safly access
last_flowret. Found using thread sanatizer.

(cherry picked from commit 81802e1)
The task variable could dissappear while in set_task_state, so by taking
a lock and then a ref this problem goes away.

(cherry picked from commit b74e3d7)
By letting go of the lock, the entry could poentially be invalidated
while we were checking the status.

Grabbing the status before releasing the lock fixes this problem.

(cherry picked from commit 30e3945)
Prevents possible data-races.

(cherry picked from commit 64f984d)
TWCC has applied this duplicate length conversion since its original implementation in 1df7064. The caller already supplies bytes.

The overstated length can let malformed feedback read beyond its RTCP packet, potentially beyond allocated memory, risking crashes or incorrect feedback and stats. This does not establish the cause of the observed contention on an issue on our end (pexip/mcu#51159)

Pass the byte count unchanged, check delta sizes before reading, and correct test helpers with session-boundary regressions.

(cherry picked from commit 725a467)
estimate_latency fed the raw 32-bit rtptime into the clock difference,
so two kinds of step were indistinguishable from jitter:

* The 32-bit rollover, which produces a clock_diff jump of 2^32 divided
  by the clock rate -- thirteen hours at 90 kHz. Extend the timestamp to
  64 bits with gst_rtp_buffer_ext_timestamp.

* A sender that restarts and picks a new random rtptime base. The step
  goes into max_jitter_estimation, which decays slowly, so the estimate
  stays pinned at the size of the step long after the event. Reset the
  estimation instead, on the same delta the skew calculation already
  treats as a restarted sender.

Also log the inputs of the estimation. The sum on its own does not say
whether it came from a single outlier or from a shifted mean.

Tests live in pexip/media: test_latency_estimation_across_rtptime_wrap
and test_latency_estimation_reset_on_rtptime_step.

(cherry picked from commit eea932d)
rtp_twcc_stats_set_sock_ts() wrote SentPacket::socket_ts from the sink
thread after _find_sentpacket() had already dropped sent_packets_lock,
while the stats code read it without any synchronization. The slot could
also be evicted and reused between lookup and write.

Do the lookup and write under sent_packets_lock, and publish socket_ts
once through an atomic flag so the stats calculation can read it without
taking the lock. Add a regression test for TSAN.

(cherry picked from commit 34adb59)
…anges

* flvdemux: upstream added a guint64 "no-more-pads-threshold" property
  (f16074c) that replaces the fork's gint64 one. The fork's default of
  -1 ("never signal no-more-pads", Pexip only uses flvdemux live) is out
  of range for the new property, so use the property's maximum instead.
* sctp (dcsctp import): upstream pad tasks now require a strong reference
  as user data (1179387); hold one in the srcpad activate_mode of
  sctpdec and sctpenc.
First parent: the Pexip patch series replayed on upstream/main (404 of the
422 fork-only commits; 18 dropped because upstream already contains them or
they became obsolete). Second parent: previous fork main (34adb59), kept
only so this branch fast-forwards the existing history. The tree is exactly
that of the first parent.
Copilot AI and others added 8 commits October 13, 2026 12:58
Co-authored-by: havardgraff <1926313+havardgraff@users.noreply.github.com>
Co-authored-by: havardgraff <1926313+havardgraff@users.noreply.github.com>
Co-authored-by: havardgraff <1926313+havardgraff@users.noreply.github.com>
Co-authored-by: havardgraff <1926313+havardgraff@users.noreply.github.com>
Co-authored-by: havardgraff <1926313+havardgraff@users.noreply.github.com>
Co-authored-by: havardgraff <1926313+havardgraff@users.noreply.github.com>
Co-authored-by: havardgraff <1926313+havardgraff@users.noreply.github.com>
Co-authored-by: havardgraff <1926313+havardgraff@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.