First release
This commit is contained in:
commit
fa6c85266e
2339 changed files with 761050 additions and 0 deletions
201
node_modules/mpd-parser/test/segment/segmentBase.test.js
generated
vendored
Normal file
201
node_modules/mpd-parser/test/segment/segmentBase.test.js
generated
vendored
Normal file
|
@ -0,0 +1,201 @@
|
|||
import QUnit from 'qunit';
|
||||
import {
|
||||
segmentsFromBase,
|
||||
addSidxSegmentsToPlaylist
|
||||
} from '../../src/segment/segmentBase';
|
||||
import errors from '../../src/errors';
|
||||
|
||||
QUnit.module('segmentBase - segmentsFromBase');
|
||||
|
||||
QUnit.test('sets segment to baseUrl', function(assert) {
|
||||
const inputAttributes = {
|
||||
baseUrl: 'http://www.example.com/i.fmp4',
|
||||
initialization: { sourceURL: 'http://www.example.com/init.fmp4' }
|
||||
};
|
||||
|
||||
assert.deepEqual(segmentsFromBase(inputAttributes), [{
|
||||
map: {
|
||||
resolvedUri: 'http://www.example.com/init.fmp4',
|
||||
uri: 'http://www.example.com/init.fmp4'
|
||||
},
|
||||
resolvedUri: 'http://www.example.com/i.fmp4',
|
||||
uri: 'http://www.example.com/i.fmp4',
|
||||
number: 0
|
||||
}]);
|
||||
});
|
||||
|
||||
QUnit.test('sets duration based on sourceDuration', function(assert) {
|
||||
const inputAttributes = {
|
||||
baseUrl: 'http://www.example.com/i.fmp4',
|
||||
initialization: { sourceURL: 'http://www.example.com/init.fmp4' },
|
||||
sourceDuration: 10
|
||||
};
|
||||
|
||||
assert.deepEqual(segmentsFromBase(inputAttributes), [{
|
||||
duration: 10,
|
||||
timeline: 0,
|
||||
map: {
|
||||
resolvedUri: 'http://www.example.com/init.fmp4',
|
||||
uri: 'http://www.example.com/init.fmp4'
|
||||
},
|
||||
resolvedUri: 'http://www.example.com/i.fmp4',
|
||||
uri: 'http://www.example.com/i.fmp4',
|
||||
number: 0
|
||||
}]);
|
||||
});
|
||||
|
||||
// sourceDuration comes from mediaPresentationDuration. The DASH spec defines the type of
|
||||
// mediaPresentationDuration as xs:duration, which follows ISO 8601. It does not need to
|
||||
// be adjusted based on timescale.
|
||||
//
|
||||
// References:
|
||||
// https://www.w3.org/TR/xmlschema-2/#duration
|
||||
// https://en.wikipedia.org/wiki/ISO_8601
|
||||
QUnit.test('sets duration based on sourceDuration and not @timescale', function(assert) {
|
||||
const inputAttributes = {
|
||||
baseUrl: 'http://www.example.com/i.fmp4',
|
||||
initialization: { sourceURL: 'http://www.example.com/init.fmp4' },
|
||||
sourceDuration: 10,
|
||||
timescale: 2
|
||||
};
|
||||
|
||||
assert.deepEqual(segmentsFromBase(inputAttributes), [{
|
||||
duration: 10,
|
||||
timeline: 0,
|
||||
map: {
|
||||
resolvedUri: 'http://www.example.com/init.fmp4',
|
||||
uri: 'http://www.example.com/init.fmp4'
|
||||
},
|
||||
resolvedUri: 'http://www.example.com/i.fmp4',
|
||||
uri: 'http://www.example.com/i.fmp4',
|
||||
number: 0
|
||||
}]);
|
||||
});
|
||||
|
||||
QUnit.test('sets duration based on @duration', function(assert) {
|
||||
const inputAttributes = {
|
||||
duration: 10,
|
||||
sourceDuration: 20,
|
||||
baseUrl: 'http://www.example.com/i.fmp4',
|
||||
initialization: { sourceURL: 'http://www.example.com/init.fmp4' },
|
||||
periodIndex: 0
|
||||
};
|
||||
|
||||
assert.deepEqual(segmentsFromBase(inputAttributes), [{
|
||||
duration: 10,
|
||||
timeline: 0,
|
||||
map: {
|
||||
resolvedUri: 'http://www.example.com/init.fmp4',
|
||||
uri: 'http://www.example.com/init.fmp4'
|
||||
},
|
||||
resolvedUri: 'http://www.example.com/i.fmp4',
|
||||
uri: 'http://www.example.com/i.fmp4',
|
||||
number: 0
|
||||
}]);
|
||||
});
|
||||
|
||||
QUnit.test('sets duration based on @duration and @timescale', function(assert) {
|
||||
const inputAttributes = {
|
||||
duration: 10,
|
||||
sourceDuration: 20,
|
||||
timescale: 5,
|
||||
baseUrl: 'http://www.example.com/i.fmp4',
|
||||
initialization: { sourceURL: 'http://www.example.com/init.fmp4' },
|
||||
periodIndex: 0
|
||||
};
|
||||
|
||||
assert.deepEqual(segmentsFromBase(inputAttributes), [{
|
||||
duration: 2,
|
||||
timeline: 0,
|
||||
map: {
|
||||
resolvedUri: 'http://www.example.com/init.fmp4',
|
||||
uri: 'http://www.example.com/init.fmp4'
|
||||
},
|
||||
resolvedUri: 'http://www.example.com/i.fmp4',
|
||||
uri: 'http://www.example.com/i.fmp4',
|
||||
number: 0
|
||||
}]);
|
||||
});
|
||||
|
||||
QUnit.test('translates ranges in <Initialization> node', function(assert) {
|
||||
const inputAttributes = {
|
||||
duration: 10,
|
||||
sourceDuration: 20,
|
||||
timescale: 5,
|
||||
baseUrl: 'http://www.example.com/i.fmp4',
|
||||
initialization: {
|
||||
sourceURL: 'http://www.example.com/init.fmp4',
|
||||
range: '121-125'
|
||||
},
|
||||
periodIndex: 0
|
||||
};
|
||||
|
||||
assert.deepEqual(segmentsFromBase(inputAttributes), [{
|
||||
duration: 2,
|
||||
timeline: 0,
|
||||
map: {
|
||||
resolvedUri: 'http://www.example.com/init.fmp4',
|
||||
uri: 'http://www.example.com/init.fmp4',
|
||||
byterange: {
|
||||
length: 5,
|
||||
offset: 121
|
||||
}
|
||||
},
|
||||
resolvedUri: 'http://www.example.com/i.fmp4',
|
||||
uri: 'http://www.example.com/i.fmp4',
|
||||
number: 0
|
||||
}]);
|
||||
});
|
||||
|
||||
QUnit.test('errors if no baseUrl exists', function(assert) {
|
||||
assert.throws(() => segmentsFromBase({}), new Error(errors.NO_BASE_URL));
|
||||
});
|
||||
|
||||
QUnit.module('segmentBase - addSidxSegmentsToPlaylist');
|
||||
|
||||
QUnit.test('generates playlist from sidx references', function(assert) {
|
||||
const baseUrl = 'http://www.example.com/i.fmp4';
|
||||
const playlist = {
|
||||
sidx: {
|
||||
map: {
|
||||
byterange: {
|
||||
offset: 0,
|
||||
length: 10
|
||||
}
|
||||
},
|
||||
duration: 10,
|
||||
byterange: {
|
||||
offset: 9,
|
||||
length: 11
|
||||
}
|
||||
},
|
||||
segments: []
|
||||
};
|
||||
const sidx = {
|
||||
timescale: 1,
|
||||
firstOffset: 0,
|
||||
references: [{
|
||||
referenceType: 0,
|
||||
referencedSize: 5,
|
||||
subsegmentDuration: 2
|
||||
}]
|
||||
};
|
||||
|
||||
assert.deepEqual(addSidxSegmentsToPlaylist(playlist, sidx, baseUrl).segments, [{
|
||||
map: {
|
||||
byterange: {
|
||||
offset: 0,
|
||||
length: 10
|
||||
}
|
||||
},
|
||||
uri: 'http://www.example.com/i.fmp4',
|
||||
resolvedUri: 'http://www.example.com/i.fmp4',
|
||||
byterange: {
|
||||
offset: 20,
|
||||
length: 5
|
||||
},
|
||||
duration: 2,
|
||||
timeline: 0,
|
||||
number: 0
|
||||
}]);
|
||||
});
|
553
node_modules/mpd-parser/test/segment/segmentList.test.js
generated
vendored
Normal file
553
node_modules/mpd-parser/test/segment/segmentList.test.js
generated
vendored
Normal file
|
@ -0,0 +1,553 @@
|
|||
import QUnit from 'qunit';
|
||||
import {
|
||||
segmentsFromList
|
||||
} from '../../src/segment/segmentList';
|
||||
import errors from '../../src/errors';
|
||||
|
||||
QUnit.module('segmentList - segmentsFromList');
|
||||
|
||||
QUnit.test('uses segmentTimeline to set segments', function(assert) {
|
||||
const inputAttributes = {
|
||||
segmentUrls: [{
|
||||
media: '1.fmp4'
|
||||
}, {
|
||||
media: '2.fmp4'
|
||||
}, {
|
||||
media: '3.fmp4'
|
||||
}, {
|
||||
media: '4.fmp4'
|
||||
}, {
|
||||
media: '5.fmp4'
|
||||
}],
|
||||
initialization: { sourceURL: 'init.fmp4' },
|
||||
periodIndex: 0,
|
||||
startNumber: 1,
|
||||
baseUrl: 'http://example.com/'
|
||||
};
|
||||
|
||||
const inputTimeline = [{
|
||||
t: 1000,
|
||||
d: 1000,
|
||||
r: 4
|
||||
}];
|
||||
|
||||
assert.deepEqual(segmentsFromList(inputAttributes, inputTimeline), [{
|
||||
duration: 1000,
|
||||
map: {
|
||||
resolvedUri: 'http://example.com/init.fmp4',
|
||||
uri: 'init.fmp4'
|
||||
},
|
||||
resolvedUri: 'http://example.com/1.fmp4',
|
||||
timeline: 0,
|
||||
uri: '1.fmp4',
|
||||
number: 1
|
||||
}, {
|
||||
duration: 1000,
|
||||
map: {
|
||||
resolvedUri: 'http://example.com/init.fmp4',
|
||||
uri: 'init.fmp4'
|
||||
},
|
||||
resolvedUri: 'http://example.com/2.fmp4',
|
||||
timeline: 0,
|
||||
uri: '2.fmp4',
|
||||
number: 2
|
||||
}, {
|
||||
duration: 1000,
|
||||
map: {
|
||||
resolvedUri: 'http://example.com/init.fmp4',
|
||||
uri: 'init.fmp4'
|
||||
},
|
||||
resolvedUri: 'http://example.com/3.fmp4',
|
||||
timeline: 0,
|
||||
uri: '3.fmp4',
|
||||
number: 3
|
||||
}, {
|
||||
duration: 1000,
|
||||
map: {
|
||||
resolvedUri: 'http://example.com/init.fmp4',
|
||||
uri: 'init.fmp4'
|
||||
},
|
||||
resolvedUri: 'http://example.com/4.fmp4',
|
||||
timeline: 0,
|
||||
uri: '4.fmp4',
|
||||
number: 4
|
||||
}, {
|
||||
duration: 1000,
|
||||
map: {
|
||||
resolvedUri: 'http://example.com/init.fmp4',
|
||||
uri: 'init.fmp4'
|
||||
},
|
||||
resolvedUri: 'http://example.com/5.fmp4',
|
||||
timeline: 0,
|
||||
uri: '5.fmp4',
|
||||
number: 5
|
||||
}]);
|
||||
});
|
||||
|
||||
QUnit.test(
|
||||
'truncates if segmentTimeline does not apply for all segments',
|
||||
function(assert) {
|
||||
const inputAttributes = {
|
||||
segmentUrls: [{
|
||||
media: '1.fmp4'
|
||||
}, {
|
||||
media: '2.fmp4'
|
||||
}, {
|
||||
media: '3.fmp4'
|
||||
}, {
|
||||
media: '4.fmp4'
|
||||
}, {
|
||||
media: '5.fmp4'
|
||||
}],
|
||||
initialization: { sourceURL: 'init.fmp4' },
|
||||
periodIndex: 0,
|
||||
startNumber: 1,
|
||||
baseUrl: 'http://example.com/'
|
||||
};
|
||||
|
||||
const inputTimeline = [{
|
||||
t: 1000,
|
||||
d: 1000,
|
||||
r: 1
|
||||
}];
|
||||
|
||||
assert.deepEqual(segmentsFromList(inputAttributes, inputTimeline), [{
|
||||
duration: 1000,
|
||||
map: {
|
||||
resolvedUri: 'http://example.com/init.fmp4',
|
||||
uri: 'init.fmp4'
|
||||
},
|
||||
resolvedUri: 'http://example.com/1.fmp4',
|
||||
timeline: 0,
|
||||
uri: '1.fmp4',
|
||||
number: 1
|
||||
}, {
|
||||
duration: 1000,
|
||||
map: {
|
||||
resolvedUri: 'http://example.com/init.fmp4',
|
||||
uri: 'init.fmp4'
|
||||
},
|
||||
resolvedUri: 'http://example.com/2.fmp4',
|
||||
timeline: 0,
|
||||
uri: '2.fmp4',
|
||||
number: 2
|
||||
}]);
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test(
|
||||
'if segment timeline is too long does not add extra blank segments',
|
||||
function(assert) {
|
||||
const inputAttributes = {
|
||||
segmentUrls: [{
|
||||
media: '1.fmp4'
|
||||
}, {
|
||||
media: '2.fmp4'
|
||||
}, {
|
||||
media: '3.fmp4'
|
||||
}, {
|
||||
media: '4.fmp4'
|
||||
}, {
|
||||
media: '5.fmp4'
|
||||
}],
|
||||
initialization: { sourceURL: 'init.fmp4' },
|
||||
periodIndex: 0,
|
||||
startNumber: 1,
|
||||
baseUrl: 'http://example.com/'
|
||||
};
|
||||
|
||||
const inputTimeline = [{
|
||||
t: 1000,
|
||||
d: 1000,
|
||||
r: 10
|
||||
}];
|
||||
|
||||
assert.deepEqual(segmentsFromList(inputAttributes, inputTimeline), [{
|
||||
duration: 1000,
|
||||
map: {
|
||||
resolvedUri: 'http://example.com/init.fmp4',
|
||||
uri: 'init.fmp4'
|
||||
},
|
||||
resolvedUri: 'http://example.com/1.fmp4',
|
||||
timeline: 0,
|
||||
uri: '1.fmp4',
|
||||
number: 1
|
||||
}, {
|
||||
duration: 1000,
|
||||
map: {
|
||||
resolvedUri: 'http://example.com/init.fmp4',
|
||||
uri: 'init.fmp4'
|
||||
},
|
||||
resolvedUri: 'http://example.com/2.fmp4',
|
||||
timeline: 0,
|
||||
uri: '2.fmp4',
|
||||
number: 2
|
||||
}, {
|
||||
duration: 1000,
|
||||
map: {
|
||||
resolvedUri: 'http://example.com/init.fmp4',
|
||||
uri: 'init.fmp4'
|
||||
},
|
||||
resolvedUri: 'http://example.com/3.fmp4',
|
||||
timeline: 0,
|
||||
uri: '3.fmp4',
|
||||
number: 3
|
||||
}, {
|
||||
duration: 1000,
|
||||
map: {
|
||||
resolvedUri: 'http://example.com/init.fmp4',
|
||||
uri: 'init.fmp4'
|
||||
},
|
||||
resolvedUri: 'http://example.com/4.fmp4',
|
||||
timeline: 0,
|
||||
uri: '4.fmp4',
|
||||
number: 4
|
||||
}, {
|
||||
duration: 1000,
|
||||
map: {
|
||||
resolvedUri: 'http://example.com/init.fmp4',
|
||||
uri: 'init.fmp4'
|
||||
},
|
||||
resolvedUri: 'http://example.com/5.fmp4',
|
||||
timeline: 0,
|
||||
uri: '5.fmp4',
|
||||
number: 5
|
||||
}]);
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test('uses duration to set segments', function(assert) {
|
||||
const inputAttributes = {
|
||||
segmentUrls: [{
|
||||
media: '1.fmp4'
|
||||
}, {
|
||||
media: '2.fmp4'
|
||||
}, {
|
||||
media: '3.fmp4'
|
||||
}, {
|
||||
media: '4.fmp4'
|
||||
}, {
|
||||
media: '5.fmp4'
|
||||
}],
|
||||
initialization: { sourceURL: 'init.fmp4' },
|
||||
duration: 10,
|
||||
periodIndex: 0,
|
||||
startNumber: 1,
|
||||
sourceDuration: 50,
|
||||
baseUrl: 'http://example.com/'
|
||||
};
|
||||
|
||||
assert.deepEqual(segmentsFromList(inputAttributes), [{
|
||||
duration: 10,
|
||||
map: {
|
||||
resolvedUri: 'http://example.com/init.fmp4',
|
||||
uri: 'init.fmp4'
|
||||
},
|
||||
resolvedUri: 'http://example.com/1.fmp4',
|
||||
timeline: 0,
|
||||
uri: '1.fmp4',
|
||||
number: 1
|
||||
}, {
|
||||
duration: 10,
|
||||
map: {
|
||||
resolvedUri: 'http://example.com/init.fmp4',
|
||||
uri: 'init.fmp4'
|
||||
},
|
||||
resolvedUri: 'http://example.com/2.fmp4',
|
||||
timeline: 0,
|
||||
uri: '2.fmp4',
|
||||
number: 2
|
||||
}, {
|
||||
duration: 10,
|
||||
map: {
|
||||
resolvedUri: 'http://example.com/init.fmp4',
|
||||
uri: 'init.fmp4'
|
||||
},
|
||||
resolvedUri: 'http://example.com/3.fmp4',
|
||||
timeline: 0,
|
||||
uri: '3.fmp4',
|
||||
number: 3
|
||||
}, {
|
||||
duration: 10,
|
||||
map: {
|
||||
resolvedUri: 'http://example.com/init.fmp4',
|
||||
uri: 'init.fmp4'
|
||||
},
|
||||
resolvedUri: 'http://example.com/4.fmp4',
|
||||
timeline: 0,
|
||||
uri: '4.fmp4',
|
||||
number: 4
|
||||
}, {
|
||||
duration: 10,
|
||||
map: {
|
||||
resolvedUri: 'http://example.com/init.fmp4',
|
||||
uri: 'init.fmp4'
|
||||
},
|
||||
resolvedUri: 'http://example.com/5.fmp4',
|
||||
timeline: 0,
|
||||
uri: '5.fmp4',
|
||||
number: 5
|
||||
}]);
|
||||
});
|
||||
|
||||
QUnit.test('uses timescale to set segment duration', function(assert) {
|
||||
const inputAttributes = {
|
||||
segmentUrls: [{
|
||||
media: '1.fmp4'
|
||||
}, {
|
||||
media: '2.fmp4'
|
||||
}, {
|
||||
media: '3.fmp4'
|
||||
}, {
|
||||
media: '4.fmp4'
|
||||
}, {
|
||||
media: '5.fmp4'
|
||||
}],
|
||||
initialization: { sourceURL: 'init.fmp4' },
|
||||
duration: 10,
|
||||
timescale: 2,
|
||||
periodIndex: 0,
|
||||
startNumber: 1,
|
||||
sourceDuration: 25,
|
||||
baseUrl: 'http://example.com/'
|
||||
};
|
||||
|
||||
assert.deepEqual(segmentsFromList(inputAttributes), [{
|
||||
duration: 5,
|
||||
map: {
|
||||
resolvedUri: 'http://example.com/init.fmp4',
|
||||
uri: 'init.fmp4'
|
||||
},
|
||||
resolvedUri: 'http://example.com/1.fmp4',
|
||||
timeline: 0,
|
||||
uri: '1.fmp4',
|
||||
number: 1
|
||||
}, {
|
||||
duration: 5,
|
||||
map: {
|
||||
resolvedUri: 'http://example.com/init.fmp4',
|
||||
uri: 'init.fmp4'
|
||||
},
|
||||
resolvedUri: 'http://example.com/2.fmp4',
|
||||
timeline: 0,
|
||||
uri: '2.fmp4',
|
||||
number: 2
|
||||
}, {
|
||||
duration: 5,
|
||||
map: {
|
||||
resolvedUri: 'http://example.com/init.fmp4',
|
||||
uri: 'init.fmp4'
|
||||
},
|
||||
resolvedUri: 'http://example.com/3.fmp4',
|
||||
timeline: 0,
|
||||
uri: '3.fmp4',
|
||||
number: 3
|
||||
}, {
|
||||
duration: 5,
|
||||
map: {
|
||||
resolvedUri: 'http://example.com/init.fmp4',
|
||||
uri: 'init.fmp4'
|
||||
},
|
||||
resolvedUri: 'http://example.com/4.fmp4',
|
||||
timeline: 0,
|
||||
uri: '4.fmp4',
|
||||
number: 4
|
||||
}, {
|
||||
duration: 5,
|
||||
map: {
|
||||
resolvedUri: 'http://example.com/init.fmp4',
|
||||
uri: 'init.fmp4'
|
||||
},
|
||||
resolvedUri: 'http://example.com/5.fmp4',
|
||||
timeline: 0,
|
||||
uri: '5.fmp4',
|
||||
number: 5
|
||||
}]);
|
||||
});
|
||||
|
||||
QUnit.test('timescale sets duration of last segment correctly', function(assert) {
|
||||
const inputAttributes = {
|
||||
segmentUrls: [{
|
||||
media: '1.fmp4'
|
||||
}, {
|
||||
media: '2.fmp4'
|
||||
}],
|
||||
initialization: { sourceURL: 'init.fmp4' },
|
||||
duration: 10,
|
||||
timescale: 1,
|
||||
periodIndex: 0,
|
||||
startNumber: 1,
|
||||
sourceDuration: 15,
|
||||
baseUrl: 'http://example.com/'
|
||||
};
|
||||
|
||||
assert.deepEqual(segmentsFromList(inputAttributes), [{
|
||||
duration: 10,
|
||||
map: {
|
||||
resolvedUri: 'http://example.com/init.fmp4',
|
||||
uri: 'init.fmp4'
|
||||
},
|
||||
resolvedUri: 'http://example.com/1.fmp4',
|
||||
timeline: 0,
|
||||
uri: '1.fmp4',
|
||||
number: 1
|
||||
}, {
|
||||
duration: 5,
|
||||
map: {
|
||||
resolvedUri: 'http://example.com/init.fmp4',
|
||||
uri: 'init.fmp4'
|
||||
},
|
||||
resolvedUri: 'http://example.com/2.fmp4',
|
||||
timeline: 0,
|
||||
uri: '2.fmp4',
|
||||
number: 2
|
||||
}]);
|
||||
});
|
||||
|
||||
QUnit.test('segmentUrl translates ranges correctly', function(assert) {
|
||||
const inputAttributes = {
|
||||
segmentUrls: [{
|
||||
media: '1.fmp4',
|
||||
mediaRange: '0-200'
|
||||
}, {
|
||||
media: '1.fmp4',
|
||||
mediaRange: '201-400'
|
||||
}],
|
||||
initialization: { sourceURL: 'init.fmp4' },
|
||||
duration: 10,
|
||||
timescale: 1,
|
||||
periodIndex: 0,
|
||||
startNumber: 1,
|
||||
sourceDuration: 20,
|
||||
baseUrl: 'http://example.com/'
|
||||
};
|
||||
|
||||
assert.deepEqual(segmentsFromList(inputAttributes), [{
|
||||
duration: 10,
|
||||
map: {
|
||||
resolvedUri: 'http://example.com/init.fmp4',
|
||||
uri: 'init.fmp4'
|
||||
},
|
||||
byterange: {
|
||||
length: 201,
|
||||
offset: 0
|
||||
},
|
||||
resolvedUri: 'http://example.com/1.fmp4',
|
||||
timeline: 0,
|
||||
uri: '1.fmp4',
|
||||
number: 1
|
||||
}, {
|
||||
duration: 10,
|
||||
byterange: {
|
||||
length: 200,
|
||||
offset: 201
|
||||
},
|
||||
map: {
|
||||
resolvedUri: 'http://example.com/init.fmp4',
|
||||
uri: 'init.fmp4'
|
||||
},
|
||||
resolvedUri: 'http://example.com/1.fmp4',
|
||||
timeline: 0,
|
||||
uri: '1.fmp4',
|
||||
number: 2
|
||||
}]);
|
||||
});
|
||||
|
||||
QUnit.test(
|
||||
'throws error if more than 1 segment and no duration or timeline',
|
||||
function(assert) {
|
||||
const inputAttributes = {
|
||||
segmentUrls: [{
|
||||
media: '1.fmp4'
|
||||
}, {
|
||||
media: '2.fmp4'
|
||||
}],
|
||||
duration: 10,
|
||||
initialization: { sourceURL: 'init.fmp4' },
|
||||
timescale: 1,
|
||||
periodIndex: 0,
|
||||
startNumber: 1,
|
||||
sourceDuration: 20,
|
||||
baseUrl: 'http://example.com/'
|
||||
};
|
||||
|
||||
const inputTimeline = [{
|
||||
t: 1000,
|
||||
d: 1000,
|
||||
r: 4
|
||||
}];
|
||||
|
||||
assert.throws(
|
||||
() => segmentsFromList(inputAttributes, inputTimeline),
|
||||
new Error(errors.SEGMENT_TIME_UNSPECIFIED)
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test('throws error if timeline and duration are both defined', function(assert) {
|
||||
const inputAttributes = {
|
||||
segmentUrls: [{
|
||||
media: '1.fmp4'
|
||||
}, {
|
||||
media: '2.fmp4'
|
||||
}],
|
||||
initialization: { sourceURL: 'init.fmp4' },
|
||||
timescale: 1,
|
||||
periodIndex: 0,
|
||||
startNumber: 1,
|
||||
sourceDuration: 20,
|
||||
baseUrl: 'http://example.com/'
|
||||
};
|
||||
|
||||
assert.throws(
|
||||
() => segmentsFromList(inputAttributes),
|
||||
new Error(errors.SEGMENT_TIME_UNSPECIFIED)
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test('translates ranges in <Initialization> node', function(assert) {
|
||||
const inputAttributes = {
|
||||
segmentUrls: [{
|
||||
media: '1.fmp4'
|
||||
}, {
|
||||
media: '1.fmp4'
|
||||
}],
|
||||
initialization: { sourceURL: 'init.fmp4', range: '121-125' },
|
||||
duration: 10,
|
||||
timescale: 1,
|
||||
periodIndex: 0,
|
||||
startNumber: 1,
|
||||
sourceDuration: 20,
|
||||
baseUrl: 'http://example.com/'
|
||||
};
|
||||
|
||||
assert.deepEqual(segmentsFromList(inputAttributes), [{
|
||||
duration: 10,
|
||||
map: {
|
||||
resolvedUri: 'http://example.com/init.fmp4',
|
||||
uri: 'init.fmp4',
|
||||
byterange: {
|
||||
length: 5,
|
||||
offset: 121
|
||||
}
|
||||
},
|
||||
resolvedUri: 'http://example.com/1.fmp4',
|
||||
timeline: 0,
|
||||
uri: '1.fmp4',
|
||||
number: 1
|
||||
}, {
|
||||
duration: 10,
|
||||
map: {
|
||||
resolvedUri: 'http://example.com/init.fmp4',
|
||||
uri: 'init.fmp4',
|
||||
byterange: {
|
||||
length: 5,
|
||||
offset: 121
|
||||
}
|
||||
},
|
||||
resolvedUri: 'http://example.com/1.fmp4',
|
||||
timeline: 0,
|
||||
uri: '1.fmp4',
|
||||
number: 2
|
||||
}]);
|
||||
});
|
1482
node_modules/mpd-parser/test/segment/segmentTemplate.test.js
generated
vendored
Normal file
1482
node_modules/mpd-parser/test/segment/segmentTemplate.test.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
94
node_modules/mpd-parser/test/segment/urlType.test.js
generated
vendored
Normal file
94
node_modules/mpd-parser/test/segment/urlType.test.js
generated
vendored
Normal file
|
@ -0,0 +1,94 @@
|
|||
import QUnit from 'qunit';
|
||||
import {
|
||||
urlTypeToSegment as urlTypeConverter,
|
||||
byteRangeToString
|
||||
} from '../../src/segment/urlType';
|
||||
|
||||
QUnit.module('urlType - urlTypeConverter');
|
||||
|
||||
QUnit.test('returns correct object if given baseUrl only', function(assert) {
|
||||
assert.deepEqual(urlTypeConverter({ baseUrl: 'http://example.com/' }), {
|
||||
resolvedUri: 'http://example.com/',
|
||||
uri: ''
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.test('returns correct object if given baseUrl and source', function(assert) {
|
||||
assert.deepEqual(urlTypeConverter({
|
||||
baseUrl: 'http://example.com',
|
||||
source: 'init.fmp4'
|
||||
}), {
|
||||
resolvedUri: 'http://example.com/init.fmp4',
|
||||
uri: 'init.fmp4'
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.test('returns correct object if given baseUrl, source and range', function(assert) {
|
||||
assert.deepEqual(urlTypeConverter({
|
||||
baseUrl: 'http://example.com',
|
||||
source: 'init.fmp4',
|
||||
range: '101-105'
|
||||
}), {
|
||||
resolvedUri: 'http://example.com/init.fmp4',
|
||||
uri: 'init.fmp4',
|
||||
byterange: {
|
||||
offset: 101,
|
||||
length: 5
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.test('returns correct object if given baseUrl, source and indexRange', function(assert) {
|
||||
assert.deepEqual(urlTypeConverter({
|
||||
baseUrl: 'http://example.com',
|
||||
source: 'sidx.fmp4',
|
||||
indexRange: '101-105'
|
||||
}), {
|
||||
resolvedUri: 'http://example.com/sidx.fmp4',
|
||||
uri: 'sidx.fmp4',
|
||||
byterange: {
|
||||
offset: 101,
|
||||
length: 5
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.test('returns correct object if given baseUrl and range', function(assert) {
|
||||
assert.deepEqual(urlTypeConverter({
|
||||
baseUrl: 'http://example.com/',
|
||||
range: '101-105'
|
||||
}), {
|
||||
resolvedUri: 'http://example.com/',
|
||||
uri: '',
|
||||
byterange: {
|
||||
offset: 101,
|
||||
length: 5
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.test('returns correct object if given baseUrl and indexRange', function(assert) {
|
||||
assert.deepEqual(urlTypeConverter({
|
||||
baseUrl: 'http://example.com/',
|
||||
indexRange: '101-105'
|
||||
}), {
|
||||
resolvedUri: 'http://example.com/',
|
||||
uri: '',
|
||||
byterange: {
|
||||
offset: 101,
|
||||
length: 5
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.module('urlType - byteRangeToString');
|
||||
|
||||
QUnit.test('returns correct string representing byterange object', function(assert) {
|
||||
assert.strictEqual(
|
||||
byteRangeToString({
|
||||
offset: 0,
|
||||
length: 100
|
||||
}),
|
||||
'0-99'
|
||||
);
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue