Skip to content

Commit

Permalink
small logging fix, bring map to skipped segments
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonocasey committed Apr 28, 2021
1 parent 1ff48b0 commit 046fa94
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
26 changes: 15 additions & 11 deletions src/playlist-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,25 +75,29 @@ export const updateSegment = (a, b) => {
*/
export const updateSegments = (original, update, offset) => {
const oldSegments = original.slice();
const result = update.slice();
const newSegments = update.slice();

offset = offset || 0;
const length = Math.min(original.length, update.length + offset);
const result = [];

let currentMap;

for (let i = offset; i < length; i++) {
const newIndex = i - offset;
for (let newIndex = 0; newIndex < newSegments.length; newIndex++) {
const oldSegment = oldSegments[newIndex + offset];
const newSegment = newSegments[newIndex];

currentMap = oldSegments[i].map;
if (oldSegment) {
currentMap = oldSegment.map || currentMap;

result[newIndex] = updateSegment(oldSegments[i], result[newIndex]);
result.push(updateSegment(oldSegment, newSegment));
} else {
// carry over map to new segment if it is missing
if (currentMap && !newSegment.map) {
newSegment.map = currentMap;
}

result.push(newSegment);

// if EXT-X-SKIP is used, even the init segment will be skipped
// we need to make sure that we bring the map over
// to all new segments.
if (!result[newIndex].map && currentMap) {
result[newIndex].map = currentMap;
}
}
return result;
Expand Down
3 changes: 2 additions & 1 deletion src/segment-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,10 @@ const segmentInfoString = (segmentInfo) => {
}

const name = segmentInfo.segment.uri ? 'segment' : 'pre-segment';
const totalParts = parts ? parts.length - 1 : 0;

return `${name} [${index}/${segmentLen}]` +
(partIndex ? ` part [${partIndex}/${parts.length - 1}]` : '') +
(partIndex ? ` part [${partIndex}/${totalParts}]` : '') +
` mediaSequenceNumber [${seq}/${seq + segmentLen}]` +
` start/end [${start} => ${end}]` +
` startOfSegment [${startOfSegment}]` +
Expand Down

0 comments on commit 046fa94

Please sign in to comment.