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
35cc479f
authored
Oct 04, 2018
by
Brandon Davis
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Create unique id for hls audio and text tracks
Combine groupId and name for uniqueness
parent
7849a5eb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
4 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 @
35cc479f
...
...
@@ -341,6 +341,7 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli
String
name
=
parseStringAttr
(
line
,
REGEX_NAME
,
variableDefinitions
);
String
language
=
parseOptionalStringAttr
(
line
,
REGEX_LANGUAGE
,
variableDefinitions
);
String
groupId
=
parseOptionalStringAttr
(
line
,
REGEX_GROUP_ID
,
variableDefinitions
);
String
id
=
String
.
format
(
"%s:%s"
,
groupId
,
name
);
Format
format
;
switch
(
parseStringAttr
(
line
,
REGEX_TYPE
,
variableDefinitions
))
{
case
TYPE_AUDIO:
...
...
@@ -348,7 +349,7 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli
String
sampleMimeType
=
codecs
!=
null
?
MimeTypes
.
getMediaMimeType
(
codecs
)
:
null
;
format
=
Format
.
createAudioContainerFormat
(
/* id= */
name
,
/* id= */
id
,
/* label= */
name
,
/* containerMimeType= */
MimeTypes
.
APPLICATION_M3U8
,
sampleMimeType
,
...
...
@@ -368,7 +369,7 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli
case
TYPE_SUBTITLES:
format
=
Format
.
createTextContainerFormat
(
/* id= */
name
,
/* id= */
id
,
/* label= */
name
,
/* containerMimeType= */
MimeTypes
.
APPLICATION_M3U8
,
/* sampleMimeType= */
MimeTypes
.
TEXT_VTT
,
...
...
@@ -394,7 +395,7 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli
}
muxedCaptionFormats
.
add
(
Format
.
createTextContainerFormat
(
/* id= */
name
,
/* id= */
id
,
/* label= */
name
,
/* containerMimeType= */
null
,
/* sampleMimeType= */
mimeType
,
...
...
library/hls/src/test/java/com/google/android/exoplayer2/source/hls/playlist/HlsMasterPlaylistParserTest.java
View file @
35cc479f
...
...
@@ -75,7 +75,7 @@ public class HlsMasterPlaylistParserTest {
private
static
final
String
PLAYLIST_WITH_CC
=
" #EXTM3U \n"
+
"#EXT-X-MEDIA:TYPE=CLOSED-CAPTIONS,"
+
"#EXT-X-MEDIA:TYPE=CLOSED-CAPTIONS,
GROUP-ID=\"cc1\",
"
+
"LANGUAGE=\"es\",NAME=\"Eng\",INSTREAM-ID=\"SERVICE4\"\n"
+
"#EXT-X-STREAM-INF:BANDWIDTH=1280000,"
+
"CODECS=\"mp4a.40.2,avc1.66.30\",RESOLUTION=304x128\n"
...
...
@@ -90,6 +90,14 @@ public class HlsMasterPlaylistParserTest {
+
"CLOSED-CAPTIONS=NONE\n"
+
"http://example.com/low.m3u8\n"
;
private
static
final
String
PLAYLIST_WITH_SUBTITLES
=
" #EXTM3U \n"
+
"#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID=\"sub1\","
+
"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_AUDIO_MEDIA_TAG
=
"#EXTM3U\n"
+
"#EXT-X-STREAM-INF:BANDWIDTH=2227464,CODECS=\"avc1.640020,mp4a.40.2\",AUDIO=\"aud1\"\n"
...
...
@@ -217,6 +225,33 @@ public class HlsMasterPlaylistParserTest {
}
@Test
public
void
testAudioIdPropagation
()
throws
IOException
{
HlsMasterPlaylist
playlist
=
parseMasterPlaylist
(
PLAYLIST_URI
,
PLAYLIST_WITH_AUDIO_MEDIA_TAG
);
Format
firstAudioFormat
=
playlist
.
audios
.
get
(
0
).
format
;
assertThat
(
firstAudioFormat
.
id
).
isEqualTo
(
"aud1:English"
);
Format
secondAudioFormat
=
playlist
.
audios
.
get
(
1
).
format
;
assertThat
(
secondAudioFormat
.
id
).
isEqualTo
(
"aud2:English"
);
}
@Test
public
void
testCCIdPropagation
()
throws
IOException
{
HlsMasterPlaylist
playlist
=
parseMasterPlaylist
(
PLAYLIST_URI
,
PLAYLIST_WITH_CC
);
Format
firstTextFormat
=
playlist
.
muxedCaptionFormats
.
get
(
0
);
assertThat
(
firstTextFormat
.
id
).
isEqualTo
(
"cc1:Eng"
);
}
@Test
public
void
testSubtitleIdPropagation
()
throws
IOException
{
HlsMasterPlaylist
playlist
=
parseMasterPlaylist
(
PLAYLIST_URI
,
PLAYLIST_WITH_SUBTITLES
);
Format
firstTextFormat
=
playlist
.
subtitles
.
get
(
0
).
format
;
assertThat
(
firstTextFormat
.
id
).
isEqualTo
(
"sub1:Eng"
);
}
@Test
public
void
testIndependentSegments
()
throws
IOException
{
HlsMasterPlaylist
playlistWithIndependentSegments
=
parseMasterPlaylist
(
PLAYLIST_URI
,
PLAYLIST_WITH_INDEPENDENT_SEGMENTS
);
...
...
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