Commit 14cfb803 by olly Committed by bachinger

Use peak rather than average bitrate for HLS

This is a minor change ahead of merging a full variant of
https://github.com/google/ExoPlayer/pull/6706, to make
re-buffers less likely.

Also remove variable substitution when parsing
AVERAGE-BANDWIDTH (it's not required for integer attributes)

PiperOrigin-RevId: 283554106
parent 21dd59ba
...@@ -126,9 +126,11 @@ ...@@ -126,9 +126,11 @@
fragment) ([#6470](https://github.com/google/ExoPlayer/issues/6470)). fragment) ([#6470](https://github.com/google/ExoPlayer/issues/6470)).
* DASH: Support negative @r values in segment timelines * DASH: Support negative @r values in segment timelines
([#1787](https://github.com/google/ExoPlayer/issues/1787)). ([#1787](https://github.com/google/ExoPlayer/issues/1787)).
* HLS: Fix issue where streams could get stuck in an infinite buffering state * HLS:
after a postroll ad * Use peak bitrate rather than average bitrate for adaptive track selection.
([#6314](https://github.com/google/ExoPlayer/issues/6314)). * Fix issue where streams could get stuck in an infinite buffering state
after a postroll ad
([#6314](https://github.com/google/ExoPlayer/issues/6314)).
* AV1 extension: * AV1 extension:
* New in this release. The AV1 extension allows use of the * New in this release. The AV1 extension allows use of the
[libgav1 software decoder](https://chromium.googlesource.com/codecs/libgav1/) [libgav1 software decoder](https://chromium.googlesource.com/codecs/libgav1/)
......
...@@ -304,12 +304,8 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli ...@@ -304,12 +304,8 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli
} else if (line.startsWith(TAG_STREAM_INF)) { } else if (line.startsWith(TAG_STREAM_INF)) {
noClosedCaptions |= line.contains(ATTR_CLOSED_CAPTIONS_NONE); noClosedCaptions |= line.contains(ATTR_CLOSED_CAPTIONS_NONE);
int bitrate = parseIntAttr(line, REGEX_BANDWIDTH); int bitrate = parseIntAttr(line, REGEX_BANDWIDTH);
String averageBandwidthString = // TODO: Plumb this into Format.
parseOptionalStringAttr(line, REGEX_AVERAGE_BANDWIDTH, variableDefinitions); int averageBitrate = parseOptionalIntAttr(line, REGEX_AVERAGE_BANDWIDTH, -1);
if (averageBandwidthString != null) {
// If available, the average bandwidth attribute is used as the variant's bitrate.
bitrate = Integer.parseInt(averageBandwidthString);
}
String codecs = parseOptionalStringAttr(line, REGEX_CODECS, variableDefinitions); String codecs = parseOptionalStringAttr(line, REGEX_CODECS, variableDefinitions);
String resolutionString = String resolutionString =
parseOptionalStringAttr(line, REGEX_RESOLUTION, variableDefinitions); parseOptionalStringAttr(line, REGEX_RESOLUTION, variableDefinitions);
...@@ -869,6 +865,14 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli ...@@ -869,6 +865,14 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli
return Integer.parseInt(parseStringAttr(line, pattern, Collections.emptyMap())); return Integer.parseInt(parseStringAttr(line, pattern, Collections.emptyMap()));
} }
private static int parseOptionalIntAttr(String line, Pattern pattern, int defaultValue) {
Matcher matcher = pattern.matcher(line);
if (matcher.find()) {
return Integer.parseInt(matcher.group(1));
}
return defaultValue;
}
private static long parseLongAttr(String line, Pattern pattern) throws ParserException { private static long parseLongAttr(String line, Pattern pattern) throws ParserException {
return Long.parseLong(parseStringAttr(line, pattern, Collections.emptyMap())); return Long.parseLong(parseStringAttr(line, pattern, Collections.emptyMap()));
} }
......
...@@ -243,7 +243,7 @@ public class HlsMasterPlaylistParserTest { ...@@ -243,7 +243,7 @@ public class HlsMasterPlaylistParserTest {
List<HlsMasterPlaylist.Variant> variants = masterPlaylist.variants; List<HlsMasterPlaylist.Variant> variants = masterPlaylist.variants;
assertThat(variants.get(0).format.bitrate).isEqualTo(1280000); assertThat(variants.get(0).format.bitrate).isEqualTo(1280000);
assertThat(variants.get(1).format.bitrate).isEqualTo(1270000); assertThat(variants.get(1).format.bitrate).isEqualTo(1280000);
} }
@Test @Test
......
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