mirror of
https://github.com/androidx/media.git
synced 2025-05-09 16:40:55 +08:00
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
This commit is contained in:
parent
6c24d93805
commit
efd17f86c5
@ -30,6 +30,7 @@ import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Queue;
|
||||
@ -174,6 +175,7 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli
|
||||
|
||||
private static HlsMasterPlaylist parseMasterPlaylist(LineIterator iterator, String baseUri)
|
||||
throws IOException {
|
||||
HashSet<String> variantUrls = new HashSet<>();
|
||||
ArrayList<HlsMasterPlaylist.HlsUrl> variants = new ArrayList<>();
|
||||
ArrayList<HlsMasterPlaylist.HlsUrl> audios = new ArrayList<>();
|
||||
ArrayList<HlsMasterPlaylist.HlsUrl> subtitles = new ArrayList<>();
|
||||
@ -251,13 +253,15 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli
|
||||
width = 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()),
|
||||
MimeTypes.APPLICATION_M3U8, null, codecs, bitrate, width, height, Format.NO_VALUE, null,
|
||||
0);
|
||||
MimeTypes.APPLICATION_M3U8, null, codecs, bitrate, width, height, Format.NO_VALUE,
|
||||
null, 0);
|
||||
variants.add(new HlsMasterPlaylist.HlsUrl(line, format));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (noClosedCaptions) {
|
||||
muxedCaptionFormats = Collections.emptyList();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user