mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Ignore invalid interstitials instead of throwing
The HLS spec says so in rfc8216bis (4.4.5.1) PiperOrigin-RevId: 705829265
This commit is contained in:
parent
522883bf16
commit
07b658a6da
2 changed files with 33 additions and 32 deletions
|
|
@ -1003,12 +1003,6 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli
|
||||||
if (assetListUriString != null) {
|
if (assetListUriString != null) {
|
||||||
assetListUri = Uri.parse(assetListUriString);
|
assetListUri = Uri.parse(assetListUriString);
|
||||||
}
|
}
|
||||||
if ((assetUri == null && assetListUri == null)
|
|
||||||
|| (assetUri != null && assetListUri != null)) {
|
|
||||||
throw ParserException.createForMalformedManifest(
|
|
||||||
"#EXT-X-DATARANGE: Exactly one of X-ASSET-URI or X-ASSET-LIST must be included",
|
|
||||||
/* cause= */ null);
|
|
||||||
}
|
|
||||||
long startDateUnixUs =
|
long startDateUnixUs =
|
||||||
msToUs(parseXsDateTime(parseStringAttr(line, REGEX_START_DATE, variableDefinitions)));
|
msToUs(parseXsDateTime(parseStringAttr(line, REGEX_START_DATE, variableDefinitions)));
|
||||||
long endDateUnixUs = C.TIME_UNSET;
|
long endDateUnixUs = C.TIME_UNSET;
|
||||||
|
|
@ -1115,6 +1109,8 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ((assetListUri == null && assetUri != null)
|
||||||
|
|| (assetListUri != null && assetUri == null)) {
|
||||||
interstitials.add(
|
interstitials.add(
|
||||||
new Interstitial(
|
new Interstitial(
|
||||||
id,
|
id,
|
||||||
|
|
@ -1131,6 +1127,7 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli
|
||||||
snapTypes,
|
snapTypes,
|
||||||
restrictions,
|
restrictions,
|
||||||
clientDefinedAttributes.build()));
|
clientDefinedAttributes.build()));
|
||||||
|
}
|
||||||
} else if (!line.startsWith("#")) {
|
} else if (!line.startsWith("#")) {
|
||||||
@Nullable
|
@Nullable
|
||||||
String segmentEncryptionIV =
|
String segmentEncryptionIV =
|
||||||
|
|
|
||||||
|
|
@ -1469,7 +1469,8 @@ public class HlsMediaPlaylistParserTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parseMediaPlaylist_withInterstitialWithAssetUriAndList_throwsParserException() {
|
public void parseMediaPlaylist_withInterstitialWithAssetUriAndList_interstitialIgnored()
|
||||||
|
throws IOException {
|
||||||
Uri playlistUri = Uri.parse("https://example.com/test.m3u8");
|
Uri playlistUri = Uri.parse("https://example.com/test.m3u8");
|
||||||
String playlistString =
|
String playlistString =
|
||||||
"#EXTM3U\n"
|
"#EXTM3U\n"
|
||||||
|
|
@ -1487,16 +1488,18 @@ public class HlsMediaPlaylistParserTest {
|
||||||
+ "X-ASSET-LIST=\"http://example.com/ad2-assets.json\"\n";
|
+ "X-ASSET-LIST=\"http://example.com/ad2-assets.json\"\n";
|
||||||
HlsPlaylistParser hlsPlaylistParser = new HlsPlaylistParser();
|
HlsPlaylistParser hlsPlaylistParser = new HlsPlaylistParser();
|
||||||
|
|
||||||
assertThrows(
|
HlsMediaPlaylist hlsMediaPlaylist =
|
||||||
ParserException.class,
|
(HlsMediaPlaylist)
|
||||||
() ->
|
|
||||||
hlsPlaylistParser.parse(
|
hlsPlaylistParser.parse(
|
||||||
playlistUri, new ByteArrayInputStream(Util.getUtf8Bytes(playlistString))));
|
playlistUri, new ByteArrayInputStream(Util.getUtf8Bytes(playlistString)));
|
||||||
|
|
||||||
|
assertThat(hlsMediaPlaylist.interstitials).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void
|
public void
|
||||||
parseMediaPlaylist_withInterstitialWithNeitherAssetUriNorAssetList_throwsParserException() {
|
parseMediaPlaylist_withInterstitialWithNeitherAssetUriNorAssetList_interstitialIgnored()
|
||||||
|
throws IOException {
|
||||||
Uri playlistUri = Uri.parse("https://example.com/test.m3u8");
|
Uri playlistUri = Uri.parse("https://example.com/test.m3u8");
|
||||||
String playlistString =
|
String playlistString =
|
||||||
"#EXTM3U\n"
|
"#EXTM3U\n"
|
||||||
|
|
@ -1512,11 +1515,12 @@ public class HlsMediaPlaylistParserTest {
|
||||||
+ "START-DATE=\"2020-01-02T21:55:44.000Z\"\n";
|
+ "START-DATE=\"2020-01-02T21:55:44.000Z\"\n";
|
||||||
HlsPlaylistParser hlsPlaylistParser = new HlsPlaylistParser();
|
HlsPlaylistParser hlsPlaylistParser = new HlsPlaylistParser();
|
||||||
|
|
||||||
assertThrows(
|
HlsMediaPlaylist hlsMediaPlaylist =
|
||||||
ParserException.class,
|
(HlsMediaPlaylist)
|
||||||
() ->
|
|
||||||
hlsPlaylistParser.parse(
|
hlsPlaylistParser.parse(
|
||||||
playlistUri, new ByteArrayInputStream(Util.getUtf8Bytes(playlistString))));
|
playlistUri, new ByteArrayInputStream(Util.getUtf8Bytes(playlistString)));
|
||||||
|
|
||||||
|
assertThat(hlsMediaPlaylist.interstitials).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue