Commit eb282639 by Rik Heijdens

Parse NAME label from HLS Master Playlist

The HlsPlaylistParser now parses the "NAME" property
from the MasterHlsPlaylist and saves it in the Variant
parent 5b81612c
...@@ -184,7 +184,7 @@ public class HlsChunkSource { ...@@ -184,7 +184,7 @@ public class HlsChunkSource {
playlistParser = new HlsPlaylistParser(); playlistParser = new HlsPlaylistParser();
if (playlist.type == HlsPlaylist.TYPE_MEDIA) { if (playlist.type == HlsPlaylist.TYPE_MEDIA) {
variants = new Variant[] {new Variant(0, playlistUrl, 0, null, -1, -1)}; variants = new Variant[] {new Variant(0, null, playlistUrl, 0, null, -1, -1)};
variantPlaylists = new HlsMediaPlaylist[1]; variantPlaylists = new HlsMediaPlaylist[1];
variantLastPlaylistLoadTimesMs = new long[1]; variantLastPlaylistLoadTimesMs = new long[1];
variantBlacklistTimes = new long[1]; variantBlacklistTimes = new long[1];
......
...@@ -143,6 +143,7 @@ public final class HlsPlaylistParser implements UriLoadable.Parser<HlsPlaylist> ...@@ -143,6 +143,7 @@ public final class HlsPlaylistParser implements UriLoadable.Parser<HlsPlaylist>
String codecs = null; String codecs = null;
int width = -1; int width = -1;
int height = -1; int height = -1;
String name = null;
boolean expectingStreamInfUrl = false; boolean expectingStreamInfUrl = false;
String line; String line;
...@@ -152,18 +153,20 @@ public final class HlsPlaylistParser implements UriLoadable.Parser<HlsPlaylist> ...@@ -152,18 +153,20 @@ public final class HlsPlaylistParser implements UriLoadable.Parser<HlsPlaylist>
String type = HlsParserUtil.parseStringAttr(line, TYPE_ATTR_REGEX, TYPE_ATTR); String type = HlsParserUtil.parseStringAttr(line, TYPE_ATTR_REGEX, TYPE_ATTR);
if (SUBTITLES_TYPE.equals(type)) { if (SUBTITLES_TYPE.equals(type)) {
// We assume all subtitles belong to the same group. // We assume all subtitles belong to the same group.
String name = HlsParserUtil.parseStringAttr(line, NAME_ATTR_REGEX, NAME_ATTR); name = HlsParserUtil.parseStringAttr(line, NAME_ATTR_REGEX, NAME_ATTR);
String uri = HlsParserUtil.parseStringAttr(line, URI_ATTR_REGEX, URI_ATTR); String uri = HlsParserUtil.parseStringAttr(line, URI_ATTR_REGEX, URI_ATTR);
String language = HlsParserUtil.parseOptionalStringAttr(line, LANGUAGE_ATTR_REGEX); String language = HlsParserUtil.parseOptionalStringAttr(line, LANGUAGE_ATTR_REGEX);
boolean isDefault = HlsParserUtil.parseOptionalBooleanAttr(line, DEFAULT_ATTR_REGEX); boolean isDefault = HlsParserUtil.parseOptionalBooleanAttr(line, DEFAULT_ATTR_REGEX);
boolean autoSelect = HlsParserUtil.parseOptionalBooleanAttr(line, AUTOSELECT_ATTR_REGEX); boolean autoSelect = HlsParserUtil.parseOptionalBooleanAttr(line, AUTOSELECT_ATTR_REGEX);
subtitles.add(new Subtitle(name, uri, language, isDefault, autoSelect)); subtitles.add(new Subtitle(name, uri, language, isDefault, autoSelect));
name = null;
} else { } else {
// TODO: Support other types of media tag. // TODO: Support other types of media tag.
} }
} 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);
String resolutionString = HlsParserUtil.parseOptionalStringAttr(line, String resolutionString = HlsParserUtil.parseOptionalStringAttr(line,
RESOLUTION_ATTR_REGEX); RESOLUTION_ATTR_REGEX);
if (resolutionString != null) { if (resolutionString != null) {
...@@ -184,9 +187,10 @@ public final class HlsPlaylistParser implements UriLoadable.Parser<HlsPlaylist> ...@@ -184,9 +187,10 @@ public final class HlsPlaylistParser implements UriLoadable.Parser<HlsPlaylist>
} }
expectingStreamInfUrl = true; expectingStreamInfUrl = true;
} else if (!line.startsWith("#") && expectingStreamInfUrl) { } else if (!line.startsWith("#") && expectingStreamInfUrl) {
variants.add(new Variant(variants.size(), line, bitrate, codecs, width, height)); variants.add(new Variant(variants.size(), name, line, bitrate, codecs, width, height));
bitrate = 0; bitrate = 0;
codecs = null; codecs = null;
name = null;
width = -1; width = -1;
height = -1; height = -1;
expectingStreamInfUrl = false; expectingStreamInfUrl = false;
......
...@@ -26,9 +26,11 @@ public final class Variant implements FormatWrapper { ...@@ -26,9 +26,11 @@ 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 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;
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);
} }
......
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