Fix HLS download failure when EXT-X-DEFINE variables are referenced in media playlist segment URLs#3259
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
Thanks. Please can you file the CLA? We can't process this before the CLA requirements. As you are saying that the problem manifests in download use cases only. Would you be able to craft a unit test that demonstrates the failure and verifies the fix? That's what we have to do anyway internally when processing your fix, and if you are able to provide this, this may make taking the pull a bit quicker. Thanks for considering adding such a unit test. We'd need the CLA in any case. |
3161a6b to
0affbd7
Compare
… HlsDownloader
HlsDownloader.getSegments() now creates a HlsPlaylistParser with the
multivariant playlist context and uses ParsingLoadable.load() to parse
child manifests. This allows EXT-X-DEFINE variables defined in the
multivariant playlist to be resolved via IMPORT in media playlists
during the download path.
Previously, child manifests were parsed via getManifest() which uses
the original parser constructed with HlsMultivariantPlaylist.EMPTY.
Variables imported via #EXT-X-DEFINE:IMPORT could not be resolved,
causing segment URLs with unresolved {$variable} references to fail
during download.
This fixes HLS download failures for streams that define variables in
the multivariant playlist and reference them in media playlist segment
URLs (e.g. {$awsContentSegmentPrefix} in Art19 video podcasts).
Issue: androidx#3259
0affbd7 to
9356b0f
Compare
… HlsDownloader
HlsDownloader.getSegments() now creates a HlsPlaylistParser with the
multivariant playlist context and uses ParsingLoadable.load() to parse
child manifests. This allows EXT-X-DEFINE variables defined in the
multivariant playlist to be resolved via IMPORT in media playlists
during the download path.
Previously, child manifests were parsed via getManifest() which uses
the original parser constructed with HlsMultivariantPlaylist.EMPTY.
Variables imported via #EXT-X-DEFINE:IMPORT could not be resolved,
causing segment URLs with unresolved {$variable} references to fail
during download.
This fixes HLS download failures for streams that define variables in
the multivariant playlist and reference them in media playlist segment
URLs (e.g. {$awsContentSegmentPrefix} in Art19 video podcasts).
Issue: androidx#3259
9356b0f to
b879848
Compare
… HlsDownloader
HlsDownloader.getSegments() now creates a HlsPlaylistParser with the
multivariant playlist context and uses ParsingLoadable.load() to parse
child manifests. This allows EXT-X-DEFINE variables defined in the
multivariant playlist to be resolved via IMPORT in media playlists
during the download path.
Previously, child manifests were parsed via getManifest() which uses
the original parser constructed with HlsMultivariantPlaylist.EMPTY.
Variables imported via #EXT-X-DEFINE:IMPORT could not be resolved,
causing segment URLs with unresolved {$variable} references to fail
during download.
This fixes HLS download failures for streams that define variables in
the multivariant playlist and reference them in media playlist segment
URLs (e.g. {$awsContentSegmentPrefix} in Art19 video podcasts).
Issue: androidx#3259
b879848 to
1bf8f43
Compare
PR Description:
Summary
Fixes HLS download failures for streams where the multivariant playlist defines
variables via
#EXT-X-DEFINE:NAME=...,VALUE=...and media playlists referencethem in segment URLs without an explicit
#EXT-X-DEFINE:IMPORT=...tag.Fixes #3258
Problem
HlsDownloader(viaSegmentDownloader) uses a singleHlsPlaylistParser()instance constructed with
HlsMultivariantPlaylist.EMPTY. This instance firstparses the multivariant playlist, then parses each media playlist. However, the
parsed multivariant playlist was never stored back into the parser instance.
When media playlists are subsequently parsed,
multivariantPlaylistis stillEMPTY, so:variableDefinitionsis unavailable duringreplaceVariableReferences(){$variable}references in segment URLs pass through unsubstitutedHlsMediaPeriod.getStreamKeys()crashes withIndexOutOfBoundsExceptionDuring playback this works correctly because
HlsPlaylistTrackerconstructsthe parser with the real multivariant playlist.
Fix
HlsPlaylistParser.java:multivariantPlaylistfield non-finalparse(), store it in the instanceparseMediaPlaylist()calls on the same instance now have accessto the correct
variableDefinitionsfor variable substitutionHlsMediaPeriod.java:getStreamKeys()to preventIndexOutOfBoundsExceptionwhen
redundantGroupIndicesPerWrapperhas an empty array or whenrenditionRedundantGroupIndexexceeds the redundant groups list sizeTesting
Tested with an HLS stream using:
#EXT-X-DEFINE:NAME="awsContentSegmentPrefix",VALUE="https://cdn.example.com/"
in the multivariant playlist, with media playlist segment URLs referencing
{$awsContentSegmentPrefix}directly. Download completes successfully withvariables resolved. Existing playback behavior is unchanged