UNPKG

npaw-plugin

Version:
78 lines (77 loc) 2.71 kB
import Interceptors from './Interceptors/Interceptors'; import BalancerOptions from './Utils/Options'; import Emitter from './Utils/Emitter'; import NpawPluginOptions from '../core/NpawPluginOptions'; import BalancerAnalytics from './video/BalancerAnalytics'; import PeakBandwidthSampler from './Utils/PeakBandwidthSampler'; import { FirstChunkProbeRegistry } from './Utils/FirstChunkProbe'; declare global { interface XMLHttpRequest { isAsync: boolean; __balancerConnectTimer?: ReturnType<typeof setTimeout>; __balancerTotalTimer?: ReturnType<typeof setTimeout>; } } /** * @class * @description Core class for the p2p plugin. It includes the options, the websocket communication, * @exports CdnBalancer */ export default class CdnBalancer extends Emitter { interceptors: Interceptors; options: BalancerOptions; /** * Central peak-bandwidth sampler (PR5). One per balancer instance; tags are * registered at xhr.send and unregistered at loadend / abort. Public so * Loader.progressEM can update read counters without an extra hop. */ peakBandwidthSampler: PeakBandwidthSampler; /** * First-chunk probe registry (PR6). Holds FirstChunkProbeTag per in-flight * probe; consumed by the sampler's evaluateFirstChunkAborts on every tick. */ firstChunkProbeRegistry: FirstChunkProbeRegistry; private loader; private videoLogic?; private readonly _accountCode; private isEnabled; private defaultChunkDownloadTimeout; private isBitmovin; private isTheoplayer; private responseHeader; private allResponseHeader; private abort; private overrideMimeType; private requestHeader; private send; private open; private lastDecisionTimestamp; private apiHost; /** * Constructs CdnBalancer. * @param {string} accountCode NPAW Suite account code * @param npawPluginOptions Plugin-wide options */ constructor(accountCode: string, npawPluginOptions?: NpawPluginOptions, videoLogic?: BalancerAnalytics); private openAndSend; getManifestResolutionStats(): { parseCount: number; resolveCount: number; resolveHits: number; resolveMisses: number; lookaheadHits: number; lastHitFastHits: number; lastHitForceHits: number; multiPassHits: number; subManifestAttachments: number; manifestCount: number; lookaheadSize: number; modelHits: number; fallbackCount: number; }; setVideoLogic(videoLogic?: BalancerAnalytics): void; enable(): void; disable(): void; getIsEnabled(): boolean; isCdnBalancerSupported(): boolean; }