Reverting breaking changes by keeping label and adding labels.

This commit is contained in:
Juan Carlos Penalver 2024-01-31 12:35:44 -07:00 committed by tonihei
parent df763220c8
commit 63fb68e99e
39 changed files with 198 additions and 64 deletions

View file

@ -49,6 +49,7 @@ import java.util.UUID;
* *
* <ul> * <ul>
* <li>{@link #id} * <li>{@link #id}
* <li>{@link #label}
* <li>{@link #labels} * <li>{@link #labels}
* <li>{@link #language} * <li>{@link #language}
* <li>{@link #selectionFlags} * <li>{@link #selectionFlags}
@ -136,6 +137,8 @@ public final class Format implements Bundleable {
public static final class Builder { public static final class Builder {
@Nullable private String id; @Nullable private String id;
@Nullable private String label;
@Nullable private List<Label> labels; @Nullable private List<Label> labels;
@Nullable private String language; @Nullable private String language;
private @C.SelectionFlags int selectionFlags; private @C.SelectionFlags int selectionFlags;
@ -224,6 +227,7 @@ public final class Format implements Bundleable {
*/ */
private Builder(Format format) { private Builder(Format format) {
this.id = format.id; this.id = format.id;
this.label = format.label;
this.labels = format.labels; this.labels = format.labels;
this.language = format.language; this.language = format.language;
this.selectionFlags = format.selectionFlags; this.selectionFlags = format.selectionFlags;
@ -290,6 +294,18 @@ public final class Format implements Bundleable {
return this; return this;
} }
/**
* Sets {@link Format#label}. The default value is {@code null}.
*
* @param label The {@link Format#label}.
* @return The builder.
*/
@CanIgnoreReturnValue
public Builder setLabel(@Nullable String label) {
this.label = label;
return this;
}
/** /**
* Sets {@link Format#labels}. The default value is {@code null}. * Sets {@link Format#labels}. The default value is {@code null}.
* *
@ -740,8 +756,15 @@ public final class Format implements Bundleable {
/** An identifier for the format, or null if unknown or not applicable. */ /** An identifier for the format, or null if unknown or not applicable. */
@Nullable public final String id; @Nullable public final String id;
/** The human readable label, or null if unknown or not applicable. */ /**
@Nullable public final List<Label> labels; * The human readable label, or null if unknown or not applicable.
*
* @deprecated Use {@link #labels} instead.
*/
@Deprecated @Nullable public final String label;
/** The human readable list of labels, or null if unknown or not applicable. */
@UnstableApi public final List<Label> labels;
/** The language as an IETF BCP 47 conformant tag, or null if unknown or not applicable. */ /** The language as an IETF BCP 47 conformant tag, or null if unknown or not applicable. */
@Nullable public final String language; @Nullable public final String language;
@ -931,7 +954,8 @@ public final class Format implements Bundleable {
private Format(Builder builder) { private Format(Builder builder) {
id = builder.id; id = builder.id;
labels = builder.labels; label = builder.label;
labels = builder.labels == null ? Collections.emptyList() : builder.labels;
language = Util.normalizeLanguageCode(builder.language); language = Util.normalizeLanguageCode(builder.language);
selectionFlags = builder.selectionFlags; selectionFlags = builder.selectionFlags;
roleFlags = builder.roleFlags; roleFlags = builder.roleFlags;
@ -1002,8 +1026,8 @@ public final class Format implements Bundleable {
int tileCountVertical = manifestFormat.tileCountVertical; int tileCountVertical = manifestFormat.tileCountVertical;
// Prefer manifest values, but fill in from sample format if missing. // Prefer manifest values, but fill in from sample format if missing.
@Nullable @Nullable String label = manifestFormat.label != null ? manifestFormat.label : this.label;
List<Label> labels = manifestFormat.labels != null ? manifestFormat.labels : this.labels; List<Label> labels = manifestFormat.labels;
@Nullable String language = this.language; @Nullable String language = this.language;
if ((trackType == C.TRACK_TYPE_TEXT || trackType == C.TRACK_TYPE_AUDIO) if ((trackType == C.TRACK_TYPE_TEXT || trackType == C.TRACK_TYPE_AUDIO)
&& manifestFormat.language != null) { && manifestFormat.language != null) {
@ -1044,6 +1068,7 @@ public final class Format implements Bundleable {
return buildUpon() return buildUpon()
.setId(id) .setId(id)
.setLabel(label)
.setLabels(labels) .setLabels(labels)
.setLanguage(language) .setLanguage(language)
.setSelectionFlags(selectionFlags) .setSelectionFlags(selectionFlags)
@ -1079,7 +1104,7 @@ public final class Format implements Bundleable {
return "Format(" return "Format("
+ id + id
+ ", " + ", "
+ labels + label
+ ", " + ", "
+ containerMimeType + containerMimeType
+ ", " + ", "
@ -1112,7 +1137,8 @@ public final class Format implements Bundleable {
// Some fields for which hashing is expensive are deliberately omitted. // Some fields for which hashing is expensive are deliberately omitted.
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 + (labels != null ? labels.hashCode() : 0); result = 31 * result + (label == null ? 0 : label.hashCode());
// [Omitted] labels.
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;
@ -1190,7 +1216,7 @@ public final class Format implements Bundleable {
&& Float.compare(frameRate, other.frameRate) == 0 && Float.compare(frameRate, other.frameRate) == 0
&& Float.compare(pixelWidthHeightRatio, other.pixelWidthHeightRatio) == 0 && Float.compare(pixelWidthHeightRatio, other.pixelWidthHeightRatio) == 0
&& Util.areEqual(id, other.id) && Util.areEqual(id, other.id)
&& Util.areEqual(labels, other.labels) && Util.areEqual(label, other.label)
&& Util.areEqual(codecs, other.codecs) && Util.areEqual(codecs, other.codecs)
&& Util.areEqual(containerMimeType, other.containerMimeType) && Util.areEqual(containerMimeType, other.containerMimeType)
&& Util.areEqual(sampleMimeType, other.sampleMimeType) && Util.areEqual(sampleMimeType, other.sampleMimeType)
@ -1199,7 +1225,8 @@ public final class Format implements Bundleable {
&& Util.areEqual(metadata, other.metadata) && Util.areEqual(metadata, other.metadata)
&& 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);
} }
/** /**
@ -1223,6 +1250,32 @@ 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. */
@ -1282,8 +1335,13 @@ public final class Format implements Bundleable {
if (format.language != null) { if (format.language != null) {
builder.append(", language=").append(format.language); builder.append(", language=").append(format.language);
} }
if (format.label != null) {
builder.append(", label=").append(format.label);
}
if (format.labels != null) { if (format.labels != null) {
builder.append(", label=").append(format.labels); builder.append(", labels=[");
Joiner.on(',').appendTo(builder, format.labels);
builder.append("]");
} }
if (format.selectionFlags != 0) { if (format.selectionFlags != 0) {
builder.append(", selectionFlags=["); builder.append(", selectionFlags=[");
@ -1301,37 +1359,38 @@ public final class Format implements Bundleable {
// Bundleable implementation. // Bundleable implementation.
private static final String FIELD_ID = Util.intToStringMaxRadix(0); private static final String FIELD_ID = Util.intToStringMaxRadix(0);
private static final String FIELD_LABELS = Util.intToStringMaxRadix(1); private static final String FIELD_LABEL = Util.intToStringMaxRadix(1);
private static final String FIELD_LANGUAGE = Util.intToStringMaxRadix(2); private static final String FIELD_LABELS = Util.intToStringMaxRadix(2);
private static final String FIELD_SELECTION_FLAGS = Util.intToStringMaxRadix(3); private static final String FIELD_LANGUAGE = Util.intToStringMaxRadix(3);
private static final String FIELD_ROLE_FLAGS = Util.intToStringMaxRadix(4); private static final String FIELD_SELECTION_FLAGS = Util.intToStringMaxRadix(4);
private static final String FIELD_AVERAGE_BITRATE = Util.intToStringMaxRadix(5); private static final String FIELD_ROLE_FLAGS = Util.intToStringMaxRadix(5);
private static final String FIELD_PEAK_BITRATE = Util.intToStringMaxRadix(6); private static final String FIELD_AVERAGE_BITRATE = Util.intToStringMaxRadix(6);
private static final String FIELD_CODECS = Util.intToStringMaxRadix(7); private static final String FIELD_PEAK_BITRATE = Util.intToStringMaxRadix(7);
private static final String FIELD_METADATA = Util.intToStringMaxRadix(8); private static final String FIELD_CODECS = Util.intToStringMaxRadix(8);
private static final String FIELD_CONTAINER_MIME_TYPE = Util.intToStringMaxRadix(9); private static final String FIELD_METADATA = Util.intToStringMaxRadix(9);
private static final String FIELD_SAMPLE_MIME_TYPE = Util.intToStringMaxRadix(10); private static final String FIELD_CONTAINER_MIME_TYPE = Util.intToStringMaxRadix(10);
private static final String FIELD_MAX_INPUT_SIZE = Util.intToStringMaxRadix(11); private static final String FIELD_SAMPLE_MIME_TYPE = Util.intToStringMaxRadix(11);
private static final String FIELD_INITIALIZATION_DATA = Util.intToStringMaxRadix(12); private static final String FIELD_MAX_INPUT_SIZE = Util.intToStringMaxRadix(12);
private static final String FIELD_DRM_INIT_DATA = Util.intToStringMaxRadix(13); private static final String FIELD_INITIALIZATION_DATA = Util.intToStringMaxRadix(13);
private static final String FIELD_SUBSAMPLE_OFFSET_US = Util.intToStringMaxRadix(14); private static final String FIELD_DRM_INIT_DATA = Util.intToStringMaxRadix(14);
private static final String FIELD_WIDTH = Util.intToStringMaxRadix(15); private static final String FIELD_SUBSAMPLE_OFFSET_US = Util.intToStringMaxRadix(15);
private static final String FIELD_HEIGHT = Util.intToStringMaxRadix(16); private static final String FIELD_WIDTH = Util.intToStringMaxRadix(16);
private static final String FIELD_FRAME_RATE = Util.intToStringMaxRadix(17); private static final String FIELD_HEIGHT = Util.intToStringMaxRadix(17);
private static final String FIELD_ROTATION_DEGREES = Util.intToStringMaxRadix(18); private static final String FIELD_FRAME_RATE = Util.intToStringMaxRadix(18);
private static final String FIELD_PIXEL_WIDTH_HEIGHT_RATIO = Util.intToStringMaxRadix(19); private static final String FIELD_ROTATION_DEGREES = Util.intToStringMaxRadix(19);
private static final String FIELD_PROJECTION_DATA = Util.intToStringMaxRadix(20); private static final String FIELD_PIXEL_WIDTH_HEIGHT_RATIO = Util.intToStringMaxRadix(20);
private static final String FIELD_STEREO_MODE = Util.intToStringMaxRadix(21); private static final String FIELD_PROJECTION_DATA = Util.intToStringMaxRadix(21);
private static final String FIELD_COLOR_INFO = Util.intToStringMaxRadix(22); private static final String FIELD_STEREO_MODE = Util.intToStringMaxRadix(22);
private static final String FIELD_CHANNEL_COUNT = Util.intToStringMaxRadix(23); private static final String FIELD_COLOR_INFO = Util.intToStringMaxRadix(23);
private static final String FIELD_SAMPLE_RATE = Util.intToStringMaxRadix(24); private static final String FIELD_CHANNEL_COUNT = Util.intToStringMaxRadix(24);
private static final String FIELD_PCM_ENCODING = Util.intToStringMaxRadix(25); private static final String FIELD_SAMPLE_RATE = Util.intToStringMaxRadix(25);
private static final String FIELD_ENCODER_DELAY = Util.intToStringMaxRadix(26); private static final String FIELD_PCM_ENCODING = Util.intToStringMaxRadix(26);
private static final String FIELD_ENCODER_PADDING = Util.intToStringMaxRadix(27); private static final String FIELD_ENCODER_DELAY = Util.intToStringMaxRadix(27);
private static final String FIELD_ACCESSIBILITY_CHANNEL = Util.intToStringMaxRadix(28); private static final String FIELD_ENCODER_PADDING = Util.intToStringMaxRadix(28);
private static final String FIELD_CRYPTO_TYPE = Util.intToStringMaxRadix(29); private static final String FIELD_ACCESSIBILITY_CHANNEL = Util.intToStringMaxRadix(29);
private static final String FIELD_TILE_COUNT_HORIZONTAL = Util.intToStringMaxRadix(30); private static final String FIELD_CRYPTO_TYPE = Util.intToStringMaxRadix(30);
private static final String FIELD_TILE_COUNT_VERTICAL = Util.intToStringMaxRadix(31); private static final String FIELD_TILE_COUNT_HORIZONTAL = Util.intToStringMaxRadix(31);
private static final String FIELD_TILE_COUNT_VERTICAL = Util.intToStringMaxRadix(32);
@UnstableApi @UnstableApi
@Override @Override
@ -1347,6 +1406,7 @@ public final class Format implements Bundleable {
public Bundle toBundle(boolean excludeMetadata) { public Bundle toBundle(boolean excludeMetadata) {
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString(FIELD_ID, id); bundle.putString(FIELD_ID, id);
bundle.putString(FIELD_LABEL, label);
if (labels != null) { if (labels != null) {
for (int i = 0; i < labels.size(); i++) { for (int i = 0; i < labels.size(); i++) {
bundle.putParcelable(keyForLabel(i), labels.get(i)); bundle.putParcelable(keyForLabel(i), labels.get(i));
@ -1416,8 +1476,9 @@ public final class Format implements Bundleable {
public static Format fromBundle(Bundle bundle) { public static Format fromBundle(Bundle bundle) {
Builder builder = new Builder(); Builder builder = new Builder();
BundleCollectionUtil.ensureClassLoader(bundle); BundleCollectionUtil.ensureClassLoader(bundle);
builder.setId(defaultIfNull(bundle.getString(FIELD_ID), DEFAULT.id)); builder
.setId(defaultIfNull(bundle.getString(FIELD_ID), DEFAULT.id))
.setLabel(defaultIfNull(bundle.getString(FIELD_LABEL), DEFAULT.label));
List<Label> labels = new ArrayList<>(); List<Label> labels = new ArrayList<>();
for (int i = 0; ; i++) { for (int i = 0; ; i++) {
@Nullable Label label = bundle.getParcelable(keyForLabel(i)); @Nullable Label label = bundle.getParcelable(keyForLabel(i));

View file

@ -87,6 +87,7 @@ public final class FormatTest {
labels.add(new Label("id", "en", "label")); labels.add(new Label("id", "en", "label"));
return new Format.Builder() return new Format.Builder()
.setId("id") .setId("id")
.setLabel("label")
.setLabels(labels) .setLabels(labels)
.setLanguage("language") .setLanguage("language")
.setSelectionFlags(C.SELECTION_FLAG_DEFAULT) .setSelectionFlags(C.SELECTION_FLAG_DEFAULT)

View file

@ -450,6 +450,7 @@ public abstract class DecoderAudioRenderer<
.setEncoderPadding(encoderPadding) .setEncoderPadding(encoderPadding)
.setMetadata(inputFormat.metadata) .setMetadata(inputFormat.metadata)
.setId(inputFormat.id) .setId(inputFormat.id)
.setLabel(inputFormat.label)
.setLabels(inputFormat.labels) .setLabels(inputFormat.labels)
.setLanguage(inputFormat.language) .setLanguage(inputFormat.language)
.setSelectionFlags(inputFormat.selectionFlags) .setSelectionFlags(inputFormat.selectionFlags)

View file

@ -551,6 +551,7 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
.setEncoderPadding(format.encoderPadding) .setEncoderPadding(format.encoderPadding)
.setMetadata(format.metadata) .setMetadata(format.metadata)
.setId(format.id) .setId(format.id)
.setLabel(format.label)
.setLabels(format.labels) .setLabels(format.labels)
.setLanguage(format.language) .setLanguage(format.language)
.setSelectionFlags(format.selectionFlags) .setSelectionFlags(format.selectionFlags)

View file

@ -519,8 +519,6 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory {
String label = subtitleConfigurations.get(i).label; String label = subtitleConfigurations.get(i).label;
if (label != null) { if (label != null) {
labels.add(new Label(null, null, label)); labels.add(new Label(null, null, label));
} else {
labels = null;
} }
Format format = Format format =
@ -529,6 +527,7 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory {
.setLanguage(subtitleConfigurations.get(i).language) .setLanguage(subtitleConfigurations.get(i).language)
.setSelectionFlags(subtitleConfigurations.get(i).selectionFlags) .setSelectionFlags(subtitleConfigurations.get(i).selectionFlags)
.setRoleFlags(subtitleConfigurations.get(i).roleFlags) .setRoleFlags(subtitleConfigurations.get(i).roleFlags)
.setLabel(label)
.setLabels(labels) .setLabels(labels)
.setId(subtitleConfigurations.get(i).id) .setId(subtitleConfigurations.get(i).id)
.build(); .build();

View file

@ -177,8 +177,6 @@ public final class SingleSampleMediaSource extends BaseMediaSource {
String label = subtitleConfiguration.label; String label = subtitleConfiguration.label;
if (label != null) { if (label != null) {
labels.add(new Label(null, null, label)); labels.add(new Label(null, null, label));
} else {
labels = null;
} }
this.format = this.format =
new Format.Builder() new Format.Builder()
@ -186,6 +184,7 @@ public final class SingleSampleMediaSource extends BaseMediaSource {
.setLanguage(subtitleConfiguration.language) .setLanguage(subtitleConfiguration.language)
.setSelectionFlags(subtitleConfiguration.selectionFlags) .setSelectionFlags(subtitleConfiguration.selectionFlags)
.setRoleFlags(subtitleConfiguration.roleFlags) .setRoleFlags(subtitleConfiguration.roleFlags)
.setLabel(label)
.setLabels(labels) .setLabels(labels)
.setId(subtitleConfiguration.id != null ? subtitleConfiguration.id : trackId) .setId(subtitleConfiguration.id != null ? subtitleConfiguration.id : trackId)
.build(); .build();

View file

@ -517,6 +517,7 @@ public final class OutputConsumerAdapterV30 implements MediaParser.OutputConsume
.setLanguage(muxedCaptionFormat.language) .setLanguage(muxedCaptionFormat.language)
.setRoleFlags(muxedCaptionFormat.roleFlags) .setRoleFlags(muxedCaptionFormat.roleFlags)
.setSelectionFlags(muxedCaptionFormat.selectionFlags) .setSelectionFlags(muxedCaptionFormat.selectionFlags)
.setLabel(muxedCaptionFormat.label)
.setLabels(muxedCaptionFormat.labels) .setLabels(muxedCaptionFormat.labels)
.setMetadata(muxedCaptionFormat.metadata); .setMetadata(muxedCaptionFormat.metadata);
break; break;

View file

@ -2058,7 +2058,7 @@ public final class SampleQueueTest {
} }
private static Format copyWithLabel(Format format, String label) { private static Format copyWithLabel(Format format, String label) {
return format.buildUpon().setLabels(label).build(); return format.buildUpon().setLabel(label).build();
} }
private static final class MockDrmSessionManager implements DrmSessionManager { private static final class MockDrmSessionManager implements DrmSessionManager {

View file

@ -405,7 +405,7 @@ public class DashManifestParser extends DefaultHandler
int audioChannels = Format.NO_VALUE; int audioChannels = Format.NO_VALUE;
int audioSamplingRate = parseInt(xpp, "audioSamplingRate", Format.NO_VALUE); int audioSamplingRate = parseInt(xpp, "audioSamplingRate", Format.NO_VALUE);
String language = xpp.getAttributeValue(null, "lang"); String language = xpp.getAttributeValue(null, "lang");
String adaptationSetLabel = xpp.getAttributeValue(null, "label"); String label = xpp.getAttributeValue(null, "label");
List<Label> labels = new ArrayList<>(); List<Label> labels = new ArrayList<>();
String drmSchemeType = null; String drmSchemeType = null;
ArrayList<SchemeData> drmSchemeDatas = new ArrayList<>(); ArrayList<SchemeData> drmSchemeDatas = new ArrayList<>();
@ -506,23 +506,22 @@ public class DashManifestParser extends DefaultHandler
} else if (XmlPullParserUtil.isStartTag(xpp, "InbandEventStream")) { } else if (XmlPullParserUtil.isStartTag(xpp, "InbandEventStream")) {
inbandEventStreams.add(parseDescriptor(xpp, "InbandEventStream")); inbandEventStreams.add(parseDescriptor(xpp, "InbandEventStream"));
} else if (XmlPullParserUtil.isStartTag(xpp, "Label")) { } else if (XmlPullParserUtil.isStartTag(xpp, "Label")) {
labels.add(parseLabel(xpp)); Label parsedLabel = parseLabel(xpp);
label = parsedLabel.value;
labels.add(parsedLabel);
} else if (XmlPullParserUtil.isStartTag(xpp)) { } else if (XmlPullParserUtil.isStartTag(xpp)) {
parseAdaptationSetChild(xpp); parseAdaptationSetChild(xpp);
} }
} while (!XmlPullParserUtil.isEndTag(xpp, "AdaptationSet")); } while (!XmlPullParserUtil.isEndTag(xpp, "AdaptationSet"));
if (labels.size() == 0 && adaptationSetLabel != null) {
labels.add(new Label(null, null, adaptationSetLabel));
}
// Build the representations. // Build the representations.
List<Representation> representations = new ArrayList<>(representationInfos.size()); List<Representation> representations = new ArrayList<>(representationInfos.size());
for (int i = 0; i < representationInfos.size(); i++) { for (int i = 0; i < representationInfos.size(); i++) {
representations.add( representations.add(
buildRepresentation( buildRepresentation(
representationInfos.get(i), representationInfos.get(i),
labels.isEmpty() ? null : labels, label,
labels,
drmSchemeType, drmSchemeType,
drmSchemeDatas, drmSchemeDatas,
inbandEventStreams)); inbandEventStreams));
@ -861,11 +860,15 @@ public class DashManifestParser extends DefaultHandler
protected Representation buildRepresentation( protected Representation buildRepresentation(
RepresentationInfo representationInfo, RepresentationInfo representationInfo,
@Nullable String label,
@Nullable List<Label> labels, @Nullable List<Label> labels,
@Nullable String extraDrmSchemeType, @Nullable String extraDrmSchemeType,
ArrayList<SchemeData> extraDrmSchemeDatas, ArrayList<SchemeData> extraDrmSchemeDatas,
ArrayList<Descriptor> extraInbandEventStreams) { ArrayList<Descriptor> extraInbandEventStreams) {
Format.Builder formatBuilder = representationInfo.format.buildUpon(); Format.Builder formatBuilder = representationInfo.format.buildUpon();
if (label != null) {
formatBuilder.setLabel(label);
}
formatBuilder.setLabels(labels); formatBuilder.setLabels(labels);
@Nullable String drmSchemeType = representationInfo.drmSchemeType; @Nullable String drmSchemeType = representationInfo.drmSchemeType;
if (drmSchemeType == null) { if (drmSchemeType == null) {

View file

@ -279,8 +279,9 @@ public class DashManifestParserTest {
List<AdaptationSet> adaptationSets = manifest.getPeriod(0).adaptationSets; List<AdaptationSet> adaptationSets = manifest.getPeriod(0).adaptationSets;
assertThat(adaptationSets.get(0).representations.get(0).format.labels.get(0).value) assertThat(adaptationSets.get(0).representations.get(0).format.label).isEqualTo("audio label");
.isEqualTo("audio label"); assertThat(adaptationSets.get(1).representations.get(0).format.label).isEqualTo("video label");
assertThat(adaptationSets.get(0).representations.get(0).format.labels.size()).isEqualTo(0);
assertThat(adaptationSets.get(1).representations.get(0).format.labels.get(0).value) assertThat(adaptationSets.get(1).representations.get(0).format.labels.get(0).value)
.isEqualTo("video label"); .isEqualTo("video label");
} }

View file

@ -852,6 +852,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
@Nullable String sampleMimeType = MimeTypes.getMediaMimeType(codecs); @Nullable String sampleMimeType = MimeTypes.getMediaMimeType(codecs);
return new Format.Builder() return new Format.Builder()
.setId(variantFormat.id) .setId(variantFormat.id)
.setLabel(variantFormat.label)
.setLabels(variantFormat.labels) .setLabels(variantFormat.labels)
.setContainerMimeType(variantFormat.containerMimeType) .setContainerMimeType(variantFormat.containerMimeType)
.setSampleMimeType(sampleMimeType) .setSampleMimeType(sampleMimeType)
@ -875,6 +876,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
int selectionFlags = 0; int selectionFlags = 0;
int roleFlags = 0; int roleFlags = 0;
@Nullable String language = null; @Nullable String language = null;
@Nullable String label = null;
@Nullable List<Label> labels = null; @Nullable List<Label> labels = null;
if (mediaTagFormat != null) { if (mediaTagFormat != null) {
codecs = mediaTagFormat.codecs; codecs = mediaTagFormat.codecs;
@ -883,6 +885,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
selectionFlags = mediaTagFormat.selectionFlags; selectionFlags = mediaTagFormat.selectionFlags;
roleFlags = mediaTagFormat.roleFlags; roleFlags = mediaTagFormat.roleFlags;
language = mediaTagFormat.language; language = mediaTagFormat.language;
label = mediaTagFormat.label;
labels = mediaTagFormat.labels; labels = mediaTagFormat.labels;
} else { } else {
codecs = Util.getCodecsOfType(variantFormat.codecs, C.TRACK_TYPE_AUDIO); codecs = Util.getCodecsOfType(variantFormat.codecs, C.TRACK_TYPE_AUDIO);
@ -892,6 +895,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
selectionFlags = variantFormat.selectionFlags; selectionFlags = variantFormat.selectionFlags;
roleFlags = variantFormat.roleFlags; roleFlags = variantFormat.roleFlags;
language = variantFormat.language; language = variantFormat.language;
label = variantFormat.label;
labels = variantFormat.labels; labels = variantFormat.labels;
} }
} }
@ -900,6 +904,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
int peakBitrate = isPrimaryTrackInVariant ? variantFormat.peakBitrate : Format.NO_VALUE; int peakBitrate = isPrimaryTrackInVariant ? variantFormat.peakBitrate : Format.NO_VALUE;
return new Format.Builder() return new Format.Builder()
.setId(variantFormat.id) .setId(variantFormat.id)
.setLabel(label)
.setLabels(labels) .setLabels(labels)
.setContainerMimeType(variantFormat.containerMimeType) .setContainerMimeType(variantFormat.containerMimeType)
.setSampleMimeType(sampleMimeType) .setSampleMimeType(sampleMimeType)

View file

@ -1583,6 +1583,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
sampleFormat sampleFormat
.buildUpon() .buildUpon()
.setId(playlistFormat.id) .setId(playlistFormat.id)
.setLabel(playlistFormat.label)
.setLabels(playlistFormat.labels) .setLabels(playlistFormat.labels)
.setLanguage(playlistFormat.language) .setLanguage(playlistFormat.language)
.setSelectionFlags(playlistFormat.selectionFlags) .setSelectionFlags(playlistFormat.selectionFlags)

View file

@ -477,6 +477,7 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli
Format.Builder formatBuilder = Format.Builder formatBuilder =
new Format.Builder() new Format.Builder()
.setId(groupId + ":" + name) .setId(groupId + ":" + name)
.setLabel(name)
.setLabels(labels) .setLabels(labels)
.setContainerMimeType(MimeTypes.APPLICATION_M3U8) .setContainerMimeType(MimeTypes.APPLICATION_M3U8)
.setSelectionFlags(parseSelectionFlags(line)) .setSelectionFlags(parseSelectionFlags(line))

View file

@ -745,12 +745,11 @@ public class SsManifestParser implements ParsingLoadable.Parser<SsManifest> {
String label = (String) getNormalizedAttribute(KEY_NAME); String label = (String) getNormalizedAttribute(KEY_NAME);
if (label != null) { if (label != null) {
labels.add(new Label(null, null, label)); labels.add(new Label(null, null, label));
} else {
labels = null;
} }
format = format =
formatBuilder formatBuilder
.setId(parser.getAttributeValue(null, KEY_INDEX)) .setId(parser.getAttributeValue(null, KEY_INDEX))
.setLabel(label)
.setLabels(labels) .setLabels(labels)
.setSampleMimeType(sampleMimeType) .setSampleMimeType(sampleMimeType)
.setAverageBitrate(parseRequiredInt(parser, KEY_BITRATE)) .setAverageBitrate(parseRequiredInt(parser, KEY_BITRATE))

View file

@ -51,6 +51,7 @@ public final class SsManifestParserTest {
Uri.parse("https://example.com/test.ismc"), Uri.parse("https://example.com/test.ismc"),
TestUtil.getInputStream(ApplicationProvider.getApplicationContext(), SAMPLE_ISMC_1)); TestUtil.getInputStream(ApplicationProvider.getApplicationContext(), SAMPLE_ISMC_1));
assertThat(ssManifest.streamElements[0].formats[0].labels).isEqualTo("video"); assertThat(ssManifest.streamElements[0].formats[0].label).isEqualTo("video");
assertThat(ssManifest.streamElements[0].formats[0].labels.get(0).value).isEqualTo("video");
} }
} }

View file

@ -516,8 +516,11 @@ public final class AviExtractor implements Extractor {
} }
StreamNameChunk streamName = streamList.getChild(StreamNameChunk.class); StreamNameChunk streamName = streamList.getChild(StreamNameChunk.class);
if (streamName != null) { if (streamName != null) {
String label = streamName.name;
builder.setLabel(label);
List<Label> labels = new ArrayList<>(); List<Label> labels = new ArrayList<>();
labels.add(new Label(null, null, streamName.name)); labels.add(new Label(null, null, label));
builder.setLabels(labels); builder.setLabels(labels);
} }
int trackType = MimeTypes.getTrackType(streamFormat.sampleMimeType); int trackType = MimeTypes.getTrackType(streamFormat.sampleMimeType);

View file

@ -2424,6 +2424,8 @@ public class MatroskaExtractor implements Extractor {
} }
if (name != null && !TRACK_NAME_TO_ROTATION_DEGREES.containsKey(name)) { if (name != null && !TRACK_NAME_TO_ROTATION_DEGREES.containsKey(name)) {
formatBuilder.setLabel(name);
List<Label> labels = new ArrayList<>(); List<Label> labels = new ArrayList<>();
labels.add(new Label(null, null, name)); labels.add(new Label(null, null, name));
formatBuilder.setLabels(labels); formatBuilder.setLabels(labels);

View file

@ -275,6 +275,8 @@ track 3:
selectionFlags = [default] selectionFlags = [default]
language = en language = en
label = Subs Label label = Subs Label
labels:
value = Subs Label
sample 0: sample 0:
time = 0 time = 0
flags = 1 flags = 1

View file

@ -275,6 +275,8 @@ track 3:
selectionFlags = [default] selectionFlags = [default]
language = en language = en
label = Subs Label label = Subs Label
labels:
value = Subs Label
sample 0: sample 0:
time = 0 time = 0
flags = 1 flags = 1

View file

@ -275,6 +275,8 @@ track 3:
selectionFlags = [default] selectionFlags = [default]
language = en language = en
label = Subs Label label = Subs Label
labels:
value = Subs Label
sample 0: sample 0:
time = 0 time = 0
flags = 1 flags = 1

View file

@ -275,6 +275,8 @@ track 3:
selectionFlags = [default] selectionFlags = [default]
language = en language = en
label = Subs Label label = Subs Label
labels:
value = Subs Label
sample 0: sample 0:
time = 0 time = 0
flags = 1 flags = 1

View file

@ -275,6 +275,8 @@ track 3:
selectionFlags = [default] selectionFlags = [default]
language = en language = en
label = Subs Label label = Subs Label
labels:
value = Subs Label
sample 0: sample 0:
time = 0 time = 0
flags = 1 flags = 1

View file

@ -275,6 +275,8 @@ track 3:
selectionFlags = [default] selectionFlags = [default]
language = en language = en
label = Subs Label label = Subs Label
labels:
value = Subs Label
sample 0: sample 0:
time = 0 time = 0
flags = 1 flags = 1

View file

@ -275,6 +275,8 @@ track 3:
selectionFlags = [default] selectionFlags = [default]
language = en language = en
label = Subs Label label = Subs Label
labels:
value = Subs Label
sample 0: sample 0:
time = 0 time = 0
flags = 1 flags = 1

View file

@ -275,6 +275,8 @@ track 3:
selectionFlags = [default] selectionFlags = [default]
language = en language = en
label = Subs Label label = Subs Label
labels:
value = Subs Label
sample 0: sample 0:
time = 0 time = 0
flags = 1 flags = 1

View file

@ -275,6 +275,8 @@ track 3:
selectionFlags = [default] selectionFlags = [default]
language = en language = en
label = Subs Label label = Subs Label
labels:
value = Subs Label
sample 0: sample 0:
time = 0 time = 0
flags = 1 flags = 1

View file

@ -275,6 +275,8 @@ track 3:
selectionFlags = [default] selectionFlags = [default]
language = en language = en
label = Subs Label label = Subs Label
labels:
value = Subs Label
sample 0: sample 0:
time = 0 time = 0
flags = 1 flags = 1

View file

@ -276,6 +276,8 @@ track 3:
selectionFlags = [default] selectionFlags = [default]
language = en language = en
label = Subs Label label = Subs Label
labels:
value = Subs Label
sample 0: sample 0:
time = 0 time = 0
flags = 1 flags = 1

View file

@ -276,6 +276,8 @@ track 3:
selectionFlags = [default] selectionFlags = [default]
language = en language = en
label = Subs Label label = Subs Label
labels:
value = Subs Label
sample 0: sample 0:
time = 0 time = 0
flags = 1 flags = 1

View file

@ -276,6 +276,8 @@ track 3:
selectionFlags = [default] selectionFlags = [default]
language = en language = en
label = Subs Label label = Subs Label
labels:
value = Subs Label
sample 0: sample 0:
time = 0 time = 0
flags = 1 flags = 1

View file

@ -276,6 +276,8 @@ track 3:
selectionFlags = [default] selectionFlags = [default]
language = en language = en
label = Subs Label label = Subs Label
labels:
value = Subs Label
sample 0: sample 0:
time = 0 time = 0
flags = 1 flags = 1

View file

@ -276,6 +276,8 @@ track 3:
selectionFlags = [default] selectionFlags = [default]
language = en language = en
label = Subs Label label = Subs Label
labels:
value = Subs Label
sample 0: sample 0:
time = 0 time = 0
flags = 1 flags = 1

View file

@ -276,6 +276,8 @@ track 3:
selectionFlags = [default] selectionFlags = [default]
language = en language = en
label = Subs Label label = Subs Label
labels:
value = Subs Label
sample 0: sample 0:
time = 0 time = 0
flags = 1 flags = 1

View file

@ -276,6 +276,8 @@ track 3:
selectionFlags = [default] selectionFlags = [default]
language = en language = en
label = Subs Label label = Subs Label
labels:
value = Subs Label
sample 0: sample 0:
time = 0 time = 0
flags = 1 flags = 1

View file

@ -276,6 +276,8 @@ track 3:
selectionFlags = [default] selectionFlags = [default]
language = en language = en
label = Subs Label label = Subs Label
labels:
value = Subs Label
sample 0: sample 0:
time = 0 time = 0
flags = 1 flags = 1

View file

@ -276,6 +276,8 @@ track 3:
selectionFlags = [default] selectionFlags = [default]
language = en language = en
label = Subs Label label = Subs Label
labels:
value = Subs Label
sample 0: sample 0:
time = 0 time = 0
flags = 1 flags = 1

View file

@ -276,6 +276,8 @@ track 3:
selectionFlags = [default] selectionFlags = [default]
language = en language = en
label = Subs Label label = Subs Label
labels:
value = Subs Label
sample 0: sample 0:
time = 0 time = 0
flags = 1 flags = 1

View file

@ -100,7 +100,22 @@ public final class DumpableFormat implements Dumper.Dumpable {
DEFAULT_FORMAT, DEFAULT_FORMAT,
format -> Util.getRoleFlagStrings(format.roleFlags)); format -> Util.getRoleFlagStrings(format.roleFlags));
addIfNonDefault(dumper, "language", format, DEFAULT_FORMAT, format -> format.language); addIfNonDefault(dumper, "language", format, DEFAULT_FORMAT, format -> format.language);
addIfNonDefault(dumper, "label", format, DEFAULT_FORMAT, format -> format.labels); addIfNonDefault(dumper, "label", format, DEFAULT_FORMAT, format -> format.label);
if (!format.labels.isEmpty()) {
dumper.startBlock("labels");
for (int i = 0; i < format.labels.size(); i++) {
String id = format.labels.get(i).id;
String lang = format.labels.get(i).lang;
if (id != null) {
dumper.add("id", id);
}
if (lang != null) {
dumper.add("lang", lang);
}
dumper.add("value", format.labels.get(i).value);
}
dumper.endBlock();
}
if (format.drmInitData != null) { if (format.drmInitData != null) {
dumper.add("drmInitData", format.drmInitData.hashCode()); dumper.add("drmInitData", format.drmInitData.hashCode());
} }

View file

@ -110,8 +110,8 @@ public class DefaultTrackNameProvider implements TrackNameProvider {
} }
private String buildLabelString(Format format) { private String buildLabelString(Format format) {
if (format.labels == null || format.labels.isEmpty()) { if (format.labels.isEmpty()) {
return ""; return TextUtils.isEmpty(format.label) ? "" : format.label;
} }
if (!TextUtils.isEmpty(format.language)) { if (!TextUtils.isEmpty(format.language)) {
List<Label> labelsByLanguage = List<Label> labelsByLanguage =