Declaraciones públicas de transmux/packager.zig (transmux).
apps/docs/generated/zig/transmux.jsonPágina generada desde
native/zig/transmux/transmux.zig. No se edita a mano:bun run docs:genla regenera ybun run docs:checkfalla si difiere.
HLS/CMAF packager common to both engines (dec-0110 §1): a Session owns
one engine's demuxer and fragment muxer for one asset and produces, on
demand and in any order, the init segment, media segment N and the
playlists. What a segment holds is decided here, identically for both
engines:
plan[N].start_us up to (excluding) the keyframe at
plan[N].end_us; every other track's packets with PTS in
[start, end) (segment 0 also takes anything before its start: codec
priming, Opus pre-skip).DtsMap): PTS' = PTS - origin and DTS' = DTS +
(PTS0 - DTS0) - origin per track, where PTS0/DTS0 are the track's first
packet in the file and origin = min(0, earliest first PTS). The first
sample of every track decodes at its presentation time, nothing is
negative (tfdt is unsigned), A/V offsets are kept, and every engine
maps a packet to the same output tick whatever DTS convention its
demuxer uses (libav shifts DTS by the edit list; Matroska has none).Thread safety: one segment at a time per session; any thread may call in, a second caller waits (and stops waiting when its request is cancelled). Segments are produced into the caller's buffer; between requests a session holds no media bytes.
packager.Optionstype · línea 35
pub const Options = structSin ///.
packager.Options.maxSegmentBytesfn · línea 79
pub fn maxSegmentBytes(self: Options) u64Largest media segment Session.segment hands out: the payload
budget plus room for the fragment's boxes (moof: ~16 B of trun
per sample with either muxer, doubled). Past it, TooLarge: the
HTTP/3 pump reserves this much of its send budget per segment
being produced, so the bound is enforced, not estimated.
packager.Options.segmentCapfn · línea 84
pub fn segmentCap(self: Options, file_size: u64) usizeThe most segments a plan for a file of file_size bytes may have.
packager.Options.maxPlaylistBytesfn · línea 91
pub fn maxPlaylistBytes(self: Options) u64Bound of the media playlist of any session opened with these options (enforced at open).
packager.Options.maxAssetBytesfn · línea 98
pub fn maxAssetBytes(self: Options) u64Bound of any asset of a session besides its media segments (the
playlists and the init segment): what the HTTP/3 pump reserves of
its send budget for one (PackagingLimits.max_asset_bytes).
packager.playlist_header_maxconst · línea 105
pub const playlist_header_max: u64 = 512Media playlist bytes besides its segment lines (writeMediaPlaylist:
~170 B of tags, a target duration of at most 13 digits).
packager.playlist_line_maxconst · línea 109
pub const playlist_line_max: u64 = 40One segment's #EXTINF:<s>.<us>,\nseg-<n>.m4s\n: a duration within
plan.max_span_us (7 digits of seconds) and an index below
plan.max_segments (7 digits) take 40 B.
packager.master_playlist_maxconst · línea 111
pub const master_playlist_max: u64 = 1024Master playlist (writeMasterPlaylist): one variant, two codec strings.
packager.PayloadStoretype · línea 142
pub const PayloadStore = structPayload bytes one request collected, in chunks that never move (no
growth by reallocation) and are trimmed to what they hold when sealed.
Memory is the bytes pulled from the demuxer, not a growth-rounded
capacity: in safety-checked builds (the daemon runs parsers in
ReleaseSafe) the allocator writes undefined over a whole allocation
when it is made and when it is freed, so any unused capacity is
resident memory too.
packager.PayloadStore.chunk_sizeconst · línea 148
pub const chunk_size = 1 << 20Sin ///.
packager.PayloadStore.putfn · línea 151
pub fn put(self: *PayloadStore, gpa: std.mem.Allocator, data: []const u8) error{OutOfMemory}![]const u8Copies data in and returns the stable copy.
packager.PayloadStore.resetfn · línea 177
pub fn reset(self: *PayloadStore, gpa: std.mem.Allocator) voidSin ///.
packager.PayloadStore.allocatedfn · línea 185
pub fn allocated(self: *const PayloadStore) u64Bytes allocated (resident in safety-checked builds).
packager.Statstype · línea 210
pub const Stats = structSin ///.
packager.Sessiontype · línea 217
pub const Session = structSin ///.
packager.Session.openfn · línea 244
pub fn open(gpa: std.mem.Allocator, engine: contract.MediaEngine, src: contract.ByteSource, cancel: *contract.CancelToken, opts: Options) EngineError!*SessionOpens src with engine: header pass, track choice, first packet of
each track (timeline + AC-3 configuration), keyframe index, plan and
fragment muxer. cancel must outlive the session.
packager.Session.deinitfn · línea 357
pub fn deinit(self: *Session) voidSin ///.
packager.Session.pickfn · línea 378
pub fn pick(info: *const facts.ContainerInfo, kind: facts.Kind, want: ?u32) ?u32The stream of kind to package: want when it names one of that
kind, else the first known one. A want that names nothing packable
is null (the caller refuses the session: an explicit choice is never
replaced).
packager.Session.segmentCountfn · línea 412
pub fn segmentCount(self: *const Session) usizeSin ///.
packager.Session.initSegmentfn · línea 417
pub fn initSegment(self: *Session) []const u8ftyp + moov, owned by the session.
packager.Session.outputTracksfn · línea 421
pub fn outputTracks(self: *Session) []const contract.OutputTrackSin ///.
packager.Session.segmentfn · línea 428
pub fn segment(self: *Session, index: usize, gpa: std.mem.Allocator, out: *std.ArrayList(u8), request: ?*const contract.CancelToken) EngineError!voidAppends media segment index (one CMAF fragment) to out, grown
with gpa (the caller's buffer, the caller's allocator). request
(optional) cancels just this segment.
packager.Session.segmentNamefn · línea 552
pub fn segmentName(buf: []u8, index: usize) []const u8Sin ///.
packager.Session.mediaPlaylistfn · línea 558
pub fn mediaPlaylist(self: *const Session) []const u8VOD media playlist (fMP4 segments, EXT-X-MAP = init.mp4), owned
by the session; at most Options.maxPlaylistBytes.
packager.Session.masterPlaylistfn · línea 564
pub fn masterPlaylist(self: *const Session) []const u8Master playlist with one variant (CODECS from the facts), owned by
the session; at most master_playlist_max.
packager.writeMediaPlaylistfn · línea 569
pub fn writeMediaPlaylist(w: *std.Io.Writer, plan: plan_mod.Plan) std.Io.Writer.Error!voidSin ///.
packager.writeMasterPlaylistfn · línea 579
pub fn writeMasterPlaylist(w: *std.Io.Writer, tracks: []const contract.OutputTrack, avg_bps: u64) std.Io.Writer.Error!voidSin ///.
Sessiontype · línea 217
pub const Session = structSin ///.
Session.openfn · línea 244
pub fn open(gpa: std.mem.Allocator, engine: contract.MediaEngine, src: contract.ByteSource, cancel: *contract.CancelToken, opts: Options) EngineError!*SessionOpens src with engine: header pass, track choice, first packet of
each track (timeline + AC-3 configuration), keyframe index, plan and
fragment muxer. cancel must outlive the session.
Session.deinitfn · línea 357
pub fn deinit(self: *Session) voidSin ///.
Session.pickfn · línea 378
pub fn pick(info: *const facts.ContainerInfo, kind: facts.Kind, want: ?u32) ?u32The stream of kind to package: want when it names one of that
kind, else the first known one. A want that names nothing packable
is null (the caller refuses the session: an explicit choice is never
replaced).
Session.segmentCountfn · línea 412
pub fn segmentCount(self: *const Session) usizeSin ///.
Session.initSegmentfn · línea 417
pub fn initSegment(self: *Session) []const u8ftyp + moov, owned by the session.
Session.outputTracksfn · línea 421
pub fn outputTracks(self: *Session) []const contract.OutputTrackSin ///.
Session.segmentfn · línea 428
pub fn segment(self: *Session, index: usize, gpa: std.mem.Allocator, out: *std.ArrayList(u8), request: ?*const contract.CancelToken) EngineError!voidAppends media segment index (one CMAF fragment) to out, grown
with gpa (the caller's buffer, the caller's allocator). request
(optional) cancels just this segment.
Session.segmentNamefn · línea 552
pub fn segmentName(buf: []u8, index: usize) []const u8Sin ///.
Session.mediaPlaylistfn · línea 558
pub fn mediaPlaylist(self: *const Session) []const u8VOD media playlist (fMP4 segments, EXT-X-MAP = init.mp4), owned
by the session; at most Options.maxPlaylistBytes.
Session.masterPlaylistfn · línea 564
pub fn masterPlaylist(self: *const Session) []const u8Master playlist with one variant (CODECS from the facts), owned by
the session; at most master_playlist_max.