Fix bug where missing switch adaptation set causes multiple identical track groups.

When the extra adaptation set of a switch group isn't defined in the manifest, we
currently assume it's the first adaptation group. This either leads to wrong grouping
or duplicate track groups.

Such a case may easily happen if the manifest is filtered such that only one of the
switch adaptation sets will be present in the manifest.

PiperOrigin-RevId: 229365379
This commit is contained in:
tonihei 2019-01-15 15:08:12 +00:00 committed by Oliver Woodman
parent c6092bbb43
commit ca7675ceae

View File

@ -46,6 +46,7 @@ import com.google.android.exoplayer2.upstream.LoadErrorHandlingPolicy;
import com.google.android.exoplayer2.upstream.LoaderErrorThrower;
import com.google.android.exoplayer2.upstream.TransferListener;
import com.google.android.exoplayer2.util.MimeTypes;
import com.google.android.exoplayer2.util.Util;
import java.io.IOException;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
@ -452,13 +453,22 @@ import java.util.List;
if (adaptationSetSwitchingProperty == null) {
groupedAdaptationSetIndices[groupCount++] = new int[] {i};
} else {
String[] extraAdaptationSetIds = adaptationSetSwitchingProperty.value.split(",");
String[] extraAdaptationSetIds = Util.split(adaptationSetSwitchingProperty.value, ",");
int[] adaptationSetIndices = new int[1 + extraAdaptationSetIds.length];
adaptationSetIndices[0] = i;
int outputIndex = 1;
for (int j = 0; j < extraAdaptationSetIds.length; j++) {
int extraIndex = idToIndexMap.get(Integer.parseInt(extraAdaptationSetIds[j]));
adaptationSetUsedFlags[extraIndex] = true;
adaptationSetIndices[1 + j] = extraIndex;
int extraIndex =
idToIndexMap.get(
Integer.parseInt(extraAdaptationSetIds[j]), /* valueIfKeyNotFound= */ -1);
if (extraIndex != -1) {
adaptationSetUsedFlags[extraIndex] = true;
adaptationSetIndices[outputIndex] = extraIndex;
outputIndex++;
}
}
if (outputIndex < adaptationSetIndices.length) {
adaptationSetIndices = Arrays.copyOf(adaptationSetIndices, outputIndex);
}
groupedAdaptationSetIndices[groupCount++] = adaptationSetIndices;
}