First release

This commit is contained in:
Owen Quinlan 2021-07-02 19:29:34 +10:00
commit fa6c85266e
2339 changed files with 761050 additions and 0 deletions

211
node_modules/mpd-parser/test/toPlaylists.test.js generated vendored Normal file
View file

@ -0,0 +1,211 @@
import {
toPlaylists
} from '../src/toPlaylists';
import QUnit from 'qunit';
QUnit.module('toPlaylists');
QUnit.test('no representations', function(assert) {
assert.deepEqual(toPlaylists([]), []);
});
QUnit.test('pretty simple', function(assert) {
const representations = [{
attributes: { baseUrl: 'http://example.com/', periodIndex: 0, sourceDuration: 2 },
segmentInfo: {
template: { }
}
}];
const playlists = [{
attributes: {
baseUrl: 'http://example.com/',
periodIndex: 0,
sourceDuration: 2,
duration: 2
},
segments: [{
uri: '',
timeline: 0,
duration: 2,
resolvedUri: 'http://example.com/',
map: {
uri: '',
resolvedUri: 'http://example.com/'
},
number: 1
}]
}];
assert.deepEqual(toPlaylists(representations), playlists);
});
QUnit.test('segment base', function(assert) {
const representations = [{
attributes: { baseUrl: 'http://example.com/', periodIndex: 0, sourceDuration: 2 },
segmentInfo: {
base: true
}
}];
const playlists = [{
attributes: {
baseUrl: 'http://example.com/',
periodIndex: 0,
sourceDuration: 2,
duration: 2
},
segments: [{
map: {
resolvedUri: 'http://example.com/',
uri: ''
},
resolvedUri: 'http://example.com/',
uri: 'http://example.com/',
timeline: 0,
duration: 2,
number: 0
}]
}];
assert.deepEqual(toPlaylists(representations), playlists);
});
QUnit.test('segment base with sidx', function(assert) {
const representations = [{
attributes: {
baseUrl: 'http://example.com/',
periodIndex: 0,
sourceDuration: 2,
indexRange: '10-19'
},
segmentInfo: {
base: true
}
}];
const playlists = [{
attributes: {
baseUrl: 'http://example.com/',
periodIndex: 0,
sourceDuration: 2,
duration: 2,
indexRange: '10-19'
},
segments: [],
sidx: {
map: {
resolvedUri: 'http://example.com/',
uri: ''
},
resolvedUri: 'http://example.com/',
uri: 'http://example.com/',
byterange: {
offset: 10,
length: 10
},
timeline: 0,
duration: 2,
number: 0
}
}];
assert.deepEqual(toPlaylists(representations), playlists);
});
QUnit.test('segment list', function(assert) {
const representations = [{
attributes: {
baseUrl: 'http://example.com/',
duration: 10,
sourceDuration: 11,
periodIndex: 0
},
segmentInfo: {
list: {
segmentUrls: [{
media: '1.fmp4'
}, {
media: '2.fmp4'
}]
}
}
}];
const playlists = [{
attributes: {
baseUrl: 'http://example.com/',
duration: 10,
sourceDuration: 11,
segmentUrls: [{
media: '1.fmp4'
}, {
media: '2.fmp4'
}],
periodIndex: 0
},
segments: [{
duration: 10,
map: {
resolvedUri: 'http://example.com/',
uri: ''
},
resolvedUri: 'http://example.com/1.fmp4',
timeline: 0,
uri: '1.fmp4',
number: 1
}, {
duration: 1,
map: {
resolvedUri: 'http://example.com/',
uri: ''
},
resolvedUri: 'http://example.com/2.fmp4',
timeline: 0,
uri: '2.fmp4',
number: 2
}]
}];
assert.deepEqual(toPlaylists(representations), playlists);
});
QUnit.test('presentationTimeOffset', function(assert) {
const representations = [{
attributes: { baseUrl: 'http://example.com/', periodIndex: 0, sourceDuration: 2 },
segmentInfo: {
template: {
presentationTimeOffset: 100,
timescale: 4
}
}
}];
// the presentationTimeOffset output should be the value in the template
// divided by the timescale in the template.
// It should be available on segments
const playlists = [{
attributes: {
baseUrl: 'http://example.com/',
periodIndex: 0,
sourceDuration: 2,
duration: 2,
presentationTimeOffset: 25,
timescale: 4
},
segments: [{
uri: '',
timeline: 0,
duration: 2,
presentationTimeOffset: 25,
resolvedUri: 'http://example.com/',
map: {
uri: '',
resolvedUri: 'http://example.com/'
},
number: 1
}]
}];
assert.deepEqual(toPlaylists(representations), playlists);
});