Dash: add segment ranges only to streams that have them

This commit is contained in:
Rafał Dzięgiel
2021-03-19 15:19:00 +01:00
parent d762a59cc4
commit 2e97fc362c

View File

@@ -160,15 +160,28 @@ function _getStreamRepresentation(stream)
.replace(/&/g, '/') .replace(/&/g, '/')
.replace(/=/g, '/'); .replace(/=/g, '/');
repArr.push(
` <BaseURL>${encodedURL}</BaseURL>`
);
if(stream.indexRange) {
const segRange = `${stream.indexRange.start}-${stream.indexRange.end}`; const segRange = `${stream.indexRange.start}-${stream.indexRange.end}`;
repArr.push(
` <SegmentBase indexRange="${segRange}">`
);
if(stream.initRange) {
const initRange = `${stream.initRange.start}-${stream.initRange.end}`; const initRange = `${stream.initRange.start}-${stream.initRange.end}`;
repArr.push(
` <Initialization range="${initRange}"/>`
);
}
repArr.push(
` </SegmentBase>`
);
}
repArr.push( repArr.push(
` <BaseURL>${encodedURL}</BaseURL>`, ` </Representation>`
` <SegmentBase indexRange="${segRange}">`,
` <Initialization range="${initRange}"/>`,
` </SegmentBase>`,
` </Representation>`,
); );
return repArr.join('\n'); return repArr.join('\n');