UNPKG

active-switching

Version:

NPAW's SDK for CDN Balancing and P2P

95 lines (94 loc) 3.27 kB
import { VideoSegment } from '../Storage/VideoSegment'; /** * @class * @description This class stores information about every CDN available for the played content. * It also keeps updated the estimated bandwidth value. * @exports Cdn */ export default class Cdn { static initialBw: number; provider: string; name: string; url: string; original: boolean; score: number; active: boolean; banned: boolean; bannedCount: number; unBannedCount: number; host: string; downloadedChunks: number; downloadedBytes: number; downloadedBytesForScoring: number; downloadTimeForScoring: number; hugeChunks: number; firstHugeChunkSize: number; private bandwidthForScoring; private wBandwidthForScoring; failures: number; retries: number; totalFail: number; cacheHit: number; downloadMillis: number; usedOnce: boolean; maxBandwidth: number; lastPreferedVideoBandwidth: number; private _lastsPreferedVideoBandwidth; highestRenditionBandwidth: number; lastPreferedVideoChunkSize: number; lastPreferedVideoChunkDownloadTime: number; lastPingTime: number; private _accumBw; private bandwidth; private wBandwidth; private _lastResponses; highestSegmentBandwidth: number; lowestSegmentBandwidth: number; highestPingTime: number; lowestPingTime: number; avgPingTime: number; private downloadedSegments; /** * Constructs Cdn definition class. * @param {string} provider CDN provider. * @param {string} name CDN name. * @param {String} url CDN URL (host and path). * @param {number} score Given score by the API. * @param {number} relScore Relative score calculated with other CDN scores. * @param {boolean} original If the CDN is the one used in the manifest URL provided by the customer. */ constructor(provider: string, name: string, url: string, score: number, original: boolean); private pushLastPreferedVideoBandwidth; getAvgLastVideoBandwidth(): number; /** * Add the data of a response, successful or not, of the defined CDN. * It stores the properties of the response in lastResponses list and calculates the future estimated bandwidth. * @param {VideoSegment} segment URL of the request. * @public */ addResp(segment: VideoSegment): void; calculateEffectiveBadnwidth(chunkBitrate: number, chunkDuration: number): number; getVideoBandwidth(): number; /** * Returns the the expected bandwidth for the following request, based on previous requests. * @returns {number} Bandwidth value. * @public */ getBandwidth(): number; getAvgBandwidth(): number; getAvgRecentBandwidth(): number; getAvgWBandwidth(): number; getAvgRecentWBandwidth(): number; getWeightedBandwidth(): number; /** * Resets the bandwidth value of the CDN, to discard previous wrong values and restart algorythms. * @public */ resetBandwidth(): void; /** * Returns the timestamp of the oldest request stored in the lastResponses object, or 0 if is empty. * @returns {number} Timestamp of the oldest stored request. * @public */ getOldestRequestTS(): number; }