active-switching
Version:
NPAW's SDK for CDN Balancing and P2P
44 lines (43 loc) • 1.81 kB
TypeScript
/**
* @class
* @description This class connect to cdn the cdb balancer api and hepls to get data
* @exports CDNSelectorBusinessObject
*/
import { VideoSegment } from '../Storage/VideoSegment';
import Cdn from '../Loaders/Cdn';
export default class CDNSelectorBusinessObject {
private _cdnList;
private _activeSwitching?;
private _bandwidthThreshold;
private _highetsSegmentBandwidth;
constructor(cdnList: Map<string, Cdn>, bandwidthThreshold: number, highetsSegmentBandwidth: number, activeSwitching?: string);
getCDN(segment: VideoSegment): string;
/**
* Using previous requests throughput and active requests count returns a CDN in proportion of their scores.
* Prevents excess of parallel requests to the same CDN.
* @returns {string} CDN name.
* @private
*
*
* Para sacarlo rapido seria, coger los CDN's con el bitrate mas alto que max bitrate de las renditions, y hacer el algoritmo ese que ya teniamos si quieres con los CDN's estos. ( Solo tener en cuenta los bandwidth de descarga de los segmentos del vidoe )
* en caso de que ningun cdn de la talla nos quedariamos solo con el que va más rapido
* sencillo y debería de más o menos funcionar
*
*
*/
private _qualityPriority;
private _getNotUsedCdn;
/**
* Uses always the first CDN of the list until its bandwidth is lower than the defined value, then uses following one as a fallback.
* If no CDNs are valid, it reset the scores and uses the best scored by the API to start again.
* @returns {string} CDN name.
* @private
*/
private _cdnPriority;
/**
* Returns always the CDN with the best score value provided by the API.
* @returns {string} CDN name.
* @private
*/
private _bestScoredCdn;
}