StreamConfig: {
    isP2PDisabled: boolean;
    highDemandTimeWindow: number;
    httpDownloadTimeWindow: number;
    p2pDownloadTimeWindow: number;
    simultaneousHttpDownloads: number;
    simultaneousP2PDownloads: number;
    webRtcMaxMessageSize: number;
    p2pNotReceivingBytesTimeoutMs: number;
    p2pInactiveLoaderDestroyTimeoutMs: number;
    httpNotReceivingBytesTimeoutMs: number;
    httpErrorRetries: number;
    p2pErrorRetries: number;
    announceTrackers: string[];
    rtcConfig: RTCConfiguration;
    trackerClientVersionPrefix: string;
    swarmId?: string;
    validateP2PSegment?: ((url: string, byteRange?: ByteRange) => Promise<boolean>);
    httpRequestSetup?: ((segmentUrl: string, segmentByteRange: ByteRange | undefined, requestAbortSignal: AbortSignal, requestByteRange: {
        start: number;
        end?: number;
    } | undefined) => Promise<Request | undefined | null>);
}

Configuration options for the Core functionality, including network and processing parameters.

Type declaration

  • isP2PDisabled: boolean

    Indicates whether Peer-to-Peer (P2P) functionality is disabled for the stream. If set to true, P2P functionality is disabled for the stream.

    isP2PDisabled: false
    
  • highDemandTimeWindow: number

    Defines the duration of the time window, in seconds, during which segments are pre-loaded to ensure smooth playback. This window helps prioritize the fetching of media segments that are imminent to playback.

    highDemandTimeWindow: 15
    
  • httpDownloadTimeWindow: number

    Defines the time window, in seconds, for HTTP segment downloads. This property specifies the duration over which media segments are pre-fetched using HTTP requests.

    For a better P2P ratio, it is recommended to set this httpDownloadTimeWindow to be lower than p2pDownloadTimeWindow.

    NOTE: This setting only takes effect if there is at least one peer connection and the connected peer does not have the requested segments available to share via P2P.

    httpDownloadTimeWindow: 3000
    
  • p2pDownloadTimeWindow: number

    Defines the time window, in seconds, dedicated to pre-fetching media segments via Peer-to-Peer (P2P) downloads. This duration determines how much content is downloaded in advance using P2P connections to ensure smooth playback and reduce reliance on HTTP downloads.

    For a better P2P ratio, it is recommended to set this time window to be greater than httpDownloadTimeWindow to maximize P2P usage.

    p2pDownloadTimeWindow: 6000
    
  • simultaneousHttpDownloads: number

    Maximum number of simultaneous HTTP downloads allowed.

    simultaneousHttpDownloads: 2
    
  • simultaneousP2PDownloads: number

    Maximum number of simultaneous P2P downloads allowed.

    simultaneousP2PDownloads: 3
    
  • webRtcMaxMessageSize: number

    Maximum message size for WebRTC communications, in bytes.

    webRtcMaxMessageSize: 64 * 1024 - 1
    
  • p2pNotReceivingBytesTimeoutMs: number

    Timeout for not receiving bytes from P2P, in milliseconds.

    p2pNotReceivingBytesTimeoutMs: 2000
    
  • p2pInactiveLoaderDestroyTimeoutMs: number

    Timeout for destroying the P2P loader if inactive, in milliseconds.

    p2pInactiveLoaderDestroyTimeoutMs: 30 * 1000
    
  • httpNotReceivingBytesTimeoutMs: number

    Timeout for not receiving bytes from HTTP downloads, in milliseconds.

    httpNotReceivingBytesTimeoutMs: 3000
    
  • httpErrorRetries: number

    Number of retries allowed after an HTTP error.

    httpErrorRetries: 3
    
  • p2pErrorRetries: number

    Number of retries allowed after a P2P error.

    p2pErrorRetries: 3
    
  • announceTrackers: string[]

    List of URLs to the WebTorrent trackers used for announcing and discovering peers (i.e. WebRTC signaling).

    WARNING: In the Safari browser, only the first tracker will be used. Safari has issues with multiple trackers, leading to problems with sending SDP messages for WebRTC signaling.

    The default trackers used are:

    [
    "wss://tracker.novage.com.ua",
    "wss://tracker.webtorrent.dev",
    "wss://tracker.openwebtorrent.com",
    ]
  • rtcConfig: RTCConfiguration

    Configuration for the RTC layer, used in WebRTC communication. This configuration specifies the STUN/TURN servers used by WebRTC to establish connections through NATs and firewalls.

    https://developer.mozilla.org/en-US/docs/Web/API/RTCConfiguration

    {
    "rtcConfig": {
    "iceServers": [
    { "urls": "stun:stun.l.google.com:19302" },
    { "urls": "stun:global.stun.twilio.com:3478" }
    ]
    }
    }
  • trackerClientVersionPrefix: string

    Prefix to use for the WebTorrent client version in tracker communications. If undefined, the default version prefix is used, which is calculated based on the package version.

    trackerClientVersionPrefix: undefined
    
  • OptionalswarmId?: string

    Optional unique identifier for the swarm, used to isolate peer pools by media stream. If undefined, the URL of the manifest is used as the swarm ID.

    swarmId: undefined
    
  • OptionalvalidateP2PSegment?: ((url: string, byteRange?: ByteRange) => Promise<boolean>)

    Optional function to validate a P2P segment before fully integrating it into the playback buffer.

    validateP2PSegment: undefined
    
      • (url, byteRange?): Promise<boolean>
      • Parameters

        • url: string

          URL of the segment to validate.

        • OptionalbyteRange: ByteRange

          Optional byte range of the segment.

        Returns Promise<boolean>

        A promise that resolves with a boolean indicating if the segment is valid.

  • OptionalhttpRequestSetup?: ((segmentUrl: string, segmentByteRange: ByteRange | undefined, requestAbortSignal: AbortSignal, requestByteRange: {
        start: number;
        end?: number;
    } | undefined) => Promise<Request | undefined | null>)

    Optional function to customize the setup of HTTP requests for segment downloads.

    httpRequestSetup: undefined
    
      • (segmentUrl, segmentByteRange, requestAbortSignal, requestByteRange): Promise<Request | undefined | null>
      • Parameters

        • segmentUrl: string

          URL of the segment.

        • segmentByteRange: ByteRange | undefined

          The range of bytes requested for the segment.

        • requestAbortSignal: AbortSignal

          An abort signal to cancel the request if needed.

        • requestByteRange: {
              start: number;
              end?: number;
          } | undefined

          Additional byte range for partial requests, if required.

        Returns Promise<Request | undefined | null>

        A promise that resolves with the configured request, or undefined if no customization should be made.