这是indexloc提供的服务,不要输入任何密码
Skip to content

HlsPlaylistParser fails to parse when EXT-X-DATERANGE does not have START-DATE #2428

@TomVarga

Description

@TomVarga

Version

Media3 main branch

More version details

e1abda0

Devices that reproduce the issue

any

Devices that do not reproduce the issue

No response

Reproducible in the demo app?

Yes

Reproduction steps

Here is simplified example stream:

https://raw.githubusercontent.com/TomVarga/HLS-test-stream/refs/heads/main/ride/audio.m3u8

Expected result

According to the latest version of the HLS spec at https://datatracker.ietf.org/doc/html/draft-pantos-hls-rfc8216bis#section-4.4.5.1

If a Playlist contains two EXT-X-DATERANGE tags with the same ID
attribute value, then any AttributeName that appears in both tags
MUST have the same AttributeValue. A Server MAY augment a Date Range
with additional attributes by adding subsequent EXT-X-DATERANGE tags
with the same ID attribute to a Playlist. The client is responsible
for consolidating the tags. The subsequent EXT-X-DATERANGE tags can
appear in a subsequent playlist update, in the case of live or event
streams.

In a live stream scenario our system does updates to an interstitial according to the spec, so it's ok for a START-DATE to not be present in a follow up EXT-X-DATERANGE tag with the same id

A test like this should pass:

  @Test
  public void
  parseMediaPlaylist_withInterstitialWithUpdatingDateRange()
      throws IOException {
    Uri playlistUri = Uri.parse("https://raw.githubusercontent.com/TomVarga/HLS-test-stream/refs/heads/main/ride/audio.m3u8");
    String playlistString =
        "#EXTM3U\n"
            + "#EXT-X-VERSION:3\n"
            + "#EXT-X-TARGETDURATION:10\n"
            + "#EXT-X-MEDIA-SEQUENCE:0\n"
            + "#EXT-X-PROGRAM-DATE-TIME:2024-09-20T15:29:20.000Z\n"
            + "#EXTINF:10.007800,\n"
            + "audio0000.ts\n"
            + "#EXT-X-DATERANGE:ID=\"15943\","
            + "CLASS=\"com.apple.hls.interstitial\","
            + "START-DATE=\"2024-09-20T15:29:24.006Z\",PLANNED-DURATION=25,"
            + "X-ASSET-LIST=\"myapp://interstitial/req?_HLS_interstitial_id=15943\","
            + "X-SNAP=\"OUT,IN\",X-TIMELINE-OCCUPIES=\"RANGE\","
            + "X-TIMELINE-STYLE=\"HIGHLIGHT\",X-CONTENT-MAY-VARY=\"YES\"\n"
            + "#EXTINF:10.007800,\n"
            + "audio0001.ts\n"
            + "#EXT-X-DATERANGE:ID=\"15943\",CLASS=\"com.apple.hls.interstitial\","
            + "END-DATE=\"2024-09-20T15:29:49.006Z\",X-PLAYOUT-LIMIT=24.953741497,"
            + "X-RESUME-OFFSET=24.953741497";

    HlsMediaPlaylist playlist =
        (HlsMediaPlaylist)
            new HlsPlaylistParser()
                .parse(playlistUri, new ByteArrayInputStream(Util.getUtf8Bytes(playlistString)));

    assertThat(playlist.interstitials.get(0).id).isEqualTo("15943");
    assertThat(playlist.interstitials.get(0).resumeOffsetUs).isEqualTo(24953741L);
    assertThat(playlist.interstitials.get(0).endDateUnixUs).isEqualTo(1726846189006000L);
    assertThat(playlist.interstitials.get(0).playoutLimitUs).isEqualTo(24953741L);
  }

Actual result

playback fails with error:

Couldn't match START-DATE="(.+?)" in #EXT-X-DATERANGE:ID="15943",CLASS="com.apple.hls.interstitial",END-DATE="2024-09-20T15:29:49.006Z",X-PLAYOUT-LIMIT=24.953741497,X-RESUME-OFFSET=24.953741497 {contentIsMalformed=true, dataType=4}

Media

https://raw.githubusercontent.com/TomVarga/HLS-test-stream/refs/heads/main/ride/audio.m3u8

Bug Report

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions