mirror of
https://github.com/androidx/media.git
synced 2025-05-07 15:40:37 +08:00
FragmentedMp4Extractor: simplify track bundle initialization
This will simplify the addition of nullness annotations. PiperOrigin-RevId: 325414700
This commit is contained in:
parent
a5e6e3054d
commit
d8a95af5e0
@ -285,18 +285,22 @@ public class FragmentedMp4Extractor implements Extractor {
|
|||||||
extractorOutput = output;
|
extractorOutput = output;
|
||||||
initExtraTracks();
|
initExtraTracks();
|
||||||
if (sideloadedTrack != null) {
|
if (sideloadedTrack != null) {
|
||||||
TrackBundle bundle = new TrackBundle(output.track(0, sideloadedTrack.type));
|
TrackBundle bundle =
|
||||||
bundle.init(
|
new TrackBundle(
|
||||||
new TrackSampleTable(
|
output.track(0, sideloadedTrack.type),
|
||||||
sideloadedTrack,
|
new TrackSampleTable(
|
||||||
/* offsets= */ new long[0],
|
sideloadedTrack,
|
||||||
/* sizes= */ new int[0],
|
/* offsets= */ new long[0],
|
||||||
/* maximumSize= */ 0,
|
/* sizes= */ new int[0],
|
||||||
/* timestampsUs= */ new long[0],
|
/* maximumSize= */ 0,
|
||||||
/* flags= */ new int[0],
|
/* timestampsUs= */ new long[0],
|
||||||
/* durationUs= */ 0),
|
/* flags= */ new int[0],
|
||||||
new DefaultSampleValues(
|
/* durationUs= */ 0),
|
||||||
/* sampleDescriptionIndex= */ 0, /* duration= */ 0, /* size= */ 0, /* flags= */ 0));
|
new DefaultSampleValues(
|
||||||
|
/* sampleDescriptionIndex= */ 0,
|
||||||
|
/* duration= */ 0,
|
||||||
|
/* size= */ 0,
|
||||||
|
/* flags= */ 0));
|
||||||
trackBundles.put(0, bundle);
|
trackBundles.put(0, bundle);
|
||||||
extractorOutput.endTracks();
|
extractorOutput.endTracks();
|
||||||
}
|
}
|
||||||
@ -306,7 +310,7 @@ public class FragmentedMp4Extractor implements Extractor {
|
|||||||
public void seek(long position, long timeUs) {
|
public void seek(long position, long timeUs) {
|
||||||
int trackCount = trackBundles.size();
|
int trackCount = trackBundles.size();
|
||||||
for (int i = 0; i < trackCount; i++) {
|
for (int i = 0; i < trackCount; i++) {
|
||||||
trackBundles.valueAt(i).reset();
|
trackBundles.valueAt(i).resetFragmentInfo();
|
||||||
}
|
}
|
||||||
pendingMetadataSampleInfos.clear();
|
pendingMetadataSampleInfos.clear();
|
||||||
pendingMetadataSampleBytes = 0;
|
pendingMetadataSampleBytes = 0;
|
||||||
@ -517,8 +521,11 @@ public class FragmentedMp4Extractor implements Extractor {
|
|||||||
for (int i = 0; i < trackCount; i++) {
|
for (int i = 0; i < trackCount; i++) {
|
||||||
TrackSampleTable sampleTable = sampleTables.get(i);
|
TrackSampleTable sampleTable = sampleTables.get(i);
|
||||||
Track track = sampleTable.track;
|
Track track = sampleTable.track;
|
||||||
TrackBundle trackBundle = new TrackBundle(extractorOutput.track(i, track.type));
|
TrackBundle trackBundle =
|
||||||
trackBundle.init(sampleTable, getDefaultSampleValues(defaultSampleValuesArray, track.id));
|
new TrackBundle(
|
||||||
|
extractorOutput.track(i, track.type),
|
||||||
|
sampleTable,
|
||||||
|
getDefaultSampleValues(defaultSampleValuesArray, track.id));
|
||||||
trackBundles.put(track.id, trackBundle);
|
trackBundles.put(track.id, trackBundle);
|
||||||
durationUs = max(durationUs, track.durationUs);
|
durationUs = max(durationUs, track.durationUs);
|
||||||
}
|
}
|
||||||
@ -530,7 +537,7 @@ public class FragmentedMp4Extractor implements Extractor {
|
|||||||
Track track = sampleTable.track;
|
Track track = sampleTable.track;
|
||||||
trackBundles
|
trackBundles
|
||||||
.get(track.id)
|
.get(track.id)
|
||||||
.init(sampleTable, getDefaultSampleValues(defaultSampleValuesArray, track.id));
|
.reset(sampleTable, getDefaultSampleValues(defaultSampleValuesArray, track.id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -719,7 +726,7 @@ public class FragmentedMp4Extractor implements Extractor {
|
|||||||
TrackFragment fragment = trackBundle.fragment;
|
TrackFragment fragment = trackBundle.fragment;
|
||||||
long fragmentDecodeTime = fragment.nextFragmentDecodeTime;
|
long fragmentDecodeTime = fragment.nextFragmentDecodeTime;
|
||||||
boolean fragmentDecodeTimeIncludesMoov = fragment.nextFragmentDecodeTimeIncludesMoov;
|
boolean fragmentDecodeTimeIncludesMoov = fragment.nextFragmentDecodeTimeIncludesMoov;
|
||||||
trackBundle.reset();
|
trackBundle.resetFragmentInfo();
|
||||||
trackBundle.currentlyInFragment = true;
|
trackBundle.currentlyInFragment = true;
|
||||||
@Nullable LeafAtom tfdtAtom = traf.getLeafAtomOfType(Atom.TYPE_tfdt);
|
@Nullable LeafAtom tfdtAtom = traf.getLeafAtomOfType(Atom.TYPE_tfdt);
|
||||||
if (tfdtAtom != null && (flags & FLAG_WORKAROUND_IGNORE_TFDT_BOX) == 0) {
|
if (tfdtAtom != null && (flags & FLAG_WORKAROUND_IGNORE_TFDT_BOX) == 0) {
|
||||||
@ -1567,20 +1574,24 @@ public class FragmentedMp4Extractor implements Extractor {
|
|||||||
|
|
||||||
private boolean currentlyInFragment;
|
private boolean currentlyInFragment;
|
||||||
|
|
||||||
public TrackBundle(TrackOutput output) {
|
public TrackBundle(
|
||||||
|
TrackOutput output,
|
||||||
|
TrackSampleTable moovSampleTable,
|
||||||
|
DefaultSampleValues defaultSampleValues) {
|
||||||
this.output = output;
|
this.output = output;
|
||||||
fragment = new TrackFragment();
|
fragment = new TrackFragment();
|
||||||
scratch = new ParsableByteArray();
|
scratch = new ParsableByteArray();
|
||||||
encryptionSignalByte = new ParsableByteArray(1);
|
encryptionSignalByte = new ParsableByteArray(1);
|
||||||
defaultInitializationVector = new ParsableByteArray();
|
defaultInitializationVector = new ParsableByteArray();
|
||||||
|
reset(moovSampleTable, defaultSampleValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(TrackSampleTable moovSampleTable, DefaultSampleValues defaultSampleValues) {
|
public void reset(TrackSampleTable moovSampleTable, DefaultSampleValues defaultSampleValues) {
|
||||||
Assertions.checkNotNull(moovSampleTable.track);
|
Assertions.checkNotNull(moovSampleTable.track);
|
||||||
this.moovSampleTable = moovSampleTable;
|
this.moovSampleTable = moovSampleTable;
|
||||||
this.defaultSampleValues = Assertions.checkNotNull(defaultSampleValues);
|
this.defaultSampleValues = Assertions.checkNotNull(defaultSampleValues);
|
||||||
output.format(moovSampleTable.track.format);
|
output.format(moovSampleTable.track.format);
|
||||||
reset();
|
resetFragmentInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateDrmInitData(DrmInitData drmInitData) {
|
public void updateDrmInitData(DrmInitData drmInitData) {
|
||||||
@ -1596,7 +1607,7 @@ public class FragmentedMp4Extractor implements Extractor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Resets the current fragment, sample indices and {@link #currentlyInFragment} boolean. */
|
/** Resets the current fragment, sample indices and {@link #currentlyInFragment} boolean. */
|
||||||
public void reset() {
|
public void resetFragmentInfo() {
|
||||||
fragment.reset();
|
fragment.reset();
|
||||||
currentSampleIndex = 0;
|
currentSampleIndex = 0;
|
||||||
currentTrackRunIndex = 0;
|
currentTrackRunIndex = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user