npaw-plugin-nwf
Version:
NPAW's Plugin
131 lines (130 loc) • 3.7 kB
TypeScript
import Interceptors from './Interceptors/Interceptors';
import BalancerOptions from './Utils/Options';
import Loader from './Loaders/Loader';
import Emitter from './Utils/Emitter';
import { VideoSegment } from './Storage/VideoSegment';
import NpawPluginOptions from '../core/NpawPluginOptions';
declare global {
interface XMLHttpRequest {
isAsync: boolean;
}
}
/**
* @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;
private loader;
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);
/**
* @internal
*/
destroy(): void;
/**
* @internal
*/
getAccountCode(): string;
/**
* @internal
* @param options
*/
setOptions(options: BalancerOptions): void;
private openAndSend;
/**
* Redirects adapter's requests to loader.
* If loader is not yet ready it retries again after 200ms.
*
* @internal
* @param {URL} url URL object for the request.
* @param download
* @param {callback} callbacks Callback method to call back when loaded.
* @param {Object} headers Optional headers of the request.
* @param {number} retries Number of retries before giving up to load a segment if it fails, optional.
* @param {boolean} forceArrayBuffer set as true if is expected to get the manifest response in ArrayBuffer format.
* @param stats
* @public
*/
request(url: URL, download: true, callbacks: callback[], headers: {
[key: string]: string;
}, retries?: number, forceArrayBuffer?: boolean, stats?: fragStats): void;
/**
* Sets the manifest URL of the played content to the options object.
* For url changes the loader is restarted.
*
* @internal
* @param {string} url Manifest url of the content being played.
* @public
*/
setManifestResource(url: string): void;
/**
* @internal
*/
getLoader(): Loader;
/**
* @internal
* @param name
* @param player
*/
addInterceptor(name: string, player: any): void;
/**
* @internal
*/
getRecommendedManifest(): Promise<string>;
/**
* @internal
*/
useTheoplayer(): void;
/**
* @internal
*/
getBitmovinSendHttpRequest(): (type: any, request: any) => {
getResponse(): any;
cancel(): void;
setProgressListener(): void;
} | null;
/**
* Restarts P2P connection in case the client needs to play another video
*
* @internal
*/
resetP2PConnection(): void;
/**
* @internal
* @param urlString
* @param params
* @param headers
*/
simpleRequest(urlString: string, params: any, headers: {
[key: string]: string;
}): VideoSegment;
enable(): void;
disable(): void;
getIsEnabled(): boolean;
/**
* @internal
* @param constructionOptions
*/
reload(constructionOptions?: constructionOptions): void;
}