-
Notifications
You must be signed in to change notification settings - Fork 836
Fix HLS download failure when EXT-X-DEFINE variables are referenced in media playlist segment URLs #3259
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
base: release
Are you sure you want to change the base?
Fix HLS download failure when EXT-X-DEFINE variables are referenced in media playlist segment URLs #3259
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,6 +29,7 @@ | |
| import androidx.media3.exoplayer.hls.playlist.HlsPlaylist; | ||
| import androidx.media3.exoplayer.hls.playlist.HlsPlaylistParser; | ||
| import androidx.media3.exoplayer.offline.SegmentDownloader; | ||
| import androidx.media3.exoplayer.upstream.ParsingLoadable; | ||
| import androidx.media3.exoplayer.upstream.ParsingLoadable.Parser; | ||
| import com.google.errorprone.annotations.CanIgnoreReturnValue; | ||
| import java.io.IOException; | ||
|
|
@@ -220,21 +221,37 @@ private HlsDownloader( | |
| protected List<Segment> getSegments(DataSource dataSource, HlsPlaylist manifest, boolean removing) | ||
| throws IOException, InterruptedException { | ||
| ArrayList<DataSpec> mediaPlaylistDataSpecs = new ArrayList<>(); | ||
| HlsMultivariantPlaylist multivariantPlaylist = HlsMultivariantPlaylist.EMPTY; | ||
| if (manifest instanceof HlsMultivariantPlaylist) { | ||
| HlsMultivariantPlaylist multivariantPlaylist = (HlsMultivariantPlaylist) manifest; | ||
| multivariantPlaylist = (HlsMultivariantPlaylist) manifest; | ||
| addMediaPlaylistDataSpecs(multivariantPlaylist.mediaPlaylistUrls, mediaPlaylistDataSpecs); | ||
| } else { | ||
| mediaPlaylistDataSpecs.add( | ||
| SegmentDownloader.getCompressibleDataSpec(Uri.parse(manifest.baseUri))); | ||
| } | ||
|
|
||
| // When the multivariant playlist defines variables, create a parser that propagates | ||
| // them to child manifests for IMPORT resolution. Otherwise use the default path. | ||
| boolean hasVariables = !multivariantPlaylist.variableDefinitions.isEmpty(); | ||
| @Nullable HlsPlaylistParser childManifestParser = hasVariables | ||
| ? new HlsPlaylistParser(multivariantPlaylist, /* previousMediaPlaylist= */ null) | ||
| : null; | ||
|
|
||
| ArrayList<Segment> segments = new ArrayList<>(); | ||
| HashSet<Uri> seenEncryptionKeyUris = new HashSet<>(); | ||
| for (DataSpec mediaPlaylistDataSpec : mediaPlaylistDataSpecs) { | ||
| segments.add(new Segment(/* startTimeUs= */ 0, mediaPlaylistDataSpec)); | ||
| HlsMediaPlaylist mediaPlaylist; | ||
| try { | ||
| mediaPlaylist = (HlsMediaPlaylist) getManifest(dataSource, mediaPlaylistDataSpec, removing); | ||
| if (childManifestParser != null) { | ||
| mediaPlaylist = | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should not load here. When looking at I think instead we should overload Instead of the This way we take advantage of the harness in |
||
| (HlsMediaPlaylist) | ||
| ParsingLoadable.load( | ||
| dataSource, childManifestParser, mediaPlaylistDataSpec, C.DATA_TYPE_MANIFEST); | ||
| } else { | ||
| mediaPlaylist = (HlsMediaPlaylist) getManifest(dataSource, mediaPlaylistDataSpec, | ||
| removing); | ||
| } | ||
| } catch (IOException e) { | ||
| if (!removing) { | ||
| throw e; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename from
childManifestParsertomediaPlaylistParser?