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; host: string; path: string; url: string; original: boolean; score: number; active: boolean; banned: boolean; private _parser?; bannedCount: number; unBannedCount: number; downloadedChunks: number; downloadedBytes: number; downloadedBytesForScoring: number; downloadTimeForScoring: number; hugeChunks: number; firstHugeChunkSize: number; private bandwidthForScoring; private wBandwidthForScoring; failures: number; retries: number; totalFail: number; browserCacheHits: number; private numberOfCdnCacheHits; private numberOfCdnCacheMisses; private numberOfCdnCacheUnknowns; responseTime: number; downloadMillis: number; usedOnce: boolean; downloadedBytesVideo: number; downloadMillisVideo: number; downloadedChunksVideo: number; 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} host CDN URL host. * @param {string} path CDN URL path. * @param {String} url CDN URL (host and path). * @param {number} score Given score by the API. * @param {boolean} original If the CDN is the one used in the manifest URL provided by the customer. * @param {cdnHeaderParser} parser Object with information for CDN header parsing */ constructor(provider: string, name: string, host: string, path: string, url: string, score: number, original: boolean, parser?: cdnHeaderParser); private pushLastPreferedVideoBandwidth; getAvgLastVideoBandwidth(): number; getLastResponse(): responseStorageObject; setLastResponses(responses: responseStorageObject[]): void; addResponse(response: responseStorageObject): void; getAvgResponseTime(): number; getCdnCacheHits(): number; getCdnCacheMisses(): number; private _processCdnCache; private _updateCacheCounts; private _updateCacheCount; private _incrementCacheCount; /** * 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; calculateEffectiveBandwidth(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; setBandwidth(bw: number): void; /** * Returns the the expected bandwidth in bits for the following request, based on previous requests. * @returns {number} Bandwidth in bits */ getBandwidthInBits(): 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; clone(): Cdn; }