Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
ffc925f1
authored
Oct 28, 2015
by
ojw28
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge pull request #885 from RikHeijdens/parse-hls-name-label
Parse HLS NAME label from the MasterPlaylist
parents
b9224160
d49d3e2c
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
6 deletions
library/src/main/java/com/google/android/exoplayer/hls/HlsChunkSource.java
library/src/main/java/com/google/android/exoplayer/hls/HlsPlaylistParser.java
library/src/main/java/com/google/android/exoplayer/hls/Variant.java
library/src/main/java/com/google/android/exoplayer/hls/HlsChunkSource.java
View file @
ffc925f1
...
...
@@ -184,7 +184,7 @@ public class HlsChunkSource {
playlistParser
=
new
HlsPlaylistParser
();
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
];
variantLastPlaylistLoadTimesMs
=
new
long
[
1
];
variantBlacklistTimes
=
new
long
[
1
];
...
...
library/src/main/java/com/google/android/exoplayer/hls/HlsPlaylistParser.java
View file @
ffc925f1
...
...
@@ -143,6 +143,7 @@ public final class HlsPlaylistParser implements UriLoadable.Parser<HlsPlaylist>
String
codecs
=
null
;
int
width
=
-
1
;
int
height
=
-
1
;
String
name
=
null
;
boolean
expectingStreamInfUrl
=
false
;
String
line
;
...
...
@@ -152,18 +153,19 @@ public final class HlsPlaylistParser implements UriLoadable.Parser<HlsPlaylist>
String
type
=
HlsParserUtil
.
parseStringAttr
(
line
,
TYPE_ATTR_REGEX
,
TYPE_ATTR
);
if
(
SUBTITLES_TYPE
.
equals
(
type
))
{
// We assume all subtitles belong to the same group.
String
n
ame
=
HlsParserUtil
.
parseStringAttr
(
line
,
NAME_ATTR_REGEX
,
NAME_ATTR
);
String
subtitleN
ame
=
HlsParserUtil
.
parseStringAttr
(
line
,
NAME_ATTR_REGEX
,
NAME_ATTR
);
String
uri
=
HlsParserUtil
.
parseStringAttr
(
line
,
URI_ATTR_REGEX
,
URI_ATTR
);
String
language
=
HlsParserUtil
.
parseOptionalStringAttr
(
line
,
LANGUAGE_ATTR_REGEX
);
boolean
isDefault
=
HlsParserUtil
.
parseOptionalBooleanAttr
(
line
,
DEFAULT_ATTR_REGEX
);
boolean
autoSelect
=
HlsParserUtil
.
parseOptionalBooleanAttr
(
line
,
AUTOSELECT_ATTR_REGEX
);
subtitles
.
add
(
new
Subtitle
(
n
ame
,
uri
,
language
,
isDefault
,
autoSelect
));
subtitles
.
add
(
new
Subtitle
(
subtitleN
ame
,
uri
,
language
,
isDefault
,
autoSelect
));
}
else
{
// TODO: Support other types of media tag.
}
}
else
if
(
line
.
startsWith
(
STREAM_INF_TAG
))
{
bitrate
=
HlsParserUtil
.
parseIntAttr
(
line
,
BANDWIDTH_ATTR_REGEX
,
BANDWIDTH_ATTR
);
codecs
=
HlsParserUtil
.
parseOptionalStringAttr
(
line
,
CODECS_ATTR_REGEX
);
name
=
HlsParserUtil
.
parseOptionalStringAttr
(
line
,
NAME_ATTR_REGEX
);
String
resolutionString
=
HlsParserUtil
.
parseOptionalStringAttr
(
line
,
RESOLUTION_ATTR_REGEX
);
if
(
resolutionString
!=
null
)
{
...
...
@@ -184,9 +186,10 @@ public final class HlsPlaylistParser implements UriLoadable.Parser<HlsPlaylist>
}
expectingStreamInfUrl
=
true
;
}
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
;
codecs
=
null
;
name
=
null
;
width
=
-
1
;
height
=
-
1
;
expectingStreamInfUrl
=
false
;
...
...
library/src/main/java/com/google/android/exoplayer/hls/Variant.java
View file @
ffc925f1
...
...
@@ -26,10 +26,13 @@ public final class Variant implements FormatWrapper {
public
final
String
url
;
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
;
format
=
new
Format
(
Integer
.
toString
(
index
),
MimeTypes
.
APPLICATION_M3U8
,
width
,
height
,
-
1
,
-
1
,
this
.
name
=
name
;
String
formatName
=
name
!=
null
?
name
:
Integer
.
toString
(
index
);
format
=
new
Format
(
formatName
,
MimeTypes
.
APPLICATION_M3U8
,
width
,
height
,
-
1
,
-
1
,
-
1
,
bitrate
,
null
,
codecs
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment