Skip to content

Commit

Permalink
Add support for variable substition in HLS
Browse files Browse the repository at this point in the history
Issue:#4422

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=209958623
  • Loading branch information
AquilesCanta authored and ojw28 committed Aug 24, 2018
1 parent 4d8a5c4 commit 24d04a2
Show file tree
Hide file tree
Showing 5 changed files with 204 additions and 47 deletions.
2 changes: 2 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@
* Allow configuration of the Loader retry delay
([#3370](https://github.com/google/ExoPlayer/issues/3370)).
* HLS:
* Add support for variable substitution
([#4422](https://github.com/google/ExoPlayer/issues/4422)).
* Add support for PlayReady.
* Add support for alternative EXT-X-KEY tags.
* Set the bitrate on primary track sample formats
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;

/** Represents an HLS master playlist. */
public final class HlsMasterPlaylist extends HlsPlaylist {
Expand All @@ -35,7 +36,8 @@ public final class HlsMasterPlaylist extends HlsPlaylist {
/* subtitles= */ Collections.emptyList(),
/* muxedAudioFormat= */ null,
/* muxedCaptionFormats= */ Collections.emptyList(),
/* hasIndependentSegments= */ false);
/* hasIndependentSegments= */ false,
/* variableDefinitions= */ Collections.emptyMap());

public static final int GROUP_INDEX_VARIANT = 0;
public static final int GROUP_INDEX_AUDIO = 1;
Expand Down Expand Up @@ -110,6 +112,8 @@ public HlsUrl(String url, Format format) {
* captions information.
*/
public final List<Format> muxedCaptionFormats;
/** Contains variable definitions, as defined by the #EXT-X-DEFINE tag. */
public final Map<String, String> variableDefinitions;

/**
* @param baseUri See {@link #baseUri}.
Expand All @@ -120,6 +124,7 @@ public HlsUrl(String url, Format format) {
* @param muxedAudioFormat See {@link #muxedAudioFormat}.
* @param muxedCaptionFormats See {@link #muxedCaptionFormats}.
* @param hasIndependentSegments See {@link #hasIndependentSegments}.
* @param variableDefinitions See {@link #variableDefinitions}.
*/
public HlsMasterPlaylist(
String baseUri,
Expand All @@ -129,14 +134,16 @@ public HlsMasterPlaylist(
List<HlsUrl> subtitles,
Format muxedAudioFormat,
List<Format> muxedCaptionFormats,
boolean hasIndependentSegments) {
boolean hasIndependentSegments,
Map<String, String> variableDefinitions) {
super(baseUri, tags, hasIndependentSegments);
this.variants = Collections.unmodifiableList(variants);
this.audios = Collections.unmodifiableList(audios);
this.subtitles = Collections.unmodifiableList(subtitles);
this.muxedAudioFormat = muxedAudioFormat;
this.muxedCaptionFormats = muxedCaptionFormats != null
? Collections.unmodifiableList(muxedCaptionFormats) : null;
this.variableDefinitions = Collections.unmodifiableMap(variableDefinitions);
}

@Override
Expand All @@ -149,7 +156,8 @@ public HlsMasterPlaylist copy(List<StreamKey> streamKeys) {
copyRenditionsList(subtitles, GROUP_INDEX_SUBTITLE, streamKeys),
muxedAudioFormat,
muxedCaptionFormats,
hasIndependentSegments);
hasIndependentSegments,
variableDefinitions);
}

/**
Expand All @@ -169,7 +177,8 @@ public static HlsMasterPlaylist createSingleVariantMasterPlaylist(String variant
emptyList,
/* muxedAudioFormat= */ null,
/* muxedCaptionFormats= */ null,
/* hasIndependentSegments= */ false);
/* hasIndependentSegments= */ false,
/* variableDefinitions= */ Collections.emptyMap());
}

private static List<HlsUrl> copyRenditionsList(
Expand Down
Loading

0 comments on commit 24d04a2

Please sign in to comment.