Addressing PR feedback.
This commit is contained in:
parent
591020065a
commit
0a04e7908b
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,6 +1,6 @@
|
|||||||
#Tue Jan 30 08:51:00 MST 2024
|
#Tue Jan 30 08:51:00 MST 2024
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
@ -25,6 +25,7 @@ import androidx.media3.common.util.BundleCollectionUtil;
|
|||||||
import androidx.media3.common.util.UnstableApi;
|
import androidx.media3.common.util.UnstableApi;
|
||||||
import androidx.media3.common.util.Util;
|
import androidx.media3.common.util.Util;
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.errorprone.annotations.CanIgnoreReturnValue;
|
import com.google.errorprone.annotations.CanIgnoreReturnValue;
|
||||||
import java.lang.annotation.Documented;
|
import java.lang.annotation.Documented;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
@ -955,8 +956,12 @@ public final class Format implements Bundleable {
|
|||||||
labels = builder.labels == null ? new ArrayList<>() : builder.labels;
|
labels = builder.labels == null ? new ArrayList<>() : builder.labels;
|
||||||
if (labels.isEmpty() && !TextUtils.isEmpty(tmpLabel)) {
|
if (labels.isEmpty() && !TextUtils.isEmpty(tmpLabel)) {
|
||||||
labels.add(new Label(language, tmpLabel));
|
labels.add(new Label(language, tmpLabel));
|
||||||
|
label = tmpLabel;
|
||||||
|
} else if (!labels.isEmpty() && TextUtils.isEmpty(tmpLabel)) {
|
||||||
|
label = getDefaultLabel(tmpLabel, labels);
|
||||||
|
} else {
|
||||||
|
label = tmpLabel;
|
||||||
}
|
}
|
||||||
label = makeLabelIfNeeded(tmpLabel, labels);
|
|
||||||
checkLabels(label, labels);
|
checkLabels(label, labels);
|
||||||
selectionFlags = builder.selectionFlags;
|
selectionFlags = builder.selectionFlags;
|
||||||
roleFlags = builder.roleFlags;
|
roleFlags = builder.roleFlags;
|
||||||
@ -1005,7 +1010,7 @@ public final class Format implements Bundleable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private @Nullable String makeLabelIfNeeded(@Nullable String label, List<Label> labels) {
|
private @Nullable String getDefaultLabel(@Nullable String label, List<Label> labels) {
|
||||||
if (TextUtils.isEmpty(label)) {
|
if (TextUtils.isEmpty(label)) {
|
||||||
for (Label l : labels) {
|
for (Label l : labels) {
|
||||||
if (TextUtils.equals(l.lang, language)) {
|
if (TextUtils.equals(l.lang, language)) {
|
||||||
@ -1162,7 +1167,7 @@ public final class Format implements Bundleable {
|
|||||||
int result = 17;
|
int result = 17;
|
||||||
result = 31 * result + (id == null ? 0 : id.hashCode());
|
result = 31 * result + (id == null ? 0 : id.hashCode());
|
||||||
result = 31 * result + (label == null ? 0 : label.hashCode());
|
result = 31 * result + (label == null ? 0 : label.hashCode());
|
||||||
// [Omitted] labels.
|
result = 31 * result + labels.hashCode();
|
||||||
result = 31 * result + (language == null ? 0 : language.hashCode());
|
result = 31 * result + (language == null ? 0 : language.hashCode());
|
||||||
result = 31 * result + selectionFlags;
|
result = 31 * result + selectionFlags;
|
||||||
result = 31 * result + roleFlags;
|
result = 31 * result + roleFlags;
|
||||||
@ -1250,7 +1255,7 @@ public final class Format implements Bundleable {
|
|||||||
&& Util.areEqual(colorInfo, other.colorInfo)
|
&& Util.areEqual(colorInfo, other.colorInfo)
|
||||||
&& Util.areEqual(drmInitData, other.drmInitData)
|
&& Util.areEqual(drmInitData, other.drmInitData)
|
||||||
&& initializationDataEquals(other)
|
&& initializationDataEquals(other)
|
||||||
&& labelsEquals(other);
|
&& labels.equals(other.labels);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1274,32 +1279,6 @@ public final class Format implements Bundleable {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether the {@link #labels}s belonging to this format and {@code other} are equal.
|
|
||||||
*
|
|
||||||
* @param other The other format whose {@link #labels} is being compared.
|
|
||||||
* @return Whether the {@link #labels} belonging to this format and {@code other} are equal.
|
|
||||||
*/
|
|
||||||
@UnstableApi
|
|
||||||
public boolean labelsEquals(Format other) {
|
|
||||||
if ((labels == null && other.labels != null) || (labels != null && other.labels == null)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (labels == null && other.labels == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (labels.size() != other.labels.size()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
for (int i = 0; i < labels.size(); i++) {
|
|
||||||
if (!Util.areEqual(labels.get(i), other.labels.get(i))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Utility methods
|
// Utility methods
|
||||||
|
|
||||||
/** Returns a prettier {@link String} than {@link #toString()}, intended for logging. */
|
/** Returns a prettier {@link String} than {@link #toString()}, intended for logging. */
|
||||||
@ -1362,7 +1341,7 @@ public final class Format implements Bundleable {
|
|||||||
if (format.label != null) {
|
if (format.label != null) {
|
||||||
builder.append(", label=").append(format.label);
|
builder.append(", label=").append(format.label);
|
||||||
}
|
}
|
||||||
if (format.labels != null) {
|
if (format.labels.size() > 0) {
|
||||||
builder.append(", labels=[");
|
builder.append(", labels=[");
|
||||||
Joiner.on(',').appendTo(builder, format.labels);
|
Joiner.on(',').appendTo(builder, format.labels);
|
||||||
builder.append("]");
|
builder.append("]");
|
||||||
@ -1384,37 +1363,37 @@ public final class Format implements Bundleable {
|
|||||||
|
|
||||||
private static final String FIELD_ID = Util.intToStringMaxRadix(0);
|
private static final String FIELD_ID = Util.intToStringMaxRadix(0);
|
||||||
private static final String FIELD_LABEL = Util.intToStringMaxRadix(1);
|
private static final String FIELD_LABEL = Util.intToStringMaxRadix(1);
|
||||||
private static final String FIELD_LABELS = Util.intToStringMaxRadix(2);
|
private static final String FIELD_LANGUAGE = Util.intToStringMaxRadix(2);
|
||||||
private static final String FIELD_LANGUAGE = Util.intToStringMaxRadix(3);
|
private static final String FIELD_SELECTION_FLAGS = Util.intToStringMaxRadix(3);
|
||||||
private static final String FIELD_SELECTION_FLAGS = Util.intToStringMaxRadix(4);
|
private static final String FIELD_ROLE_FLAGS = Util.intToStringMaxRadix(4);
|
||||||
private static final String FIELD_ROLE_FLAGS = Util.intToStringMaxRadix(5);
|
private static final String FIELD_AVERAGE_BITRATE = Util.intToStringMaxRadix(5);
|
||||||
private static final String FIELD_AVERAGE_BITRATE = Util.intToStringMaxRadix(6);
|
private static final String FIELD_PEAK_BITRATE = Util.intToStringMaxRadix(6);
|
||||||
private static final String FIELD_PEAK_BITRATE = Util.intToStringMaxRadix(7);
|
private static final String FIELD_CODECS = Util.intToStringMaxRadix(7);
|
||||||
private static final String FIELD_CODECS = Util.intToStringMaxRadix(8);
|
private static final String FIELD_METADATA = Util.intToStringMaxRadix(8);
|
||||||
private static final String FIELD_METADATA = Util.intToStringMaxRadix(9);
|
private static final String FIELD_CONTAINER_MIME_TYPE = Util.intToStringMaxRadix(9);
|
||||||
private static final String FIELD_CONTAINER_MIME_TYPE = Util.intToStringMaxRadix(10);
|
private static final String FIELD_SAMPLE_MIME_TYPE = Util.intToStringMaxRadix(10);
|
||||||
private static final String FIELD_SAMPLE_MIME_TYPE = Util.intToStringMaxRadix(11);
|
private static final String FIELD_MAX_INPUT_SIZE = Util.intToStringMaxRadix(11);
|
||||||
private static final String FIELD_MAX_INPUT_SIZE = Util.intToStringMaxRadix(12);
|
private static final String FIELD_INITIALIZATION_DATA = Util.intToStringMaxRadix(12);
|
||||||
private static final String FIELD_INITIALIZATION_DATA = Util.intToStringMaxRadix(13);
|
private static final String FIELD_DRM_INIT_DATA = Util.intToStringMaxRadix(13);
|
||||||
private static final String FIELD_DRM_INIT_DATA = Util.intToStringMaxRadix(14);
|
private static final String FIELD_SUBSAMPLE_OFFSET_US = Util.intToStringMaxRadix(14);
|
||||||
private static final String FIELD_SUBSAMPLE_OFFSET_US = Util.intToStringMaxRadix(15);
|
private static final String FIELD_WIDTH = Util.intToStringMaxRadix(15);
|
||||||
private static final String FIELD_WIDTH = Util.intToStringMaxRadix(16);
|
private static final String FIELD_HEIGHT = Util.intToStringMaxRadix(16);
|
||||||
private static final String FIELD_HEIGHT = Util.intToStringMaxRadix(17);
|
private static final String FIELD_FRAME_RATE = Util.intToStringMaxRadix(17);
|
||||||
private static final String FIELD_FRAME_RATE = Util.intToStringMaxRadix(18);
|
private static final String FIELD_ROTATION_DEGREES = Util.intToStringMaxRadix(18);
|
||||||
private static final String FIELD_ROTATION_DEGREES = Util.intToStringMaxRadix(19);
|
private static final String FIELD_PIXEL_WIDTH_HEIGHT_RATIO = Util.intToStringMaxRadix(19);
|
||||||
private static final String FIELD_PIXEL_WIDTH_HEIGHT_RATIO = Util.intToStringMaxRadix(20);
|
private static final String FIELD_PROJECTION_DATA = Util.intToStringMaxRadix(20);
|
||||||
private static final String FIELD_PROJECTION_DATA = Util.intToStringMaxRadix(21);
|
private static final String FIELD_STEREO_MODE = Util.intToStringMaxRadix(21);
|
||||||
private static final String FIELD_STEREO_MODE = Util.intToStringMaxRadix(22);
|
private static final String FIELD_COLOR_INFO = Util.intToStringMaxRadix(22);
|
||||||
private static final String FIELD_COLOR_INFO = Util.intToStringMaxRadix(23);
|
private static final String FIELD_CHANNEL_COUNT = Util.intToStringMaxRadix(23);
|
||||||
private static final String FIELD_CHANNEL_COUNT = Util.intToStringMaxRadix(24);
|
private static final String FIELD_SAMPLE_RATE = Util.intToStringMaxRadix(24);
|
||||||
private static final String FIELD_SAMPLE_RATE = Util.intToStringMaxRadix(25);
|
private static final String FIELD_PCM_ENCODING = Util.intToStringMaxRadix(25);
|
||||||
private static final String FIELD_PCM_ENCODING = Util.intToStringMaxRadix(26);
|
private static final String FIELD_ENCODER_DELAY = Util.intToStringMaxRadix(26);
|
||||||
private static final String FIELD_ENCODER_DELAY = Util.intToStringMaxRadix(27);
|
private static final String FIELD_ENCODER_PADDING = Util.intToStringMaxRadix(27);
|
||||||
private static final String FIELD_ENCODER_PADDING = Util.intToStringMaxRadix(28);
|
private static final String FIELD_ACCESSIBILITY_CHANNEL = Util.intToStringMaxRadix(28);
|
||||||
private static final String FIELD_ACCESSIBILITY_CHANNEL = Util.intToStringMaxRadix(29);
|
private static final String FIELD_CRYPTO_TYPE = Util.intToStringMaxRadix(29);
|
||||||
private static final String FIELD_CRYPTO_TYPE = Util.intToStringMaxRadix(30);
|
private static final String FIELD_TILE_COUNT_HORIZONTAL = Util.intToStringMaxRadix(30);
|
||||||
private static final String FIELD_TILE_COUNT_HORIZONTAL = Util.intToStringMaxRadix(31);
|
private static final String FIELD_TILE_COUNT_VERTICAL = Util.intToStringMaxRadix(31);
|
||||||
private static final String FIELD_TILE_COUNT_VERTICAL = Util.intToStringMaxRadix(32);
|
private static final String FIELD_LABELS = Util.intToStringMaxRadix(32);
|
||||||
|
|
||||||
@UnstableApi
|
@UnstableApi
|
||||||
@Override
|
@Override
|
||||||
@ -1431,11 +1410,8 @@ public final class Format implements Bundleable {
|
|||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putString(FIELD_ID, id);
|
bundle.putString(FIELD_ID, id);
|
||||||
bundle.putString(FIELD_LABEL, label);
|
bundle.putString(FIELD_LABEL, label);
|
||||||
if (labels != null) {
|
bundle.putParcelableArrayList(
|
||||||
for (int i = 0; i < labels.size(); i++) {
|
FIELD_LABELS, BundleCollectionUtil.toBundleArrayList(labels, Label::toBundle));
|
||||||
bundle.putParcelable(keyForLabel(i), labels.get(i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bundle.putString(FIELD_LANGUAGE, language);
|
bundle.putString(FIELD_LANGUAGE, language);
|
||||||
bundle.putInt(FIELD_SELECTION_FLAGS, selectionFlags);
|
bundle.putInt(FIELD_SELECTION_FLAGS, selectionFlags);
|
||||||
bundle.putInt(FIELD_ROLE_FLAGS, roleFlags);
|
bundle.putInt(FIELD_ROLE_FLAGS, roleFlags);
|
||||||
@ -1503,14 +1479,11 @@ public final class Format implements Bundleable {
|
|||||||
builder
|
builder
|
||||||
.setId(defaultIfNull(bundle.getString(FIELD_ID), DEFAULT.id))
|
.setId(defaultIfNull(bundle.getString(FIELD_ID), DEFAULT.id))
|
||||||
.setLabel(defaultIfNull(bundle.getString(FIELD_LABEL), DEFAULT.label));
|
.setLabel(defaultIfNull(bundle.getString(FIELD_LABEL), DEFAULT.label));
|
||||||
List<Label> labels = new ArrayList<>();
|
@Nullable List<Bundle> labelsBundles = bundle.getParcelableArrayList(FIELD_LABELS);
|
||||||
for (int i = 0; ; i++) {
|
List<Label> labels =
|
||||||
@Nullable Label label = bundle.getParcelable(keyForLabel(i));
|
labelsBundles == null
|
||||||
if (label == null) {
|
? ImmutableList.of()
|
||||||
break;
|
: BundleCollectionUtil.fromBundleList(Label::fromBundle, labelsBundles);
|
||||||
}
|
|
||||||
labels.add(label);
|
|
||||||
}
|
|
||||||
builder
|
builder
|
||||||
.setLabels(labels)
|
.setLabels(labels)
|
||||||
.setLanguage(defaultIfNull(bundle.getString(FIELD_LANGUAGE), DEFAULT.language))
|
.setLanguage(defaultIfNull(bundle.getString(FIELD_LANGUAGE), DEFAULT.language))
|
||||||
@ -1579,10 +1552,6 @@ public final class Format implements Bundleable {
|
|||||||
+ Integer.toString(initialisationDataIndex, Character.MAX_RADIX);
|
+ Integer.toString(initialisationDataIndex, Character.MAX_RADIX);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String keyForLabel(int labelIndex) {
|
|
||||||
return FIELD_LABELS + "_" + Integer.toString(labelIndex, Character.MAX_RADIX);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility method to get {@code defaultValue} if {@code value} is {@code null}. {@code
|
* Utility method to get {@code defaultValue} if {@code value} is {@code null}. {@code
|
||||||
* defaultValue} can be {@code null}.
|
* defaultValue} can be {@code null}.
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
package androidx.media3.common;
|
package androidx.media3.common;
|
||||||
|
|
||||||
|
import static androidx.media3.common.util.Assertions.checkNotNull;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
@ -9,7 +12,7 @@ import androidx.media3.common.util.Util;
|
|||||||
|
|
||||||
/** A Label, as defined by ISO 23009-1, 4th edition, 5.3.7.2. */
|
/** A Label, as defined by ISO 23009-1, 4th edition, 5.3.7.2. */
|
||||||
@UnstableApi
|
@UnstableApi
|
||||||
public class Label implements Parcelable {
|
public class Label implements Parcelable, Bundleable {
|
||||||
/** Declares the language code(s) for this Label. */
|
/** Declares the language code(s) for this Label. */
|
||||||
@Nullable public final String lang;
|
@Nullable public final String lang;
|
||||||
|
|
||||||
@ -35,8 +38,7 @@ public class Label implements Parcelable {
|
|||||||
if (this == o) return true;
|
if (this == o) return true;
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
Label label = (Label) o;
|
Label label = (Label) o;
|
||||||
return Util.areEqual(lang, label.lang)
|
return Util.areEqual(lang, label.lang) && Util.areEqual(value, label.value);
|
||||||
&& Util.areEqual(value, label.value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -70,4 +72,23 @@ public class Label implements Parcelable {
|
|||||||
return new Label[size];
|
return new Label[size];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private static final String FIELD_LANG_INDEX = Util.intToStringMaxRadix(0);
|
||||||
|
private static final String FIELD_VALUE_INDEX = Util.intToStringMaxRadix(1);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Bundle toBundle() {
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putString(FIELD_LANG_INDEX, lang);
|
||||||
|
bundle.putString(FIELD_VALUE_INDEX, value);
|
||||||
|
return bundle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs an instance of {@link Label} from a {@link Bundle} produced by {@link #toBundle()}.
|
||||||
|
*/
|
||||||
|
public static Label fromBundle(Bundle bundle) {
|
||||||
|
return new Label(
|
||||||
|
bundle.getString(FIELD_LANG_INDEX), checkNotNull(bundle.getString(FIELD_VALUE_INDEX)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user