mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-05 02:39:46 +02:00
This commit is contained in:
parent
746e163d01
commit
1c7ea28b46
808 changed files with 316395 additions and 381162 deletions
285
node_modules/mpd-parser/test/inheritAttributes.test.js
generated
vendored
285
node_modules/mpd-parser/test/inheritAttributes.test.js
generated
vendored
|
@ -3,13 +3,15 @@ import {
|
|||
buildBaseUrls,
|
||||
parseCaptionServiceMetadata,
|
||||
getSegmentInformation,
|
||||
getPeriodStart
|
||||
getPeriodStart,
|
||||
toEventStream
|
||||
} from '../src/inheritAttributes';
|
||||
import { stringToMpdXml } from '../src/stringToMpdXml';
|
||||
import errors from '../src/errors';
|
||||
import QUnit from 'qunit';
|
||||
import { toPlaylists } from '../src/toPlaylists';
|
||||
import decodeB64ToUint8Array from '@videojs/vhs-utils/es/decode-b64-to-uint8-array';
|
||||
import { findChildren } from '../src/utils/xml';
|
||||
|
||||
QUnit.module('buildBaseUrls');
|
||||
|
||||
|
@ -544,6 +546,7 @@ QUnit.test('end to end - basic', function(assert) {
|
|||
`), { NOW });
|
||||
|
||||
const expected = {
|
||||
eventStream: [],
|
||||
locations: undefined,
|
||||
representationInfo: [{
|
||||
attributes: {
|
||||
|
@ -618,6 +621,7 @@ QUnit.test('end to end - basic dynamic', function(assert) {
|
|||
`), { NOW });
|
||||
|
||||
const expected = {
|
||||
eventStream: [],
|
||||
locations: undefined,
|
||||
representationInfo: [{
|
||||
attributes: {
|
||||
|
@ -699,6 +703,7 @@ QUnit.test('end to end - basic multiperiod', function(assert) {
|
|||
`), { NOW });
|
||||
|
||||
const expected = {
|
||||
eventStream: [],
|
||||
locations: undefined,
|
||||
representationInfo: [{
|
||||
attributes: {
|
||||
|
@ -785,6 +790,7 @@ QUnit.test('end to end - inherits BaseURL from all levels', function(assert) {
|
|||
`), { NOW });
|
||||
|
||||
const expected = {
|
||||
eventStream: [],
|
||||
locations: undefined,
|
||||
representationInfo: [{
|
||||
attributes: {
|
||||
|
@ -861,6 +867,7 @@ QUnit.test('end to end - alternate BaseURLs', function(assert) {
|
|||
`), { NOW });
|
||||
|
||||
const expected = {
|
||||
eventStream: [],
|
||||
locations: undefined,
|
||||
representationInfo: [{
|
||||
attributes: {
|
||||
|
@ -1028,6 +1035,7 @@ QUnit.test(
|
|||
`), { NOW });
|
||||
|
||||
const expected = {
|
||||
eventStream: [],
|
||||
locations: undefined,
|
||||
representationInfo: [{
|
||||
attributes: {
|
||||
|
@ -1140,6 +1148,7 @@ QUnit.test(
|
|||
`), { NOW });
|
||||
|
||||
const expected = {
|
||||
eventStream: [],
|
||||
locations: undefined,
|
||||
representationInfo: [{
|
||||
attributes: {
|
||||
|
@ -1263,6 +1272,7 @@ QUnit.test(
|
|||
`), { NOW });
|
||||
|
||||
const expected = {
|
||||
eventStream: [],
|
||||
locations: undefined,
|
||||
representationInfo: [{
|
||||
attributes: {
|
||||
|
@ -2106,6 +2116,7 @@ QUnit.test('keySystem info for representation - lowercase UUIDs', function(asser
|
|||
|
||||
// inconsistent quoting because of quote-props
|
||||
const expected = {
|
||||
eventStream: [],
|
||||
locations: undefined,
|
||||
representationInfo: [{
|
||||
attributes: {
|
||||
|
@ -2192,6 +2203,7 @@ QUnit.test('keySystem info for representation - uppercase UUIDs', function(asser
|
|||
|
||||
// inconsistent quoting because of quote-props
|
||||
const expected = {
|
||||
eventStream: [],
|
||||
locations: undefined,
|
||||
representationInfo: [{
|
||||
attributes: {
|
||||
|
@ -2238,3 +2250,274 @@ QUnit.test('keySystem info for representation - uppercase UUIDs', function(asser
|
|||
assert.equal(actual.representationInfo.length, 1);
|
||||
assert.deepEqual(actual, expected);
|
||||
});
|
||||
|
||||
QUnit.test('gets EventStream data from toEventStream', function(assert) {
|
||||
const mpd = stringToMpdXml(`
|
||||
<MPD mediaPresentationDuration="PT30S" xmlns:cenc="urn:mpeg:cenc:2013">
|
||||
<Period id="dai_pod-0001065804-ad-1" start="PT17738H17M14.156S" duration="PT9.977S">
|
||||
<BaseURL>https://www.example.com/base/</BaseURL>
|
||||
<SegmentTemplate media="$RepresentationID$/$Number$.mp4" initialization="$RepresentationID$/init.mp4"/>
|
||||
<EventStream schemeIdUri="urn:google:dai:2018" timescale="1000" contentEncoding="foo" presentationTimeOffset="1">
|
||||
<Event presentationTime="100" duration="0" id="0" messageData="foo"/>
|
||||
<Event presentationTime="900" duration="0" id="5" messageData="bar"/>
|
||||
<Event presentationTime="1900" duration="0" id="6" messageData="foo_bar"/>
|
||||
</EventStream>
|
||||
</Period>
|
||||
</MPD>`);
|
||||
const expected = [
|
||||
{
|
||||
end: 2.1,
|
||||
id: '0',
|
||||
messageData: 'foo',
|
||||
schemeIdUri: 'urn:google:dai:2018',
|
||||
start: 2.1,
|
||||
value: undefined,
|
||||
contentEncoding: 'foo',
|
||||
presentationTimeOffset: 1
|
||||
|
||||
},
|
||||
{
|
||||
end: 2.9,
|
||||
id: '5',
|
||||
messageData: 'bar',
|
||||
schemeIdUri: 'urn:google:dai:2018',
|
||||
start: 2.9,
|
||||
value: undefined,
|
||||
contentEncoding: 'foo',
|
||||
presentationTimeOffset: 1
|
||||
},
|
||||
{
|
||||
end: 3.9,
|
||||
id: '6',
|
||||
messageData: 'foo_bar',
|
||||
schemeIdUri: 'urn:google:dai:2018',
|
||||
start: 3.9,
|
||||
value: undefined,
|
||||
contentEncoding: 'foo',
|
||||
presentationTimeOffset: 1
|
||||
}
|
||||
];
|
||||
|
||||
const firstPeriod = { node: findChildren(mpd, 'Period')[0], attributes: { start: 2 } };
|
||||
const eventStreams = toEventStream(firstPeriod);
|
||||
|
||||
assert.deepEqual(eventStreams, expected, 'toEventStream returns the expected object');
|
||||
});
|
||||
|
||||
QUnit.test('can get EventStream data from toEventStream with no schemeIdUri', function(assert) {
|
||||
const mpd = stringToMpdXml(`
|
||||
<MPD mediaPresentationDuration="PT30S" xmlns:cenc="urn:mpeg:cenc:2013">
|
||||
<Period id="dai_pod-0001065804-ad-1" start="PT17738H17M14.156S" duration="PT9.977S">
|
||||
<BaseURL>https://www.example.com/base/</BaseURL>
|
||||
<SegmentTemplate media="$RepresentationID$/$Number$.mp4" initialization="$RepresentationID$/init.mp4"/>
|
||||
<EventStream timescale="1000">
|
||||
<Event presentationTime="100" duration="0" id="0" messageData="foo"/>
|
||||
<Event presentationTime="900" duration="0" id="5" messageData="bar"/>
|
||||
<Event presentationTime="1900" duration="0" id="6" messageData="foo_bar"/>
|
||||
</EventStream>
|
||||
</Period>
|
||||
</MPD>`);
|
||||
|
||||
const expected = [
|
||||
{
|
||||
end: 2.1,
|
||||
id: '0',
|
||||
messageData: 'foo',
|
||||
schemeIdUri: undefined,
|
||||
start: 2.1,
|
||||
value: undefined,
|
||||
contentEncoding: undefined,
|
||||
presentationTimeOffset: 0
|
||||
|
||||
},
|
||||
{
|
||||
end: 2.9,
|
||||
id: '5',
|
||||
messageData: 'bar',
|
||||
schemeIdUri: undefined,
|
||||
start: 2.9,
|
||||
value: undefined,
|
||||
contentEncoding: undefined,
|
||||
presentationTimeOffset: 0
|
||||
},
|
||||
{
|
||||
end: 3.9,
|
||||
id: '6',
|
||||
messageData: 'foo_bar',
|
||||
schemeIdUri: undefined,
|
||||
start: 3.9,
|
||||
value: undefined,
|
||||
contentEncoding: undefined,
|
||||
presentationTimeOffset: 0
|
||||
}
|
||||
];
|
||||
|
||||
const firstPeriod = { node: findChildren(mpd, 'Period')[0], attributes: { start: 2} };
|
||||
const eventStreams = toEventStream(firstPeriod);
|
||||
|
||||
assert.deepEqual(eventStreams, expected, 'toEventStream returns the expected object');
|
||||
});
|
||||
|
||||
QUnit.test('gets eventStream from inheritAttributes', function(assert) {
|
||||
const mpd = stringToMpdXml(`
|
||||
<MPD mediaPresentationDuration="PT30S" xmlns:cenc="urn:mpeg:cenc:2013">
|
||||
<Period id="dai_pod-0001065804-ad-1" start="PT0H0M14.9S" duration="PT9.977S">
|
||||
<BaseURL>https://www.example.com/base/</BaseURL>
|
||||
<SegmentTemplate media="$RepresentationID$/$Number$.mp4" initialization="$RepresentationID$/init.mp4"/>
|
||||
<EventStream schemeIdUri="urn:google:dai:2018" timescale="1000" value="foo">
|
||||
<Event presentationTime="100" duration="0" id="0" messageData="foo"/>
|
||||
<Event presentationTime="1100" duration="0" id="5" messageData="bar"/>
|
||||
<Event presentationTime="2100" duration="0" id="6" messageData="foo_bar"/>
|
||||
</EventStream>
|
||||
</Period>
|
||||
</MPD>`);
|
||||
const expected = {
|
||||
eventStream: [
|
||||
{
|
||||
end: 15,
|
||||
id: '0',
|
||||
messageData: 'foo',
|
||||
schemeIdUri: 'urn:google:dai:2018',
|
||||
start: 15,
|
||||
value: 'foo',
|
||||
contentEncoding: undefined,
|
||||
presentationTimeOffset: 0
|
||||
},
|
||||
{
|
||||
end: 16,
|
||||
id: '5',
|
||||
messageData: 'bar',
|
||||
schemeIdUri: 'urn:google:dai:2018',
|
||||
start: 16,
|
||||
value: 'foo',
|
||||
contentEncoding: undefined,
|
||||
presentationTimeOffset: 0
|
||||
},
|
||||
{
|
||||
end: 17,
|
||||
id: '6',
|
||||
messageData: 'foo_bar',
|
||||
schemeIdUri: 'urn:google:dai:2018',
|
||||
start: 17,
|
||||
value: 'foo',
|
||||
contentEncoding: undefined,
|
||||
presentationTimeOffset: 0
|
||||
}
|
||||
],
|
||||
locations: undefined,
|
||||
representationInfo: []
|
||||
};
|
||||
|
||||
const eventStreams = inheritAttributes(mpd);
|
||||
|
||||
assert.deepEqual(eventStreams, expected, 'inheritAttributes returns the expected object');
|
||||
});
|
||||
|
||||
QUnit.test('can get EventStream data from toEventStream with data in Event tags', function(assert) {
|
||||
const mpd = stringToMpdXml(`
|
||||
<MPD mediaPresentationDuration="PT30S" xmlns:cenc="urn:mpeg:cenc:2013">
|
||||
<Period id="dai_pod-0001065804-ad-1" start="PT17738H17M14.156S" duration="PT9.977S">
|
||||
<BaseURL>https://www.example.com/base/</BaseURL>
|
||||
<SegmentTemplate media="$RepresentationID$/$Number$.mp4" initialization="$RepresentationID$/init.mp4"/>
|
||||
<EventStream timescale="1000">
|
||||
<Event presentationTime="100" duration="0" id="0">foo</Event>
|
||||
<Event presentationTime="900" duration="0" id="5">bar</Event>
|
||||
<Event presentationTime="1900" duration="0" id="6">foo_bar</Event>
|
||||
</EventStream>
|
||||
</Period>
|
||||
</MPD>`);
|
||||
|
||||
const expected = [
|
||||
{
|
||||
end: 2.1,
|
||||
id: '0',
|
||||
messageData: 'foo',
|
||||
schemeIdUri: undefined,
|
||||
start: 2.1,
|
||||
value: undefined,
|
||||
contentEncoding: undefined,
|
||||
presentationTimeOffset: 0
|
||||
|
||||
},
|
||||
{
|
||||
end: 2.9,
|
||||
id: '5',
|
||||
messageData: 'bar',
|
||||
schemeIdUri: undefined,
|
||||
start: 2.9,
|
||||
value: undefined,
|
||||
contentEncoding: undefined,
|
||||
presentationTimeOffset: 0
|
||||
},
|
||||
{
|
||||
end: 3.9,
|
||||
id: '6',
|
||||
messageData: 'foo_bar',
|
||||
schemeIdUri: undefined,
|
||||
start: 3.9,
|
||||
value: undefined,
|
||||
contentEncoding: undefined,
|
||||
presentationTimeOffset: 0
|
||||
}
|
||||
];
|
||||
|
||||
const firstPeriod = { node: findChildren(mpd, 'Period')[0], attributes: { start: 2} };
|
||||
const eventStreams = toEventStream(firstPeriod);
|
||||
|
||||
assert.deepEqual(eventStreams, expected, 'toEventStream returns the expected object');
|
||||
});
|
||||
|
||||
QUnit.test('gets eventStream from inheritAttributes with data in Event tags', function(assert) {
|
||||
const mpd = stringToMpdXml(`
|
||||
<MPD mediaPresentationDuration="PT30S" xmlns:cenc="urn:mpeg:cenc:2013">
|
||||
<Period id="dai_pod-0001065804-ad-1" start="PT0H0M14.9S" duration="PT9.977S">
|
||||
<BaseURL>https://www.example.com/base/</BaseURL>
|
||||
<SegmentTemplate media="$RepresentationID$/$Number$.mp4" initialization="$RepresentationID$/init.mp4"/>
|
||||
<EventStream schemeIdUri="urn:google:dai:2018" timescale="1000" value="foo">
|
||||
<Event presentationTime="100" duration="0" id="0">foo</Event>
|
||||
<Event presentationTime="1100" duration="0" id="5">bar</Event>
|
||||
<Event presentationTime="2100" duration="0" id="6">foo_bar</Event>
|
||||
</EventStream>
|
||||
</Period>
|
||||
</MPD>`);
|
||||
const expected = {
|
||||
eventStream: [
|
||||
{
|
||||
end: 15,
|
||||
id: '0',
|
||||
messageData: 'foo',
|
||||
schemeIdUri: 'urn:google:dai:2018',
|
||||
start: 15,
|
||||
value: 'foo',
|
||||
contentEncoding: undefined,
|
||||
presentationTimeOffset: 0
|
||||
},
|
||||
{
|
||||
end: 16,
|
||||
id: '5',
|
||||
messageData: 'bar',
|
||||
schemeIdUri: 'urn:google:dai:2018',
|
||||
start: 16,
|
||||
value: 'foo',
|
||||
contentEncoding: undefined,
|
||||
presentationTimeOffset: 0
|
||||
},
|
||||
{
|
||||
end: 17,
|
||||
id: '6',
|
||||
messageData: 'foo_bar',
|
||||
schemeIdUri: 'urn:google:dai:2018',
|
||||
start: 17,
|
||||
value: 'foo',
|
||||
contentEncoding: undefined,
|
||||
presentationTimeOffset: 0
|
||||
}
|
||||
],
|
||||
locations: undefined,
|
||||
representationInfo: []
|
||||
};
|
||||
|
||||
const eventStreams = inheritAttributes(mpd);
|
||||
|
||||
assert.deepEqual(eventStreams, expected, 'inheritAttributes returns the expected object');
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue