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
3
node_modules/mpd-parser/src/index.js
generated
vendored
3
node_modules/mpd-parser/src/index.js
generated
vendored
|
@ -29,7 +29,8 @@ const parse = (manifestString, options = {}) => {
|
|||
dashPlaylists: playlists,
|
||||
locations: parsedManifestInfo.locations,
|
||||
sidxMapping: options.sidxMapping,
|
||||
previousManifest: options.previousManifest
|
||||
previousManifest: options.previousManifest,
|
||||
eventStream: parsedManifestInfo.eventStream
|
||||
});
|
||||
};
|
||||
|
||||
|
|
39
node_modules/mpd-parser/src/inheritAttributes.js
generated
vendored
39
node_modules/mpd-parser/src/inheritAttributes.js
generated
vendored
|
@ -287,6 +287,42 @@ export const parseCaptionServiceMetadata = (service) => {
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* A map callback that will parse all event stream data for a collection of periods
|
||||
* DASH ISO_IEC_23009 5.10.2.2
|
||||
* https://dashif-documents.azurewebsites.net/Events/master/event.html#mpd-event-timing
|
||||
*
|
||||
* @param {PeriodInformation} period object containing necessary period information
|
||||
* @return a collection of parsed eventstream event objects
|
||||
*/
|
||||
export const toEventStream = (period) => {
|
||||
// get and flatten all EventStreams tags and parse attributes and children
|
||||
return flatten(findChildren(period.node, 'EventStream').map((eventStream) => {
|
||||
const eventStreamAttributes = parseAttributes(eventStream);
|
||||
const schemeIdUri = eventStreamAttributes.schemeIdUri;
|
||||
|
||||
// find all Events per EventStream tag and map to return objects
|
||||
return findChildren(eventStream, 'Event').map((event) => {
|
||||
const eventAttributes = parseAttributes(event);
|
||||
const presentationTime = eventAttributes.presentationTime || 0;
|
||||
const timescale = eventStreamAttributes.timescale || 1;
|
||||
const duration = eventAttributes.duration || 0;
|
||||
const start = (presentationTime / timescale) + period.attributes.start;
|
||||
|
||||
return {
|
||||
schemeIdUri,
|
||||
value: eventStreamAttributes.value,
|
||||
id: eventAttributes.id,
|
||||
start,
|
||||
end: start + (duration / timescale),
|
||||
messageData: getContent(event) || eventAttributes.messageData,
|
||||
contentEncoding: eventStreamAttributes.contentEncoding,
|
||||
presentationTimeOffset: eventStreamAttributes.presentationTimeOffset || 0
|
||||
};
|
||||
});
|
||||
}));
|
||||
};
|
||||
|
||||
/**
|
||||
* Maps an AdaptationSet node to a list of Representation information objects
|
||||
*
|
||||
|
@ -531,6 +567,7 @@ export const inheritAttributes = (mpd, options = {}) => {
|
|||
|
||||
return {
|
||||
locations: mpdAttributes.locations,
|
||||
representationInfo: flatten(periods.map(toAdaptationSets(mpdAttributes, mpdBaseUrls)))
|
||||
representationInfo: flatten(periods.map(toAdaptationSets(mpdAttributes, mpdBaseUrls))),
|
||||
eventStream: flatten(periods.map(toEventStream))
|
||||
};
|
||||
};
|
||||
|
|
13
node_modules/mpd-parser/src/parseAttributes.js
generated
vendored
13
node_modules/mpd-parser/src/parseAttributes.js
generated
vendored
|
@ -241,6 +241,19 @@ export const parsers = {
|
|||
return parseInt(value, 10);
|
||||
},
|
||||
|
||||
/**
|
||||
* Specifies the presentationTime.
|
||||
*
|
||||
* @param {string} value
|
||||
* value of the attribute as a string
|
||||
*
|
||||
* @return {number}
|
||||
* The parsed presentationTime
|
||||
*/
|
||||
presentationTime(value) {
|
||||
return parseInt(value, 10);
|
||||
},
|
||||
|
||||
/**
|
||||
* Default parser for all other attributes. Acts as a no-op and just returns the value
|
||||
* as a string
|
||||
|
|
19
node_modules/mpd-parser/src/playlist-merge.js
generated
vendored
19
node_modules/mpd-parser/src/playlist-merge.js
generated
vendored
|
@ -1,5 +1,5 @@
|
|||
import { forEachMediaGroup } from '@videojs/vhs-utils/es/media-groups';
|
||||
import { findIndex, union } from './utils/list';
|
||||
import { union } from './utils/list';
|
||||
|
||||
const SUPPORTED_MEDIA_TYPES = ['AUDIO', 'SUBTITLES'];
|
||||
// allow one 60fps frame as leniency (arbitrarily chosen)
|
||||
|
@ -82,10 +82,11 @@ export const updateMediaSequenceForPlaylist = ({ playlist, mediaSequence }) => {
|
|||
*/
|
||||
export const updateSequenceNumbers = ({ oldPlaylists, newPlaylists, timelineStarts }) => {
|
||||
newPlaylists.forEach((playlist) => {
|
||||
playlist.discontinuitySequence = findIndex(
|
||||
timelineStarts,
|
||||
({ timeline }) => timeline === playlist.timeline
|
||||
);
|
||||
playlist.discontinuitySequence = timelineStarts.findIndex(function({
|
||||
timeline
|
||||
}) {
|
||||
return timeline === playlist.timeline;
|
||||
});
|
||||
|
||||
// Playlists NAMEs come from DASH Representation IDs, which are mandatory
|
||||
// (see ISO_23009-1-2012 5.3.5.2).
|
||||
|
@ -116,9 +117,11 @@ export const updateSequenceNumbers = ({ oldPlaylists, newPlaylists, timelineStar
|
|||
// Since we don't yet support early available timelines, we don't need to support
|
||||
// playlists with no segments.
|
||||
const firstNewSegment = playlist.segments[0];
|
||||
const oldMatchingSegmentIndex = findIndex(oldPlaylist.segments, (oldSegment) =>
|
||||
Math.abs(oldSegment.presentationTime - firstNewSegment.presentationTime) <
|
||||
TIME_FUDGE);
|
||||
const oldMatchingSegmentIndex = oldPlaylist.segments.findIndex(function(oldSegment) {
|
||||
return (
|
||||
Math.abs(oldSegment.presentationTime - firstNewSegment.presentationTime) < TIME_FUDGE
|
||||
);
|
||||
});
|
||||
|
||||
// No matching segment from the old playlist means the entire playlist was refreshed.
|
||||
// In this case the media sequence should account for this update, and the new segments
|
||||
|
|
17
node_modules/mpd-parser/src/toM3u8.js
generated
vendored
17
node_modules/mpd-parser/src/toM3u8.js
generated
vendored
|
@ -1,5 +1,5 @@
|
|||
import { values } from './utils/object';
|
||||
import { findIndex, findIndexes } from './utils/list';
|
||||
import { findIndexes } from './utils/list';
|
||||
import { addSidxSegmentsToPlaylist as addSidxSegmentsToPlaylist_ } from './segment/segmentBase';
|
||||
import { byteRangeToString } from './segment/urlType';
|
||||
import {
|
||||
|
@ -217,7 +217,7 @@ export const organizeAudioPlaylists = (playlists, sidxMapping = {}, isAudioOnly
|
|||
|
||||
export const organizeVttPlaylists = (playlists, sidxMapping = {}) => {
|
||||
return playlists.reduce((a, playlist) => {
|
||||
const label = playlist.attributes.lang || 'text';
|
||||
const label = playlist.attributes.label || playlist.attributes.lang || 'text';
|
||||
|
||||
if (!a[label]) {
|
||||
a[label] = {
|
||||
|
@ -352,7 +352,11 @@ export const addMediaSequenceValues = (playlists, timelineStarts) => {
|
|||
// increment all segments sequentially
|
||||
playlists.forEach((playlist) => {
|
||||
playlist.mediaSequence = 0;
|
||||
playlist.discontinuitySequence = findIndex(timelineStarts, ({ timeline }) => timeline === playlist.timeline);
|
||||
playlist.discontinuitySequence = timelineStarts.findIndex(function({
|
||||
timeline
|
||||
}) {
|
||||
return timeline === playlist.timeline;
|
||||
});
|
||||
|
||||
if (!playlist.segments) {
|
||||
return;
|
||||
|
@ -389,7 +393,8 @@ export const toM3u8 = ({
|
|||
dashPlaylists,
|
||||
locations,
|
||||
sidxMapping = {},
|
||||
previousManifest
|
||||
previousManifest,
|
||||
eventStream
|
||||
}) => {
|
||||
if (!dashPlaylists.length) {
|
||||
return {};
|
||||
|
@ -436,6 +441,10 @@ export const toM3u8 = ({
|
|||
manifest.suggestedPresentationDelay = suggestedPresentationDelay;
|
||||
}
|
||||
|
||||
if (eventStream && eventStream.length > 0) {
|
||||
manifest.eventStream = eventStream;
|
||||
}
|
||||
|
||||
const isAudioOnly = manifest.playlists.length === 0;
|
||||
const organizedAudioGroup = audioPlaylists.length ?
|
||||
organizeAudioPlaylists(audioPlaylists, sidxMapping, isAudioOnly) : null;
|
||||
|
|
34
node_modules/mpd-parser/src/utils/list.js
generated
vendored
34
node_modules/mpd-parser/src/utils/list.js
generated
vendored
|
@ -34,40 +34,6 @@ export const findIndexes = (l, key) => l.reduce((a, e, i) => {
|
|||
return a;
|
||||
}, []);
|
||||
|
||||
/**
|
||||
* Returns the first index that satisfies the matching function, or -1 if not found.
|
||||
*
|
||||
* Only necessary because of IE11 support.
|
||||
*
|
||||
* @param {Array} list - the list to search through
|
||||
* @param {Function} matchingFunction - the matching function
|
||||
*
|
||||
* @return {number} the matching index or -1 if not found
|
||||
*/
|
||||
export const findIndex = (list, matchingFunction) => {
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
if (matchingFunction(list[i])) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns whether the list contains the search element.
|
||||
*
|
||||
* Only necessary because of IE11 support.
|
||||
*
|
||||
* @param {Array} list - the list to search through
|
||||
* @param {*} searchElement - the element to look for
|
||||
*
|
||||
* @return {boolean} whether the list includes the search element or not
|
||||
*/
|
||||
export const includes = (list, searchElement) => {
|
||||
return list.some((element) => element === searchElement);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a union of the included lists provided each element can be identified by a key.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue