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
c22fd76b
authored
Dec 16, 2020
by
christosts
Committed by
Ian Baker
Jan 11, 2021
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
HlsPlaylistParser: ignore subtitles without URI
Issue: #8323 PiperOrigin-RevId: 347827615
parent
d0e6dec1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
1 deletions
library/hls/src/main/java/com/google/android/exoplayer2/source/hls/playlist/HlsPlaylistParser.java
library/hls/src/test/java/com/google/android/exoplayer2/source/hls/playlist/HlsMasterPlaylistParserTest.java
library/hls/src/main/java/com/google/android/exoplayer2/source/hls/playlist/HlsPlaylistParser.java
View file @
c22fd76b
...
...
@@ -34,6 +34,7 @@ import com.google.android.exoplayer2.source.hls.playlist.HlsMasterPlaylist.Varia
import
com.google.android.exoplayer2.source.hls.playlist.HlsMediaPlaylist.Segment
;
import
com.google.android.exoplayer2.upstream.ParsingLoadable
;
import
com.google.android.exoplayer2.util.Assertions
;
import
com.google.android.exoplayer2.util.Log
;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
com.google.android.exoplayer2.util.UriUtil
;
import
com.google.android.exoplayer2.util.Util
;
...
...
@@ -61,6 +62,8 @@ import org.checkerframework.checker.nullness.qual.PolyNull;
*/
public
final
class
HlsPlaylistParser
implements
ParsingLoadable
.
Parser
<
HlsPlaylist
>
{
private
static
final
String
LOG_TAG
=
"HlsPlaylistParser"
;
private
static
final
String
PLAYLIST_HEADER
=
"#EXTM3U"
;
private
static
final
String
TAG_PREFIX
=
"#EXT"
;
...
...
@@ -480,7 +483,11 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli
sampleMimeType
=
MimeTypes
.
TEXT_VTT
;
}
formatBuilder
.
setSampleMimeType
(
sampleMimeType
).
setMetadata
(
metadata
);
subtitles
.
add
(
new
Rendition
(
uri
,
formatBuilder
.
build
(),
groupId
,
name
));
if
(
uri
!=
null
)
{
subtitles
.
add
(
new
Rendition
(
uri
,
formatBuilder
.
build
(),
groupId
,
name
));
}
else
{
Log
.
w
(
LOG_TAG
,
"EXT-X-MEDIA tag with missing mandatory URI attribute: skipping"
);
}
break
;
case
TYPE_CLOSED_CAPTIONS:
String
instreamId
=
parseStringAttr
(
line
,
REGEX_INSTREAM_ID
,
variableDefinitions
);
...
...
library/hls/src/test/java/com/google/android/exoplayer2/source/hls/playlist/HlsMasterPlaylistParserTest.java
View file @
c22fd76b
...
...
@@ -109,6 +109,14 @@ public class HlsMasterPlaylistParserTest {
private
static
final
String
PLAYLIST_WITH_SUBTITLES
=
" #EXTM3U \n"
+
"#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID=\"sub1\",URI=\"s1/en/prog_index.m3u8\","
+
"LANGUAGE=\"es\",NAME=\"Eng\"\n"
+
"#EXT-X-STREAM-INF:BANDWIDTH=1280000,"
+
"CODECS=\"mp4a.40.2,avc1.66.30\",RESOLUTION=304x128\n"
+
"http://example.com/low.m3u8\n"
;
private
static
final
String
PLAYLIST_WITH_SUBTITLES_NO_URI
=
" #EXTM3U \n"
+
"#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID=\"sub1\","
+
"LANGUAGE=\"es\",NAME=\"Eng\"\n"
+
"#EXT-X-STREAM-INF:BANDWIDTH=1280000,"
...
...
@@ -355,6 +363,13 @@ public class HlsMasterPlaylistParserTest {
}
@Test
public
void
parseMasterPlaylist_subtitlesWithoutUri_skipsSubtitles
()
throws
IOException
{
HlsMasterPlaylist
playlist
=
parseMasterPlaylist
(
PLAYLIST_URI
,
PLAYLIST_WITH_SUBTITLES_NO_URI
);
assertThat
(
playlist
.
subtitles
).
isEmpty
();
}
@Test
public
void
parseMasterPlaylist_withIndependentSegments_hasNoIndenpendentSegments
()
throws
IOException
{
HlsMasterPlaylist
playlistWithIndependentSegments
=
...
...
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