Constructs a new Core instance with optional initial configuration.
Optional
config: Partial<CoreConfig>Optional partial configuration to override default settings.
// Create a Core instance with custom configuration for HTTP and P2P downloads.
const core = new Core({
simultaneousHttpDownloads: 5,
simultaneousP2PDownloads: 5,
httpErrorRetries: 5,
p2pErrorRetries: 5
});
// Create a Core instance using the default configuration.
const core = new Core();
Static
Readonly
DEFAULT_Default configuration for common core settings.
Static
Readonly
DEFAULT_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 = {
httpDownloadTimeWindowMs: 60, // Set HTTP download time window to 60 seconds
p2pDownloadTimeWindowMs: 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.
Retrieves a specific stream by its runtime identifier, if it exists.
The runtime identifier of the stream to retrieve.
The stream with its segments, or undefined
if not found.
Ensures a stream exists in the map; adds it if it does not.
The stream to potentially add to the map.
Updates the segments associated with a specific stream.
The runtime identifier of the stream to update.
Optional
addSegments: Iterable<Segment>Optional segments to add to the stream.
Optional
removeSegmentIds: Iterable<string>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.
Core class for managing media streams loading via P2P.