P2P Media Loader Documentation
    Preparing search index...

    Interface SegmentStorage

    The interface for segment storage.

    interface SegmentStorage {
        initialize(
            coreConfig: CommonCoreConfig,
            mainStreamConfig: StreamConfig,
            secondaryStreamConfig: StreamConfig,
        ): Promise<void>;
        onPlaybackUpdated(position: number, rate: number): void;
        onSegmentRequested(
            swarmId: string,
            streamId: string,
            segmentId: number,
            startTime: number,
            endTime: number,
            streamType: StreamType,
            isLiveStream: boolean,
        ): void;
        storeSegment(
            swarmId: string,
            streamId: string,
            segmentId: number,
            data: ArrayBuffer,
            startTime: number,
            endTime: number,
            streamType: StreamType,
            isLiveStream: boolean,
        ): Promise<void>;
        getSegmentData(
            swarmId: string,
            streamId: string,
            segmentId: number,
        ): Promise<ArrayBuffer | undefined>;
        getUsage(): { totalCapacity: number; usedCapacity: number };
        hasSegment(swarmId: string, streamId: string, segmentId: number): boolean;
        getStoredSegmentIds(swarmId: string, streamId: string): number[];
        setSegmentChangeCallback(
            callback: ((streamId: string) => void) | undefined,
        ): void;
        destroy(): void;
    }
    Index

    Methods

    • Updates the storage with the current playback position from the player.

      Parameters

      • position: number

        The current playback position.

      • rate: number

        The current playback rate.

      Returns void

    • Provides the storage with information about a segment requested by the player.

      Parameters

      • swarmId: string

        The swarm identifier.

      • streamId: string

        The stream identifier.

      • segmentId: number

        The segment identifier.

      • startTime: number

        The start time of the segment.

      • endTime: number

        The end time of the segment.

      • streamType: StreamType

        The type of the stream.

      • isLiveStream: boolean

        Indicates whether the stream is live.

      Returns void

    • Stores the data for a specific segment.

      Parameters

      • swarmId: string

        The swarm identifier.

      • streamId: string

        The stream identifier.

      • segmentId: number

        The segment identifier.

      • data: ArrayBuffer

        The segment data to store.

      • startTime: number

        The start time of the segment.

      • endTime: number

        The end time of the segment.

      • streamType: StreamType

        The type of the stream.

      • isLiveStream: boolean

        Indicates whether the stream is live.

      Returns Promise<void>

    • Retrieves the data for a specific segment.

      Parameters

      • swarmId: string

        The swarm identifier.

      • streamId: string

        The stream identifier.

      • segmentId: number

        The segment identifier.

      Returns Promise<ArrayBuffer | undefined>

    • Retrieves information about the current memory usage of the storage.

      Returns { totalCapacity: number; usedCapacity: number }

    • Checks if a specific segment is present in the storage.

      Parameters

      • swarmId: string

        The swarm identifier.

      • streamId: string

        The stream identifier.

      • segmentId: number

        The segment identifier.

      Returns boolean

      true if the segment is in the storage, otherwise false.

    • Retrieves the IDs of all segments for a specific stream currently stored in the storage.

      Parameters

      • swarmId: string

        The swarm identifier.

      • streamId: string

        The stream identifier.

      Returns number[]

    • Sets the callback function to be invoked when segments are added to or removed from the storage.

      Parameters

      • callback: ((streamId: string) => void) | undefined

        The callback function, which receives the streamId of the affected stream.

      Returns void