PrismCore / API reference / Engine and session

Enumeration

PlaybackEvent

enum PlaybackEvent

Declared in Sources/PrismCore/PlaybackEvents.swift · PrismCore 3.5.4

Something the running session noticed that a host can explain to a viewer.

Before these existed, every runtime trouble reached the host the same way: a generic AVPlayer error some seconds later, with the cause — an origin shedding load, a producer parked inside a read nobody answers — known only to the engine's own log. Report-only: the events describe what happened, including the one repair the engine makes on its own (producerRecovered); a host acting on them changes nothing inside it.

Equatable compares a PrismCoreError payload by its description: the error carries any Error and is not Equatable itself, and two failures that print the same are the same thing to everything that compares events (tests, a host de-duplicating a banner).

Cases

case slowServe(path: String, waited: Duration)

A served file took longer than the server's slow-serve threshold (2 s) to be ready, and was then delivered. waited is the whole wait.

case serveTimedOut(path: String)

A served file never landed within the production window, and the request was answered with the miss (an aborted transfer for media, an empty WebVTT for subtitles). AVPlayer usually reports an error next.

case producerStalled(since: Duration, lastPTS: Double?)

A request is waiting on the producer and the producer has not cut a segment for since — whether or not it is still reading. lastPTS is the newest packet timestamp it did read, in seconds on the source's timeline (nil before the first): one far past the waited segment means reading without cutting, one standing still means a starved read. (Through 3.5.2 the clock was the last read, which a producer reading toward a boundary it never reached kept resetting.)

Measured only while a serve is pending, and never while the producer is deliberately parked, so a paused player does not look stalled.

case originThrottled(retryAfter: Duration?)

The source origin answered 429/503/509. retryAfter is what its Retry-After header asked for, when it sent one.

Origin admission is shared by every session reading the same origin, so every session on that origin sees this, including one whose own requests were never refused — they are all held back by it.

case originRecovered

The first good response from a throttled origin. Shared like originThrottled.

case segmentPlanAvailable(segments: Int)

This session is playing sequentially because the source's seek index did not load within the startup budget, and a background load has now read it in full and stored it in the keyframe index cache. A successor (makeSession(changing:), same keyframeIndexCacheDirectory) plans from that map: a VOD playlist of segments entries, seekable anywhere, where this session can only grow its EVENT playlist.

Only ever sent once the map is stored — never for a source whose version cannot be proven (see keyframeIndexCacheDirectory), because a successor of that source would face the same budget and most likely play sequentially again. This session itself does not change.

case producerRecovered(attempt: Int, cause: PrismCoreError)

A read of the source failed mid-session, and production carried on: the producer re-opened the source and re-anchored at the segment it was producing. cause is the failure it recovered from; attempt counts re-opens inside the current 60 s window, the one the cap of 3 applies to — so attempt == 3 means the next failure inside that window ends the session.

Planned sessions only (see the README's Streaming section). While it re-opens, fetches of unproduced segments are held exactly as for a seek, so AVPlayer sees a slow segment rather than an error.

case producerFailed(PrismCoreError)

The producer stopped for good: remuxFailure is now set, to this same classification. Sent exactly once per session that fails, and never for a stop(). A failure during startup sends it too — start() throws the same failure there.

Generated from the public symbols of PrismCore 3.5.4. All types