Pixel Fusion v1.0.2版本的 MD5 值为:7c04c460c2996569d4ad075cd671a946
以下内容为反编译后的 DashMediaPeriod.java 源代码,内容仅作参考
package io.bidmachine.media3.exoplayer.dash;
import android.util.Pair;
import android.util.SparseArray;
import android.util.SparseIntArray;
import androidx.annotation.Nullable;
import com.google.common.primitives.dcadbB;
import com.trycrash.aid.c.ext.CrashCConstants;
import io.bidmachine.media3.common.Format;
import io.bidmachine.media3.common.StreamKey;
import io.bidmachine.media3.common.TrackGroup;
import io.bidmachine.media3.common.util.Util;
import io.bidmachine.media3.datasource.TransferListener;
import io.bidmachine.media3.exoplayer.SeekParameters;
import io.bidmachine.media3.exoplayer.analytics.PlayerId;
import io.bidmachine.media3.exoplayer.dash.DashChunkSource;
import io.bidmachine.media3.exoplayer.dash.PlayerEmsgHandler;
import io.bidmachine.media3.exoplayer.dash.manifest.AdaptationSet;
import io.bidmachine.media3.exoplayer.dash.manifest.DashManifest;
import io.bidmachine.media3.exoplayer.dash.manifest.Descriptor;
import io.bidmachine.media3.exoplayer.dash.manifest.EventStream;
import io.bidmachine.media3.exoplayer.dash.manifest.Period;
import io.bidmachine.media3.exoplayer.dash.manifest.Representation;
import io.bidmachine.media3.exoplayer.drm.DrmSessionEventListener;
import io.bidmachine.media3.exoplayer.drm.DrmSessionManager;
import io.bidmachine.media3.exoplayer.source.CompositeSequenceableLoaderFactory;
import io.bidmachine.media3.exoplayer.source.EmptySampleStream;
import io.bidmachine.media3.exoplayer.source.MediaPeriod;
import io.bidmachine.media3.exoplayer.source.MediaSourceEventListener;
import io.bidmachine.media3.exoplayer.source.SampleStream;
import io.bidmachine.media3.exoplayer.source.SequenceableLoader;
import io.bidmachine.media3.exoplayer.source.TrackGroupArray;
import io.bidmachine.media3.exoplayer.source.chunk.ChunkSampleStream;
import io.bidmachine.media3.exoplayer.trackselection.ExoTrackSelection;
import io.bidmachine.media3.exoplayer.upstream.Allocator;
import io.bidmachine.media3.exoplayer.upstream.CmcdConfiguration;
import io.bidmachine.media3.exoplayer.upstream.LoadErrorHandlingPolicy;
import io.bidmachine.media3.exoplayer.upstream.LoaderErrorThrower;
import java.io.IOException;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public final class DashMediaPeriod implements MediaPeriod, SequenceableLoader.Callback<ChunkSampleStream<DashChunkSource>>, ChunkSampleStream.ReleaseCallback<DashChunkSource> {
private static final Pattern CEA608_SERVICE_DESCRIPTOR_REGEX = Pattern.compile("CC([1-4])=(.+)");
private static final Pattern CEA708_SERVICE_DESCRIPTOR_REGEX = Pattern.compile("([1-4])=lang:(\\w+)(,.+)?");
private final Allocator allocator;
private final BaseUrlExclusionList baseUrlExclusionList;
@Nullable
private MediaPeriod.Callback callback;
private final DashChunkSource.Factory chunkSourceFactory;
@Nullable
private final CmcdConfiguration cmcdConfiguration;
private SequenceableLoader compositeSequenceableLoader;
private final CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory;
private final DrmSessionEventListener.EventDispatcher drmEventDispatcher;
private final DrmSessionManager drmSessionManager;
private final long elapsedRealtimeOffsetMs;
private List<EventStream> eventStreams;
final int id;
private final LoadErrorHandlingPolicy loadErrorHandlingPolicy;
private DashManifest manifest;
private final LoaderErrorThrower manifestLoaderErrorThrower;
private final MediaSourceEventListener.EventDispatcher mediaSourceEventDispatcher;
private int periodIndex;
private final PlayerEmsgHandler playerEmsgHandler;
private final PlayerId playerId;
private final TrackGroupInfo[] trackGroupInfos;
private final TrackGroupArray trackGroups;
@Nullable
private final TransferListener transferListener;
private ChunkSampleStream<DashChunkSource>[] sampleStreams = newSampleStreamArray(0);
private bBDaADdaAa[] eventSampleStreams = new bBDaADdaAa[0];
private final IdentityHashMap<ChunkSampleStream<DashChunkSource>, PlayerEmsgHandler.PlayerTrackEmsgHandler> trackEmsgHandlerBySampleStream = new IdentityHashMap<>();
public static final class TrackGroupInfo {
private static final int CATEGORY_EMBEDDED = 1;
private static final int CATEGORY_MANIFEST_EVENTS = 2;
private static final int CATEGORY_PRIMARY = 0;
public final int[] adaptationSetIndices;
public final int embeddedClosedCaptionTrackGroupIndex;
public final int embeddedEventMessageTrackGroupIndex;
public final int eventStreamGroupIndex;
public final int primaryTrackGroupIndex;
public final int trackGroupCategory;
public final int trackType;
@Target({ElementType.TYPE_USE})
@Documented
@Retention(RetentionPolicy.SOURCE)
public @interface TrackGroupCategory {
}
private TrackGroupInfo(int i, int i2, int[] iArr, int i3, int i4, int i5, int i6) {
this.trackType = i;
this.adaptationSetIndices = iArr;
this.trackGroupCategory = i2;
this.primaryTrackGroupIndex = i3;
this.embeddedEventMessageTrackGroupIndex = i4;
this.embeddedClosedCaptionTrackGroupIndex = i5;
this.eventStreamGroupIndex = i6;
}
public static TrackGroupInfo embeddedClosedCaptionTrack(int[] iArr, int i) {
return new TrackGroupInfo(3, 1, iArr, i, -1, -1, -1);
}
public static TrackGroupInfo embeddedEmsgTrack(int[] iArr, int i) {
return new TrackGroupInfo(5, 1, iArr, i, -1, -1, -1);
}
public static TrackGroupInfo mpdEventTrack(int i) {
return new TrackGroupInfo(5, 2, new int[0], -1, -1, -1, i);
}
public static TrackGroupInfo primaryTrack(int i, int[] iArr, int i2, int i3, int i4) {
return new TrackGroupInfo(i, 0, iArr, i2, i3, i4, -1);
}
}
public DashMediaPeriod(int i, DashManifest dashManifest, BaseUrlExclusionList baseUrlExclusionList, int i2, DashChunkSource.Factory factory, @Nullable TransferListener transferListener, @Nullable CmcdConfiguration cmcdConfiguration, DrmSessionManager drmSessionManager, DrmSessionEventListener.EventDispatcher eventDispatcher, LoadErrorHandlingPolicy loadErrorHandlingPolicy, MediaSourceEventListener.EventDispatcher eventDispatcher2, long j, LoaderErrorThrower loaderErrorThrower, Allocator allocator, CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory, PlayerEmsgHandler.PlayerEmsgCallback playerEmsgCallback, PlayerId playerId) {
this.id = i;
this.manifest = dashManifest;
this.baseUrlExclusionList = baseUrlExclusionList;
this.periodIndex = i2;
this.chunkSourceFactory = factory;
this.transferListener = transferListener;
this.cmcdConfiguration = cmcdConfiguration;
this.drmSessionManager = drmSessionManager;
this.drmEventDispatcher = eventDispatcher;
this.loadErrorHandlingPolicy = loadErrorHandlingPolicy;
this.mediaSourceEventDispatcher = eventDispatcher2;
this.elapsedRealtimeOffsetMs = j;
this.manifestLoaderErrorThrower = loaderErrorThrower;
this.allocator = allocator;
this.compositeSequenceableLoaderFactory = compositeSequenceableLoaderFactory;
this.playerId = playerId;
this.playerEmsgHandler = new PlayerEmsgHandler(dashManifest, playerEmsgCallback, allocator);
this.compositeSequenceableLoader = compositeSequenceableLoaderFactory.createCompositeSequenceableLoader(this.sampleStreams);
Period period = dashManifest.getPeriod(i2);
List<EventStream> list = period.eventStreams;
this.eventStreams = list;
Pair<TrackGroupArray, TrackGroupInfo[]> buildTrackGroups = buildTrackGroups(drmSessionManager, period.adaptationSets, list);
this.trackGroups = (TrackGroupArray) buildTrackGroups.first;
this.trackGroupInfos = (TrackGroupInfo[]) buildTrackGroups.second;
}
private static void buildManifestEventTrackGroupInfos(List<EventStream> list, TrackGroup[] trackGroupArr, TrackGroupInfo[] trackGroupInfoArr, int i) {
int i2 = 0;
while (i2 < list.size()) {
EventStream eventStream = list.get(i2);
trackGroupArr[i] = new TrackGroup(eventStream.id() + CrashCConstants.COLON_SEPARATOR + i2, new Format.Builder().setId(eventStream.id()).setSampleMimeType("application/x-emsg").build());
trackGroupInfoArr[i] = TrackGroupInfo.mpdEventTrack(i2);
i2++;
i++;
}
}
private static int buildPrimaryAndEmbeddedTrackGroupInfos(DrmSessionManager drmSessionManager, List<AdaptationSet> list, int[][] iArr, int i, boolean[] zArr, Format[][] formatArr, TrackGroup[] trackGroupArr, TrackGroupInfo[] trackGroupInfoArr) {
String BbdcDCacCa2;
int i2;
int i3;
int i4 = 0;
int i5 = 0;
while (i4 < i) {
int[] iArr2 = iArr[i4];
ArrayList arrayList = new ArrayList();
for (int i6 : iArr2) {
arrayList.addAll(list.get(i6).representations);
}
int size = arrayList.size();
Format[] formatArr2 = new Format[size];
for (int i7 = 0; i7 < size; i7++) {
Format format = ((Representation) arrayList.get(i7)).format;
formatArr2[i7] = format.copyWithCryptoType(drmSessionManager.getCryptoType(format));
}
AdaptationSet adaptationSet = list.get(iArr2[0]);
int i8 = adaptationSet.id;
if (i8 != -1) {
BbdcDCacCa2 = Integer.toString(i8);
} else {
BbdcDCacCa2 = android.support.v4.media.bBDaADdaAa.BbdcDCacCa("unset:", i4);
}
int i9 = i5 + 1;
if (zArr[i4]) {
i2 = i9;
i9++;
} else {
i2 = -1;
}
if (formatArr[i4].length != 0) {
i3 = i9;
i9++;
} else {
i3 = -1;
}
trackGroupArr[i5] = new TrackGroup(BbdcDCacCa2, formatArr2);
trackGroupInfoArr[i5] = TrackGroupInfo.primaryTrack(adaptationSet.type, iArr2, i5, i2, i3);
if (i2 != -1) {
String BbdcDCacCa3 = caCbdcBC.BbdcDCacCa.BbdcDCacCa(BbdcDCacCa2, ":emsg");
trackGroupArr[i2] = new TrackGroup(BbdcDCacCa3, new Format.Builder().setId(BbdcDCacCa3).setSampleMimeType("application/x-emsg").build());
trackGroupInfoArr[i2] = TrackGroupInfo.embeddedEmsgTrack(iArr2, i5);
}
if (i3 != -1) {
trackGroupArr[i3] = new TrackGroup(caCbdcBC.BbdcDCacCa.BbdcDCacCa(BbdcDCacCa2, ":cc"), formatArr[i4]);
trackGroupInfoArr[i3] = TrackGroupInfo.embeddedClosedCaptionTrack(iArr2, i5);
}
i4++;
i5 = i9;
}
return i5;
}
private ChunkSampleStream<DashChunkSource> buildSampleStream(TrackGroupInfo trackGroupInfo, ExoTrackSelection exoTrackSelection, long j) {
boolean z;
TrackGroup trackGroup;
int i;
boolean z2;
TrackGroup trackGroup2;
int i2;
int i3 = trackGroupInfo.embeddedEventMessageTrackGroupIndex;
if (i3 != -1) {
z = true;
} else {
z = false;
}
PlayerEmsgHandler.PlayerTrackEmsgHandler playerTrackEmsgHandler = null;
if (z) {
trackGroup = this.trackGroups.get(i3);
i = 1;
} else {
trackGroup = null;
i = 0;
}
int i4 = trackGroupInfo.embeddedClosedCaptionTrackGroupIndex;
if (i4 != -1) {
z2 = true;
} else {
z2 = false;
}
if (z2) {
trackGroup2 = this.trackGroups.get(i4);
i += trackGroup2.length;
} else {
trackGroup2 = null;
}
Format[] formatArr = new Format[i];
int[] iArr = new int[i];
if (z) {
formatArr[0] = trackGroup.getFormat(0);
iArr[0] = 5;
i2 = 1;
} else {
i2 = 0;
}
ArrayList arrayList = new ArrayList();
if (z2) {
for (int i5 = 0; i5 < trackGroup2.length; i5++) {
Format format = trackGroup2.getFormat(i5);
formatArr[i2] = format;
iArr[i2] = 3;
arrayList.add(format);
i2++;
}
}
if (this.manifest.dynamic && z) {
playerTrackEmsgHandler = this.playerEmsgHandler.newPlayerTrackEmsgHandler();
}
PlayerEmsgHandler.PlayerTrackEmsgHandler playerTrackEmsgHandler2 = playerTrackEmsgHandler;
ChunkSampleStream<DashChunkSource> chunkSampleStream = new ChunkSampleStream<>(trackGroupInfo.trackType, iArr, formatArr, this.chunkSourceFactory.createDashChunkSource(this.manifestLoaderErrorThrower, this.manifest, this.baseUrlExclusionList, this.periodIndex, trackGroupInfo.adaptationSetIndices, exoTrackSelection, trackGroupInfo.trackType, this.elapsedRealtimeOffsetMs, z, arrayList, playerTrackEmsgHandler2, this.transferListener, this.playerId, this.cmcdConfiguration), this, this.allocator, j, this.drmSessionManager, this.drmEventDispatcher, this.loadErrorHandlingPolicy, this.mediaSourceEventDispatcher);
synchronized (this) {
this.trackEmsgHandlerBySampleStream.put(chunkSampleStream, playerTrackEmsgHandler2);
}
return chunkSampleStream;
}
private static Pair<TrackGroupArray, TrackGroupInfo[]> buildTrackGroups(DrmSessionManager drmSessionManager, List<AdaptationSet> list, List<EventStream> list2) {
int[][] groupedAdaptationSetIndices = getGroupedAdaptationSetIndices(list);
int length = groupedAdaptationSetIndices.length;
boolean[] zArr = new boolean[length];
Format[][] formatArr = new Format[length];
int size = list2.size() + identifyEmbeddedTracks(length, list, groupedAdaptationSetIndices, zArr, formatArr) + length;
TrackGroup[] trackGroupArr = new TrackGroup[size];
TrackGroupInfo[] trackGroupInfoArr = new TrackGroupInfo[size];
buildManifestEventTrackGroupInfos(list2, trackGroupArr, trackGroupInfoArr, buildPrimaryAndEmbeddedTrackGroupInfos(drmSessionManager, list, groupedAdaptationSetIndices, length, zArr, formatArr, trackGroupArr, trackGroupInfoArr));
return Pair.create(new TrackGroupArray(trackGroupArr), trackGroupInfoArr);
}
@Nullable
private static Descriptor findAdaptationSetSwitchingProperty(List<Descriptor> list) {
return findDescriptor(list, "urn:mpeg:dash:adaptation-set-switching:2016");
}
@Nullable
private static Descriptor findDescriptor(List<Descriptor> list, String str) {
for (int i = 0; i < list.size(); i++) {
Descriptor descriptor = list.get(i);
if (str.equals(descriptor.schemeIdUri)) {
return descriptor;
}
}
return null;
}
@Nullable
private static Descriptor findTrickPlayProperty(List<Descriptor> list) {
return findDescriptor(list, "http://dashif.org/guidelines/trickmode");
}
private static Format[] getClosedCaptionTrackFormats(List<AdaptationSet> list, int[] iArr) {
for (int i : iArr) {
AdaptationSet adaptationSet = list.get(i);
List<Descriptor> list2 = list.get(i).accessibilityDescriptors;
for (int i2 = 0; i2 < list2.size(); i2++) {
Descriptor descriptor = list2.get(i2);
if ("urn:scte:dash:cc:cea-608:2015".equals(descriptor.schemeIdUri)) {
return parseClosedCaptionDescriptor(descriptor, CEA608_SERVICE_DESCRIPTOR_REGEX, new Format.Builder().setSampleMimeType("application/cea-608").setId(adaptationSet.id + ":cea608").build());
}
if ("urn:scte:dash:cc:cea-708:2015".equals(descriptor.schemeIdUri)) {
return parseClosedCaptionDescriptor(descriptor, CEA708_SERVICE_DESCRIPTOR_REGEX, new Format.Builder().setSampleMimeType("application/cea-708").setId(adaptationSet.id + ":cea708").build());
}
}
}
return new Format[0];
}
private static int[][] getGroupedAdaptationSetIndices(List<AdaptationSet> list) {
int i;
Descriptor findAdaptationSetSwitchingProperty;
int size = list.size();
SparseIntArray sparseIntArray = new SparseIntArray(size);
ArrayList arrayList = new ArrayList(size);
SparseArray sparseArray = new SparseArray(size);
for (int i2 = 0; i2 < size; i2++) {
sparseIntArray.put(list.get(i2).id, i2);
ArrayList arrayList2 = new ArrayList();
arrayList2.add(Integer.valueOf(i2));
arrayList.add(arrayList2);
sparseArray.put(i2, arrayList2);
}
for (int i3 = 0; i3 < size; i3++) {
AdaptationSet adaptationSet = list.get(i3);
Descriptor findTrickPlayProperty = findTrickPlayProperty(adaptationSet.essentialProperties);
if (findTrickPlayProperty == null) {
findTrickPlayProperty = findTrickPlayProperty(adaptationSet.supplementalProperties);
}
if (findTrickPlayProperty == null || (i = sparseIntArray.get(Integer.parseInt(findTrickPlayProperty.value), -1)) == -1) {
i = i3;
}
if (i == i3 && (findAdaptationSetSwitchingProperty = findAdaptationSetSwitchingProperty(adaptationSet.supplementalProperties)) != null) {
for (String str : Util.split(findAdaptationSetSwitchingProperty.value, ",")) {
int i4 = sparseIntArray.get(Integer.parseInt(str), -1);
if (i4 != -1) {
i = Math.min(i, i4);
}
}
}
if (i != i3) {
List list2 = (List) sparseArray.get(i3);
List list3 = (List) sparseArray.get(i);
list3.addAll(list2);
sparseArray.put(i3, list3);
arrayList.remove(list2);
}
}
int size2 = arrayList.size();
int[][] iArr = new int[size2];
for (int i5 = 0; i5 < size2; i5++) {
int[] DaACacB2 = dcadbB.DaACacB((Collection) arrayList.get(i5));
iArr[i5] = DaACacB2;
Arrays.sort(DaACacB2);
}
return iArr;
}
private int getPrimaryStreamIndex(int i, int[] iArr) {
int i2 = iArr[i];
if (i2 == -1) {
return -1;
}
int i3 = this.trackGroupInfos[i2].primaryTrackGroupIndex;
for (int i4 = 0; i4 < iArr.length; i4++) {
int i5 = iArr[i4];
if (i5 == i3 && this.trackGroupInfos[i5].trackGroupCategory == 0) {
return i4;
}
}
return -1;
}
private int[] getStreamIndexToTrackGroupIndex(ExoTrackSelection[] exoTrackSelectionArr) {
int[] iArr = new int[exoTrackSelectionArr.length];
for (int i = 0; i < exoTrackSelectionArr.length; i++) {
ExoTrackSelection exoTrackSelection = exoTrackSelectionArr[i];
if (exoTrackSelection != null) {
iArr[i] = this.trackGroups.indexOf(exoTrackSelection.getTrackGroup());
} else {
iArr[i] = -1;
}
}
return iArr;
}
private static boolean hasEventMessageTrack(List<AdaptationSet> list, int[] iArr) {
for (int i : iArr) {
List<Representation> list2 = list.get(i).representations;
for (int i2 = 0; i2 < list2.size(); i2++) {
if (!list2.get(i2).inbandEventStreams.isEmpty()) {
return true;
}
}
}
return false;
}
private static int identifyEmbeddedTracks(int i, List<AdaptationSet> list, int[][] iArr, boolean[] zArr, Format[][] formatArr) {
int i2 = 0;
for (int i3 = 0; i3 < i; i3++) {
if (hasEventMessageTrack(list, iArr[i3])) {
zArr[i3] = true;
i2++;
}
Format[] closedCaptionTrackFormats = getClosedCaptionTrackFormats(list, iArr[i3]);
formatArr[i3] = closedCaptionTrackFormats;
if (closedCaptionTrackFormats.length != 0) {
i2++;
}
}
return i2;
}
private static ChunkSampleStream<DashChunkSource>[] newSampleStreamArray(int i) {
return new ChunkSampleStream[i];
}
private static Format[] parseClosedCaptionDescriptor(Descriptor descriptor, Pattern pattern, Format format) {
String str = descriptor.value;
if (str == null) {
return new Format[]{format};
}
String[] split = Util.split(str, ";");
Format[] formatArr = new Format[split.length];
for (int i = 0; i < split.length; i++) {
Matcher matcher = pattern.matcher(split[i]);
if (!matcher.matches()) {
return new Format[]{format};
}
int parseInt = Integer.parseInt(matcher.group(1));
formatArr[i] = format.buildUpon().setId(format.id + CrashCConstants.COLON_SEPARATOR + parseInt).setAccessibilityChannel(parseInt).setLanguage(matcher.group(2)).build();
}
return formatArr;
}
private void releaseDisabledStreams(ExoTrackSelection[] exoTrackSelectionArr, boolean[] zArr, SampleStream[] sampleStreamArr) {
for (int i = 0; i < exoTrackSelectionArr.length; i++) {
if (exoTrackSelectionArr[i] == null || !zArr[i]) {
SampleStream sampleStream = sampleStreamArr[i];
if (sampleStream instanceof ChunkSampleStream) {
((ChunkSampleStream) sampleStream).release(this);
} else if (sampleStream instanceof ChunkSampleStream.EmbeddedSampleStream) {
((ChunkSampleStream.EmbeddedSampleStream) sampleStream).release();
}
sampleStreamArr[i] = null;
}
}
}
private void releaseOrphanEmbeddedStreams(ExoTrackSelection[] exoTrackSelectionArr, SampleStream[] sampleStreamArr, int[] iArr) {
boolean z;
for (int i = 0; i < exoTrackSelectionArr.length; i++) {
SampleStream sampleStream = sampleStreamArr[i];
if ((sampleStream instanceof EmptySampleStream) || (sampleStream instanceof ChunkSampleStream.EmbeddedSampleStream)) {
int primaryStreamIndex = getPrimaryStreamIndex(i, iArr);
if (primaryStreamIndex == -1) {
z = sampleStreamArr[i] instanceof EmptySampleStream;
} else {
SampleStream sampleStream2 = sampleStreamArr[i];
if ((sampleStream2 instanceof ChunkSampleStream.EmbeddedSampleStream) && ((ChunkSampleStream.EmbeddedSampleStream) sampleStream2).parent == sampleStreamArr[primaryStreamIndex]) {
z = true;
} else {
z = false;
}
}
if (!z) {
SampleStream sampleStream3 = sampleStreamArr[i];
if (sampleStream3 instanceof ChunkSampleStream.EmbeddedSampleStream) {
((ChunkSampleStream.EmbeddedSampleStream) sampleStream3).release();
}
sampleStreamArr[i] = null;
}
}
}
}
private void selectNewStreams(ExoTrackSelection[] exoTrackSelectionArr, SampleStream[] sampleStreamArr, boolean[] zArr, long j, int[] iArr) {
for (int i = 0; i < exoTrackSelectionArr.length; i++) {
ExoTrackSelection exoTrackSelection = exoTrackSelectionArr[i];
if (exoTrackSelection != null) {
SampleStream sampleStream = sampleStreamArr[i];
if (sampleStream == null) {
zArr[i] = true;
TrackGroupInfo trackGroupInfo = this.trackGroupInfos[iArr[i]];
int i2 = trackGroupInfo.trackGroupCategory;
if (i2 == 0) {
sampleStreamArr[i] = buildSampleStream(trackGroupInfo, exoTrackSelection, j);
} else if (i2 == 2) {
sampleStreamArr[i] = new bBDaADdaAa(this.eventStreams.get(trackGroupInfo.eventStreamGroupIndex), exoTrackSelection.getTrackGroup().getFormat(0), this.manifest.dynamic);
}
} else if (sampleStream instanceof ChunkSampleStream) {
((DashChunkSource) ((ChunkSampleStream) sampleStream).getChunkSource()).updateTrackSelection(exoTrackSelection);
}
}
}
for (int i3 = 0; i3 < exoTrackSelectionArr.length; i3++) {
if (sampleStreamArr[i3] == null && exoTrackSelectionArr[i3] != null) {
TrackGroupInfo trackGroupInfo2 = this.trackGroupInfos[iArr[i3]];
if (trackGroupInfo2.trackGroupCategory == 1) {
int primaryStreamIndex = getPrimaryStreamIndex(i3, iArr);
if (primaryStreamIndex == -1) {
sampleStreamArr[i3] = new EmptySampleStream();
} else {
sampleStreamArr[i3] = ((ChunkSampleStream) sampleStreamArr[primaryStreamIndex]).selectEmbeddedTrack(j, trackGroupInfo2.trackType);
}
}
}
}
}
@Override
public boolean continueLoading(long j) {
return this.compositeSequenceableLoader.continueLoading(j);
}
@Override
public void discardBuffer(long j, boolean z) {
for (ChunkSampleStream<DashChunkSource> chunkSampleStream : this.sampleStreams) {
chunkSampleStream.discardBuffer(j, z);
}
}
@Override
public long getAdjustedSeekPositionUs(long j, SeekParameters seekParameters) {
for (ChunkSampleStream<DashChunkSource> chunkSampleStream : this.sampleStreams) {
if (chunkSampleStream.primaryTrackType == 2) {
return chunkSampleStream.getAdjustedSeekPositionUs(j, seekParameters);
}
}
return j;
}
@Override
public long getBufferedPositionUs() {
return this.compositeSequenceableLoader.getBufferedPositionUs();
}
@Override
public long getNextLoadPositionUs() {
return this.compositeSequenceableLoader.getNextLoadPositionUs();
}
@Override
public List<StreamKey> getStreamKeys(List<ExoTrackSelection> list) {
List<AdaptationSet> list2 = this.manifest.getPeriod(this.periodIndex).adaptationSets;
ArrayList arrayList = new ArrayList();
for (ExoTrackSelection exoTrackSelection : list) {
TrackGroupInfo trackGroupInfo = this.trackGroupInfos[this.trackGroups.indexOf(exoTrackSelection.getTrackGroup())];
if (trackGroupInfo.trackGroupCategory == 0) {
int[] iArr = trackGroupInfo.adaptationSetIndices;
int length = exoTrackSelection.length();
int[] iArr2 = new int[length];
for (int i = 0; i < exoTrackSelection.length(); i++) {
iArr2[i] = exoTrackSelection.getIndexInTrackGroup(i);
}
Arrays.sort(iArr2);
int size = list2.get(iArr[0]).representations.size();
int i2 = 0;
int i3 = 0;
for (int i4 = 0; i4 < length; i4++) {
int i5 = iArr2[i4];
while (true) {
int i6 = i3 + size;
if (i5 >= i6) {
i2++;
size = list2.get(iArr[i2]).representations.size();
i3 = i6;
}
}
arrayList.add(new StreamKey(this.periodIndex, iArr[i2], i5 - i3));
}
}
}
return arrayList;
}
@Override
public TrackGroupArray getTrackGroups() {
return this.trackGroups;
}
@Override
public boolean isLoading() {
return this.compositeSequenceableLoader.isLoading();
}
@Override
public void maybeThrowPrepareError() throws IOException {
this.manifestLoaderErrorThrower.maybeThrowError();
}
@Override
public synchronized void onSampleStreamReleased(ChunkSampleStream<DashChunkSource> chunkSampleStream) {
PlayerEmsgHandler.PlayerTrackEmsgHandler remove = this.trackEmsgHandlerBySampleStream.remove(chunkSampleStream);
if (remove != null) {
remove.release();
}
}
@Override
public void prepare(MediaPeriod.Callback callback, long j) {
this.callback = callback;
callback.onPrepared(this);
}
@Override
public long readDiscontinuity() {
return -9223372036854775807L;
}
@Override
public void reevaluateBuffer(long j) {
this.compositeSequenceableLoader.reevaluateBuffer(j);
}
public void release() {
this.playerEmsgHandler.release();
for (ChunkSampleStream<DashChunkSource> chunkSampleStream : this.sampleStreams) {
chunkSampleStream.release(this);
}
this.callback = null;
}
@Override
public long seekToUs(long j) {
for (ChunkSampleStream<DashChunkSource> chunkSampleStream : this.sampleStreams) {
chunkSampleStream.seekToUs(j);
}
for (bBDaADdaAa bbdaaddaaa : this.eventSampleStreams) {
bbdaaddaaa.seekToUs(j);
}
return j;
}
@Override
public long selectTracks(ExoTrackSelection[] exoTrackSelectionArr, boolean[] zArr, SampleStream[] sampleStreamArr, boolean[] zArr2, long j) {
int[] streamIndexToTrackGroupIndex = getStreamIndexToTrackGroupIndex(exoTrackSelectionArr);
releaseDisabledStreams(exoTrackSelectionArr, zArr, sampleStreamArr);
releaseOrphanEmbeddedStreams(exoTrackSelectionArr, sampleStreamArr, streamIndexToTrackGroupIndex);
selectNewStreams(exoTrackSelectionArr, sampleStreamArr, zArr2, j, streamIndexToTrackGroupIndex);
ArrayList arrayList = new ArrayList();
ArrayList arrayList2 = new ArrayList();
for (SampleStream sampleStream : sampleStreamArr) {
if (sampleStream instanceof ChunkSampleStream) {
arrayList.add((ChunkSampleStream) sampleStream);
} else if (sampleStream instanceof bBDaADdaAa) {
arrayList2.add((bBDaADdaAa) sampleStream);
}
}
ChunkSampleStream<DashChunkSource>[] newSampleStreamArray = newSampleStreamArray(arrayList.size());
this.sampleStreams = newSampleStreamArray;
arrayList.toArray(newSampleStreamArray);
bBDaADdaAa[] bbdaaddaaaArr = new bBDaADdaAa[arrayList2.size()];
this.eventSampleStreams = bbdaaddaaaArr;
arrayList2.toArray(bbdaaddaaaArr);
this.compositeSequenceableLoader = this.compositeSequenceableLoaderFactory.createCompositeSequenceableLoader(this.sampleStreams);
return j;
}
public void updateManifest(DashManifest dashManifest, int i) {
this.manifest = dashManifest;
this.periodIndex = i;
this.playerEmsgHandler.updateManifest(dashManifest);
ChunkSampleStream<DashChunkSource>[] chunkSampleStreamArr = this.sampleStreams;
if (chunkSampleStreamArr != null) {
for (ChunkSampleStream<DashChunkSource> chunkSampleStream : chunkSampleStreamArr) {
chunkSampleStream.getChunkSource().updateManifest(dashManifest, i);
}
this.callback.onContinueLoadingRequested(this);
}
this.eventStreams = dashManifest.getPeriod(i).eventStreams;
for (bBDaADdaAa bbdaaddaaa : this.eventSampleStreams) {
Iterator<EventStream> it = this.eventStreams.iterator();
while (true) {
if (it.hasNext()) {
EventStream next = it.next();
if (next.id().equals(bbdaaddaaa.eventStreamId())) {
boolean z = true;
int periodCount = dashManifest.getPeriodCount() - 1;
if (!dashManifest.dynamic || i != periodCount) {
z = false;
}
bbdaaddaaa.updateEventStream(next, z);
}
}
}
}
}
@Override
public void onContinueLoadingRequested(ChunkSampleStream<DashChunkSource> chunkSampleStream) {
this.callback.onContinueLoadingRequested(this);
}
}