Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove default value of 0 for minimumUpdatePeriod #103

Merged
merged 3 commits into from
Sep 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/location.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,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/locations.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,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/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.equal(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.equal(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.equal(toM3u8(input).minimumUpdatePeriod, 2000, 'converts update period to ms');
});

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