Skip to content

uref: allow a uref to carry multiple ubufs - #1214

Draft
kierank wants to merge 2 commits into
Upipe:masterfrom
kierank:uref-sub
Draft

uref: allow a uref to carry multiple ubufs#1214
kierank wants to merge 2 commits into
Upipe:masterfrom
kierank:uref-sub

Conversation

@kierank

@kierank kierank commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Add a chain of additional ubufs to struct uref, linked by their own uchain (unused while a ubuf is in flight), so that a single uref can carry e.g. video, audio and subtitles at the same time.

The primary uref->ubuf is entry 0 and is untouched: legacy pipes keep working unmodified and transparently pass additional entries through, since uref_free frees the chain and uref_dup/uref_fork duplicate it (a cheap reference increment). uref_dup_inner deliberately does not duplicate the chain, so derived urefs (block splice/split, field split) do not fan out the additional payloads.

Per-entry metadata (flow ID, flow def, date, duration) is stored in the parent uref attributes under indexed names ("sub[i].*") and is thus carried and duplicated by the existing udict handling. The new uref_sub.h API provides attach/get/detach/replace/find accessors, with lookup by flow ID.

@kierank

kierank commented Jul 25, 2026

Copy link
Copy Markdown
Contributor Author

Maybe I can dump timestamp and duration as by definition of being in a uref they are the same

Add a chain of additional ubufs to struct uref, linked by their own
uchain (unused while a ubuf is in flight), so that a single uref can
carry e.g. video, audio and subtitles at the same time.

The primary uref->ubuf is entry 0 and is untouched: legacy pipes keep
working unmodified and transparently pass additional entries through,
since uref_free frees the chain and uref_dup/uref_fork duplicate it
(a cheap reference increment). uref_dup_inner deliberately does not
duplicate the chain, so derived urefs (block splice/split, field
split) do not fan out the additional payloads.

Per-entry metadata (flow ID, flow def) is stored in the parent uref
attributes under indexed names ("sub[i].*") and is thus carried and
duplicated by the existing udict handling. All entries share the
dates and duration of the uref by definition, since they are part of
the same uref. The new uref_sub.h API provides
attach/get/detach/replace/find accessors, with lookup by flow ID.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Add helpers to move attributes between the plain namespace of a
standalone uref and the per-entry "sub[i]." namespace of a carrier
uref, built generically on udict_iterate so they cover any attribute
type, including ones defined in the future:

 - uref_sub_merge() consumes a standalone uref and appends its ubuf
   as a new entry, copying its plain attributes (with shorthands
   resolved to their canonical names) into the entry namespace. Its
   dates are discarded since all entries share the dates of the
   carrier by definition.
 - uref_sub_extract() creates a standalone uref from an entry,
   duplicating its ubuf, inheriting the carrier dates and flags, and
   renaming the entry attributes back to plain names, converted back
   to shorthand storage where applicable so that legacy typed
   accessors (uref_flow_get_def() etc.) find them.
 - uref_sub_delete_attrs() and uref_sub_rename_attrs() manage entry
   namespaces; uref_sub_detach_ubuf() now uses them to delete the
   detached entry's attributes and renumber the following entries,
   keeping indices and attributes consistent.

The intended model is that entries are merged into a carrier at one
pipe boundary and extracted back at another, so that pipes in between
never need per-entry attribute access.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@funman

funman commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Looks simple enough, I guess use it to see if something is missing

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.

2 participants