Skip to content

fix: remove duplicate representation entries for absolute BaseURLs - #191

Open
cpruijsen wants to merge 1 commit into
videojs:mainfrom
cpruijsen:fix/issue-175
Open

fix: remove duplicate representation entries for absolute BaseURLs#191
cpruijsen wants to merge 1 commit into
videojs:mainfrom
cpruijsen:fix/issue-175

Conversation

@cpruijsen

Copy link
Copy Markdown

Description

buildBaseUrls dedupes the cartesian product by exact object identity (first copy wins). When an MPD has more than one parent BaseURL (CDN / content steering) and a child BaseURL is absolute, that child is no longer emitted once per parent, so representationInfo does not contain duplicate playlist entries. Fixes #175.

resolveUrl returns a scheme-bearing URL unchanged, so the product is N identical objects. Parent serviceLocation is not copied in that case, so the copies are exact duplicates.

Relative parent×child combinations are unchanged. Content-steering copies that differ by serviceLocation (or any other attribute) are kept.

The TODO that used to sit on inheritAttributes described these duplicates. On PR #17, mjneil described the same cartesian product: the subtitle representation is duplicated because the absolute child is resolved against each parent BaseURL; the fix belongs in base URL creation.

Decision

Drop exact-duplicate resolved BaseURL objects in buildBaseUrls.

Alternative: skip the product only when the child URL did not resolve (resolvedUrl === childUrl), or unique the final representationInfo list.

The product is built in buildBaseUrls, and exact-object identity is the smallest key that still keeps distinct serviceLocation copies. Open to uniquing later or special-casing only absolute URLs.

Identity is JSON.stringify of the resolved object. Objects are always built as merge(parseAttributes(el), { baseUrl }) plus an optional serviceLocation assignment, so key order is stable for cartesian clones. Two identical <BaseURL> nodes written in the MPD (not a cartesian artifact) also collapse; copies that differ by any attribute do not.

Example

<MPD>
  <BaseURL serviceLocation="alpha">https://cdn1.example.com/</BaseURL>
  <BaseURL serviceLocation="beta">https://cdn2.example.com/</BaseURL>
  ...
  <Representation id="en">
    <BaseURL>https://example.com/en.vtt</BaseURL>
  </Representation>
</MPD>

representationInfo for en is one entry (https://example.com/en.vtt), not two. Video representations still have one playlist per CDN.

When a child BaseURL is absolute, resolving it against every parent BaseURL repeats the same URL. Dedupe the cartesian product by exact object identity so content-steering copies that differ by serviceLocation stay distinct.
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

Successfully merging this pull request may close these issues.

Duplicate Playlist Entries with BaseURL tags at different levels of the Manifest

1 participant