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
82b26357
authored
Aug 11, 2020
by
olly
Committed by
kim-vde
Aug 17, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Infer ISM content type from URL specified extension
PiperOrigin-RevId: 326012248
parent
443468d1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
4 deletions
library/common/src/main/java/com/google/android/exoplayer2/util/Util.java
library/common/src/test/java/com/google/android/exoplayer2/util/UtilTest.java
library/common/src/main/java/com/google/android/exoplayer2/util/Util.java
View file @
82b26357
...
@@ -141,6 +141,12 @@ public final class Util {
...
@@ -141,6 +141,12 @@ public final class Util {
+
"(T(([0-9]*)H)?(([0-9]*)M)?(([0-9.]*)S)?)?$"
);
+
"(T(([0-9]*)H)?(([0-9]*)M)?(([0-9.]*)S)?)?$"
);
private
static
final
Pattern
ESCAPED_CHARACTER_PATTERN
=
Pattern
.
compile
(
"%([A-Fa-f0-9]{2})"
);
private
static
final
Pattern
ESCAPED_CHARACTER_PATTERN
=
Pattern
.
compile
(
"%([A-Fa-f0-9]{2})"
);
// https://docs.microsoft.com/en-us/azure/media-services/previous/media-services-deliver-content-overview#URLs.
private
static
final
Pattern
ISM_URL_PATTERN
=
Pattern
.
compile
(
".*\\.ism(?:l)?(?:/(?:manifest(?:\\((.+)\\))?)?)?"
);
private
static
final
String
ISM_HLS_FORMAT_EXTENSION
=
"format=m3u8-aapl"
;
private
static
final
String
ISM_DASH_FORMAT_EXTENSION
=
"format=mpd-time-csf"
;
// Replacement map of ISO language codes used for normalization.
// Replacement map of ISO language codes used for normalization.
@Nullable
private
static
HashMap
<
String
,
String
>
languageTagReplacementMap
;
@Nullable
private
static
HashMap
<
String
,
String
>
languageTagReplacementMap
;
...
@@ -1714,11 +1720,20 @@ public final class Util {
...
@@ -1714,11 +1720,20 @@ public final class Util {
return
C
.
TYPE_DASH
;
return
C
.
TYPE_DASH
;
}
else
if
(
fileName
.
endsWith
(
".m3u8"
))
{
}
else
if
(
fileName
.
endsWith
(
".m3u8"
))
{
return
C
.
TYPE_HLS
;
return
C
.
TYPE_HLS
;
}
else
if
(
fileName
.
matches
(
".*\\.ism(l)?(/manifest(\\(.+\\))?)?"
))
{
}
Matcher
ismMatcher
=
ISM_URL_PATTERN
.
matcher
(
fileName
);
if
(
ismMatcher
.
matches
())
{
@Nullable
String
extensions
=
ismMatcher
.
group
(
1
);
if
(
extensions
!=
null
)
{
if
(
extensions
.
contains
(
ISM_DASH_FORMAT_EXTENSION
))
{
return
C
.
TYPE_DASH
;
}
else
if
(
extensions
.
contains
(
ISM_HLS_FORMAT_EXTENSION
))
{
return
C
.
TYPE_HLS
;
}
}
return
C
.
TYPE_SS
;
return
C
.
TYPE_SS
;
}
else
{
return
C
.
TYPE_OTHER
;
}
}
return
C
.
TYPE_OTHER
;
}
}
/**
/**
...
...
library/common/src/test/java/com/google/android/exoplayer2/util/UtilTest.java
View file @
82b26357
...
@@ -89,13 +89,49 @@ public class UtilTest {
...
@@ -89,13 +89,49 @@ public class UtilTest {
}
}
@Test
@Test
public
void
inferContentType_returnsInferredResult
()
{
public
void
inferContentType_handlesHlsIsmUris
()
{
assertThat
(
Util
.
inferContentType
(
"http://a.b/c.ism/manifest(format=m3u8-aapl)"
))
.
isEqualTo
(
C
.
TYPE_HLS
);
assertThat
(
Util
.
inferContentType
(
"http://a.b/c.ism/manifest(format=m3u8-aapl,quality=hd)"
))
.
isEqualTo
(
C
.
TYPE_HLS
);
assertThat
(
Util
.
inferContentType
(
"http://a.b/c.ism/manifest(quality=hd,format=m3u8-aapl)"
))
.
isEqualTo
(
C
.
TYPE_HLS
);
}
@Test
public
void
inferContentType_handlesHlsIsmV3Uris
()
{
assertThat
(
Util
.
inferContentType
(
"http://a.b/c.ism/manifest(format=m3u8-aapl-v3)"
))
.
isEqualTo
(
C
.
TYPE_HLS
);
assertThat
(
Util
.
inferContentType
(
"http://a.b/c.ism/manifest(format=m3u8-aapl-v3,quality=hd)"
))
.
isEqualTo
(
C
.
TYPE_HLS
);
assertThat
(
Util
.
inferContentType
(
"http://a.b/c.ism/manifest(quality=hd,format=m3u8-aapl-v3)"
))
.
isEqualTo
(
C
.
TYPE_HLS
);
}
@Test
public
void
inferContentType_handlesDashIsmUris
()
{
assertThat
(
Util
.
inferContentType
(
"http://a.b/c.isml/manifest(format=mpd-time-csf)"
))
.
isEqualTo
(
C
.
TYPE_DASH
);
assertThat
(
Util
.
inferContentType
(
"http://a.b/c.isml/manifest(format=mpd-time-csf,quality=hd)"
))
.
isEqualTo
(
C
.
TYPE_DASH
);
assertThat
(
Util
.
inferContentType
(
"http://a.b/c.isml/manifest(quality=hd,format=mpd-time-csf)"
))
.
isEqualTo
(
C
.
TYPE_DASH
);
}
@Test
public
void
inferContentType_handlesSmoothStreamingIsmUris
()
{
assertThat
(
Util
.
inferContentType
(
"http://a.b/c.ism"
)).
isEqualTo
(
C
.
TYPE_SS
);
assertThat
(
Util
.
inferContentType
(
"http://a.b/c.ism"
)).
isEqualTo
(
C
.
TYPE_SS
);
assertThat
(
Util
.
inferContentType
(
"http://a.b/c.isml"
)).
isEqualTo
(
C
.
TYPE_SS
);
assertThat
(
Util
.
inferContentType
(
"http://a.b/c.isml"
)).
isEqualTo
(
C
.
TYPE_SS
);
assertThat
(
Util
.
inferContentType
(
"http://a.b/c.ism/"
)).
isEqualTo
(
C
.
TYPE_SS
);
assertThat
(
Util
.
inferContentType
(
"http://a.b/c.isml/"
)).
isEqualTo
(
C
.
TYPE_SS
);
assertThat
(
Util
.
inferContentType
(
"http://a.b/c.ism/Manifest"
)).
isEqualTo
(
C
.
TYPE_SS
);
assertThat
(
Util
.
inferContentType
(
"http://a.b/c.ism/Manifest"
)).
isEqualTo
(
C
.
TYPE_SS
);
assertThat
(
Util
.
inferContentType
(
"http://a.b/c.isml/manifest"
)).
isEqualTo
(
C
.
TYPE_SS
);
assertThat
(
Util
.
inferContentType
(
"http://a.b/c.isml/manifest"
)).
isEqualTo
(
C
.
TYPE_SS
);
assertThat
(
Util
.
inferContentType
(
"http://a.b/c.isml/manifest(filter=x)"
)).
isEqualTo
(
C
.
TYPE_SS
);
assertThat
(
Util
.
inferContentType
(
"http://a.b/c.isml/manifest(filter=x)"
)).
isEqualTo
(
C
.
TYPE_SS
);
}
@Test
public
void
inferContentType_handlesOtherIsmUris
()
{
assertThat
(
Util
.
inferContentType
(
"http://a.b/c.ism/video.mp4"
)).
isEqualTo
(
C
.
TYPE_OTHER
);
assertThat
(
Util
.
inferContentType
(
"http://a.b/c.ism/prefix-manifest"
)).
isEqualTo
(
C
.
TYPE_OTHER
);
assertThat
(
Util
.
inferContentType
(
"http://a.b/c.ism/prefix-manifest"
)).
isEqualTo
(
C
.
TYPE_OTHER
);
assertThat
(
Util
.
inferContentType
(
"http://a.b/c.ism/manifest-suffix"
)).
isEqualTo
(
C
.
TYPE_OTHER
);
assertThat
(
Util
.
inferContentType
(
"http://a.b/c.ism/manifest-suffix"
)).
isEqualTo
(
C
.
TYPE_OTHER
);
}
}
...
...
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