Skip to content

Commit

Permalink
Fix bandwidth matching
Browse files Browse the repository at this point in the history
  • Loading branch information
birme committed Feb 11, 2021
1 parent 7245cc6 commit a525df1
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 859 deletions.
9 changes: 9 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const m3u8 = require('@eyevinn/m3u8');
const request = require('request');
const url = require('url');

/*
const findNearestBw = (bw, array) => {
// TO BE IMPLEMENTED
const sorted = array.sort((a, b) => b - a);
Expand All @@ -12,6 +13,14 @@ const findNearestBw = (bw, array) => {
}
return sorted[sorted.length - 1];
};
*/

const findNearestBw = (bw, array) => {
const sorted = array.sort((a, b) => b - a);
return sorted.reduce((a, b) => {
return Math.abs(b - bw) < Math.abs(a - bw) ? b : a;
});
}

class HLSSpliceVod {
/**
Expand Down

0 comments on commit a525df1

Please sign in to comment.