Removing id from Label and ensuring label/labels consistency in Format.Builder.
This commit is contained in:
parent
63fb68e99e
commit
e9e47f4fe6
@ -18,6 +18,7 @@ package androidx.media3.common;
|
|||||||
import static java.lang.annotation.ElementType.TYPE_USE;
|
import static java.lang.annotation.ElementType.TYPE_USE;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.text.TextUtils;
|
||||||
import androidx.annotation.IntDef;
|
import androidx.annotation.IntDef;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.media3.common.util.BundleCollectionUtil;
|
import androidx.media3.common.util.BundleCollectionUtil;
|
||||||
@ -137,7 +138,6 @@ 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 String label;
|
||||||
@Nullable private List<Label> labels;
|
@Nullable private List<Label> labels;
|
||||||
@Nullable private String language;
|
@Nullable private String language;
|
||||||
@ -756,12 +756,8 @@ 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. */
|
||||||
* The human readable label, or null if unknown or not applicable.
|
@Nullable public final String label;
|
||||||
*
|
|
||||||
* @deprecated Use {@link #labels} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated @Nullable public final String label;
|
|
||||||
|
|
||||||
/** The human readable list of labels, or null if unknown or not applicable. */
|
/** The human readable list of labels, or null if unknown or not applicable. */
|
||||||
@UnstableApi public final List<Label> labels;
|
@UnstableApi public final List<Label> labels;
|
||||||
@ -954,9 +950,13 @@ public final class Format implements Bundleable {
|
|||||||
|
|
||||||
private Format(Builder builder) {
|
private Format(Builder builder) {
|
||||||
id = builder.id;
|
id = builder.id;
|
||||||
label = builder.label;
|
|
||||||
labels = builder.labels == null ? Collections.emptyList() : builder.labels;
|
|
||||||
language = Util.normalizeLanguageCode(builder.language);
|
language = Util.normalizeLanguageCode(builder.language);
|
||||||
|
@Nullable String tmpLabel = builder.label;
|
||||||
|
labels = builder.labels == null ? new ArrayList<>() : builder.labels;
|
||||||
|
if (labels.isEmpty() && tmpLabel != null && !tmpLabel.isEmpty()) {
|
||||||
|
labels.add(new Label(language, tmpLabel));
|
||||||
|
}
|
||||||
|
label = makeLabelIfNeeded(tmpLabel, labels);
|
||||||
selectionFlags = builder.selectionFlags;
|
selectionFlags = builder.selectionFlags;
|
||||||
roleFlags = builder.roleFlags;
|
roleFlags = builder.roleFlags;
|
||||||
averageBitrate = builder.averageBitrate;
|
averageBitrate = builder.averageBitrate;
|
||||||
@ -1004,6 +1004,20 @@ public final class Format implements Bundleable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private @Nullable String makeLabelIfNeeded(@Nullable String label, List<Label> labels) {
|
||||||
|
if (label == null || label.isEmpty()) {
|
||||||
|
for (Label l : labels) {
|
||||||
|
if (TextUtils.equals(l.lang, language)) {
|
||||||
|
return l.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!labels.isEmpty()) {
|
||||||
|
return labels.get(0).value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|
||||||
/** Returns a {@link Format.Builder} initialized with the values of this instance. */
|
/** Returns a {@link Format.Builder} initialized with the values of this instance. */
|
||||||
@UnstableApi
|
@UnstableApi
|
||||||
public Builder buildUpon() {
|
public Builder buildUpon() {
|
||||||
|
@ -10,9 +10,6 @@ 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 {
|
||||||
/** The Label identifier, if one exists. */
|
|
||||||
@Nullable public final String id;
|
|
||||||
|
|
||||||
/** 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;
|
||||||
|
|
||||||
@ -20,18 +17,15 @@ public class Label implements Parcelable {
|
|||||||
public final String value;
|
public final String value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param id The id.
|
|
||||||
* @param lang The lang code.
|
* @param lang The lang code.
|
||||||
* @param value The value.
|
* @param value The value.
|
||||||
*/
|
*/
|
||||||
public Label(@Nullable String id, @Nullable String lang, String value) {
|
public Label(@Nullable String lang, String value) {
|
||||||
this.id = id;
|
|
||||||
this.lang = lang;
|
this.lang = lang;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* package */ Label(Parcel in) {
|
/* package */ Label(Parcel in) {
|
||||||
id = in.readString();
|
|
||||||
lang = in.readString();
|
lang = in.readString();
|
||||||
value = in.readString();
|
value = in.readString();
|
||||||
}
|
}
|
||||||
@ -41,15 +35,13 @@ 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(id, label.id)
|
return Util.areEqual(lang, label.lang)
|
||||||
&& Util.areEqual(lang, label.lang)
|
|
||||||
&& Util.areEqual(value, label.value);
|
&& Util.areEqual(value, label.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int result = value.hashCode();
|
int result = value.hashCode();
|
||||||
result = 31 * result + (id != null ? id.hashCode() : 0);
|
|
||||||
result = 31 * result + (lang != null ? lang.hashCode() : 0);
|
result = 31 * result + (lang != null ? lang.hashCode() : 0);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -61,7 +53,6 @@ public class Label implements Parcelable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToParcel(@NonNull Parcel dest, int flags) {
|
public void writeToParcel(@NonNull Parcel dest, int flags) {
|
||||||
dest.writeString(id);
|
|
||||||
dest.writeString(lang);
|
dest.writeString(lang);
|
||||||
dest.writeString(value);
|
dest.writeString(value);
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ public final class FormatTest {
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
List<Label> labels = new ArrayList<>();
|
List<Label> labels = new ArrayList<>();
|
||||||
labels.add(new Label("id", "en", "label"));
|
labels.add(new Label("en", "label"));
|
||||||
return new Format.Builder()
|
return new Format.Builder()
|
||||||
.setId("id")
|
.setId("id")
|
||||||
.setLabel("label")
|
.setLabel("label")
|
||||||
|
@ -26,7 +26,6 @@ import androidx.annotation.Nullable;
|
|||||||
import androidx.media3.common.AdViewProvider;
|
import androidx.media3.common.AdViewProvider;
|
||||||
import androidx.media3.common.C;
|
import androidx.media3.common.C;
|
||||||
import androidx.media3.common.Format;
|
import androidx.media3.common.Format;
|
||||||
import androidx.media3.common.Label;
|
|
||||||
import androidx.media3.common.MediaItem;
|
import androidx.media3.common.MediaItem;
|
||||||
import androidx.media3.common.MimeTypes;
|
import androidx.media3.common.MimeTypes;
|
||||||
import androidx.media3.common.util.Assertions;
|
import androidx.media3.common.util.Assertions;
|
||||||
@ -59,7 +58,6 @@ import com.google.common.collect.ImmutableList;
|
|||||||
import com.google.common.primitives.Ints;
|
import com.google.common.primitives.Ints;
|
||||||
import com.google.errorprone.annotations.CanIgnoreReturnValue;
|
import com.google.errorprone.annotations.CanIgnoreReturnValue;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -515,20 +513,13 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory {
|
|||||||
mediaSources[0] = mediaSource;
|
mediaSources[0] = mediaSource;
|
||||||
for (int i = 0; i < subtitleConfigurations.size(); i++) {
|
for (int i = 0; i < subtitleConfigurations.size(); i++) {
|
||||||
if (parseSubtitlesDuringExtraction) {
|
if (parseSubtitlesDuringExtraction) {
|
||||||
List<Label> labels = new ArrayList<>();
|
|
||||||
String label = subtitleConfigurations.get(i).label;
|
|
||||||
if (label != null) {
|
|
||||||
labels.add(new Label(null, null, label));
|
|
||||||
}
|
|
||||||
|
|
||||||
Format format =
|
Format format =
|
||||||
new Format.Builder()
|
new Format.Builder()
|
||||||
.setSampleMimeType(subtitleConfigurations.get(i).mimeType)
|
.setSampleMimeType(subtitleConfigurations.get(i).mimeType)
|
||||||
.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)
|
.setLabel(subtitleConfigurations.get(i).label)
|
||||||
.setLabels(labels)
|
|
||||||
.setId(subtitleConfigurations.get(i).id)
|
.setId(subtitleConfigurations.get(i).id)
|
||||||
.build();
|
.build();
|
||||||
ExtractorsFactory extractorsFactory =
|
ExtractorsFactory extractorsFactory =
|
||||||
|
@ -21,7 +21,6 @@ import static com.google.common.base.MoreObjects.firstNonNull;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.media3.common.Format;
|
import androidx.media3.common.Format;
|
||||||
import androidx.media3.common.Label;
|
|
||||||
import androidx.media3.common.MediaItem;
|
import androidx.media3.common.MediaItem;
|
||||||
import androidx.media3.common.MimeTypes;
|
import androidx.media3.common.MimeTypes;
|
||||||
import androidx.media3.common.Timeline;
|
import androidx.media3.common.Timeline;
|
||||||
@ -34,8 +33,6 @@ import androidx.media3.exoplayer.upstream.DefaultLoadErrorHandlingPolicy;
|
|||||||
import androidx.media3.exoplayer.upstream.LoadErrorHandlingPolicy;
|
import androidx.media3.exoplayer.upstream.LoadErrorHandlingPolicy;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.errorprone.annotations.CanIgnoreReturnValue;
|
import com.google.errorprone.annotations.CanIgnoreReturnValue;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads data at a given {@link Uri} as a single sample belonging to a single {@link MediaPeriod}.
|
* Loads data at a given {@link Uri} as a single sample belonging to a single {@link MediaPeriod}.
|
||||||
@ -173,19 +170,13 @@ public final class SingleSampleMediaSource extends BaseMediaSource {
|
|||||||
.setSubtitleConfigurations(ImmutableList.of(subtitleConfiguration))
|
.setSubtitleConfigurations(ImmutableList.of(subtitleConfiguration))
|
||||||
.setTag(tag)
|
.setTag(tag)
|
||||||
.build();
|
.build();
|
||||||
List<Label> labels = new ArrayList<>();
|
|
||||||
String label = subtitleConfiguration.label;
|
|
||||||
if (label != null) {
|
|
||||||
labels.add(new Label(null, null, label));
|
|
||||||
}
|
|
||||||
this.format =
|
this.format =
|
||||||
new Format.Builder()
|
new Format.Builder()
|
||||||
.setSampleMimeType(firstNonNull(subtitleConfiguration.mimeType, MimeTypes.TEXT_UNKNOWN))
|
.setSampleMimeType(firstNonNull(subtitleConfiguration.mimeType, MimeTypes.TEXT_UNKNOWN))
|
||||||
.setLanguage(subtitleConfiguration.language)
|
.setLanguage(subtitleConfiguration.language)
|
||||||
.setSelectionFlags(subtitleConfiguration.selectionFlags)
|
.setSelectionFlags(subtitleConfiguration.selectionFlags)
|
||||||
.setRoleFlags(subtitleConfiguration.roleFlags)
|
.setRoleFlags(subtitleConfiguration.roleFlags)
|
||||||
.setLabel(label)
|
.setLabel(subtitleConfiguration.label)
|
||||||
.setLabels(labels)
|
|
||||||
.setId(subtitleConfiguration.id != null ? subtitleConfiguration.id : trackId)
|
.setId(subtitleConfiguration.id != null ? subtitleConfiguration.id : trackId)
|
||||||
.build();
|
.build();
|
||||||
this.dataSpec =
|
this.dataSpec =
|
||||||
|
@ -506,9 +506,7 @@ 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")) {
|
||||||
Label parsedLabel = parseLabel(xpp);
|
labels.add(parseLabel(xpp));
|
||||||
label = parsedLabel.value;
|
|
||||||
labels.add(parsedLabel);
|
|
||||||
} else if (XmlPullParserUtil.isStartTag(xpp)) {
|
} else if (XmlPullParserUtil.isStartTag(xpp)) {
|
||||||
parseAdaptationSetChild(xpp);
|
parseAdaptationSetChild(xpp);
|
||||||
}
|
}
|
||||||
@ -861,7 +859,7 @@ public class DashManifestParser extends DefaultHandler
|
|||||||
protected Representation buildRepresentation(
|
protected Representation buildRepresentation(
|
||||||
RepresentationInfo representationInfo,
|
RepresentationInfo representationInfo,
|
||||||
@Nullable String label,
|
@Nullable String label,
|
||||||
@Nullable List<Label> labels,
|
List<Label> labels,
|
||||||
@Nullable String extraDrmSchemeType,
|
@Nullable String extraDrmSchemeType,
|
||||||
ArrayList<SchemeData> extraDrmSchemeDatas,
|
ArrayList<SchemeData> extraDrmSchemeDatas,
|
||||||
ArrayList<Descriptor> extraInbandEventStreams) {
|
ArrayList<Descriptor> extraInbandEventStreams) {
|
||||||
@ -1413,10 +1411,9 @@ public class DashManifestParser extends DefaultHandler
|
|||||||
* @return The parsed label.
|
* @return The parsed label.
|
||||||
*/
|
*/
|
||||||
protected Label parseLabel(XmlPullParser xpp) throws XmlPullParserException, IOException {
|
protected Label parseLabel(XmlPullParser xpp) throws XmlPullParserException, IOException {
|
||||||
String id = xpp.getAttributeValue(null, "id");
|
|
||||||
String lang = xpp.getAttributeValue(null, "lang");
|
String lang = xpp.getAttributeValue(null, "lang");
|
||||||
String value = parseText(xpp, "Label");
|
String value = parseText(xpp, "Label");
|
||||||
return new Label(id, lang, value);
|
return new Label(lang, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -435,27 +435,14 @@ public class DashManifestParserTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parseLabel() throws Exception {
|
public void parseLabel() throws Exception {
|
||||||
DashManifestParser parser = new DashManifestParser();
|
|
||||||
XmlPullParser xpp = XmlPullParserFactory.newInstance().newPullParser();
|
|
||||||
xpp.setInput(new StringReader("<Label id=\"1\" lang=\"en\">test label</Label>" + NEXT_TAG));
|
|
||||||
xpp.next();
|
|
||||||
|
|
||||||
Label label = parser.parseLabel(xpp);
|
|
||||||
assertThat(label.id).isEqualTo("1");
|
|
||||||
assertThat(label.lang).isEqualTo("en");
|
|
||||||
assertThat(label.value).isEqualTo("test label");
|
|
||||||
assertNextTag(xpp);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void parseLabel_noId() throws Exception {
|
|
||||||
DashManifestParser parser = new DashManifestParser();
|
DashManifestParser parser = new DashManifestParser();
|
||||||
XmlPullParser xpp = XmlPullParserFactory.newInstance().newPullParser();
|
XmlPullParser xpp = XmlPullParserFactory.newInstance().newPullParser();
|
||||||
xpp.setInput(new StringReader("<Label lang=\"en\">test label</Label>" + NEXT_TAG));
|
xpp.setInput(new StringReader("<Label lang=\"en\">test label</Label>" + NEXT_TAG));
|
||||||
xpp.next();
|
xpp.next();
|
||||||
|
|
||||||
Label label = parser.parseLabel(xpp);
|
Label label = parser.parseLabel(xpp);
|
||||||
assertThat(label.id).isEqualTo(null);
|
assertThat(label.lang).isEqualTo("en");
|
||||||
|
assertThat(label.value).isEqualTo("test label");
|
||||||
assertNextTag(xpp);
|
assertNextTag(xpp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,6 @@ import androidx.media3.common.C;
|
|||||||
import androidx.media3.common.DrmInitData;
|
import androidx.media3.common.DrmInitData;
|
||||||
import androidx.media3.common.DrmInitData.SchemeData;
|
import androidx.media3.common.DrmInitData.SchemeData;
|
||||||
import androidx.media3.common.Format;
|
import androidx.media3.common.Format;
|
||||||
import androidx.media3.common.Label;
|
|
||||||
import androidx.media3.common.Metadata;
|
import androidx.media3.common.Metadata;
|
||||||
import androidx.media3.common.MimeTypes;
|
import androidx.media3.common.MimeTypes;
|
||||||
import androidx.media3.common.ParserException;
|
import androidx.media3.common.ParserException;
|
||||||
@ -472,13 +471,10 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli
|
|||||||
line = mediaTags.get(i);
|
line = mediaTags.get(i);
|
||||||
String groupId = parseStringAttr(line, REGEX_GROUP_ID, variableDefinitions);
|
String groupId = parseStringAttr(line, REGEX_GROUP_ID, variableDefinitions);
|
||||||
String name = parseStringAttr(line, REGEX_NAME, variableDefinitions);
|
String name = parseStringAttr(line, REGEX_NAME, variableDefinitions);
|
||||||
List<Label> labels = new ArrayList<>();
|
|
||||||
labels.add(new Label(null, null, name));
|
|
||||||
Format.Builder formatBuilder =
|
Format.Builder formatBuilder =
|
||||||
new Format.Builder()
|
new Format.Builder()
|
||||||
.setId(groupId + ":" + name)
|
.setId(groupId + ":" + name)
|
||||||
.setLabel(name)
|
.setLabel(name)
|
||||||
.setLabels(labels)
|
|
||||||
.setContainerMimeType(MimeTypes.APPLICATION_M3U8)
|
.setContainerMimeType(MimeTypes.APPLICATION_M3U8)
|
||||||
.setSelectionFlags(parseSelectionFlags(line))
|
.setSelectionFlags(parseSelectionFlags(line))
|
||||||
.setRoleFlags(parseRoleFlags(line, variableDefinitions))
|
.setRoleFlags(parseRoleFlags(line, variableDefinitions))
|
||||||
|
@ -24,7 +24,6 @@ import androidx.media3.common.C;
|
|||||||
import androidx.media3.common.DrmInitData;
|
import androidx.media3.common.DrmInitData;
|
||||||
import androidx.media3.common.DrmInitData.SchemeData;
|
import androidx.media3.common.DrmInitData.SchemeData;
|
||||||
import androidx.media3.common.Format;
|
import androidx.media3.common.Format;
|
||||||
import androidx.media3.common.Label;
|
|
||||||
import androidx.media3.common.MimeTypes;
|
import androidx.media3.common.MimeTypes;
|
||||||
import androidx.media3.common.ParserException;
|
import androidx.media3.common.ParserException;
|
||||||
import androidx.media3.common.util.Assertions;
|
import androidx.media3.common.util.Assertions;
|
||||||
@ -741,16 +740,10 @@ public class SsManifestParser implements ParsingLoadable.Parser<SsManifest> {
|
|||||||
formatBuilder.setContainerMimeType(MimeTypes.APPLICATION_MP4);
|
formatBuilder.setContainerMimeType(MimeTypes.APPLICATION_MP4);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Label> labels = new ArrayList<>();
|
|
||||||
String label = (String) getNormalizedAttribute(KEY_NAME);
|
|
||||||
if (label != null) {
|
|
||||||
labels.add(new Label(null, null, label));
|
|
||||||
}
|
|
||||||
format =
|
format =
|
||||||
formatBuilder
|
formatBuilder
|
||||||
.setId(parser.getAttributeValue(null, KEY_INDEX))
|
.setId(parser.getAttributeValue(null, KEY_INDEX))
|
||||||
.setLabel(label)
|
.setLabel((String) getNormalizedAttribute(KEY_NAME))
|
||||||
.setLabels(labels)
|
|
||||||
.setSampleMimeType(sampleMimeType)
|
.setSampleMimeType(sampleMimeType)
|
||||||
.setAverageBitrate(parseRequiredInt(parser, KEY_BITRATE))
|
.setAverageBitrate(parseRequiredInt(parser, KEY_BITRATE))
|
||||||
.setLanguage((String) getNormalizedAttribute(KEY_LANGUAGE))
|
.setLanguage((String) getNormalizedAttribute(KEY_LANGUAGE))
|
||||||
|
@ -21,7 +21,6 @@ import androidx.annotation.IntDef;
|
|||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.media3.common.C;
|
import androidx.media3.common.C;
|
||||||
import androidx.media3.common.Format;
|
import androidx.media3.common.Format;
|
||||||
import androidx.media3.common.Label;
|
|
||||||
import androidx.media3.common.MimeTypes;
|
import androidx.media3.common.MimeTypes;
|
||||||
import androidx.media3.common.ParserException;
|
import androidx.media3.common.ParserException;
|
||||||
import androidx.media3.common.util.Assertions;
|
import androidx.media3.common.util.Assertions;
|
||||||
@ -43,7 +42,6 @@ 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.ArrayList;
|
||||||
import java.util.List;
|
|
||||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -516,12 +514,7 @@ 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(streamName.name);
|
||||||
builder.setLabel(label);
|
|
||||||
|
|
||||||
List<Label> labels = new ArrayList<>();
|
|
||||||
labels.add(new Label(null, null, label));
|
|
||||||
builder.setLabels(labels);
|
|
||||||
}
|
}
|
||||||
int trackType = MimeTypes.getTrackType(streamFormat.sampleMimeType);
|
int trackType = MimeTypes.getTrackType(streamFormat.sampleMimeType);
|
||||||
if (trackType == C.TRACK_TYPE_AUDIO || trackType == C.TRACK_TYPE_VIDEO) {
|
if (trackType == C.TRACK_TYPE_AUDIO || trackType == C.TRACK_TYPE_VIDEO) {
|
||||||
|
@ -33,7 +33,6 @@ import androidx.media3.common.ColorInfo;
|
|||||||
import androidx.media3.common.DrmInitData;
|
import androidx.media3.common.DrmInitData;
|
||||||
import androidx.media3.common.DrmInitData.SchemeData;
|
import androidx.media3.common.DrmInitData.SchemeData;
|
||||||
import androidx.media3.common.Format;
|
import androidx.media3.common.Format;
|
||||||
import androidx.media3.common.Label;
|
|
||||||
import androidx.media3.common.MimeTypes;
|
import androidx.media3.common.MimeTypes;
|
||||||
import androidx.media3.common.ParserException;
|
import androidx.media3.common.ParserException;
|
||||||
import androidx.media3.common.util.Log;
|
import androidx.media3.common.util.Log;
|
||||||
@ -2425,10 +2424,6 @@ 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);
|
formatBuilder.setLabel(name);
|
||||||
|
|
||||||
List<Label> labels = new ArrayList<>();
|
|
||||||
labels.add(new Label(null, null, name));
|
|
||||||
formatBuilder.setLabels(labels);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Format format =
|
Format format =
|
||||||
|
@ -276,6 +276,7 @@ track 3:
|
|||||||
language = en
|
language = en
|
||||||
label = Subs Label
|
label = Subs Label
|
||||||
labels:
|
labels:
|
||||||
|
lang = en
|
||||||
value = Subs Label
|
value = Subs Label
|
||||||
sample 0:
|
sample 0:
|
||||||
time = 0
|
time = 0
|
||||||
|
@ -276,6 +276,7 @@ track 3:
|
|||||||
language = en
|
language = en
|
||||||
label = Subs Label
|
label = Subs Label
|
||||||
labels:
|
labels:
|
||||||
|
lang = en
|
||||||
value = Subs Label
|
value = Subs Label
|
||||||
sample 0:
|
sample 0:
|
||||||
time = 0
|
time = 0
|
||||||
|
@ -276,6 +276,7 @@ track 3:
|
|||||||
language = en
|
language = en
|
||||||
label = Subs Label
|
label = Subs Label
|
||||||
labels:
|
labels:
|
||||||
|
lang = en
|
||||||
value = Subs Label
|
value = Subs Label
|
||||||
sample 0:
|
sample 0:
|
||||||
time = 0
|
time = 0
|
||||||
|
@ -276,6 +276,7 @@ track 3:
|
|||||||
language = en
|
language = en
|
||||||
label = Subs Label
|
label = Subs Label
|
||||||
labels:
|
labels:
|
||||||
|
lang = en
|
||||||
value = Subs Label
|
value = Subs Label
|
||||||
sample 0:
|
sample 0:
|
||||||
time = 0
|
time = 0
|
||||||
|
@ -276,6 +276,7 @@ track 3:
|
|||||||
language = en
|
language = en
|
||||||
label = Subs Label
|
label = Subs Label
|
||||||
labels:
|
labels:
|
||||||
|
lang = en
|
||||||
value = Subs Label
|
value = Subs Label
|
||||||
sample 0:
|
sample 0:
|
||||||
time = 0
|
time = 0
|
||||||
|
@ -276,6 +276,7 @@ track 3:
|
|||||||
language = en
|
language = en
|
||||||
label = Subs Label
|
label = Subs Label
|
||||||
labels:
|
labels:
|
||||||
|
lang = en
|
||||||
value = Subs Label
|
value = Subs Label
|
||||||
sample 0:
|
sample 0:
|
||||||
time = 0
|
time = 0
|
||||||
|
@ -276,6 +276,7 @@ track 3:
|
|||||||
language = en
|
language = en
|
||||||
label = Subs Label
|
label = Subs Label
|
||||||
labels:
|
labels:
|
||||||
|
lang = en
|
||||||
value = Subs Label
|
value = Subs Label
|
||||||
sample 0:
|
sample 0:
|
||||||
time = 0
|
time = 0
|
||||||
|
@ -276,6 +276,7 @@ track 3:
|
|||||||
language = en
|
language = en
|
||||||
label = Subs Label
|
label = Subs Label
|
||||||
labels:
|
labels:
|
||||||
|
lang = en
|
||||||
value = Subs Label
|
value = Subs Label
|
||||||
sample 0:
|
sample 0:
|
||||||
time = 0
|
time = 0
|
||||||
|
@ -276,6 +276,7 @@ track 3:
|
|||||||
language = en
|
language = en
|
||||||
label = Subs Label
|
label = Subs Label
|
||||||
labels:
|
labels:
|
||||||
|
lang = en
|
||||||
value = Subs Label
|
value = Subs Label
|
||||||
sample 0:
|
sample 0:
|
||||||
time = 0
|
time = 0
|
||||||
|
@ -276,6 +276,7 @@ track 3:
|
|||||||
language = en
|
language = en
|
||||||
label = Subs Label
|
label = Subs Label
|
||||||
labels:
|
labels:
|
||||||
|
lang = en
|
||||||
value = Subs Label
|
value = Subs Label
|
||||||
sample 0:
|
sample 0:
|
||||||
time = 0
|
time = 0
|
||||||
|
@ -277,6 +277,7 @@ track 3:
|
|||||||
language = en
|
language = en
|
||||||
label = Subs Label
|
label = Subs Label
|
||||||
labels:
|
labels:
|
||||||
|
lang = en
|
||||||
value = Subs Label
|
value = Subs Label
|
||||||
sample 0:
|
sample 0:
|
||||||
time = 0
|
time = 0
|
||||||
|
@ -277,6 +277,7 @@ track 3:
|
|||||||
language = en
|
language = en
|
||||||
label = Subs Label
|
label = Subs Label
|
||||||
labels:
|
labels:
|
||||||
|
lang = en
|
||||||
value = Subs Label
|
value = Subs Label
|
||||||
sample 0:
|
sample 0:
|
||||||
time = 0
|
time = 0
|
||||||
|
@ -277,6 +277,7 @@ track 3:
|
|||||||
language = en
|
language = en
|
||||||
label = Subs Label
|
label = Subs Label
|
||||||
labels:
|
labels:
|
||||||
|
lang = en
|
||||||
value = Subs Label
|
value = Subs Label
|
||||||
sample 0:
|
sample 0:
|
||||||
time = 0
|
time = 0
|
||||||
|
@ -277,6 +277,7 @@ track 3:
|
|||||||
language = en
|
language = en
|
||||||
label = Subs Label
|
label = Subs Label
|
||||||
labels:
|
labels:
|
||||||
|
lang = en
|
||||||
value = Subs Label
|
value = Subs Label
|
||||||
sample 0:
|
sample 0:
|
||||||
time = 0
|
time = 0
|
||||||
|
@ -277,6 +277,7 @@ track 3:
|
|||||||
language = en
|
language = en
|
||||||
label = Subs Label
|
label = Subs Label
|
||||||
labels:
|
labels:
|
||||||
|
lang = en
|
||||||
value = Subs Label
|
value = Subs Label
|
||||||
sample 0:
|
sample 0:
|
||||||
time = 0
|
time = 0
|
||||||
|
@ -277,6 +277,7 @@ track 3:
|
|||||||
language = en
|
language = en
|
||||||
label = Subs Label
|
label = Subs Label
|
||||||
labels:
|
labels:
|
||||||
|
lang = en
|
||||||
value = Subs Label
|
value = Subs Label
|
||||||
sample 0:
|
sample 0:
|
||||||
time = 0
|
time = 0
|
||||||
|
@ -277,6 +277,7 @@ track 3:
|
|||||||
language = en
|
language = en
|
||||||
label = Subs Label
|
label = Subs Label
|
||||||
labels:
|
labels:
|
||||||
|
lang = en
|
||||||
value = Subs Label
|
value = Subs Label
|
||||||
sample 0:
|
sample 0:
|
||||||
time = 0
|
time = 0
|
||||||
|
@ -277,6 +277,7 @@ track 3:
|
|||||||
language = en
|
language = en
|
||||||
label = Subs Label
|
label = Subs Label
|
||||||
labels:
|
labels:
|
||||||
|
lang = en
|
||||||
value = Subs Label
|
value = Subs Label
|
||||||
sample 0:
|
sample 0:
|
||||||
time = 0
|
time = 0
|
||||||
|
@ -277,6 +277,7 @@ track 3:
|
|||||||
language = en
|
language = en
|
||||||
label = Subs Label
|
label = Subs Label
|
||||||
labels:
|
labels:
|
||||||
|
lang = en
|
||||||
value = Subs Label
|
value = Subs Label
|
||||||
sample 0:
|
sample 0:
|
||||||
time = 0
|
time = 0
|
||||||
|
@ -277,6 +277,7 @@ track 3:
|
|||||||
language = en
|
language = en
|
||||||
label = Subs Label
|
label = Subs Label
|
||||||
labels:
|
labels:
|
||||||
|
lang = en
|
||||||
value = Subs Label
|
value = Subs Label
|
||||||
sample 0:
|
sample 0:
|
||||||
time = 0
|
time = 0
|
||||||
|
@ -104,11 +104,7 @@ public final class DumpableFormat implements Dumper.Dumpable {
|
|||||||
if (!format.labels.isEmpty()) {
|
if (!format.labels.isEmpty()) {
|
||||||
dumper.startBlock("labels");
|
dumper.startBlock("labels");
|
||||||
for (int i = 0; i < format.labels.size(); i++) {
|
for (int i = 0; i < format.labels.size(); i++) {
|
||||||
String id = format.labels.get(i).id;
|
|
||||||
String lang = format.labels.get(i).lang;
|
String lang = format.labels.get(i).lang;
|
||||||
if (id != null) {
|
|
||||||
dumper.add("id", id);
|
|
||||||
}
|
|
||||||
if (lang != null) {
|
if (lang != null) {
|
||||||
dumper.add("lang", lang);
|
dumper.add("lang", lang);
|
||||||
}
|
}
|
||||||
|
@ -20,14 +20,11 @@ import android.text.TextUtils;
|
|||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.media3.common.C;
|
import androidx.media3.common.C;
|
||||||
import androidx.media3.common.Format;
|
import androidx.media3.common.Format;
|
||||||
import androidx.media3.common.Label;
|
|
||||||
import androidx.media3.common.MimeTypes;
|
import androidx.media3.common.MimeTypes;
|
||||||
import androidx.media3.common.util.Assertions;
|
import androidx.media3.common.util.Assertions;
|
||||||
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 java.util.List;
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/** A default {@link TrackNameProvider}. */
|
/** A default {@link TrackNameProvider}. */
|
||||||
@UnstableApi
|
@UnstableApi
|
||||||
@ -110,20 +107,8 @@ public class DefaultTrackNameProvider implements TrackNameProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String buildLabelString(Format format) {
|
private String buildLabelString(Format format) {
|
||||||
if (format.labels.isEmpty()) {
|
|
||||||
return TextUtils.isEmpty(format.label) ? "" : format.label;
|
return TextUtils.isEmpty(format.label) ? "" : format.label;
|
||||||
}
|
}
|
||||||
if (!TextUtils.isEmpty(format.language)) {
|
|
||||||
List<Label> labelsByLanguage =
|
|
||||||
format.labels.stream()
|
|
||||||
.filter(label -> format.language.equals(label.lang))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
if (!labelsByLanguage.isEmpty()) {
|
|
||||||
return labelsByLanguage.get(0).value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return TextUtils.isEmpty(format.labels.get(0).value) ? "" : format.labels.get(0).value;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String buildLanguageString(Format format) {
|
private String buildLanguageString(Format format) {
|
||||||
@Nullable String language = format.language;
|
@Nullable String language = format.language;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user