mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-04 10:19:24 +02:00
Moving to node_modules folder to make easier to upgrade
trying to move from Bootstrap 3 to Bootstrap 5
This commit is contained in:
parent
047e363a16
commit
d4d042e041
8460 changed files with 1355889 additions and 547977 deletions
60
node_modules/mpd-parser/src/toPlaylists.js
generated
vendored
Normal file
60
node_modules/mpd-parser/src/toPlaylists.js
generated
vendored
Normal file
|
@ -0,0 +1,60 @@
|
|||
import { merge } from './utils/object';
|
||||
import { segmentsFromTemplate } from './segment/segmentTemplate';
|
||||
import { segmentsFromList } from './segment/segmentList';
|
||||
import { segmentsFromBase } from './segment/segmentBase';
|
||||
|
||||
export const generateSegments = ({ attributes, segmentInfo }) => {
|
||||
let segmentAttributes;
|
||||
let segmentsFn;
|
||||
|
||||
if (segmentInfo.template) {
|
||||
segmentsFn = segmentsFromTemplate;
|
||||
segmentAttributes = merge(attributes, segmentInfo.template);
|
||||
} else if (segmentInfo.base) {
|
||||
segmentsFn = segmentsFromBase;
|
||||
segmentAttributes = merge(attributes, segmentInfo.base);
|
||||
} else if (segmentInfo.list) {
|
||||
segmentsFn = segmentsFromList;
|
||||
segmentAttributes = merge(attributes, segmentInfo.list);
|
||||
}
|
||||
|
||||
const segmentsInfo = {
|
||||
attributes
|
||||
};
|
||||
|
||||
if (!segmentsFn) {
|
||||
return segmentsInfo;
|
||||
}
|
||||
|
||||
const segments = segmentsFn(segmentAttributes, segmentInfo.segmentTimeline);
|
||||
|
||||
// The @duration attribute will be used to determin the playlist's targetDuration which
|
||||
// must be in seconds. Since we've generated the segment list, we no longer need
|
||||
// @duration to be in @timescale units, so we can convert it here.
|
||||
if (segmentAttributes.duration) {
|
||||
const { duration, timescale = 1 } = segmentAttributes;
|
||||
|
||||
segmentAttributes.duration = duration / timescale;
|
||||
} else if (segments.length) {
|
||||
// if there is no @duration attribute, use the largest segment duration as
|
||||
// as target duration
|
||||
segmentAttributes.duration = segments.reduce((max, segment) => {
|
||||
return Math.max(max, Math.ceil(segment.duration));
|
||||
}, 0);
|
||||
} else {
|
||||
segmentAttributes.duration = 0;
|
||||
}
|
||||
|
||||
segmentsInfo.attributes = segmentAttributes;
|
||||
segmentsInfo.segments = segments;
|
||||
|
||||
// This is a sidx box without actual segment information
|
||||
if (segmentInfo.base && segmentAttributes.indexRange) {
|
||||
segmentsInfo.sidx = segments[0];
|
||||
segmentsInfo.segments = [];
|
||||
}
|
||||
|
||||
return segmentsInfo;
|
||||
};
|
||||
|
||||
export const toPlaylists = (representations) => representations.map(generateSegments);
|
Loading…
Add table
Add a link
Reference in a new issue