p2p-media-loader-core
Version:
P2P Media Loader core functionality
50 lines (49 loc) • 2.36 kB
TypeScript
import { CoreEventMap, EngineCallbacks, SegmentWithStream, StreamConfig, StreamWithSegments } from "./types.js";
import { BandwidthCalculators, StreamDetails } from "./internal-types.js";
import { EventTarget } from "./utils/event-target.js";
import { SegmentStorage } from "./segment-storage/index.js";
import { WebTorrentSocketPool } from "./webtorrent/webtorrent-socket-pool/index.js";
export declare class HybridLoader {
private streamManifestUrl;
private lastRequestedSegment;
private readonly streamDetails;
private readonly config;
private readonly bandwidthCalculators;
private readonly segmentStorage;
private readonly webTorrentSocketPool;
private readonly eventTarget;
private readonly peerId;
private readonly requests;
private engineRequest?;
private readonly p2pLoaders;
private readonly playback;
private readonly segmentAvgDuration;
private readonly logger;
private levelChangedTimestamp?;
private lastQueueProcessingTimeStamp?;
private randomHttpDownloadTimeout?;
private initialHttpDelayTimeoutId?;
private isProcessQueueMicrotaskCreated;
private readonly swarmId;
private readonly createdAt;
constructor(streamManifestUrl: string, lastRequestedSegment: Readonly<SegmentWithStream>, streamDetails: Required<Readonly<StreamDetails>>, config: StreamConfig, bandwidthCalculators: BandwidthCalculators, segmentStorage: SegmentStorage, webTorrentSocketPool: WebTorrentSocketPool, eventTarget: EventTarget<CoreEventMap>, peerId: string);
private setIntervalLoading;
loadSegment(segment: Readonly<SegmentWithStream>, callbacks: EngineCallbacks): Promise<void>;
private requestProcessQueueMicrotask;
private processRequests;
private processQueue;
abortSegmentRequest(segmentRuntimeId: string): void;
private loadThroughHttp;
private loadThroughP2P;
private loadRandomThroughHttp;
private abortLastHttpLoadingInQueueAfterItem;
private abortLastP2PLoadingInQueueAfterItem;
private getAvailableStorageCapacityPercent;
private generateQueue;
private getBandwidth;
notifyLevelChanged(): void;
sendBroadcastAnnouncement(sendEmptySegmentsAnnouncement?: boolean): void;
updatePlayback(position: number, rate: number): void;
updateStream(stream: StreamWithSegments): void;
destroy(): void;
}