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
861196a6
authored
Jul 25, 2022
by
bachinger
Committed by
Oliver Woodman
Jul 25, 2022
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Exclude Metadata from Format when bundling from TrackGroup
#minor-release PiperOrigin-RevId: 463062454
parent
46ab06b8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
8 deletions
library/common/src/main/java/com/google/android/exoplayer2/Format.java
library/common/src/main/java/com/google/android/exoplayer2/source/TrackGroup.java
library/common/src/test/java/com/google/android/exoplayer2/FormatTest.java
library/common/src/main/java/com/google/android/exoplayer2/Format.java
View file @
861196a6
...
@@ -1526,6 +1526,14 @@ public final class Format implements Bundleable {
...
@@ -1526,6 +1526,14 @@ public final class Format implements Bundleable {
@Override
@Override
public
Bundle
toBundle
()
{
public
Bundle
toBundle
()
{
return
toBundle
(
/* excludeMetadata= */
false
);
}
/**
* Returns a {@link Bundle} representing the information stored in this object. If {@code
* excludeMetadata} is true, {@linkplain Format#metadata metadata} is excluded.
*/
public
Bundle
toBundle
(
boolean
excludeMetadata
)
{
Bundle
bundle
=
new
Bundle
();
Bundle
bundle
=
new
Bundle
();
bundle
.
putString
(
keyForField
(
FIELD_ID
),
id
);
bundle
.
putString
(
keyForField
(
FIELD_ID
),
id
);
bundle
.
putString
(
keyForField
(
FIELD_LABEL
),
label
);
bundle
.
putString
(
keyForField
(
FIELD_LABEL
),
label
);
...
@@ -1535,10 +1543,10 @@ public final class Format implements Bundleable {
...
@@ -1535,10 +1543,10 @@ public final class Format implements Bundleable {
bundle
.
putInt
(
keyForField
(
FIELD_AVERAGE_BITRATE
),
averageBitrate
);
bundle
.
putInt
(
keyForField
(
FIELD_AVERAGE_BITRATE
),
averageBitrate
);
bundle
.
putInt
(
keyForField
(
FIELD_PEAK_BITRATE
),
peakBitrate
);
bundle
.
putInt
(
keyForField
(
FIELD_PEAK_BITRATE
),
peakBitrate
);
bundle
.
putString
(
keyForField
(
FIELD_CODECS
),
codecs
);
bundle
.
putString
(
keyForField
(
FIELD_CODECS
),
codecs
);
// Metadata is currently not Bundleable because Metadata.Entry is an Interface,
if
(!
excludeMetadata
)
{
// which would be difficult to unbundle in a backward compatible way.
// TODO (internal ref: b/239701618)
// The entries are additionally of limited usefulness to remote processes.
bundle
.
putParcelable
(
keyForField
(
FIELD_METADATA
),
metadata
);
bundle
.
putParcelable
(
keyForField
(
FIELD_METADATA
),
metadata
);
}
// Container specific.
// Container specific.
bundle
.
putString
(
keyForField
(
FIELD_CONTAINER_MIME_TYPE
),
containerMimeType
);
bundle
.
putString
(
keyForField
(
FIELD_CONTAINER_MIME_TYPE
),
containerMimeType
);
// Sample specific.
// Sample specific.
...
...
library/common/src/main/java/com/google/android/exoplayer2/source/TrackGroup.java
View file @
861196a6
...
@@ -30,11 +30,11 @@ import com.google.android.exoplayer2.util.BundleableUtil;
...
@@ -30,11 +30,11 @@ import com.google.android.exoplayer2.util.BundleableUtil;
import
com.google.android.exoplayer2.util.Log
;
import
com.google.android.exoplayer2.util.Log
;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
com.google.common.collect.ImmutableList
;
import
com.google.common.collect.ImmutableList
;
import
com.google.common.collect.Lists
;
import
java.lang.annotation.Documented
;
import
java.lang.annotation.Documented
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
import
java.lang.annotation.Target
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.List
;
...
@@ -177,8 +177,11 @@ public final class TrackGroup implements Bundleable {
...
@@ -177,8 +177,11 @@ public final class TrackGroup implements Bundleable {
@Override
@Override
public
Bundle
toBundle
()
{
public
Bundle
toBundle
()
{
Bundle
bundle
=
new
Bundle
();
Bundle
bundle
=
new
Bundle
();
bundle
.
putParcelableArrayList
(
ArrayList
<
Bundle
>
arrayList
=
new
ArrayList
<>(
formats
.
length
);
keyForField
(
FIELD_FORMATS
),
BundleableUtil
.
toBundleArrayList
(
Lists
.
newArrayList
(
formats
)));
for
(
Format
format
:
formats
)
{
arrayList
.
add
(
format
.
toBundle
(
/* excludeMetadata= */
true
));
}
bundle
.
putParcelableArrayList
(
keyForField
(
FIELD_FORMATS
),
arrayList
);
bundle
.
putString
(
keyForField
(
FIELD_ID
),
id
);
bundle
.
putString
(
keyForField
(
FIELD_ID
),
id
);
return
bundle
;
return
bundle
;
}
}
...
...
library/common/src/test/java/com/google/android/exoplayer2/FormatTest.java
View file @
861196a6
...
@@ -20,6 +20,7 @@ import static com.google.android.exoplayer2.util.MimeTypes.VIDEO_MP4;
...
@@ -20,6 +20,7 @@ import static com.google.android.exoplayer2.util.MimeTypes.VIDEO_MP4;
import
static
com
.
google
.
android
.
exoplayer2
.
util
.
MimeTypes
.
VIDEO_WEBM
;
import
static
com
.
google
.
android
.
exoplayer2
.
util
.
MimeTypes
.
VIDEO_WEBM
;
import
static
com
.
google
.
common
.
truth
.
Truth
.
assertThat
;
import
static
com
.
google
.
common
.
truth
.
Truth
.
assertThat
;
import
android.os.Bundle
;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
com.google.android.exoplayer2.drm.DrmInitData
;
import
com.google.android.exoplayer2.drm.DrmInitData
;
import
com.google.android.exoplayer2.metadata.Metadata
;
import
com.google.android.exoplayer2.metadata.Metadata
;
...
@@ -50,6 +51,16 @@ public final class FormatTest {
...
@@ -50,6 +51,16 @@ public final class FormatTest {
assertThat
(
formatFromBundle
).
isEqualTo
(
formatToBundle
);
assertThat
(
formatFromBundle
).
isEqualTo
(
formatToBundle
);
}
}
@Test
public
void
roundTripViaBundle_excludeMetadata_hasMetadataExcluded
()
{
Format
format
=
createTestFormat
();
Bundle
bundleWithMetadataExcluded
=
format
.
toBundle
(
/* excludeMetadata= */
true
);
Format
formatWithMetadataExcluded
=
Format
.
CREATOR
.
fromBundle
(
bundleWithMetadataExcluded
);
assertThat
(
formatWithMetadataExcluded
).
isEqualTo
(
format
.
buildUpon
().
setMetadata
(
null
).
build
());
}
private
static
Format
createTestFormat
()
{
private
static
Format
createTestFormat
()
{
byte
[]
initData1
=
new
byte
[]
{
1
,
2
,
3
};
byte
[]
initData1
=
new
byte
[]
{
1
,
2
,
3
};
byte
[]
initData2
=
new
byte
[]
{
4
,
5
,
6
};
byte
[]
initData2
=
new
byte
[]
{
4
,
5
,
6
};
...
@@ -64,7 +75,6 @@ public final class FormatTest {
...
@@ -64,7 +75,6 @@ public final class FormatTest {
DrmInitData
drmInitData
=
new
DrmInitData
(
drmData1
,
drmData2
);
DrmInitData
drmInitData
=
new
DrmInitData
(
drmData1
,
drmData2
);
byte
[]
projectionData
=
new
byte
[]
{
1
,
2
,
3
};
byte
[]
projectionData
=
new
byte
[]
{
1
,
2
,
3
};
Metadata
metadata
=
new
Metadata
(
new
FakeMetadataEntry
(
"id1"
),
new
FakeMetadataEntry
(
"id2"
));
Metadata
metadata
=
new
Metadata
(
new
FakeMetadataEntry
(
"id1"
),
new
FakeMetadataEntry
(
"id2"
));
ColorInfo
colorInfo
=
ColorInfo
colorInfo
=
...
...
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