mirror of
https://github.com/samsonjs/media.git
synced 2026-03-25 09:25:53 +00:00
Reverting breaking changes by keeping label and adding labels.
This commit is contained in:
parent
df763220c8
commit
63fb68e99e
39 changed files with 198 additions and 64 deletions
|
|
@ -49,6 +49,7 @@ import java.util.UUID;
|
|||
*
|
||||
* <ul>
|
||||
* <li>{@link #id}
|
||||
* <li>{@link #label}
|
||||
* <li>{@link #labels}
|
||||
* <li>{@link #language}
|
||||
* <li>{@link #selectionFlags}
|
||||
|
|
@ -136,6 +137,8 @@ public final class Format implements Bundleable {
|
|||
public static final class Builder {
|
||||
|
||||
@Nullable private String id;
|
||||
|
||||
@Nullable private String label;
|
||||
@Nullable private List<Label> labels;
|
||||
@Nullable private String language;
|
||||
private @C.SelectionFlags int selectionFlags;
|
||||
|
|
@ -224,6 +227,7 @@ public final class Format implements Bundleable {
|
|||
*/
|
||||
private Builder(Format format) {
|
||||
this.id = format.id;
|
||||
this.label = format.label;
|
||||
this.labels = format.labels;
|
||||
this.language = format.language;
|
||||
this.selectionFlags = format.selectionFlags;
|
||||
|
|
@ -290,6 +294,18 @@ public final class Format implements Bundleable {
|
|||
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}.
|
||||
*
|
||||
|
|
@ -740,8 +756,15 @@ public final class Format implements Bundleable {
|
|||
/** An identifier for the format, or null if unknown or not applicable. */
|
||||
@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. */
|
||||
@Nullable public final String language;
|
||||
|
|
@ -931,7 +954,8 @@ public final class Format implements Bundleable {
|
|||
|
||||
private Format(Builder builder) {
|
||||
id = builder.id;
|
||||
labels = builder.labels;
|
||||
label = builder.label;
|
||||
labels = builder.labels == null ? Collections.emptyList() : builder.labels;
|
||||
language = Util.normalizeLanguageCode(builder.language);
|
||||
selectionFlags = builder.selectionFlags;
|
||||
roleFlags = builder.roleFlags;
|
||||
|
|
@ -1002,8 +1026,8 @@ public final class Format implements Bundleable {
|
|||
int tileCountVertical = manifestFormat.tileCountVertical;
|
||||
|
||||
// Prefer manifest values, but fill in from sample format if missing.
|
||||
@Nullable
|
||||
List<Label> labels = manifestFormat.labels != null ? manifestFormat.labels : this.labels;
|
||||
@Nullable String label = manifestFormat.label != null ? manifestFormat.label : this.label;
|
||||
List<Label> labels = manifestFormat.labels;
|
||||
@Nullable String language = this.language;
|
||||
if ((trackType == C.TRACK_TYPE_TEXT || trackType == C.TRACK_TYPE_AUDIO)
|
||||
&& manifestFormat.language != null) {
|
||||
|
|
@ -1044,6 +1068,7 @@ public final class Format implements Bundleable {
|
|||
|
||||
return buildUpon()
|
||||
.setId(id)
|
||||
.setLabel(label)
|
||||
.setLabels(labels)
|
||||
.setLanguage(language)
|
||||
.setSelectionFlags(selectionFlags)
|
||||
|
|
@ -1079,7 +1104,7 @@ public final class Format implements Bundleable {
|
|||
return "Format("
|
||||
+ id
|
||||
+ ", "
|
||||
+ labels
|
||||
+ label
|
||||
+ ", "
|
||||
+ containerMimeType
|
||||
+ ", "
|
||||
|
|
@ -1112,7 +1137,8 @@ public final class Format implements Bundleable {
|
|||
// Some fields for which hashing is expensive are deliberately omitted.
|
||||
int result = 17;
|
||||
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 + selectionFlags;
|
||||
result = 31 * result + roleFlags;
|
||||
|
|
@ -1190,7 +1216,7 @@ public final class Format implements Bundleable {
|
|||
&& Float.compare(frameRate, other.frameRate) == 0
|
||||
&& Float.compare(pixelWidthHeightRatio, other.pixelWidthHeightRatio) == 0
|
||||
&& Util.areEqual(id, other.id)
|
||||
&& Util.areEqual(labels, other.labels)
|
||||
&& Util.areEqual(label, other.label)
|
||||
&& Util.areEqual(codecs, other.codecs)
|
||||
&& Util.areEqual(containerMimeType, other.containerMimeType)
|
||||
&& Util.areEqual(sampleMimeType, other.sampleMimeType)
|
||||
|
|
@ -1199,7 +1225,8 @@ public final class Format implements Bundleable {
|
|||
&& Util.areEqual(metadata, other.metadata)
|
||||
&& Util.areEqual(colorInfo, other.colorInfo)
|
||||
&& Util.areEqual(drmInitData, other.drmInitData)
|
||||
&& initializationDataEquals(other);
|
||||
&& initializationDataEquals(other)
|
||||
&& labelsEquals(other);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1223,6 +1250,32 @@ public final class Format implements Bundleable {
|
|||
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
|
||||
|
||||
/** 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) {
|
||||
builder.append(", language=").append(format.language);
|
||||
}
|
||||
if (format.label != null) {
|
||||
builder.append(", label=").append(format.label);
|
||||
}
|
||||
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) {
|
||||
builder.append(", selectionFlags=[");
|
||||
|
|
@ -1301,37 +1359,38 @@ public final class Format implements Bundleable {
|
|||
// Bundleable implementation.
|
||||
|
||||
private static final String FIELD_ID = Util.intToStringMaxRadix(0);
|
||||
private static final String FIELD_LABELS = Util.intToStringMaxRadix(1);
|
||||
private static final String FIELD_LANGUAGE = Util.intToStringMaxRadix(2);
|
||||
private static final String FIELD_SELECTION_FLAGS = Util.intToStringMaxRadix(3);
|
||||
private static final String FIELD_ROLE_FLAGS = Util.intToStringMaxRadix(4);
|
||||
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);
|
||||
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);
|
||||
private static final String FIELD_INITIALIZATION_DATA = Util.intToStringMaxRadix(12);
|
||||
private static final String FIELD_DRM_INIT_DATA = Util.intToStringMaxRadix(13);
|
||||
private static final String FIELD_SUBSAMPLE_OFFSET_US = Util.intToStringMaxRadix(14);
|
||||
private static final String FIELD_WIDTH = Util.intToStringMaxRadix(15);
|
||||
private static final String FIELD_HEIGHT = Util.intToStringMaxRadix(16);
|
||||
private static final String FIELD_FRAME_RATE = Util.intToStringMaxRadix(17);
|
||||
private static final String FIELD_ROTATION_DEGREES = Util.intToStringMaxRadix(18);
|
||||
private static final String FIELD_PIXEL_WIDTH_HEIGHT_RATIO = Util.intToStringMaxRadix(19);
|
||||
private static final String FIELD_PROJECTION_DATA = Util.intToStringMaxRadix(20);
|
||||
private static final String FIELD_STEREO_MODE = Util.intToStringMaxRadix(21);
|
||||
private static final String FIELD_COLOR_INFO = Util.intToStringMaxRadix(22);
|
||||
private static final String FIELD_CHANNEL_COUNT = Util.intToStringMaxRadix(23);
|
||||
private static final String FIELD_SAMPLE_RATE = Util.intToStringMaxRadix(24);
|
||||
private static final String FIELD_PCM_ENCODING = Util.intToStringMaxRadix(25);
|
||||
private static final String FIELD_ENCODER_DELAY = Util.intToStringMaxRadix(26);
|
||||
private static final String FIELD_ENCODER_PADDING = Util.intToStringMaxRadix(27);
|
||||
private static final String FIELD_ACCESSIBILITY_CHANNEL = Util.intToStringMaxRadix(28);
|
||||
private static final String FIELD_CRYPTO_TYPE = Util.intToStringMaxRadix(29);
|
||||
private static final String FIELD_TILE_COUNT_HORIZONTAL = Util.intToStringMaxRadix(30);
|
||||
private static final String FIELD_TILE_COUNT_VERTICAL = Util.intToStringMaxRadix(31);
|
||||
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(3);
|
||||
private static final String FIELD_SELECTION_FLAGS = Util.intToStringMaxRadix(4);
|
||||
private static final String FIELD_ROLE_FLAGS = Util.intToStringMaxRadix(5);
|
||||
private static final String FIELD_AVERAGE_BITRATE = Util.intToStringMaxRadix(6);
|
||||
private static final String FIELD_PEAK_BITRATE = Util.intToStringMaxRadix(7);
|
||||
private static final String FIELD_CODECS = Util.intToStringMaxRadix(8);
|
||||
private static final String FIELD_METADATA = Util.intToStringMaxRadix(9);
|
||||
private static final String FIELD_CONTAINER_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(12);
|
||||
private static final String FIELD_INITIALIZATION_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(15);
|
||||
private static final String FIELD_WIDTH = Util.intToStringMaxRadix(16);
|
||||
private static final String FIELD_HEIGHT = Util.intToStringMaxRadix(17);
|
||||
private static final String FIELD_FRAME_RATE = Util.intToStringMaxRadix(18);
|
||||
private static final String FIELD_ROTATION_DEGREES = Util.intToStringMaxRadix(19);
|
||||
private static final String FIELD_PIXEL_WIDTH_HEIGHT_RATIO = Util.intToStringMaxRadix(20);
|
||||
private static final String FIELD_PROJECTION_DATA = Util.intToStringMaxRadix(21);
|
||||
private static final String FIELD_STEREO_MODE = Util.intToStringMaxRadix(22);
|
||||
private static final String FIELD_COLOR_INFO = Util.intToStringMaxRadix(23);
|
||||
private static final String FIELD_CHANNEL_COUNT = Util.intToStringMaxRadix(24);
|
||||
private static final String FIELD_SAMPLE_RATE = Util.intToStringMaxRadix(25);
|
||||
private static final String FIELD_PCM_ENCODING = Util.intToStringMaxRadix(26);
|
||||
private static final String FIELD_ENCODER_DELAY = Util.intToStringMaxRadix(27);
|
||||
private static final String FIELD_ENCODER_PADDING = Util.intToStringMaxRadix(28);
|
||||
private static final String FIELD_ACCESSIBILITY_CHANNEL = Util.intToStringMaxRadix(29);
|
||||
private static final String FIELD_CRYPTO_TYPE = Util.intToStringMaxRadix(30);
|
||||
private static final String FIELD_TILE_COUNT_HORIZONTAL = Util.intToStringMaxRadix(31);
|
||||
private static final String FIELD_TILE_COUNT_VERTICAL = Util.intToStringMaxRadix(32);
|
||||
|
||||
@UnstableApi
|
||||
@Override
|
||||
|
|
@ -1347,6 +1406,7 @@ public final class Format implements Bundleable {
|
|||
public Bundle toBundle(boolean excludeMetadata) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(FIELD_ID, id);
|
||||
bundle.putString(FIELD_LABEL, label);
|
||||
if (labels != null) {
|
||||
for (int i = 0; i < labels.size(); i++) {
|
||||
bundle.putParcelable(keyForLabel(i), labels.get(i));
|
||||
|
|
@ -1416,8 +1476,9 @@ public final class Format implements Bundleable {
|
|||
public static Format fromBundle(Bundle bundle) {
|
||||
Builder builder = new Builder();
|
||||
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<>();
|
||||
for (int i = 0; ; i++) {
|
||||
@Nullable Label label = bundle.getParcelable(keyForLabel(i));
|
||||
|
|
|
|||
|
|
@ -87,6 +87,7 @@ public final class FormatTest {
|
|||
labels.add(new Label("id", "en", "label"));
|
||||
return new Format.Builder()
|
||||
.setId("id")
|
||||
.setLabel("label")
|
||||
.setLabels(labels)
|
||||
.setLanguage("language")
|
||||
.setSelectionFlags(C.SELECTION_FLAG_DEFAULT)
|
||||
|
|
|
|||
|
|
@ -450,6 +450,7 @@ public abstract class DecoderAudioRenderer<
|
|||
.setEncoderPadding(encoderPadding)
|
||||
.setMetadata(inputFormat.metadata)
|
||||
.setId(inputFormat.id)
|
||||
.setLabel(inputFormat.label)
|
||||
.setLabels(inputFormat.labels)
|
||||
.setLanguage(inputFormat.language)
|
||||
.setSelectionFlags(inputFormat.selectionFlags)
|
||||
|
|
|
|||
|
|
@ -551,6 +551,7 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
|
|||
.setEncoderPadding(format.encoderPadding)
|
||||
.setMetadata(format.metadata)
|
||||
.setId(format.id)
|
||||
.setLabel(format.label)
|
||||
.setLabels(format.labels)
|
||||
.setLanguage(format.language)
|
||||
.setSelectionFlags(format.selectionFlags)
|
||||
|
|
|
|||
|
|
@ -519,8 +519,6 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory {
|
|||
String label = subtitleConfigurations.get(i).label;
|
||||
if (label != null) {
|
||||
labels.add(new Label(null, null, label));
|
||||
} else {
|
||||
labels = null;
|
||||
}
|
||||
|
||||
Format format =
|
||||
|
|
@ -529,6 +527,7 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory {
|
|||
.setLanguage(subtitleConfigurations.get(i).language)
|
||||
.setSelectionFlags(subtitleConfigurations.get(i).selectionFlags)
|
||||
.setRoleFlags(subtitleConfigurations.get(i).roleFlags)
|
||||
.setLabel(label)
|
||||
.setLabels(labels)
|
||||
.setId(subtitleConfigurations.get(i).id)
|
||||
.build();
|
||||
|
|
|
|||
|
|
@ -177,8 +177,6 @@ public final class SingleSampleMediaSource extends BaseMediaSource {
|
|||
String label = subtitleConfiguration.label;
|
||||
if (label != null) {
|
||||
labels.add(new Label(null, null, label));
|
||||
} else {
|
||||
labels = null;
|
||||
}
|
||||
this.format =
|
||||
new Format.Builder()
|
||||
|
|
@ -186,6 +184,7 @@ public final class SingleSampleMediaSource extends BaseMediaSource {
|
|||
.setLanguage(subtitleConfiguration.language)
|
||||
.setSelectionFlags(subtitleConfiguration.selectionFlags)
|
||||
.setRoleFlags(subtitleConfiguration.roleFlags)
|
||||
.setLabel(label)
|
||||
.setLabels(labels)
|
||||
.setId(subtitleConfiguration.id != null ? subtitleConfiguration.id : trackId)
|
||||
.build();
|
||||
|
|
|
|||
|
|
@ -517,6 +517,7 @@ public final class OutputConsumerAdapterV30 implements MediaParser.OutputConsume
|
|||
.setLanguage(muxedCaptionFormat.language)
|
||||
.setRoleFlags(muxedCaptionFormat.roleFlags)
|
||||
.setSelectionFlags(muxedCaptionFormat.selectionFlags)
|
||||
.setLabel(muxedCaptionFormat.label)
|
||||
.setLabels(muxedCaptionFormat.labels)
|
||||
.setMetadata(muxedCaptionFormat.metadata);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -2058,7 +2058,7 @@ public final class SampleQueueTest {
|
|||
}
|
||||
|
||||
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 {
|
||||
|
|
|
|||
|
|
@ -405,7 +405,7 @@ public class DashManifestParser extends DefaultHandler
|
|||
int audioChannels = Format.NO_VALUE;
|
||||
int audioSamplingRate = parseInt(xpp, "audioSamplingRate", Format.NO_VALUE);
|
||||
String language = xpp.getAttributeValue(null, "lang");
|
||||
String adaptationSetLabel = xpp.getAttributeValue(null, "label");
|
||||
String label = xpp.getAttributeValue(null, "label");
|
||||
List<Label> labels = new ArrayList<>();
|
||||
String drmSchemeType = null;
|
||||
ArrayList<SchemeData> drmSchemeDatas = new ArrayList<>();
|
||||
|
|
@ -506,23 +506,22 @@ public class DashManifestParser extends DefaultHandler
|
|||
} else if (XmlPullParserUtil.isStartTag(xpp, "InbandEventStream")) {
|
||||
inbandEventStreams.add(parseDescriptor(xpp, "InbandEventStream"));
|
||||
} 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)) {
|
||||
parseAdaptationSetChild(xpp);
|
||||
}
|
||||
} while (!XmlPullParserUtil.isEndTag(xpp, "AdaptationSet"));
|
||||
|
||||
if (labels.size() == 0 && adaptationSetLabel != null) {
|
||||
labels.add(new Label(null, null, adaptationSetLabel));
|
||||
}
|
||||
|
||||
// Build the representations.
|
||||
List<Representation> representations = new ArrayList<>(representationInfos.size());
|
||||
for (int i = 0; i < representationInfos.size(); i++) {
|
||||
representations.add(
|
||||
buildRepresentation(
|
||||
representationInfos.get(i),
|
||||
labels.isEmpty() ? null : labels,
|
||||
label,
|
||||
labels,
|
||||
drmSchemeType,
|
||||
drmSchemeDatas,
|
||||
inbandEventStreams));
|
||||
|
|
@ -861,11 +860,15 @@ public class DashManifestParser extends DefaultHandler
|
|||
|
||||
protected Representation buildRepresentation(
|
||||
RepresentationInfo representationInfo,
|
||||
@Nullable String label,
|
||||
@Nullable List<Label> labels,
|
||||
@Nullable String extraDrmSchemeType,
|
||||
ArrayList<SchemeData> extraDrmSchemeDatas,
|
||||
ArrayList<Descriptor> extraInbandEventStreams) {
|
||||
Format.Builder formatBuilder = representationInfo.format.buildUpon();
|
||||
if (label != null) {
|
||||
formatBuilder.setLabel(label);
|
||||
}
|
||||
formatBuilder.setLabels(labels);
|
||||
@Nullable String drmSchemeType = representationInfo.drmSchemeType;
|
||||
if (drmSchemeType == null) {
|
||||
|
|
|
|||
|
|
@ -279,8 +279,9 @@ public class DashManifestParserTest {
|
|||
|
||||
List<AdaptationSet> adaptationSets = manifest.getPeriod(0).adaptationSets;
|
||||
|
||||
assertThat(adaptationSets.get(0).representations.get(0).format.labels.get(0).value)
|
||||
.isEqualTo("audio label");
|
||||
assertThat(adaptationSets.get(0).representations.get(0).format.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)
|
||||
.isEqualTo("video label");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -852,6 +852,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||
@Nullable String sampleMimeType = MimeTypes.getMediaMimeType(codecs);
|
||||
return new Format.Builder()
|
||||
.setId(variantFormat.id)
|
||||
.setLabel(variantFormat.label)
|
||||
.setLabels(variantFormat.labels)
|
||||
.setContainerMimeType(variantFormat.containerMimeType)
|
||||
.setSampleMimeType(sampleMimeType)
|
||||
|
|
@ -875,6 +876,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||
int selectionFlags = 0;
|
||||
int roleFlags = 0;
|
||||
@Nullable String language = null;
|
||||
@Nullable String label = null;
|
||||
@Nullable List<Label> labels = null;
|
||||
if (mediaTagFormat != null) {
|
||||
codecs = mediaTagFormat.codecs;
|
||||
|
|
@ -883,6 +885,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||
selectionFlags = mediaTagFormat.selectionFlags;
|
||||
roleFlags = mediaTagFormat.roleFlags;
|
||||
language = mediaTagFormat.language;
|
||||
label = mediaTagFormat.label;
|
||||
labels = mediaTagFormat.labels;
|
||||
} else {
|
||||
codecs = Util.getCodecsOfType(variantFormat.codecs, C.TRACK_TYPE_AUDIO);
|
||||
|
|
@ -892,6 +895,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||
selectionFlags = variantFormat.selectionFlags;
|
||||
roleFlags = variantFormat.roleFlags;
|
||||
language = variantFormat.language;
|
||||
label = variantFormat.label;
|
||||
labels = variantFormat.labels;
|
||||
}
|
||||
}
|
||||
|
|
@ -900,6 +904,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||
int peakBitrate = isPrimaryTrackInVariant ? variantFormat.peakBitrate : Format.NO_VALUE;
|
||||
return new Format.Builder()
|
||||
.setId(variantFormat.id)
|
||||
.setLabel(label)
|
||||
.setLabels(labels)
|
||||
.setContainerMimeType(variantFormat.containerMimeType)
|
||||
.setSampleMimeType(sampleMimeType)
|
||||
|
|
|
|||
|
|
@ -1583,6 +1583,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||
sampleFormat
|
||||
.buildUpon()
|
||||
.setId(playlistFormat.id)
|
||||
.setLabel(playlistFormat.label)
|
||||
.setLabels(playlistFormat.labels)
|
||||
.setLanguage(playlistFormat.language)
|
||||
.setSelectionFlags(playlistFormat.selectionFlags)
|
||||
|
|
|
|||
|
|
@ -477,6 +477,7 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli
|
|||
Format.Builder formatBuilder =
|
||||
new Format.Builder()
|
||||
.setId(groupId + ":" + name)
|
||||
.setLabel(name)
|
||||
.setLabels(labels)
|
||||
.setContainerMimeType(MimeTypes.APPLICATION_M3U8)
|
||||
.setSelectionFlags(parseSelectionFlags(line))
|
||||
|
|
|
|||
|
|
@ -745,12 +745,11 @@ public class SsManifestParser implements ParsingLoadable.Parser<SsManifest> {
|
|||
String label = (String) getNormalizedAttribute(KEY_NAME);
|
||||
if (label != null) {
|
||||
labels.add(new Label(null, null, label));
|
||||
} else {
|
||||
labels = null;
|
||||
}
|
||||
format =
|
||||
formatBuilder
|
||||
.setId(parser.getAttributeValue(null, KEY_INDEX))
|
||||
.setLabel(label)
|
||||
.setLabels(labels)
|
||||
.setSampleMimeType(sampleMimeType)
|
||||
.setAverageBitrate(parseRequiredInt(parser, KEY_BITRATE))
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ public final class SsManifestParserTest {
|
|||
Uri.parse("https://example.com/test.ismc"),
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -516,8 +516,11 @@ public final class AviExtractor implements Extractor {
|
|||
}
|
||||
StreamNameChunk streamName = streamList.getChild(StreamNameChunk.class);
|
||||
if (streamName != null) {
|
||||
String label = streamName.name;
|
||||
builder.setLabel(label);
|
||||
|
||||
List<Label> labels = new ArrayList<>();
|
||||
labels.add(new Label(null, null, streamName.name));
|
||||
labels.add(new Label(null, null, label));
|
||||
builder.setLabels(labels);
|
||||
}
|
||||
int trackType = MimeTypes.getTrackType(streamFormat.sampleMimeType);
|
||||
|
|
|
|||
|
|
@ -2424,6 +2424,8 @@ public class MatroskaExtractor implements Extractor {
|
|||
}
|
||||
|
||||
if (name != null && !TRACK_NAME_TO_ROTATION_DEGREES.containsKey(name)) {
|
||||
formatBuilder.setLabel(name);
|
||||
|
||||
List<Label> labels = new ArrayList<>();
|
||||
labels.add(new Label(null, null, name));
|
||||
formatBuilder.setLabels(labels);
|
||||
|
|
|
|||
|
|
@ -275,6 +275,8 @@ track 3:
|
|||
selectionFlags = [default]
|
||||
language = en
|
||||
label = Subs Label
|
||||
labels:
|
||||
value = Subs Label
|
||||
sample 0:
|
||||
time = 0
|
||||
flags = 1
|
||||
|
|
|
|||
|
|
@ -275,6 +275,8 @@ track 3:
|
|||
selectionFlags = [default]
|
||||
language = en
|
||||
label = Subs Label
|
||||
labels:
|
||||
value = Subs Label
|
||||
sample 0:
|
||||
time = 0
|
||||
flags = 1
|
||||
|
|
|
|||
|
|
@ -275,6 +275,8 @@ track 3:
|
|||
selectionFlags = [default]
|
||||
language = en
|
||||
label = Subs Label
|
||||
labels:
|
||||
value = Subs Label
|
||||
sample 0:
|
||||
time = 0
|
||||
flags = 1
|
||||
|
|
|
|||
|
|
@ -275,6 +275,8 @@ track 3:
|
|||
selectionFlags = [default]
|
||||
language = en
|
||||
label = Subs Label
|
||||
labels:
|
||||
value = Subs Label
|
||||
sample 0:
|
||||
time = 0
|
||||
flags = 1
|
||||
|
|
|
|||
|
|
@ -275,6 +275,8 @@ track 3:
|
|||
selectionFlags = [default]
|
||||
language = en
|
||||
label = Subs Label
|
||||
labels:
|
||||
value = Subs Label
|
||||
sample 0:
|
||||
time = 0
|
||||
flags = 1
|
||||
|
|
|
|||
|
|
@ -275,6 +275,8 @@ track 3:
|
|||
selectionFlags = [default]
|
||||
language = en
|
||||
label = Subs Label
|
||||
labels:
|
||||
value = Subs Label
|
||||
sample 0:
|
||||
time = 0
|
||||
flags = 1
|
||||
|
|
|
|||
|
|
@ -275,6 +275,8 @@ track 3:
|
|||
selectionFlags = [default]
|
||||
language = en
|
||||
label = Subs Label
|
||||
labels:
|
||||
value = Subs Label
|
||||
sample 0:
|
||||
time = 0
|
||||
flags = 1
|
||||
|
|
|
|||
|
|
@ -275,6 +275,8 @@ track 3:
|
|||
selectionFlags = [default]
|
||||
language = en
|
||||
label = Subs Label
|
||||
labels:
|
||||
value = Subs Label
|
||||
sample 0:
|
||||
time = 0
|
||||
flags = 1
|
||||
|
|
|
|||
|
|
@ -275,6 +275,8 @@ track 3:
|
|||
selectionFlags = [default]
|
||||
language = en
|
||||
label = Subs Label
|
||||
labels:
|
||||
value = Subs Label
|
||||
sample 0:
|
||||
time = 0
|
||||
flags = 1
|
||||
|
|
|
|||
|
|
@ -275,6 +275,8 @@ track 3:
|
|||
selectionFlags = [default]
|
||||
language = en
|
||||
label = Subs Label
|
||||
labels:
|
||||
value = Subs Label
|
||||
sample 0:
|
||||
time = 0
|
||||
flags = 1
|
||||
|
|
|
|||
|
|
@ -276,6 +276,8 @@ track 3:
|
|||
selectionFlags = [default]
|
||||
language = en
|
||||
label = Subs Label
|
||||
labels:
|
||||
value = Subs Label
|
||||
sample 0:
|
||||
time = 0
|
||||
flags = 1
|
||||
|
|
|
|||
|
|
@ -276,6 +276,8 @@ track 3:
|
|||
selectionFlags = [default]
|
||||
language = en
|
||||
label = Subs Label
|
||||
labels:
|
||||
value = Subs Label
|
||||
sample 0:
|
||||
time = 0
|
||||
flags = 1
|
||||
|
|
|
|||
|
|
@ -276,6 +276,8 @@ track 3:
|
|||
selectionFlags = [default]
|
||||
language = en
|
||||
label = Subs Label
|
||||
labels:
|
||||
value = Subs Label
|
||||
sample 0:
|
||||
time = 0
|
||||
flags = 1
|
||||
|
|
|
|||
|
|
@ -276,6 +276,8 @@ track 3:
|
|||
selectionFlags = [default]
|
||||
language = en
|
||||
label = Subs Label
|
||||
labels:
|
||||
value = Subs Label
|
||||
sample 0:
|
||||
time = 0
|
||||
flags = 1
|
||||
|
|
|
|||
|
|
@ -276,6 +276,8 @@ track 3:
|
|||
selectionFlags = [default]
|
||||
language = en
|
||||
label = Subs Label
|
||||
labels:
|
||||
value = Subs Label
|
||||
sample 0:
|
||||
time = 0
|
||||
flags = 1
|
||||
|
|
|
|||
|
|
@ -276,6 +276,8 @@ track 3:
|
|||
selectionFlags = [default]
|
||||
language = en
|
||||
label = Subs Label
|
||||
labels:
|
||||
value = Subs Label
|
||||
sample 0:
|
||||
time = 0
|
||||
flags = 1
|
||||
|
|
|
|||
|
|
@ -276,6 +276,8 @@ track 3:
|
|||
selectionFlags = [default]
|
||||
language = en
|
||||
label = Subs Label
|
||||
labels:
|
||||
value = Subs Label
|
||||
sample 0:
|
||||
time = 0
|
||||
flags = 1
|
||||
|
|
|
|||
|
|
@ -276,6 +276,8 @@ track 3:
|
|||
selectionFlags = [default]
|
||||
language = en
|
||||
label = Subs Label
|
||||
labels:
|
||||
value = Subs Label
|
||||
sample 0:
|
||||
time = 0
|
||||
flags = 1
|
||||
|
|
|
|||
|
|
@ -276,6 +276,8 @@ track 3:
|
|||
selectionFlags = [default]
|
||||
language = en
|
||||
label = Subs Label
|
||||
labels:
|
||||
value = Subs Label
|
||||
sample 0:
|
||||
time = 0
|
||||
flags = 1
|
||||
|
|
|
|||
|
|
@ -276,6 +276,8 @@ track 3:
|
|||
selectionFlags = [default]
|
||||
language = en
|
||||
label = Subs Label
|
||||
labels:
|
||||
value = Subs Label
|
||||
sample 0:
|
||||
time = 0
|
||||
flags = 1
|
||||
|
|
|
|||
|
|
@ -100,7 +100,22 @@ public final class DumpableFormat implements Dumper.Dumpable {
|
|||
DEFAULT_FORMAT,
|
||||
format -> Util.getRoleFlagStrings(format.roleFlags));
|
||||
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) {
|
||||
dumper.add("drmInitData", format.drmInitData.hashCode());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,8 +110,8 @@ public class DefaultTrackNameProvider implements TrackNameProvider {
|
|||
}
|
||||
|
||||
private String buildLabelString(Format format) {
|
||||
if (format.labels == null || format.labels.isEmpty()) {
|
||||
return "";
|
||||
if (format.labels.isEmpty()) {
|
||||
return TextUtils.isEmpty(format.label) ? "" : format.label;
|
||||
}
|
||||
if (!TextUtils.isEmpty(format.language)) {
|
||||
List<Label> labelsByLanguage =
|
||||
|
|
|
|||
Loading…
Reference in a new issue