mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Make TsExtractor consistent with AdtsExtractor.
This commit is contained in:
parent
55e08ff712
commit
3a1325b0af
@ -49,7 +49,7 @@ public final class TsExtractor implements Extractor {
|
|||||||
private final ParsableByteArray tsPacketBuffer;
|
private final ParsableByteArray tsPacketBuffer;
|
||||||
private final SparseArray<ElementaryStreamReader> streamReaders; // Indexed by streamType
|
private final SparseArray<ElementaryStreamReader> streamReaders; // Indexed by streamType
|
||||||
private final SparseArray<TsPayloadReader> tsPayloadReaders; // Indexed by pid
|
private final SparseArray<TsPayloadReader> tsPayloadReaders; // Indexed by pid
|
||||||
private final long firstSampleTimestamp;
|
private final long firstSampleTimestampUs;
|
||||||
private final ParsableBitArray tsScratch;
|
private final ParsableBitArray tsScratch;
|
||||||
|
|
||||||
// Accessed only by the loading thread.
|
// Accessed only by the loading thread.
|
||||||
@ -57,8 +57,12 @@ public final class TsExtractor implements Extractor {
|
|||||||
private long timestampOffsetUs;
|
private long timestampOffsetUs;
|
||||||
private long lastPts;
|
private long lastPts;
|
||||||
|
|
||||||
public TsExtractor(long firstSampleTimestamp) {
|
public TsExtractor() {
|
||||||
this.firstSampleTimestamp = firstSampleTimestamp;
|
this(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TsExtractor(long firstSampleTimestampUs) {
|
||||||
|
this.firstSampleTimestampUs = firstSampleTimestampUs;
|
||||||
tsScratch = new ParsableBitArray(new byte[3]);
|
tsScratch = new ParsableBitArray(new byte[3]);
|
||||||
tsPacketBuffer = new ParsableByteArray(TS_PACKET_SIZE);
|
tsPacketBuffer = new ParsableByteArray(TS_PACKET_SIZE);
|
||||||
streamReaders = new SparseArray<ElementaryStreamReader>();
|
streamReaders = new SparseArray<ElementaryStreamReader>();
|
||||||
@ -138,7 +142,7 @@ public final class TsExtractor implements Extractor {
|
|||||||
long timeUs = (pts * C.MICROS_PER_SECOND) / 90000;
|
long timeUs = (pts * C.MICROS_PER_SECOND) / 90000;
|
||||||
// If we haven't done the initial timestamp adjustment, do it now.
|
// If we haven't done the initial timestamp adjustment, do it now.
|
||||||
if (lastPts == Long.MIN_VALUE) {
|
if (lastPts == Long.MIN_VALUE) {
|
||||||
timestampOffsetUs = firstSampleTimestamp - timeUs;
|
timestampOffsetUs = firstSampleTimestampUs - timeUs;
|
||||||
}
|
}
|
||||||
// Record the adjusted PTS to adjust for wraparound next time.
|
// Record the adjusted PTS to adjust for wraparound next time.
|
||||||
lastPts = pts;
|
lastPts = pts;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user