Commit 30d66f50 by olly Committed by Toni

Rollback of https://github.com/google/ExoPlayer/commit/be69d5b747ca1f12129ac061cbb259ec45470ef8

Issue: #5596

This arguably made a worse problem than it solved, and also I think subtly broken HLS
downloads by changing which renditions HlsMasterPlaylist.copy would retain in some
cases. Reverting as a mini step toward removing smart logic from the HLS playlist parser.

*** Original commit ***

Expand check for muxed audio media tags to include uris that match variants

Issue:#5313

***

PiperOrigin-RevId: 240348969
parent 9220b18b
......@@ -377,7 +377,7 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli
selectionFlags,
roleFlags,
language);
if (isMediaTagMuxed(variants, uri)) {
if (uri == null) {
muxedAudioFormat = format;
} else {
audios.add(new HlsMasterPlaylist.HlsUrl(uri, format, name));
......@@ -817,20 +817,6 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli
return Pattern.compile(attribute + "=(" + BOOLEAN_FALSE + "|" + BOOLEAN_TRUE + ")");
}
private static boolean isMediaTagMuxed(
List<HlsMasterPlaylist.HlsUrl> variants, String mediaTagUri) {
if (mediaTagUri == null) {
return true;
}
// The URI attribute is defined, but it may match the uri of a variant.
for (int i = 0; i < variants.size(); i++) {
if (mediaTagUri.equals(variants.get(i).url)) {
return true;
}
}
return false;
}
private static class LineIterator {
private final BufferedReader reader;
......
......@@ -146,17 +146,6 @@ public class HlsMasterPlaylistParserTest {
+ "#EXT-X-STREAM-INF:BANDWIDTH=65000,CODECS=\"{$codecs}\"\n"
+ "http://example.com/{$tricky}\n";
private static final String PLAYLIST_WITH_MULTIPLE_MUXED_MEDIA_TAGS =
"#EXTM3U\n"
+ "#EXT-X-VERSION:3\n"
+ "#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID=\"a\",NAME=\"audio_0\",DEFAULT=YES,URI=\"0/0.m3u8\"\n"
+ "#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID=\"b\",NAME=\"audio_0\",DEFAULT=YES,URI=\"1/1.m3u8\"\n"
+ "#EXT-X-STREAM-INF:BANDWIDTH=140800,CODECS=\"mp4a.40.2\",AUDIO=\"a\"\n"
+ "0/0.m3u8\n"
+ "\n"
+ "#EXT-X-STREAM-INF:BANDWIDTH=281600,CODECS=\"mp4a.40.2\",AUDIO=\"b\"\n"
+ "1/1.m3u8\n";
@Test
public void testParseMasterPlaylist() throws IOException {
HlsMasterPlaylist masterPlaylist = parseMasterPlaylist(PLAYLIST_URI, PLAYLIST_SIMPLE);
......@@ -305,14 +294,6 @@ public class HlsMasterPlaylistParserTest {
assertThat(variant.url).isEqualTo("http://example.com/This/{$nested}/reference/shouldnt/work");
}
@Test
public void testMultipleMuxedMediaTags() throws IOException {
HlsMasterPlaylist playlistWithMultipleMuxedMediaTags =
parseMasterPlaylist(PLAYLIST_URI, PLAYLIST_WITH_MULTIPLE_MUXED_MEDIA_TAGS);
assertThat(playlistWithMultipleMuxedMediaTags.variants).hasSize(2);
assertThat(playlistWithMultipleMuxedMediaTags.audios).isEmpty();
}
private static HlsMasterPlaylist parseMasterPlaylist(String uri, String playlistString)
throws IOException {
Uri playlistUri = Uri.parse(uri);
......
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