Skip to content

Commit

Permalink
Disolve "helper" folder: all of these parts belong into other specifi…
Browse files Browse the repository at this point in the history
…c places
  • Loading branch information
tchakabam committed Apr 26, 2018
1 parent e9c780c commit ec78e24
Show file tree
Hide file tree
Showing 15 changed files with 42 additions and 31 deletions.
2 changes: 1 addition & 1 deletion src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import SubtitleTrackController from './controller/subtitle-track-controller';
import SubtitleStreamController from './controller/subtitle-stream-controller';
import EMEController from './controller/eme-controller';

import { requestMediaKeySystemAccess } from './helper/mediakeys-helper';
import { requestMediaKeySystemAccess } from './utils/mediakeys-helper';

export var hlsDefaultConfig = {
autoStartLoad: true, // used by stream-controller
Expand Down
2 changes: 1 addition & 1 deletion src/controller/abr-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import Event from '../events';
import EventHandler from '../event-handler';
import BufferHelper from '../helper/buffer-helper';
import { BufferHelper } from './buffer-helper';
import { ErrorDetails } from '../errors';
import { logger } from '../utils/logger';
import EwmaBandWidthEstimator from '../utils/ewma-bandwidth-estimator';
Expand Down
6 changes: 3 additions & 3 deletions src/controller/audio-stream-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
*/

import BinarySearch from '../utils/binary-search';
import BufferHelper from '../helper/buffer-helper';
import { BufferHelper } from './buffer-helper';
import Demuxer from '../demux/demuxer';
import Event from '../events';
import * as LevelHelper from '../helper/level-helper';
import * as LevelHelper from './level-helper';
import TimeRanges from '../utils/time-ranges';
import { ErrorTypes, ErrorDetails } from '../errors';
import { logger } from '../utils/logger';
import { findFragWithCC } from '../utils/discontinuities';
import TaskLoop from '../task-loop';
import { FragmentState } from '../helper/fragment-tracker';
import { FragmentState } from './fragment-tracker';
import Fragment from '../loader/fragment';

const State = {
Expand Down
2 changes: 1 addition & 1 deletion src/controller/buffer-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Event from '../events';
import EventHandler from '../event-handler';
import { logger } from '../utils/logger';
import { ErrorTypes, ErrorDetails } from '../errors';
import { getMediaSource } from '../helper/mediasource-helper';
import { getMediaSource } from '../utils/mediasource-helper';

const MediaSource = getMediaSource();

Expand Down
24 changes: 14 additions & 10 deletions src/helper/buffer-helper.js → src/controller/buffer-helper.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
/**
* Buffer Helper utils, providing methods dealing buffer length retrieval
* @module BufferHelper
*
* Providing methods dealing with buffer length retrieval for example.
*
* In general, a helper around HTML5 MediaElement TimeRanges gathered from `buffered` property.
*
* Also @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/buffered
*/

const BufferHelper = {
export class BufferHelper {
/**
* Return true if `media`'s buffered include `position`
* @param {HTMLMediaElement|SourceBuffer} media
* @param {number} position
* @returns {boolean}
*/
isBuffered: function (media, position) {
static isBuffered (media, position) {
try {
if (media) {
let buffered = media.buffered;
Expand All @@ -25,9 +31,9 @@ const BufferHelper = {
// This SourceBuffer has been removed from the parent media source
}
return false;
},
}

bufferInfo: function (media, pos, maxHoleDuration) {
static bufferInfo (media, pos, maxHoleDuration) {
try {
if (media) {
let vbuffered = media.buffered, buffered = [], i;
Expand All @@ -43,9 +49,9 @@ const BufferHelper = {
// This SourceBuffer has been removed from the parent media source
}
return { len: 0, start: pos, end: pos, nextStart: undefined };
},
}

bufferedInfo: function (buffered, pos, maxHoleDuration) {
static bufferedInfo (buffered, pos, maxHoleDuration) {
let buffered2 = [],
// bufferStart and bufferEnd are buffer boundaries around current video position
bufferLen, bufferStart, bufferEnd, bufferStartNext, i;
Expand Down Expand Up @@ -99,6 +105,4 @@ const BufferHelper = {
}
return { len: bufferLen, start: bufferStart, end: bufferEnd, nextStart: bufferStartNext };
}
};

export default BufferHelper;
}
File renamed without changes.
9 changes: 7 additions & 2 deletions src/helper/level-helper.js → src/controller/level-helper.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
/**
* Level Helper class, providing methods dealing with playlist sliding and drift
*/
* @module LevelHelper
*
* Providing methods dealing with playlist sliding and drift
*
* TODO: Create an actual `Level` class/model that deals with all this logic in an object-oriented-manner.
*
* */

import { logger } from '../utils/logger';

Expand Down
6 changes: 3 additions & 3 deletions src/controller/stream-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
*/

import BinarySearch from '../utils/binary-search';
import BufferHelper from '../helper/buffer-helper';
import { BufferHelper } from './buffer-helper';
import Demuxer from '../demux/demuxer';
import Event from '../events';
import { FragmentState } from '../helper/fragment-tracker';
import { FragmentState } from './fragment-tracker';
import Fragment from '../loader/fragment';
import PlaylistLoader from '../loader/playlist-loader';
import * as LevelHelper from '../helper/level-helper';
import * as LevelHelper from './level-helper';
import TimeRanges from '../utils/time-ranges';
import { ErrorTypes, ErrorDetails } from '../errors';
import { logger } from '../utils/logger';
Expand Down
7 changes: 4 additions & 3 deletions src/demux/demuxer.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import EventEmitter from 'events';
import work from 'webworkify-webpack';

import Event from '../events';
import DemuxerInline from '../demux/demuxer-inline';
import { logger } from '../utils/logger';
import { ErrorTypes, ErrorDetails } from '../errors';
import EventEmitter from 'events';
import work from 'webworkify-webpack';
import { getMediaSource } from '../helper/mediasource-helper';
import { getMediaSource } from '../utils/mediasource-helper';

const MediaSource = getMediaSource();

Expand Down
4 changes: 2 additions & 2 deletions src/hls.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import PlaylistLoader from './loader/playlist-loader';
import FragmentLoader from './loader/fragment-loader';
import KeyLoader from './loader/key-loader';

import { FragmentTracker } from './controller/fragment-tracker';
import StreamController from './controller/stream-controller';
import LevelController from './controller/level-controller';
import ID3TrackController from './controller/id3-track-controller';

import { isSupported } from './helper/is-supported';
import { isSupported } from './is-supported';
import { logger, enableLogs } from './utils/logger';
import { hlsDefaultConfig } from './config';
import { FragmentTracker } from './helper/fragment-tracker';

import HlsEvents from './events';
import EventEmitter from 'events';
Expand Down
2 changes: 1 addition & 1 deletion src/helper/is-supported.js → src/is-supported.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getMediaSource } from './mediasource-helper';
import { getMediaSource } from './utils/mediasource-helper';

export function isSupported () {
const mediaSource = getMediaSource();
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const assert = require('assert');
import BufferHelper from '../../../src/helper/buffer-helper';

import BufferHelper from '../../../src/controller/buffer-helper';

function createMockBuffer (buffered) {
return {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import Event from '../../../src/events';

const assert = require('assert');

import Hls from '../../../src/hls';
import { FragmentTracker, FragmentState } from '../../../src/helper/fragment-tracker';
import Event from '../../../src/events';
import { FragmentTracker, FragmentState } from '../../../src/controller/fragment-tracker';
import PlaylistLoader from '../../../src/loader/playlist-loader';

const LevelType = PlaylistLoader.LevelType;

function createMockBuffer (buffered) {
Expand Down

0 comments on commit ec78e24

Please sign in to comment.