Skip to content

Commit

Permalink
remove default value of 0 for minimumUpdatePeriod, update tests, reso…
Browse files Browse the repository at this point in the history
…lve conflicts with location parsing
  • Loading branch information
alex-barstow committed Aug 26, 2020
1 parent f22bb18 commit adca6d9
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 11 deletions.
9 changes: 6 additions & 3 deletions src/toM3u8.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ export const toM3u8 = (dashPlaylists, locations, sidxMapping = {}) => {
sourceDuration: duration,
type = 'static',
suggestedPresentationDelay,
minimumUpdatePeriod = 0
minimumUpdatePeriod
} = dashPlaylists[0].attributes;

const videoOnly = ({ attributes }) =>
Expand All @@ -268,10 +268,13 @@ export const toM3u8 = (dashPlaylists, locations, sidxMapping = {}) => {
},
uri: '',
duration,
playlists: addSegmentInfoFromSidx(videoPlaylists, sidxMapping),
minimumUpdatePeriod: minimumUpdatePeriod * 1000
playlists: addSegmentInfoFromSidx(videoPlaylists, sidxMapping)
};

if (minimumUpdatePeriod >= 0) {
master.minimumUpdatePeriod = minimumUpdatePeriod * 1000;
}

if (locations) {
master.locations = locations;
}
Expand Down
1 change: 0 additions & 1 deletion test/manifests/maat_vtt_segmentTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ export const parsedManifest = {
discontinuityStarts: [],
duration: 6,
endList: true,
minimumUpdatePeriod: 0,
mediaGroups: {
AUDIO: {
audio: {
Expand Down
1 change: 0 additions & 1 deletion test/manifests/multiperiod-dynamic.js
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,5 @@ export const parsedManifest = {
}
}
}],
minimumUpdatePeriod: 0,
suggestedPresentationDelay: 18
};
3 changes: 1 addition & 2 deletions test/manifests/multiperiod.js
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,5 @@ export const parsedManifest = {
pssh: new Uint8Array([181, 235, 45])
}
}
}],
minimumUpdatePeriod: 0
}]
};
1 change: 0 additions & 1 deletion test/manifests/segmentBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ export const parsedManifest = {
discontinuityStarts: [],
duration: 6,
endList: true,
minimumUpdatePeriod: 0,
mediaGroups: {
'AUDIO': {},
'CLOSED-CAPTIONS': {},
Expand Down
1 change: 0 additions & 1 deletion test/manifests/segmentList.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ export const parsedManifest = {
discontinuityStarts: [],
duration: 6,
endList: true,
minimumUpdatePeriod: 0,
mediaGroups: {
'AUDIO': {},
'CLOSED-CAPTIONS': {},
Expand Down
91 changes: 89 additions & 2 deletions test/toM3u8.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ QUnit.test('playlists', function(assert) {
discontinuityStarts: [],
duration: 100,
endList: true,
minimumUpdatePeriod: 0,
mediaGroups: {
AUDIO: {
audio: {
Expand Down Expand Up @@ -317,7 +316,6 @@ QUnit.test('playlists with segments', function(assert) {
discontinuityStarts: [],
duration: 100,
endList: true,
minimumUpdatePeriod: 0,
mediaGroups: {
AUDIO: {
audio: {
Expand Down Expand Up @@ -547,6 +545,95 @@ QUnit.test('playlists with sidx and sidxMapping', function(assert) {
assert.deepEqual(toM3u8(input, null, mapping).playlists, expected);
});

QUnit.test('playlists without minimumUpdatePeriod dont assign default value', function(assert) {
const input = [{
attributes: {
sourceDuration: 100,
id: '1',
width: 800,
height: 600,
codecs: 'foo;bar',
duration: 0,
bandwidth: 10000,
periodIndex: 1,
mimeType: 'video/mp4'
},
segments: [],
sidx: {
byterange: {
offset: 10,
length: 10
},
uri: 'sidx.mp4',
resolvedUri: 'http://example.com/sidx.mp4',
duration: 10
},
uri: 'http://example.com/fmp4.mp4'
}];

assert.deepEqual(toM3u8(input).minimumUpdatePeriod, undefined);
});

QUnit.test('playlists with minimumUpdatePeriod = 0', function(assert) {
const input = [{
attributes: {
sourceDuration: 100,
id: '1',
width: 800,
height: 600,
codecs: 'foo;bar',
duration: 0,
bandwidth: 10000,
periodIndex: 1,
mimeType: 'video/mp4',
minimumUpdatePeriod: 0
},
segments: [],
sidx: {
byterange: {
offset: 10,
length: 10
},
uri: 'sidx.mp4',
resolvedUri: 'http://example.com/sidx.mp4',
duration: 10
},
uri: 'http://example.com/fmp4.mp4'
}];

assert.deepEqual(toM3u8(input).minimumUpdatePeriod, 0);
});

QUnit.test('playlists with integer value for minimumUpdatePeriod', function(assert) {
const input = [{
attributes: {
sourceDuration: 100,
id: '1',
width: 800,
height: 600,
codecs: 'foo;bar',
duration: 0,
bandwidth: 10000,
periodIndex: 1,
mimeType: 'video/mp4',
minimumUpdatePeriod: 2
},
segments: [],
sidx: {
byterange: {
offset: 10,
length: 10
},
uri: 'sidx.mp4',
resolvedUri: 'http://example.com/sidx.mp4',
duration: 10
},
uri: 'http://example.com/fmp4.mp4'
}];

assert.deepEqual(toM3u8(input).minimumUpdatePeriod, 2000, 'converts update period to ms');
});

QUnit.test('no playlists', function(assert) {
assert.deepEqual(toM3u8([]), {});
});
Expand Down

0 comments on commit adca6d9

Please sign in to comment.