Dump DumpableSamples list in track order.
Switch to SparseArray<List> rather than a Map<Integer, List>. Track indices now determine sample list dumping, reducing flakiness. PiperOrigin-RevId: 561658586
This commit is contained in:
parent
ab64e6f92d
commit
6ecd3e9c2d
@ -17,6 +17,7 @@ package androidx.media3.transformer;
|
|||||||
|
|
||||||
import static androidx.media3.common.util.Assertions.checkNotNull;
|
import static androidx.media3.common.util.Assertions.checkNotNull;
|
||||||
|
|
||||||
|
import android.util.SparseArray;
|
||||||
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;
|
||||||
@ -28,9 +29,7 @@ import com.google.common.collect.ImmutableList;
|
|||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link Dumpable} {@link Muxer} implementation that supports dumping information about all
|
* A {@link Dumpable} {@link Muxer} implementation that supports dumping information about all
|
||||||
@ -73,14 +72,14 @@ public final class CapturingMuxer implements Muxer, Dumpable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private final Muxer wrappedMuxer;
|
private final Muxer wrappedMuxer;
|
||||||
private final Map<Integer, List<DumpableSample>> trackIndexToSampleDumpables;
|
private final SparseArray<ArrayList<DumpableSample>> dumpableSamplesByTrackIndex;
|
||||||
private final List<Dumpable> dumpables;
|
private final List<Dumpable> dumpables;
|
||||||
|
|
||||||
/** Creates a new test muxer. */
|
/** Creates a new test muxer. */
|
||||||
private CapturingMuxer(Muxer wrappedMuxer) {
|
private CapturingMuxer(Muxer wrappedMuxer) {
|
||||||
this.wrappedMuxer = wrappedMuxer;
|
this.wrappedMuxer = wrappedMuxer;
|
||||||
|
dumpableSamplesByTrackIndex = new SparseArray<>();
|
||||||
dumpables = new ArrayList<>();
|
dumpables = new ArrayList<>();
|
||||||
trackIndexToSampleDumpables = new HashMap<>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Muxer implementation.
|
// Muxer implementation.
|
||||||
@ -89,7 +88,7 @@ public final class CapturingMuxer implements Muxer, Dumpable {
|
|||||||
public int addTrack(Format format) throws MuxerException {
|
public int addTrack(Format format) throws MuxerException {
|
||||||
int trackIndex = wrappedMuxer.addTrack(format);
|
int trackIndex = wrappedMuxer.addTrack(format);
|
||||||
dumpables.add(new DumpableFormat(format, trackIndex));
|
dumpables.add(new DumpableFormat(format, trackIndex));
|
||||||
trackIndexToSampleDumpables.put(trackIndex, new ArrayList<>());
|
dumpableSamplesByTrackIndex.append(trackIndex, new ArrayList<>());
|
||||||
return trackIndex;
|
return trackIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,7 +96,7 @@ public final class CapturingMuxer implements Muxer, Dumpable {
|
|||||||
public void writeSampleData(
|
public void writeSampleData(
|
||||||
int trackIndex, ByteBuffer data, long presentationTimeUs, @C.BufferFlags int flags)
|
int trackIndex, ByteBuffer data, long presentationTimeUs, @C.BufferFlags int flags)
|
||||||
throws MuxerException {
|
throws MuxerException {
|
||||||
trackIndexToSampleDumpables
|
dumpableSamplesByTrackIndex
|
||||||
.get(trackIndex)
|
.get(trackIndex)
|
||||||
.add(
|
.add(
|
||||||
new DumpableSample(
|
new DumpableSample(
|
||||||
@ -116,8 +115,8 @@ public final class CapturingMuxer implements Muxer, Dumpable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void release(boolean forCancellation) throws MuxerException {
|
public void release(boolean forCancellation) throws MuxerException {
|
||||||
for (List<DumpableSample> value : trackIndexToSampleDumpables.values()) {
|
for (int i = 0; i < dumpableSamplesByTrackIndex.size(); i++) {
|
||||||
dumpables.addAll(value);
|
dumpables.addAll(dumpableSamplesByTrackIndex.valueAt(i));
|
||||||
}
|
}
|
||||||
dumpables.add(dumper -> dumper.add("released", true));
|
dumpables.add(dumper -> dumper.add("released", true));
|
||||||
wrappedMuxer.release(forCancellation);
|
wrappedMuxer.release(forCancellation);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user