mpd-parser icon indicating copy to clipboard operation
mpd-parser copied to clipboard

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

Open wseymour15 opened this issue 1 year ago • 0 comments

There are occurrences in the inheritAttributes functionality where this representationInfo array contains undesired duplicates. This generally occurs when there are multiple BaseURL nodes that are direct children of the MPD node. When we attempt to resolve URLs from a combination of the parent BaseURL and a child BaseURL, and the value does not resolve, we end up returning the child BaseURL multiple times. We need to determine a way to remove these duplicates in a safe way.

See: https://github.com/videojs/mpd-parser/pull/17#discussion_r162750527

Example Input (Note that there are multiple BaseURLs as direct children of the MPD tag)

<MPD type="dyanmic">
    <BaseURL serviceLocation="alpha">https://cdn1.example.com/</BaseURL>
    <BaseURL serviceLocation="beta">https://cdn2.example.com/</BaseURL>
    <Period start="PT0S">
      ...
      <AdaptationSet mimeType="text/vtt" lang="en">
        <Representation bandwidth="256" id="en">
          <BaseURL>https://example.com/en.vtt</BaseURL>
        </Representation>
      </AdaptationSet>
    </Period>
  </MPD>

Current Actual RepresentationInfo

representationInfo: [
      {
        attributes: {
          baseUrl: 'https://cdn1.example.com/',
          ...
        },
        segmentInfo: {...}
      },
      {
        attributes: {
          baseUrl: 'https://cdn2.example.com/',
          ... 
        },
        segmentInfo: {...}
      },
      {
        attributes: {
          baseUrl: 'https://example.com/en.vtt',
          ... 
        },
        segmentInfo: {...}
      },
      {
        attributes: {
          baseUrl: 'https://example.com/en.vtt',
          ...
        },
        segmentInfo: {...}
      }
    ]

Expected (Notice there is one less entry than the last)

representationInfo: [
      {
        attributes: {
          baseUrl: 'https://cdn1.example.com/',
          ...
        },
        segmentInfo: {...}
      },
      {
        attributes: {
          baseUrl: 'https://cdn2.example.com/',
          ... 
        },
        segmentInfo: {...}
      },
      {
        attributes: {
          baseUrl: 'https://example.com/en.vtt',
          ... 
        },
        segmentInfo: {...}
      }
    ]

wseymour15 avatar Aug 09 '23 19:08 wseymour15