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
585b0bdd
authored
Oct 05, 2021
by
olly
Committed by
Oliver Woodman
Oct 06, 2021
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
DASH: Set MIME, width and height for image adaptation sets
Issue: #9500 PiperOrigin-RevId: 401091261
parent
03ff5b66
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
76 additions
and
0 deletions
RELEASENOTES.md
library/common/src/main/java/com/google/android/exoplayer2/util/MimeTypes.java
library/common/src/test/java/com/google/android/exoplayer2/util/MimeTypesTest.java
library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/DashManifestParser.java
library/dash/src/test/java/com/google/android/exoplayer2/source/dash/manifest/DashManifestParserTest.java
testdata/src/test/assets/media/mpd/sample_mpd_images
RELEASENOTES.md
View file @
585b0bdd
...
...
@@ -57,6 +57,10 @@
*
RTSP:
*
Support RFC4566 SDP attribute field grammar
(
[
#9430
](
https://github.com/google/ExoPlayer/issues/9430
)
).
*
DASH:
*
Populate
`Format.sampleMimeType`
,
`width`
and
`height`
for image
`AdaptationSet`
elements
(
[
#9500
](
https://github.com/google/ExoPlayer/issues/9500
)
).
*
Remove deprecated symbols:
*
Remove
`Renderer.VIDEO_SCALING_MODE_*`
constants. Use identically named
constants in
`C`
instead.
...
...
library/common/src/main/java/com/google/android/exoplayer2/util/MimeTypes.java
View file @
585b0bdd
...
...
@@ -201,6 +201,11 @@ public final class MimeTypes {
||
APPLICATION_DVBSUBS
.
equals
(
mimeType
);
}
/** Returns whether the given string is an image MIME type. */
public
static
boolean
isImage
(
@Nullable
String
mimeType
)
{
return
BASE_TYPE_IMAGE
.
equals
(
getTopLevelType
(
mimeType
));
}
/**
* Returns true if it is known that all samples in a stream of the given MIME type and codec are
* guaranteed to be sync samples (i.e., {@link C#BUFFER_FLAG_KEY_FRAME} is guaranteed to be set on
...
...
@@ -505,6 +510,8 @@ public final class MimeTypes {
return
C
.
TRACK_TYPE_VIDEO
;
}
else
if
(
isText
(
mimeType
))
{
return
C
.
TRACK_TYPE_TEXT
;
}
else
if
(
isImage
(
mimeType
))
{
return
C
.
TRACK_TYPE_IMAGE
;
}
else
if
(
APPLICATION_ID3
.
equals
(
mimeType
)
||
APPLICATION_EMSG
.
equals
(
mimeType
)
||
APPLICATION_SCTE35
.
equals
(
mimeType
))
{
...
...
library/common/src/test/java/com/google/android/exoplayer2/util/MimeTypesTest.java
View file @
585b0bdd
...
...
@@ -21,6 +21,7 @@ import static com.google.common.truth.Truth.assertThat;
import
androidx.annotation.Nullable
;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
com.google.android.exoplayer2.C
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
...
...
@@ -115,6 +116,36 @@ public final class MimeTypesTest {
}
@Test
public
void
isImage_returnsCorrectResult
()
{
assertThat
(
MimeTypes
.
isImage
(
MimeTypes
.
IMAGE_JPEG
)).
isTrue
();
assertThat
(
MimeTypes
.
isImage
(
"image/custom"
)).
isTrue
();
assertThat
(
MimeTypes
.
isImage
(
MimeTypes
.
VIDEO_MP4
)).
isFalse
();
assertThat
(
MimeTypes
.
isImage
(
"application/custom"
)).
isFalse
();
}
@Test
public
void
getTrackType_returnsCorrectResult
()
{
assertThat
(
MimeTypes
.
getTrackType
(
MimeTypes
.
VIDEO_H264
)).
isEqualTo
(
C
.
TRACK_TYPE_VIDEO
);
assertThat
(
MimeTypes
.
getTrackType
(
"video/custom"
)).
isEqualTo
(
C
.
TRACK_TYPE_VIDEO
);
assertThat
(
MimeTypes
.
getTrackType
(
MimeTypes
.
AUDIO_AAC
)).
isEqualTo
(
C
.
TRACK_TYPE_AUDIO
);
assertThat
(
MimeTypes
.
getTrackType
(
"audio/custom"
)).
isEqualTo
(
C
.
TRACK_TYPE_AUDIO
);
assertThat
(
MimeTypes
.
getTrackType
(
MimeTypes
.
TEXT_SSA
)).
isEqualTo
(
C
.
TRACK_TYPE_TEXT
);
assertThat
(
MimeTypes
.
getTrackType
(
"text/custom"
)).
isEqualTo
(
C
.
TRACK_TYPE_TEXT
);
assertThat
(
MimeTypes
.
getTrackType
(
MimeTypes
.
IMAGE_JPEG
)).
isEqualTo
(
C
.
TRACK_TYPE_IMAGE
);
assertThat
(
MimeTypes
.
getTrackType
(
"image/custom"
)).
isEqualTo
(
C
.
TRACK_TYPE_IMAGE
);
assertThat
(
MimeTypes
.
getTrackType
(
MimeTypes
.
APPLICATION_CEA608
)).
isEqualTo
(
C
.
TRACK_TYPE_TEXT
);
assertThat
(
MimeTypes
.
getTrackType
(
MimeTypes
.
APPLICATION_EMSG
)).
isEqualTo
(
C
.
TRACK_TYPE_METADATA
);
assertThat
(
MimeTypes
.
getTrackType
(
MimeTypes
.
APPLICATION_CAMERA_MOTION
))
.
isEqualTo
(
C
.
TRACK_TYPE_CAMERA_MOTION
);
assertThat
(
MimeTypes
.
getTrackType
(
"application/custom"
)).
isEqualTo
(
C
.
TRACK_TYPE_UNKNOWN
);
}
@Test
public
void
getMediaMimeType_fromValidCodecs_returnsCorrectMimeType
()
{
assertThat
(
MimeTypes
.
getMediaMimeType
(
"avc1"
)).
isEqualTo
(
MimeTypes
.
VIDEO_H264
);
assertThat
(
MimeTypes
.
getMediaMimeType
(
"avc1.42E01E"
)).
isEqualTo
(
MimeTypes
.
VIDEO_H264
);
...
...
library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/DashManifestParser.java
View file @
585b0bdd
...
...
@@ -807,6 +807,8 @@ public class DashManifestParser extends DefaultHandler
accessibilityChannel
=
parseCea708AccessibilityChannel
(
accessibilityDescriptors
);
}
formatBuilder
.
setAccessibilityChannel
(
accessibilityChannel
);
}
else
if
(
MimeTypes
.
isImage
(
sampleMimeType
))
{
formatBuilder
.
setWidth
(
width
).
setHeight
(
height
);
}
return
formatBuilder
.
build
();
...
...
@@ -1635,6 +1637,9 @@ public class DashManifestParser extends DefaultHandler
}
// All other text types are raw formats.
return
containerMimeType
;
}
else
if
(
MimeTypes
.
isImage
(
containerMimeType
))
{
// Image types are raw formats.
return
containerMimeType
;
}
else
if
(
MimeTypes
.
APPLICATION_MP4
.
equals
(
containerMimeType
))
{
@Nullable
String
mimeType
=
MimeTypes
.
getMediaMimeType
(
codecs
);
return
MimeTypes
.
TEXT_VTT
.
equals
(
mimeType
)
?
MimeTypes
.
APPLICATION_MP4VTT
:
mimeType
;
...
...
library/dash/src/test/java/com/google/android/exoplayer2/source/dash/manifest/DashManifestParserTest.java
View file @
585b0bdd
...
...
@@ -48,6 +48,7 @@ public class DashManifestParserTest {
"media/mpd/sample_mpd_unknown_mime_type"
;
private
static
final
String
SAMPLE_MPD_SEGMENT_TEMPLATE
=
"media/mpd/sample_mpd_segment_template"
;
private
static
final
String
SAMPLE_MPD_EVENT_STREAM
=
"media/mpd/sample_mpd_event_stream"
;
private
static
final
String
SAMPLE_MPD_IMAGES
=
"media/mpd/sample_mpd_images"
;
private
static
final
String
SAMPLE_MPD_LABELS
=
"media/mpd/sample_mpd_labels"
;
private
static
final
String
SAMPLE_MPD_ASSET_IDENTIFIER
=
"media/mpd/sample_mpd_asset_identifier"
;
private
static
final
String
SAMPLE_MPD_TEXT
=
"media/mpd/sample_mpd_text"
;
...
...
@@ -193,6 +194,23 @@ public class DashManifestParserTest {
}
@Test
public
void
parseMediaPresentationDescription_images
()
throws
IOException
{
DashManifestParser
parser
=
new
DashManifestParser
();
DashManifest
manifest
=
parser
.
parse
(
Uri
.
parse
(
"https://example.com/test.mpd"
),
TestUtil
.
getInputStream
(
ApplicationProvider
.
getApplicationContext
(),
SAMPLE_MPD_IMAGES
));
AdaptationSet
adaptationSet
=
manifest
.
getPeriod
(
0
).
adaptationSets
.
get
(
0
);
Format
format
=
adaptationSet
.
representations
.
get
(
0
).
format
;
assertThat
(
format
.
sampleMimeType
).
isEqualTo
(
"image/jpeg"
);
assertThat
(
format
.
width
).
isEqualTo
(
320
);
assertThat
(
format
.
height
).
isEqualTo
(
180
);
}
@Test
public
void
parseMediaPresentationDescription_labels
()
throws
IOException
{
DashManifestParser
parser
=
new
DashManifestParser
();
DashManifest
manifest
=
...
...
testdata/src/test/assets/media/mpd/sample_mpd_images
0 → 100644
View file @
585b0bdd
<?xml version="1.0" encoding="UTF-8"?>
<MPD
type=
"static"
duration=
"1s"
mediaPresentationDuration=
"PT1000S"
>
<Period>
<AdaptationSet
id=
"3"
mimeType=
"image/jpeg"
contentType=
"image"
>
<SegmentTemplate
media=
"$RepresentationID$/tile_$Number$.jpg"
duration=
"100"
startNumber=
"1"
/>
<Representation
bandwidth=
"1234"
id=
"images_320x180"
width=
"320"
height=
"180"
>
<EssentialProperty
schemeIdUri=
"http://dashif.org/thumbnail_tile"
value=
"title"
/>
</Representation>
</AdaptationSet>
</Period>
</MPD>
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