Skip to content

Commit

Permalink
Subtitle-stream-controller: Load fragments in sync with streaming and…
Browse files Browse the repository at this point in the history
… resolve via PTS/PDT (video-dev#1882)
  • Loading branch information
tchakabam authored and johnBartos committed Nov 26, 2018
1 parent f7a4089 commit b2d0daa
Show file tree
Hide file tree
Showing 9 changed files with 319 additions and 147 deletions.
2 changes: 1 addition & 1 deletion src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import AudioStreamController from './controller/audio-stream-controller';
import * as Cues from './utils/cues';
import TimelineController from './controller/timeline-controller';
import SubtitleTrackController from './controller/subtitle-track-controller';
import SubtitleStreamController from './controller/subtitle-stream-controller';
import { SubtitleStreamController } from './controller/subtitle-stream-controller';
import EMEController from './controller/eme-controller';

import { requestMediaKeySystemAccess } from './utils/mediakeys-helper';
Expand Down
6 changes: 4 additions & 2 deletions src/controller/audio-stream-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ const State = {
WAITING_INIT_PTS: 'WAITING_INIT_PTS'
};

const TICK_INTERVAL = 100; // how often to tick in ms

class AudioStreamController extends TaskLoop {
constructor (hls, fragmentTracker) {
super(hls,
Expand Down Expand Up @@ -95,7 +97,7 @@ class AudioStreamController extends TaskLoop {
if (this.tracks) {
let lastCurrentTime = this.lastCurrentTime;
this.stopLoad();
this.setInterval(100);
this.setInterval(TICK_INTERVAL);
this.fragLoadError = 0;
if (lastCurrentTime > 0 && startPosition === -1) {
logger.log(`audio:override startPosition with lastCurrentTime @${lastCurrentTime.toFixed(3)}`);
Expand Down Expand Up @@ -476,7 +478,7 @@ class AudioStreamController extends TaskLoop {
}
} else {
// switching to audio track, start timer if not already started
this.setInterval(100);
this.setInterval(TICK_INTERVAL);
}

// should we switch tracks ?
Expand Down
4 changes: 3 additions & 1 deletion src/controller/stream-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export const State = {
ERROR: 'ERROR'
};

const TICK_INTERVAL = 100; // how often to tick in ms

class StreamController extends TaskLoop {
constructor (hls, fragmentTracker) {
super(hls,
Expand Down Expand Up @@ -76,7 +78,7 @@ class StreamController extends TaskLoop {
if (this.levels) {
let lastCurrentTime = this.lastCurrentTime, hls = this.hls;
this.stopLoad();
this.setInterval(100);
this.setInterval(TICK_INTERVAL);
this.level = -1;
this.fragLoadError = 0;
if (!this.startFragRequested) {
Expand Down
Loading

0 comments on commit b2d0daa

Please sign in to comment.