Java Code Examples for com.google.android.exoplayer2.util.TimestampAdjuster#getTimestampOffsetUs()

The following examples show how to use com.google.android.exoplayer2.util.TimestampAdjuster#getTimestampOffsetUs() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TsExtractor.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
@Override
public void seek(long position, long timeUs) {
  Assertions.checkState(mode != MODE_HLS);
  int timestampAdjustersCount = timestampAdjusters.size();
  for (int i = 0; i < timestampAdjustersCount; i++) {
    TimestampAdjuster timestampAdjuster = timestampAdjusters.get(i);
    boolean hasNotEncounteredFirstTimestamp =
        timestampAdjuster.getTimestampOffsetUs() == C.TIME_UNSET;
    if (hasNotEncounteredFirstTimestamp
        || (timestampAdjuster.getTimestampOffsetUs() != 0
            && timestampAdjuster.getFirstSampleTimestampUs() != timeUs)) {
      // - If a track in the TS stream has not encountered any sample, it's going to treat the
      // first sample encountered as timestamp 0, which is incorrect. So we have to set the first
      // sample timestamp for that track manually.
      // - If the timestamp adjuster has its timestamp set manually before, and now we seek to a
      // different position, we need to set the first sample timestamp manually again.
      timestampAdjuster.reset();
      timestampAdjuster.setFirstSampleTimestampUs(timeUs);
    }
  }
  if (timeUs != 0 && tsBinarySearchSeeker != null) {
    tsBinarySearchSeeker.setSeekTargetUs(timeUs);
  }
  tsPacketBuffer.reset();
  continuityCounters.clear();
  for (int i = 0; i < tsPayloadReaders.size(); i++) {
    tsPayloadReaders.valueAt(i).seek();
  }
  bytesSinceLastSync = 0;
}
 
Example 2
Source File: TsExtractor.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void seek(long position, long timeUs) {
  Assertions.checkState(mode != MODE_HLS);
  int timestampAdjustersCount = timestampAdjusters.size();
  for (int i = 0; i < timestampAdjustersCount; i++) {
    TimestampAdjuster timestampAdjuster = timestampAdjusters.get(i);
    boolean hasNotEncounteredFirstTimestamp =
        timestampAdjuster.getTimestampOffsetUs() == C.TIME_UNSET;
    if (hasNotEncounteredFirstTimestamp
        || (timestampAdjuster.getTimestampOffsetUs() != 0
            && timestampAdjuster.getFirstSampleTimestampUs() != timeUs)) {
      // - If a track in the TS stream has not encountered any sample, it's going to treat the
      // first sample encountered as timestamp 0, which is incorrect. So we have to set the first
      // sample timestamp for that track manually.
      // - If the timestamp adjuster has its timestamp set manually before, and now we seek to a
      // different position, we need to set the first sample timestamp manually again.
      timestampAdjuster.reset();
      timestampAdjuster.setFirstSampleTimestampUs(timeUs);
    }
  }
  if (timeUs != 0 && tsBinarySearchSeeker != null) {
    tsBinarySearchSeeker.setSeekTargetUs(timeUs);
  }
  tsPacketBuffer.reset();
  continuityCounters.clear();
  for (int i = 0; i < tsPayloadReaders.size(); i++) {
    tsPayloadReaders.valueAt(i).seek();
  }
  bytesSinceLastSync = 0;
}
 
Example 3
Source File: TsExtractor.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void seek(long position, long timeUs) {
  Assertions.checkState(mode != MODE_HLS);
  int timestampAdjustersCount = timestampAdjusters.size();
  for (int i = 0; i < timestampAdjustersCount; i++) {
    TimestampAdjuster timestampAdjuster = timestampAdjusters.get(i);
    boolean hasNotEncounteredFirstTimestamp =
        timestampAdjuster.getTimestampOffsetUs() == C.TIME_UNSET;
    if (hasNotEncounteredFirstTimestamp
        || (timestampAdjuster.getTimestampOffsetUs() != 0
            && timestampAdjuster.getFirstSampleTimestampUs() != timeUs)) {
      // - If a track in the TS stream has not encountered any sample, it's going to treat the
      // first sample encountered as timestamp 0, which is incorrect. So we have to set the first
      // sample timestamp for that track manually.
      // - If the timestamp adjuster has its timestamp set manually before, and now we seek to a
      // different position, we need to set the first sample timestamp manually again.
      timestampAdjuster.reset();
      timestampAdjuster.setFirstSampleTimestampUs(timeUs);
    }
  }
  if (timeUs != 0 && tsBinarySearchSeeker != null) {
    tsBinarySearchSeeker.setSeekTargetUs(timeUs);
  }
  tsPacketBuffer.reset();
  continuityCounters.clear();
  for (int i = 0; i < tsPayloadReaders.size(); i++) {
    tsPayloadReaders.valueAt(i).seek();
  }
  bytesSinceLastSync = 0;
}