Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong resolvedUri #117

Open
Caringor opened this issue Jan 2, 2021 · 2 comments
Open

Wrong resolvedUri #117

Caringor opened this issue Jan 2, 2021 · 2 comments

Comments

@Caringor
Copy link

Caringor commented Jan 2, 2021

Hi, I'm trying to parse SlingTV manifest, however the uri and resolvedUri in the returned parser manifest seems to be wrong.

{ uri: 'audio/stereo/192/$Number%08x$.m4s', timeline: 1, duration: 2.048, resolvedUri: 'http://p-cdn1-c-cg14-linear-cbd46b77.movetv.com/15807/live/CNNHD-DYN/6986bd324cdc11ebb62f0025b5472115/audio/stereo/192/$Number%08x$.m4s', map: [Object], number: 2877 }

The real url should be:
http://p-cdn1-c-cg14-linear-cbd46b77.movetv.com/15807/live/CNNHD-DYN/6986bd324cdc11ebb62f0025b5472115/audio/stereo/192/00000ffc.m4s

example.mpd.txt

@gkatsev
Copy link
Member

gkatsev commented Mar 24, 2021

I think it's because we only expect BaseURL elements to be children the MPD element rather than inside a Period.

@Jssly
Copy link

Jssly commented Apr 26, 2022

@gkatsev

I got the same issue on this website. My research result is that it's a regex issue here: https://github.com/videojs/mpd-parser/blob/main/src/segment/segmentTemplate.js#L6

const identifierPattern = /\$([A-z]*)(?:(%0)([0-9]+)d)?\$/g;

In this example the regex is $Number%08x$, not match to identifierPattern. The code should be

const identifierPattern = /\$([A-z]*)(?:(%0)([0-9]+)([d,x]))?\$/g;

another issue is the number need to be set as hex format in function https://github.com/videojs/mpd-parser/blob/main/src/segment/segmentTemplate.js#L44

here is my solution:
export const identifierReplacement = (values) => (match, identifier, format, width, base) => {
if (match === '$$') {
// escape sequence
return '$';
}

if (typeof values[identifier] === 'undefined') {
return match;
}

let value = '' + values[identifier];

if (identifier === 'RepresentationID') {
// Format tag shall not be present with RepresentationID
return value;
}

if (!format) {
width = 1;
} else {
width = parseInt(width, 10);
}

if(base ==='x') {
value = parseInt(value).toString(16)
}

if (value.length >= width) {
return value;
}

return ${(new Array(width - value.length + 1)).join('0')}${value};
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants