From 8aee2ca6b9aa596d3eeee2db46b05a1ad328f934 Mon Sep 17 00:00:00 2001 From: xqq Date: Wed, 26 Oct 2016 11:12:48 +0800 Subject: [PATCH] Remove unused codes --- src/core/media-segment-info.js | 37 ----------------------- src/demux/flv-demuxer.js | 1 - src/utils/bsearch.js | 54 ---------------------------------- 3 files changed, 92 deletions(-) delete mode 100644 src/utils/bsearch.js diff --git a/src/core/media-segment-info.js b/src/core/media-segment-info.js index 89016743..3d353aee 100644 --- a/src/core/media-segment-info.js +++ b/src/core/media-segment-info.js @@ -177,43 +177,6 @@ export class MediaSegmentInfoList { this._list.splice(insertIdx, 0, msi); } - removeSegmentsAfter(originalDts) { - let list = this._list; - if (list.length === 0) { - return; - } - let last = list.length - 1; - let mid = 0; - let lbound = 0; - let ubound = last; - - let idx = 0; - - if (originalDts < list[0].originalBeginDts) { - idx = 0; - lbound = ubound + 1; - } - - while (lbound <= ubound) { - mid = lbound + Math.floor((ubound - lbound) / 2); - if (mid === last) { // no segments need to be remove - return; - } else if (list[mid].lastSample.originalDts < originalDts && originalDts <= list[mid + 1].originalBeginDts) { - idx = mid + 1; - break; - } else if (list[mid].originalBeginDts <= originalDts && originalDts < list[mid].originalEndDts) { - idx = mid; - break; - } else if (originalDts > list[mid].lastSample.originalDts) { - lbound = mid + 1; - } else { - ubound = mid - 1; - } - } - - this._list.splice(idx, this._list.length - idx); - } - getLastSegmentBefore(originalBeginDts) { let idx = this._searchNearestSegmentBefore(originalBeginDts); if (idx >= 0) { diff --git a/src/demux/flv-demuxer.js b/src/demux/flv-demuxer.js index ece2284c..e2f2080d 100644 --- a/src/demux/flv-demuxer.js +++ b/src/demux/flv-demuxer.js @@ -1,6 +1,5 @@ import Log from '../utils/logger.js'; import AMF from './amf-parser.js'; -import BSearch from '../utils/bsearch.js'; import SPSParser from './sps-parser.js'; import DemuxErrors from './demux-errors.js'; import MediaInfo from '../core/media-info.js'; diff --git a/src/utils/bsearch.js b/src/utils/bsearch.js deleted file mode 100644 index 16f605cf..00000000 --- a/src/utils/bsearch.js +++ /dev/null @@ -1,54 +0,0 @@ -class BSearch { - - static search(array, value, compare) { - if (array.length === 0) { - return 0; - } - if (compare(value, array[0]) < 0) { - return 0; - } - if (compare(value, array[array.length - 1]) >= 0) { - return array.length; - } - - let mid = 0; - let low = 0; - let high = array.length; - - while (low < high) { - mid = Math.floor((low + high) / 2); - let cmp = compare(array[mid], value); - if (cmp < 0) { - low = mid + 1; - } else if (cmp > 0) { - high = mid; - } else { - return mid; - } - } - return low; - } - - static insert(array, value, compare) { - if (value == undefined) { - return -1; - } - if (compare == undefined) { - compare = BSearch.less; - } - let idx = BSearch.search(array, value, compare); - array.splice(idx, 0, value); - return idx; - } - - static less(a, b) { - return a - b; - } - - static greater(a, b) { - return b - a; - } - -} - -export default BSearch; \ No newline at end of file