mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
UrlTemplate uses ArrayLists instead of Arrays
This commit is contained in:
parent
81e2472034
commit
355484ebfb
1 changed files with 16 additions and 15 deletions
|
|
@ -16,6 +16,7 @@
|
||||||
package androidx.media3.exoplayer.dash.manifest;
|
package androidx.media3.exoplayer.dash.manifest;
|
||||||
|
|
||||||
import androidx.media3.common.util.UnstableApi;
|
import androidx.media3.common.util.UnstableApi;
|
||||||
|
import java.lang.reflect.Array;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
|
@ -39,9 +40,9 @@ public final class UrlTemplate {
|
||||||
private static final int BANDWIDTH_ID = 3;
|
private static final int BANDWIDTH_ID = 3;
|
||||||
private static final int TIME_ID = 4;
|
private static final int TIME_ID = 4;
|
||||||
|
|
||||||
private final String[] urlPieces;
|
private final ArrayList<String> urlPieces;
|
||||||
private final Integer[] identifiers;
|
private final ArrayList<Integer> identifiers;
|
||||||
private final String[] identifierFormatTags;
|
private final ArrayList<String> identifierFormatTags;
|
||||||
private final int identifierCount;
|
private final int identifierCount;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -63,9 +64,9 @@ public final class UrlTemplate {
|
||||||
/** Internal constructor. Use {@link #compile(String)} to build instances of this class. */
|
/** Internal constructor. Use {@link #compile(String)} to build instances of this class. */
|
||||||
private UrlTemplate(
|
private UrlTemplate(
|
||||||
ArrayList<String> urlPieces, ArrayList<Integer> identifiers, ArrayList<String> identifierFormatTags, int identifierCount) {
|
ArrayList<String> urlPieces, ArrayList<Integer> identifiers, ArrayList<String> identifierFormatTags, int identifierCount) {
|
||||||
this.urlPieces = urlPieces.toArray(new String[0]);
|
this.urlPieces = urlPieces;
|
||||||
this.identifiers = identifiers.toArray(new Integer[0]);
|
this.identifiers = identifiers;
|
||||||
this.identifierFormatTags = identifierFormatTags.toArray(new String[0]);
|
this.identifierFormatTags = identifierFormatTags;
|
||||||
this.identifierCount = identifierCount;
|
this.identifierCount = identifierCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -83,18 +84,18 @@ public final class UrlTemplate {
|
||||||
public String buildUri(String representationId, long segmentNumber, int bandwidth, long time) {
|
public String buildUri(String representationId, long segmentNumber, int bandwidth, long time) {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
for (int i = 0; i < identifierCount; i++) {
|
for (int i = 0; i < identifierCount; i++) {
|
||||||
builder.append(urlPieces[i]);
|
builder.append(urlPieces.get(i));
|
||||||
if (identifiers[i] == REPRESENTATION_ID) {
|
if (identifiers.get(i) == REPRESENTATION_ID) {
|
||||||
builder.append(representationId);
|
builder.append(representationId);
|
||||||
} else if (identifiers[i] == NUMBER_ID) {
|
} else if (identifiers.get(i) == NUMBER_ID) {
|
||||||
builder.append(String.format(Locale.US, identifierFormatTags[i], segmentNumber));
|
builder.append(String.format(Locale.US, identifierFormatTags.get(i), segmentNumber));
|
||||||
} else if (identifiers[i] == BANDWIDTH_ID) {
|
} else if (identifiers.get(i) == BANDWIDTH_ID) {
|
||||||
builder.append(String.format(Locale.US, identifierFormatTags[i], bandwidth));
|
builder.append(String.format(Locale.US, identifierFormatTags.get(i), bandwidth));
|
||||||
} else if (identifiers[i] == TIME_ID) {
|
} else if (identifiers.get(i) == TIME_ID) {
|
||||||
builder.append(String.format(Locale.US, identifierFormatTags[i], time));
|
builder.append(String.format(Locale.US, identifierFormatTags.get(i), time));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
builder.append(urlPieces[identifierCount]);
|
builder.append(urlPieces.get(identifierCount));
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue