Declaraciones públicas de media-core/engine/contract.zig (media-core: motor de medios).
apps/docs/generated/zig/media-engine.jsonPágina generada desde
native/zig/media-core/media_engine.zig. No se edita a mano:bun run docs:genla regenera ybun run docs:checkfalla si difiere.
MediaEngine — the contract both media engines implement (dec-0110 §1).
engine = zig demux in media-core (ISOBMFF/fMP4, Matroska/WebM) + the
fMP4-CMAF fragment muxer of native/zig/transmux.
engine = libav FFmpeg 8 as a LIBRARY (libavformat), native/zig/libav-bridge.
The surface is the same for both, so the HLS/CMAF packager (segment plan, playlists, segment cutting) is common code that only varies what differs: demux and fragment mux. Rules every implementation keeps:
ByteSource (the daemon's SeekableMediaSource);
an engine never opens paths, URLs or sockets.EngineError: no engine-specific code (AVERROR) leaks out.CancelToken, r04 / r20 §3.6).Packet carries PTS and DTS in its track time base, and DTS is
strictly increasing per track (Matroska stores no DTS: the engine
synthesizes it). Keyframe indexes are in PTS (dec-0110 §6.7 of the libav
spike: libav's MP4 index is DTS; the engine converts).TrackSpec), not from a
demuxer, so one engine's demux can feed the other's mux.contract.EngineKindtype · línea 32
pub const EngineKind = enumSin ///.
contract.EngineKind.parsefn · línea 36
pub fn parse(s: []const u8) ?EngineKindSin ///.
contract.EngineErrorconst · línea 43
pub const EngineError = error{ UnknownFormat, Malformed, Truncated, TooLarge, /// Valid input the engine does not handle (codec, container feature, /// missing index), or an engine not built in (`-Dli …Common error set of both engines. The Zig parsers speak bytes.Error;
fromParser translates at the engine boundary.
contract.fromParserfn · línea 60
pub fn fromParser(e: bytes.Error) EngineErrorA parser error (bytes.Error: the zkit.safety reader vocabulary plus the
container's own) as an EngineError.
contract.Packettype · línea 77
pub const Packet = structOne compressed access unit. data is borrowed from the demuxer until the
next nextPacket/seek/deinit.
contract.Packet.ptsUsfn · línea 91
pub fn ptsUs(self: Packet) i64Sin ///.
contract.Packet.checkTimelinefn · línea 99
pub fn checkTimeline(self: Packet) EngineError!voidZC6-P1-01: PTS, DTS and duration inside the engine timeline
(timebase.inTimeline). Checked on every packet that crosses the
contract, from either engine: the packager's timeline arithmetic
never sees a value a hostile container pushed to the i64 limits.
contract.Demuxertype · línea 105
pub const Demuxer = structSin ///.
contract.Demuxer.VTabletype · línea 109
pub const VTable = structSin ///.
contract.Demuxer.infofn · línea 131
pub fn info(self: Demuxer) *const facts.ContainerInfoSin ///.
contract.Demuxer.selectfn · línea 134
pub fn select(self: Demuxer, streams: []const u32) voidSin ///.
contract.Demuxer.keyframesfn · línea 137
pub fn keyframes(self: Demuxer, stream: u32) EngineError![]const facts.KeyframeSin ///.
contract.Demuxer.nextPacketfn · línea 140
pub fn nextPacket(self: Demuxer) EngineError!?PacketSin ///.
contract.Demuxer.seekfn · línea 145
pub fn seek(self: Demuxer, ts_us: i64) EngineError!voidSin ///.
contract.Demuxer.statsfn · línea 148
pub fn stats(self: Demuxer) ReadStatsSin ///.
contract.Demuxer.deinitfn · línea 151
pub fn deinit(self: Demuxer) voidSin ///.
contract.TrackSpectype · línea 159
pub const TrackSpec = structA source track to mux, described by its facts. first_packet is the
payload of the track's first packet: AC-3/E-AC-3 configuration (dac3,
dec3) only exists in the bitstream when the source is Matroska.
contract.OutputTracktype · línea 172
pub const OutputTrack = structOutput track as announced to the packager (HLS CODECS, RESOLUTION).
contract.TrackSamplestype · línea 185
pub const TrackSamples = structSamples of one output track inside one fragment, in decode order, with
DTS already mapped to the canonical output timeline (see DtsMap).
contract.Remuxertype · línea 192
pub const Remuxer = structSin ///.
contract.Remuxer.VTabletype · línea 196
pub const VTable = structSin ///.
contract.Remuxer.tracksfn · línea 208
pub fn tracks(self: Remuxer) []const OutputTrackSin ///.
contract.Remuxer.initSegmentfn · línea 211
pub fn initSegment(self: Remuxer) []const u8Sin ///.
contract.Remuxer.writeFragmentfn · línea 214
pub fn writeFragment(self: Remuxer, gpa: std.mem.Allocator, sequence: u32, samples: []const TrackSamples, out: *std.ArrayList(u8)) EngineError!voidSin ///.
contract.Remuxer.deinitfn · línea 217
pub fn deinit(self: Remuxer) voidSin ///.
contract.Capabilitiestype · línea 224
pub const Capabilities = structVersioned engine capabilities (r23): what each engine declares it handles. Selection consults them; it never assumes.
contract.Capabilities.supportsFormatfn · línea 230
pub fn supportsFormat(self: Capabilities, f: facts.Format) boolSin ///.
contract.Capabilities.supportsCodecfn · línea 234
pub fn supportsCodec(self: Capabilities, c: facts.Codec) boolSin ///.
contract.ProbeOptionstype · línea 239
pub const ProbeOptions = structSin ///.
contract.MediaEnginetype · línea 244
pub const MediaEngine = structSin ///.
contract.MediaEngine.VTabletype · línea 248
pub const VTable = structSin ///.
contract.MediaEngine.kindfn · línea 258
pub fn kind(self: MediaEngine) EngineKindSin ///.
contract.MediaEngine.capabilitiesfn · línea 261
pub fn capabilities(self: MediaEngine) CapabilitiesSin ///.
contract.MediaEngine.describefn · línea 264
pub fn describe(self: MediaEngine) []const u8Sin ///.
contract.MediaEngine.probefn · línea 267
pub fn probe(self: MediaEngine, gpa: std.mem.Allocator, src: ByteSource, cancel: *const CancelToken, opts: ProbeOptions) EngineError!facts.ContainerInfoSin ///.
contract.MediaEngine.openDemuxerfn · línea 270
pub fn openDemuxer(self: MediaEngine, gpa: std.mem.Allocator, src: ByteSource, cancel: *const CancelToken) EngineError!DemuxerSin ///.
contract.MediaEngine.openRemuxerfn · línea 273
pub fn openRemuxer(self: MediaEngine, gpa: std.mem.Allocator, specs: []const TrackSpec) EngineError!RemuxerSin ///.
MediaEnginetype · línea 244
pub const MediaEngine = structSin ///.
MediaEngine.VTabletype · línea 248
pub const VTable = structSin ///.
MediaEngine.kindfn · línea 258
pub fn kind(self: MediaEngine) EngineKindSin ///.
MediaEngine.capabilitiesfn · línea 261
pub fn capabilities(self: MediaEngine) CapabilitiesSin ///.
MediaEngine.describefn · línea 264
pub fn describe(self: MediaEngine) []const u8Sin ///.
MediaEngine.probefn · línea 267
pub fn probe(self: MediaEngine, gpa: std.mem.Allocator, src: ByteSource, cancel: *const CancelToken, opts: ProbeOptions) EngineError!facts.ContainerInfoSin ///.
MediaEngine.openDemuxerfn · línea 270
pub fn openDemuxer(self: MediaEngine, gpa: std.mem.Allocator, src: ByteSource, cancel: *const CancelToken) EngineError!DemuxerSin ///.
MediaEngine.openRemuxerfn · línea 273
pub fn openRemuxer(self: MediaEngine, gpa: std.mem.Allocator, specs: []const TrackSpec) EngineError!RemuxerSin ///.
EngineKindtype · línea 32
pub const EngineKind = enumSin ///.
EngineKind.parsefn · línea 36
pub fn parse(s: []const u8) ?EngineKindSin ///.
EngineErrorconst · línea 43
pub const EngineError = error{ UnknownFormat, Malformed, Truncated, TooLarge, /// Valid input the engine does not handle (codec, container feature, /// missing index), or an engine not built in (`-Dli …Common error set of both engines. The Zig parsers speak bytes.Error;
fromParser translates at the engine boundary.
Packettype · línea 77
pub const Packet = structOne compressed access unit. data is borrowed from the demuxer until the
next nextPacket/seek/deinit.
Packet.ptsUsfn · línea 91
pub fn ptsUs(self: Packet) i64Sin ///.
Packet.checkTimelinefn · línea 99
pub fn checkTimeline(self: Packet) EngineError!voidZC6-P1-01: PTS, DTS and duration inside the engine timeline
(timebase.inTimeline). Checked on every packet that crosses the
contract, from either engine: the packager's timeline arithmetic
never sees a value a hostile container pushed to the i64 limits.
Demuxertype · línea 105
pub const Demuxer = structSin ///.
Demuxer.VTabletype · línea 109
pub const VTable = structSin ///.
Demuxer.infofn · línea 131
pub fn info(self: Demuxer) *const facts.ContainerInfoSin ///.
Demuxer.selectfn · línea 134
pub fn select(self: Demuxer, streams: []const u32) voidSin ///.
Demuxer.keyframesfn · línea 137
pub fn keyframes(self: Demuxer, stream: u32) EngineError![]const facts.KeyframeSin ///.
Demuxer.nextPacketfn · línea 140
pub fn nextPacket(self: Demuxer) EngineError!?PacketSin ///.
Demuxer.seekfn · línea 145
pub fn seek(self: Demuxer, ts_us: i64) EngineError!voidSin ///.
Demuxer.statsfn · línea 148
pub fn stats(self: Demuxer) ReadStatsSin ///.
Demuxer.deinitfn · línea 151
pub fn deinit(self: Demuxer) voidSin ///.
Remuxertype · línea 192
pub const Remuxer = structSin ///.
Remuxer.VTabletype · línea 196
pub const VTable = structSin ///.
Remuxer.tracksfn · línea 208
pub fn tracks(self: Remuxer) []const OutputTrackSin ///.
Remuxer.initSegmentfn · línea 211
pub fn initSegment(self: Remuxer) []const u8Sin ///.
Remuxer.writeFragmentfn · línea 214
pub fn writeFragment(self: Remuxer, gpa: std.mem.Allocator, sequence: u32, samples: []const TrackSamples, out: *std.ArrayList(u8)) EngineError!voidSin ///.
Remuxer.deinitfn · línea 217
pub fn deinit(self: Remuxer) voidSin ///.