Hls NAME parsing changes

-   NAME is optionial now in the Hls Manifest
-   Use the id field in Format to store the NAME instead of
    a field in Variant to mimic DASH's behaviour
    (see the DASH Id PR, which is not merged yet at this time).
This commit is contained in:
Rik Heijdens 2015-10-20 15:01:44 -04:00
parent eb282639c5
commit 10f3be6d50
2 changed files with 8 additions and 5 deletions

View File

@ -166,7 +166,7 @@ public final class HlsPlaylistParser implements UriLoadable.Parser<HlsPlaylist>
} else if (line.startsWith(STREAM_INF_TAG)) { } else if (line.startsWith(STREAM_INF_TAG)) {
bitrate = HlsParserUtil.parseIntAttr(line, BANDWIDTH_ATTR_REGEX, BANDWIDTH_ATTR); bitrate = HlsParserUtil.parseIntAttr(line, BANDWIDTH_ATTR_REGEX, BANDWIDTH_ATTR);
codecs = HlsParserUtil.parseOptionalStringAttr(line, CODECS_ATTR_REGEX); codecs = HlsParserUtil.parseOptionalStringAttr(line, CODECS_ATTR_REGEX);
name = HlsParserUtil.parseStringAttr(line, NAME_ATTR_REGEX, NAME_ATTR); name = HlsParserUtil.parseOptionalStringAttr(line, NAME_ATTR_REGEX);
String resolutionString = HlsParserUtil.parseOptionalStringAttr(line, String resolutionString = HlsParserUtil.parseOptionalStringAttr(line,
RESOLUTION_ATTR_REGEX); RESOLUTION_ATTR_REGEX);
if (resolutionString != null) { if (resolutionString != null) {

View File

@ -26,14 +26,17 @@ public final class Variant implements FormatWrapper {
public final String url; public final String url;
public final Format format; public final Format format;
public final String name;
public Variant(int index, String name, String url, int bitrate, String codecs, int width, int height) { public Variant(int index, String name, String url, int bitrate, String codecs, int width, int height) {
this.url = url; this.url = url;
this.name = name; if (name != null) {
format = new Format(name, MimeTypes.APPLICATION_M3U8, width, height, -1, -1,
-1, bitrate, null, codecs);
} else {
format = new Format(Integer.toString(index), MimeTypes.APPLICATION_M3U8, width, height, -1, -1, format = new Format(Integer.toString(index), MimeTypes.APPLICATION_M3U8, width, height, -1, -1,
-1, bitrate, null, codecs); -1, bitrate, null, codecs);
} }
}
@Override @Override
public Format getFormat() { public Format getFormat() {