Skip to content

Commit

Permalink
refactored fragment tracker
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkim9 committed Dec 11, 2017
1 parent e14c9b0 commit 8393f20
Show file tree
Hide file tree
Showing 4 changed files with 142 additions and 154 deletions.
9 changes: 5 additions & 4 deletions src/controller/audio-stream-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import BufferHelper from '../helper/buffer-helper';
import Demuxer from '../demux/demuxer';
import Event from '../events';
import EventHandler from '../event-handler';
import * as LevelHelper from '../helper/level-helper';import TimeRanges from '../utils/timeRanges';
import * as LevelHelper from '../helper/level-helper';
import TimeRanges from '../utils/timeRanges';
import {ErrorDetails} from '../errors';
import {logger} from '../utils/logger';
import { findFragWithCC } from '../utils/discontinuities';
import {FragmentTrackerState} from '../helper/fragment-tracker';
import {FragmentState} from '../helper/fragment-tracker';

const State = {
STOPPED : 'STOPPED',
Expand Down Expand Up @@ -118,7 +119,7 @@ class AudioStreamController extends EventHandler {
if (frag.loader) {
frag.loader.abort();
}
this.fragmentTracker.cancelFragmentLoad(frag);
this.fragmentTracker.removeFragment(frag);
this.fragCurrent = null;
}
this.fragPrevious = null;
Expand Down Expand Up @@ -340,7 +341,7 @@ class AudioStreamController extends EventHandler {
logger.log(`Loading ${frag.sn}, cc: ${frag.cc} of [${trackDetails.startSN} ,${trackDetails.endSN}],track ${trackId}, currentTime:${pos},bufferEnd:${bufferEnd.toFixed(3)}`);
// Check if fragment is not loaded
let ftState = this.fragmentTracker.getState(frag);
if(ftState === FragmentTrackerState.NOT_LOADED) {
if(ftState === FragmentState.NOT_LOADED) {
this.fragCurrent = frag;
this.startFragRequested = true;
if (!isNaN(frag.sn)) {
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 @@ -7,7 +7,7 @@ import BufferHelper from '../helper/buffer-helper';
import Demuxer from '../demux/demuxer';
import Event from '../events';
import EventHandler from '../event-handler';
import {FragmentTrackerState} from '../helper/fragment-tracker';
import {FragmentState} from '../helper/fragment-tracker';
import * as LevelHelper from '../helper/level-helper';
import TimeRanges from '../utils/timeRanges';
import {ErrorTypes, ErrorDetails} from '../errors';
Expand Down Expand Up @@ -112,7 +112,7 @@ class StreamController extends EventHandler {
if (frag.loader) {
frag.loader.abort();
}
this.fragmentTracker.cancelFragmentLoad(frag);
this.fragmentTracker.removeFragment(frag);
this.fragCurrent = null;
}
this.fragPrevious = null;
Expand Down Expand Up @@ -508,7 +508,7 @@ class StreamController extends EventHandler {
}

// Allow backtracked fragments to load
if(frag.backtracked || ftState === FragmentTrackerState.NOT_LOADED) {
if(frag.backtracked || ftState === FragmentState.NOT_LOADED) {
frag.autoLevel = this.hls.autoLevelEnabled;
frag.bitrateTest = this.bitrateTest;

Expand Down
Loading

0 comments on commit 8393f20

Please sign in to comment.