Constructs a new Core instance with optional initial configuration.
Optionalconfig: Partial<CoreConfig>
Optional partial configuration to override default settings.
Static ReadonlyDEFAULT_Default configuration for common core settings.
Static ReadonlyDEFAULT_Default configuration for stream settings.
Retrieves the current configuration for the core instance, ensuring immutability.
A deep readonly version of the core configuration.
Applies a set of dynamic configuration updates to the core, merging with the existing configuration.
A set of configuration changes to apply.
// Example of dynamically updating the download time windows and timeout settings.
const dynamicConfig = {
httpDownloadTimeWindow: 60, // Set HTTP download time window to 60 seconds
p2pDownloadTimeWindow: 60, // Set P2P download time window to 60 seconds
httpNotReceivingBytesTimeoutMs: 1500, // Set HTTP timeout to 1500 milliseconds
p2pNotReceivingBytesTimeoutMs: 1500 // Set P2P timeout to 1500 milliseconds
};
core.applyDynamicConfig(dynamicConfig);
Adds an event listener for the specified event type on the core event target.
The name of the event to listen for.
The callback function to invoke when the event is fired.
Removes an event listener for the specified event type on the core event target.
The name of the event to listen for.
The callback function to be removed.
Sets the response URL for the manifest, stripping any query parameters.
The full URL to the manifest response.
Checks if a segment is already stored within the core.
The runtime identifier of the segment to check.
true if the segment is present, otherwise false.
Retrieves a specific stream by its runtime identifier, if it exists.
The runtime identifier of the stream to retrieve.
A detached snapshot of the registered stream with its computed
identity, or undefined if not found. The identity fields never change
after registration, so the snapshot stays accurate for the stream's lifetime.
Retrieves the runtime identifiers of the segments currently registered
for a stream. Player integrations use this to diff a refreshed manifest
against the core's registry before calling updateStream.
The runtime identifier of the stream.
A snapshot set of the registered segment runtime IDs, or
undefined if the stream is not registered.
Retrieves all currently registered streams with their computed identities,
including the infohashes announced to trackers. Unlike the onStreamAdded
event, this reflects the full set at any moment, so late subscribers can
catch up on streams registered before they attached.
Detached snapshots of the registered streams, in registration order.
Ensures a stream exists in the map; adds it if it does not.
Computes the stream's identity (swarmId, identityHash, streamSwarmId,
infoHash) exactly once at registration and freezes it on the stream.
Requires the swarm ID to be resolvable: either a swarmId is configured
or setManifestResponseUrl() has been called.
Never throws: a stream that fails to register (unresolvable swarm ID, or
an invalid or colliding custom stream swarm ID) stays unknown to the core —
its segments load through the player's default path without P2P — and the
failure is reported via the onStreamRegistrationError event.
The stream to potentially add to the map.
Updates the segments associated with a specific stream.
The runtime identifier of the stream to update.
OptionaladdSegments: Iterable<Segment, any, any>
Optional segments to add to the stream.
OptionalremoveSegmentIds: Iterable<string, any, any>
Optional segment IDs to remove from the stream.
Loads a segment given its runtime identifier and invokes the provided callbacks during the process. Initializes segment storage if it has not been initialized yet.
The runtime identifier of the segment to load.
The callbacks to be invoked during segment loading.
Aborts the loading of a segment specified by its runtime identifier.
The runtime identifier of the segment whose loading is to be aborted.
Updates the playback parameters while play head moves, specifically position and playback rate, for stream loaders.
The new position in the stream, in seconds.
The new playback rate.
Sets the active level bitrate, used for adjusting quality levels in adaptive streaming. Notifies the stream loaders if a change occurs.
The new bitrate to set as active.
Updates the 'isLive' status of the stream
Boolean indicating whether the stream is live.
Identify if a segment is loadable by the P2P core based on the segment's stream type and configuration.
Segment runtime identifier to check.
true if the segment is loadable by the P2P core, otherwise false.
Cleans up resources used by the Core instance, including destroying any active stream loaders and clearing stored segments.
Event listeners deliberately survive: the player integrations reuse one
Core instance across media sources, destroying it between loads, and
subscriptions (e.g. onStreamAdded, onPeerConnect) are expected to
keep working after the next source loads. Use removeEventListener to
unsubscribe explicitly.
Core class for managing media streams loading via P2P.