Commit efb367b4 by aquilescanta Committed by Oliver Woodman

Add URLs EXT-X-STREAM-INF uris only once

This prevents ExoPlayer from thinking there are many more video tracks
than there actually are. And will prevent downloading multiple times
the same rendition once offline support for HLS is added.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=160285777
parent 4a59c7cf
...@@ -30,6 +30,7 @@ import java.io.InputStream; ...@@ -30,6 +30,7 @@ import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Queue; import java.util.Queue;
...@@ -176,6 +177,7 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli ...@@ -176,6 +177,7 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli
private static HlsMasterPlaylist parseMasterPlaylist(LineIterator iterator, String baseUri) private static HlsMasterPlaylist parseMasterPlaylist(LineIterator iterator, String baseUri)
throws IOException { throws IOException {
HashSet<String> variantUrls = new HashSet<>();
ArrayList<HlsMasterPlaylist.HlsUrl> variants = new ArrayList<>(); ArrayList<HlsMasterPlaylist.HlsUrl> variants = new ArrayList<>();
ArrayList<HlsMasterPlaylist.HlsUrl> audios = new ArrayList<>(); ArrayList<HlsMasterPlaylist.HlsUrl> audios = new ArrayList<>();
ArrayList<HlsMasterPlaylist.HlsUrl> subtitles = new ArrayList<>(); ArrayList<HlsMasterPlaylist.HlsUrl> subtitles = new ArrayList<>();
...@@ -260,13 +262,15 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli ...@@ -260,13 +262,15 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli
width = Format.NO_VALUE; width = Format.NO_VALUE;
height = Format.NO_VALUE; height = Format.NO_VALUE;
} }
line = iterator.next(); line = iterator.next(); // #EXT-X-STREAM-INF's URI.
if (variantUrls.add(line)) {
Format format = Format.createVideoContainerFormat(Integer.toString(variants.size()), Format format = Format.createVideoContainerFormat(Integer.toString(variants.size()),
MimeTypes.APPLICATION_M3U8, null, codecs, bitrate, width, height, Format.NO_VALUE, null, MimeTypes.APPLICATION_M3U8, null, codecs, bitrate, width, height, Format.NO_VALUE,
0); null, 0);
variants.add(new HlsMasterPlaylist.HlsUrl(line, format)); variants.add(new HlsMasterPlaylist.HlsUrl(line, format));
} }
} }
}
if (noClosedCaptions) { if (noClosedCaptions) {
muxedCaptionFormats = Collections.emptyList(); muxedCaptionFormats = Collections.emptyList();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment