Commit 4451be92 by olly Committed by Oliver Woodman

Move sample offset application to RollingSampleBuffer.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=120123335
parent ffb4aeaa
......@@ -31,9 +31,6 @@ public class DefaultTrackOutput implements TrackOutput {
private final RollingSampleBuffer rollingBuffer;
private final DecoderInputBuffer sampleBuffer;
// Accessed only by the loading thread.
private long sampleOffsetUs;
// Accessed only by the consuming thread.
private boolean needKeyframe;
private long lastReadTimeUs;
......@@ -219,11 +216,9 @@ public class DefaultTrackOutput implements TrackOutput {
* @param sampleOffsetUs The offset in microseconds.
*/
public void setSampleOffsetUs(long sampleOffsetUs) {
this.sampleOffsetUs = sampleOffsetUs;
rollingBuffer.setSampleOffsetUs(sampleOffsetUs);
}
// TrackOutput implementation. Called by the loading thread.
@Override
public void format(Format format) {
rollingBuffer.format(format);
......@@ -242,7 +237,6 @@ public class DefaultTrackOutput implements TrackOutput {
@Override
public void sampleMetadata(long timeUs, int flags, int size, int offset, byte[] encryptionKey) {
timeUs += sampleOffsetUs;
largestParsedTimestampUs = Math.max(largestParsedTimestampUs, timeUs);
rollingBuffer.sampleMetadata(timeUs, flags, size, offset, encryptionKey);
}
......
......@@ -47,6 +47,7 @@ import java.util.concurrent.LinkedBlockingDeque;
private long totalBytesDropped;
// Accessed only by the loading thread.
private long sampleOffsetUs;
private long totalBytesWritten;
private Allocation lastAllocation;
private int lastAllocationOffset;
......@@ -355,6 +356,15 @@ import java.util.concurrent.LinkedBlockingDeque;
// Called by the loading thread.
/**
* Sets an offset that will be added to the timestamps of subsequently queued samples.
*
* @param sampleOffsetUs The timestamp offset in microseconds.
*/
public void setSampleOffsetUs(long sampleOffsetUs) {
this.sampleOffsetUs = sampleOffsetUs;
}
@Override
public void format(Format format) {
upstreamFormat = format;
......@@ -390,10 +400,10 @@ import java.util.concurrent.LinkedBlockingDeque;
}
@Override
public void sampleMetadata(long sampleTimeUs, int flags, int size, int offset,
byte[] encryptionKey) {
public void sampleMetadata(long timeUs, int flags, int size, int offset, byte[] encryptionKey) {
timeUs += sampleOffsetUs;
long absoluteOffset = totalBytesWritten - size - offset;
infoQueue.commitSample(sampleTimeUs, flags, absoluteOffset, size, encryptionKey);
infoQueue.commitSample(timeUs, flags, absoluteOffset, size, encryptionKey);
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment