Add ability to not offset in PtsTimestampAdjuster.
Issue: #1078 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=111325745
This commit is contained in:
parent
890dd5afb5
commit
18a39f3350
@ -23,6 +23,12 @@ import com.google.android.exoplayer.C;
|
|||||||
*/
|
*/
|
||||||
public final class PtsTimestampAdjuster {
|
public final class PtsTimestampAdjuster {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A special {@code firstSampleTimestampUs} value indicating that presentation timestamps should
|
||||||
|
* not be offset.
|
||||||
|
*/
|
||||||
|
public static final long DO_NOT_OFFSET = Long.MAX_VALUE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The value one greater than the largest representable (33 bit) presentation timestamp.
|
* The value one greater than the largest representable (33 bit) presentation timestamp.
|
||||||
*/
|
*/
|
||||||
@ -35,7 +41,8 @@ public final class PtsTimestampAdjuster {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param firstSampleTimestampUs The desired result of the first call to
|
* @param firstSampleTimestampUs The desired result of the first call to
|
||||||
* {@link #adjustTimestamp(long)}.
|
* {@link #adjustTimestamp(long)}, or {@link #DO_NOT_OFFSET} if presentation timestamps
|
||||||
|
* should not be offset.
|
||||||
*/
|
*/
|
||||||
public PtsTimestampAdjuster(long firstSampleTimestampUs) {
|
public PtsTimestampAdjuster(long firstSampleTimestampUs) {
|
||||||
this.firstSampleTimestampUs = firstSampleTimestampUs;
|
this.firstSampleTimestampUs = firstSampleTimestampUs;
|
||||||
@ -57,9 +64,9 @@ public final class PtsTimestampAdjuster {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scales and adjusts an MPEG-2 TS presentation timestamp.
|
* Scales and offsets an MPEG-2 TS presentation timestamp.
|
||||||
*
|
*
|
||||||
* @param pts The unscaled MPEG-2 TS presentation timestamp.
|
* @param pts The MPEG-2 TS presentation timestamp.
|
||||||
* @return The adjusted timestamp in microseconds.
|
* @return The adjusted timestamp in microseconds.
|
||||||
*/
|
*/
|
||||||
public long adjustTimestamp(long pts) {
|
public long adjustTimestamp(long pts) {
|
||||||
@ -74,8 +81,8 @@ public final class PtsTimestampAdjuster {
|
|||||||
}
|
}
|
||||||
// Calculate the corresponding timestamp.
|
// Calculate the corresponding timestamp.
|
||||||
long timeUs = ptsToUs(pts);
|
long timeUs = ptsToUs(pts);
|
||||||
// If we haven't done the initial timestamp adjustment, do it now.
|
if (firstSampleTimestampUs != DO_NOT_OFFSET && lastPts == Long.MIN_VALUE) {
|
||||||
if (lastPts == Long.MIN_VALUE) {
|
// Calculate the timestamp offset.
|
||||||
timestampOffsetUs = firstSampleTimestampUs - timeUs;
|
timestampOffsetUs = firstSampleTimestampUs - timeUs;
|
||||||
}
|
}
|
||||||
// Record the adjusted PTS to adjust for wraparound next time.
|
// Record the adjusted PTS to adjust for wraparound next time.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user