Skip to content

Commit

Permalink
[MSS] restore live delay and buffer settings in case they are modifie…
Browse files Browse the repository at this point in the history
…d by MSS parser for live streams (#3282)
  • Loading branch information
Bertrand Berthelot committed Jun 10, 2020
1 parent f29346d commit 15d87a9
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 9 deletions.
19 changes: 12 additions & 7 deletions src/mss/MssHandler.js
Expand Up @@ -41,16 +41,16 @@ import InitCache from '../streaming/utils/InitCache';
function MssHandler(config) {

config = config || {};
let context = this.context;
let eventBus = config.eventBus;
const context = this.context;
const eventBus = config.eventBus;
const events = config.events;
const constants = config.constants;
const initSegmentType = config.initSegmentType;
let dashMetrics = config.dashMetrics;
let playbackController = config.playbackController;
let streamController = config.streamController;
let protectionController = config.protectionController;
let mssFragmentProcessor = MssFragmentProcessor(context).create({
const dashMetrics = config.dashMetrics;
const playbackController = config.playbackController;
const streamController = config.streamController;
const protectionController = config.protectionController;
const mssFragmentProcessor = MssFragmentProcessor(context).create({
dashMetrics: dashMetrics,
playbackController: playbackController,
protectionController: protectionController,
Expand Down Expand Up @@ -219,6 +219,11 @@ function MssHandler(config) {
}

function reset() {
if (mssParser) {
mssParser.reset();
mssParser = undefined;
}

eventBus.off(events.INIT_FRAGMENT_NEEDED, onInitFragmentNeeded, this);
eventBus.off(events.PLAYBACK_PAUSED, onPlaybackPaused, this);
eventBus.off(events.PLAYBACK_SEEK_ASKED, onPlaybackSeekAsked, this);
Expand Down
24 changes: 22 additions & 2 deletions src/mss/parser/MssParser.js
Expand Up @@ -79,7 +79,8 @@ function MssParser(config) {
};

let instance,
logger;
logger,
initialBufferSettings;


function setup() {
Expand Down Expand Up @@ -722,6 +723,17 @@ function MssParser(config) {
let liveDelay = Math.min(targetDelayCapping, targetLiveDelay);
// Consider a margin of one segment in order to avoid Precondition Failed errors (412), for example if audio and video are not correctly synchronized
let bufferTime = liveDelay - segmentDuration;

// Store initial buffer settings
initialBufferSettings = {
'streaming': {
'liveDelay': settings.get().streaming.liveDelay,
'stableBufferTime': settings.get().streaming.stableBufferTime,
'bufferTimeAtTopQuality': settings.get().streaming.bufferTimeAtTopQuality,
'bufferTimeAtTopQualityLongForm': settings.get().streaming.bufferTimeAtTopQualityLongForm
}
};

settings.update({
'streaming': {
'liveDelay': liveDelay,
Expand Down Expand Up @@ -836,10 +848,18 @@ function MssParser(config) {
return manifest;
}

function reset() {
// Restore initial buffer settings
if (initialBufferSettings) {
settings.update(initialBufferSettings);
}
}

instance = {
parse: internalParse,
getMatchers: getMatchers,
getIron: getIron
getIron: getIron,
reset: reset
};

setup();
Expand Down

0 comments on commit 15d87a9

Please sign in to comment.