diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 01fc0e3415..2d6a63b5ee 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -3,6 +3,8 @@ ### Unreleased changes * Common Library: + * Remove `Format.toBundle(boolean excludeMetadata)` method, use + `Format.toBundle()` instead. * ExoPlayer: * Consider language when selecting a video track. By default select a 'main' video track that matches the language of the selected audio diff --git a/libraries/common/src/main/java/androidx/media3/common/Format.java b/libraries/common/src/main/java/androidx/media3/common/Format.java index de98f9b63a..cfbfb3e4d7 100644 --- a/libraries/common/src/main/java/androidx/media3/common/Format.java +++ b/libraries/common/src/main/java/androidx/media3/common/Format.java @@ -1496,7 +1496,8 @@ public final class Format { private static final String FIELD_AVERAGE_BITRATE = Util.intToStringMaxRadix(5); private static final String FIELD_PEAK_BITRATE = Util.intToStringMaxRadix(6); private static final String FIELD_CODECS = Util.intToStringMaxRadix(7); - private static final String FIELD_METADATA = Util.intToStringMaxRadix(8); + // Do not reuse this key. + private static final String UNUSED_FIELD_METADATA = Util.intToStringMaxRadix(8); private static final String FIELD_CONTAINER_MIME_TYPE = Util.intToStringMaxRadix(9); private static final String FIELD_SAMPLE_MIME_TYPE = Util.intToStringMaxRadix(10); private static final String FIELD_MAX_INPUT_SIZE = Util.intToStringMaxRadix(11); @@ -1523,21 +1524,12 @@ public final class Format { private static final String FIELD_LABELS = Util.intToStringMaxRadix(32); private static final String FIELD_AUXILIARY_TRACK_TYPE = Util.intToStringMaxRadix(33); - /** - * @deprecated Use {@link #toBundle(boolean)} instead. - */ - @UnstableApi - @Deprecated - 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. */ @UnstableApi - public Bundle toBundle(boolean excludeMetadata) { + public Bundle toBundle() { Bundle bundle = new Bundle(); bundle.putString(FIELD_ID, id); bundle.putString(FIELD_LABEL, label); @@ -1552,10 +1544,7 @@ public final class Format { bundle.putInt(FIELD_AVERAGE_BITRATE, averageBitrate); bundle.putInt(FIELD_PEAK_BITRATE, peakBitrate); bundle.putString(FIELD_CODECS, codecs); - if (!excludeMetadata) { - // TODO (internal ref: b/239701618) - bundle.putParcelable(FIELD_METADATA, metadata); - } + // The metadata does not implement toBundle() method, hence can not be added. // Container specific. bundle.putString(FIELD_CONTAINER_MIME_TYPE, containerMimeType); // Sample specific. @@ -1618,7 +1607,6 @@ public final class Format { .setAverageBitrate(bundle.getInt(FIELD_AVERAGE_BITRATE, DEFAULT.averageBitrate)) .setPeakBitrate(bundle.getInt(FIELD_PEAK_BITRATE, DEFAULT.peakBitrate)) .setCodecs(defaultIfNull(bundle.getString(FIELD_CODECS), DEFAULT.codecs)) - .setMetadata(defaultIfNull(bundle.getParcelable(FIELD_METADATA), DEFAULT.metadata)) // Container specific. .setContainerMimeType( defaultIfNull(bundle.getString(FIELD_CONTAINER_MIME_TYPE), DEFAULT.containerMimeType)) diff --git a/libraries/common/src/main/java/androidx/media3/common/TrackGroup.java b/libraries/common/src/main/java/androidx/media3/common/TrackGroup.java index 0b7eeb4e1e..e500b259d9 100644 --- a/libraries/common/src/main/java/androidx/media3/common/TrackGroup.java +++ b/libraries/common/src/main/java/androidx/media3/common/TrackGroup.java @@ -169,7 +169,7 @@ public final class TrackGroup { Bundle bundle = new Bundle(); ArrayList arrayList = new ArrayList<>(formats.length); for (Format format : formats) { - arrayList.add(format.toBundle(/* excludeMetadata= */ true)); + arrayList.add(format.toBundle()); } bundle.putParcelableArrayList(FIELD_FORMATS, arrayList); bundle.putString(FIELD_ID, id); diff --git a/libraries/common/src/test/java/androidx/media3/common/FormatTest.java b/libraries/common/src/test/java/androidx/media3/common/FormatTest.java index 8f1a618f3d..4f89bd847a 100644 --- a/libraries/common/src/test/java/androidx/media3/common/FormatTest.java +++ b/libraries/common/src/test/java/androidx/media3/common/FormatTest.java @@ -43,22 +43,10 @@ public final class FormatTest { } @Test - public void roundTripViaBundle_includeMetadata_includesAllBundledFields() { - Format formatToBundle = createTestFormat(); - - Format formatFromBundle = - Format.fromBundle(formatToBundle.toBundle(/* excludeMetadata= */ false)); - - // Expect all data to be bundled except the custom data. - Format expectedRoundTripFormat = formatToBundle.buildUpon().setCustomData(null).build(); - assertThat(formatFromBundle).isEqualTo(expectedRoundTripFormat); - } - - @Test - public void roundTripViaBundle_excludeMetadata_includesAllBundledFieldsExceptMetadata() { + public void roundTripViaBundle_includesAllBundledFieldsExceptMetadata() { Format format = createTestFormat(); - Format formatFromBundle = Format.fromBundle(format.toBundle(/* excludeMetadata= */ true)); + Format formatFromBundle = Format.fromBundle(format.toBundle()); // Expect all data to be bundled except the custom data and metadata. Format expectedRoundTripFormat =