Skip to content

Commit

Permalink
feat: expose suggestPresentationDelay if the type is dynamic (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
gkatsev authored Feb 4, 2020
1 parent 6e17074 commit cd27003
Show file tree
Hide file tree
Showing 6 changed files with 1,200 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/parseAttributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,32 @@ export const parsers = {
return parseDuration(value);
},

/**
* Specifies the suggested presentation delay. Format is a
* duration string as specified in ISO 8601
*
* @param {string} value
* value of attribute as a string
* @return {number}
* The duration in seconds
*/
suggestedPresentationDelay(value) {
return parseDuration(value);
},

/**
* specifices the type of mpd. Can be either "static" or "dynamic"
*
* @param {string} value
* value of attribute as a string
*
* @return {string}
* The type as a string
*/
type(value) {
return value;
},

/**
* Specifies the duration of the smallest time shifting buffer for any Representation
* in the MPD. Format is a duration string as specified in ISO 8601
Expand Down
6 changes: 6 additions & 0 deletions src/toM3u8.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ export const toM3u8 = (dashPlaylists, sidxMapping = {}) => {
// grab all master attributes
const {
sourceDuration: duration,
type = 'static',
suggestedPresentationDelay,
minimumUpdatePeriod = 0
} = dashPlaylists[0].attributes;

Expand Down Expand Up @@ -270,6 +272,10 @@ export const toM3u8 = (dashPlaylists, sidxMapping = {}) => {
minimumUpdatePeriod: minimumUpdatePeriod * 1000
};

if (type === 'dynamic') {
master.suggestedPresentationDelay = suggestedPresentationDelay;
}

if (audioPlaylists.length) {
master.mediaGroups.AUDIO.audio = organizeAudioPlaylists(audioPlaylists, sidxMapping);
}
Expand Down
8 changes: 8 additions & 0 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import maatVttSegmentTemplate from './manifests/maat_vtt_segmentTemplate.mpd';
import segmentBaseTemplate from './manifests/segmentBase.mpd';
import segmentListTemplate from './manifests/segmentList.mpd';
import multiperiod from './manifests/multiperiod.mpd';
import multiperiodDynamic from './manifests/multiperiod-dynamic.mpd';
import {
parsedManifest as maatVttSegmentTemplateManifest
} from './manifests/maat_vtt_segmentTemplate.js';
Expand All @@ -18,6 +19,9 @@ import {
import {
parsedManifest as multiperiodManifest
} from './manifests/multiperiod.js';
import {
parsedManifest as multiperiodDynamicManifest
} from './manifests/multiperiod-dynamic.js';

QUnit.module('mpd-parser');

Expand Down Expand Up @@ -45,6 +49,10 @@ QUnit.test('has parse', function(assert) {
name: 'multiperiod',
input: multiperiod,
expected: multiperiodManifest
}, {
name: 'multiperiod_dynamic',
input: multiperiodDynamic,
expected: multiperiodDynamicManifest
}].forEach(({ name, input, expected }) => {
QUnit.test(`${name} test manifest`, function(assert) {
const actual = parse(input);
Expand Down
Loading

0 comments on commit cd27003

Please sign in to comment.