com.google.android.exoplayer2.SeekParameters Java Examples

The following examples show how to use com.google.android.exoplayer2.SeekParameters. 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: DefaultDashChunkSource.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
@Override
public long getAdjustedSeekPositionUs(long positionUs, SeekParameters seekParameters) {
  // Segments are aligned across representations, so any segment index will do.
  for (RepresentationHolder representationHolder : representationHolders) {
    if (representationHolder.segmentIndex != null) {
      long segmentNum = representationHolder.getSegmentNum(positionUs);
      long firstSyncUs = representationHolder.getSegmentStartTimeUs(segmentNum);
      long secondSyncUs =
          firstSyncUs < positionUs && segmentNum < representationHolder.getSegmentCount() - 1
              ? representationHolder.getSegmentStartTimeUs(segmentNum + 1)
              : firstSyncUs;
      return Util.resolveSeekPositionUs(positionUs, seekParameters, firstSyncUs, secondSyncUs);
    }
  }
  // We don't have a segment index to adjust the seek position with yet.
  return positionUs;
}
 
Example #2
Source File: ClippingMediaPeriod.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private SeekParameters clipSeekParameters(long positionUs, SeekParameters seekParameters) {
  long toleranceBeforeUs =
      Util.constrainValue(
          seekParameters.toleranceBeforeUs, /* min= */ 0, /* max= */ positionUs - startUs);
  long toleranceAfterUs =
      Util.constrainValue(
          seekParameters.toleranceAfterUs,
          /* min= */ 0,
          /* max= */ endUs == C.TIME_END_OF_SOURCE ? Long.MAX_VALUE : endUs - positionUs);
  if (toleranceBeforeUs == seekParameters.toleranceBeforeUs
      && toleranceAfterUs == seekParameters.toleranceAfterUs) {
    return seekParameters;
  } else {
    return new SeekParameters(toleranceBeforeUs, toleranceAfterUs);
  }
}
 
Example #3
Source File: ClippingMediaPeriod.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private SeekParameters clipSeekParameters(long positionUs, SeekParameters seekParameters) {
  long toleranceBeforeUs =
      Util.constrainValue(
          seekParameters.toleranceBeforeUs, /* min= */ 0, /* max= */ positionUs - startUs);
  long toleranceAfterUs =
      Util.constrainValue(
          seekParameters.toleranceAfterUs,
          /* min= */ 0,
          /* max= */ endUs == C.TIME_END_OF_SOURCE ? Long.MAX_VALUE : endUs - positionUs);
  if (toleranceBeforeUs == seekParameters.toleranceBeforeUs
      && toleranceAfterUs == seekParameters.toleranceAfterUs) {
    return seekParameters;
  } else {
    return new SeekParameters(toleranceBeforeUs, toleranceAfterUs);
  }
}
 
Example #4
Source File: DefaultDashChunkSource.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
@Override
public long getAdjustedSeekPositionUs(long positionUs, SeekParameters seekParameters) {
  // Segments are aligned across representations, so any segment index will do.
  for (RepresentationHolder representationHolder : representationHolders) {
    if (representationHolder.segmentIndex != null) {
      long segmentNum = representationHolder.getSegmentNum(positionUs);
      long firstSyncUs = representationHolder.getSegmentStartTimeUs(segmentNum);
      long secondSyncUs =
          firstSyncUs < positionUs && segmentNum < representationHolder.getSegmentCount() - 1
              ? representationHolder.getSegmentStartTimeUs(segmentNum + 1)
              : firstSyncUs;
      return Util.resolveSeekPositionUs(positionUs, seekParameters, firstSyncUs, secondSyncUs);
    }
  }
  // We don't have a segment index to adjust the seek position with yet.
  return positionUs;
}
 
Example #5
Source File: DefaultDashChunkSource.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public long getAdjustedSeekPositionUs(long positionUs, SeekParameters seekParameters) {
  // Segments are aligned across representations, so any segment index will do.
  for (RepresentationHolder representationHolder : representationHolders) {
    if (representationHolder.segmentIndex != null) {
      long segmentNum = representationHolder.getSegmentNum(positionUs);
      long firstSyncUs = representationHolder.getSegmentStartTimeUs(segmentNum);
      long secondSyncUs =
          firstSyncUs < positionUs && segmentNum < representationHolder.getSegmentCount() - 1
              ? representationHolder.getSegmentStartTimeUs(segmentNum + 1)
              : firstSyncUs;
      return Util.resolveSeekPositionUs(positionUs, seekParameters, firstSyncUs, secondSyncUs);
    }
  }
  // We don't have a segment index to adjust the seek position with yet.
  return positionUs;
}
 
Example #6
Source File: DefaultDashChunkSource.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public long getAdjustedSeekPositionUs(long positionUs, SeekParameters seekParameters) {
  // Segments are aligned across representations, so any segment index will do.
  for (RepresentationHolder representationHolder : representationHolders) {
    if (representationHolder.segmentIndex != null) {
      long segmentNum = representationHolder.getSegmentNum(positionUs);
      long firstSyncUs = representationHolder.getSegmentStartTimeUs(segmentNum);
      long secondSyncUs =
          firstSyncUs < positionUs && segmentNum < representationHolder.getSegmentCount() - 1
              ? representationHolder.getSegmentStartTimeUs(segmentNum + 1)
              : firstSyncUs;
      return Util.resolveSeekPositionUs(positionUs, seekParameters, firstSyncUs, secondSyncUs);
    }
  }
  // We don't have a segment index to adjust the seek position with yet.
  return positionUs;
}
 
Example #7
Source File: ClippingMediaPeriod.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private SeekParameters clipSeekParameters(long positionUs, SeekParameters seekParameters) {
  long toleranceBeforeUs =
      Util.constrainValue(
          seekParameters.toleranceBeforeUs, /* min= */ 0, /* max= */ positionUs - startUs);
  long toleranceAfterUs =
      Util.constrainValue(
          seekParameters.toleranceAfterUs,
          /* min= */ 0,
          /* max= */ endUs == C.TIME_END_OF_SOURCE ? Long.MAX_VALUE : endUs - positionUs);
  if (toleranceBeforeUs == seekParameters.toleranceBeforeUs
      && toleranceAfterUs == seekParameters.toleranceAfterUs) {
    return seekParameters;
  } else {
    return new SeekParameters(toleranceBeforeUs, toleranceAfterUs);
  }
}
 
Example #8
Source File: ClippingMediaPeriod.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private SeekParameters clipSeekParameters(long positionUs, SeekParameters seekParameters) {
  long toleranceBeforeUs =
      Util.constrainValue(
          seekParameters.toleranceBeforeUs, /* min= */ 0, /* max= */ positionUs - startUs);
  long toleranceAfterUs =
      Util.constrainValue(
          seekParameters.toleranceAfterUs,
          /* min= */ 0,
          /* max= */ endUs == C.TIME_END_OF_SOURCE ? Long.MAX_VALUE : endUs - positionUs);
  if (toleranceBeforeUs == seekParameters.toleranceBeforeUs
      && toleranceAfterUs == seekParameters.toleranceAfterUs) {
    return seekParameters;
  } else {
    return new SeekParameters(toleranceBeforeUs, toleranceAfterUs);
  }
}
 
Example #9
Source File: DefaultDashChunkSource.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
@Override
public long getAdjustedSeekPositionUs(long positionUs, SeekParameters seekParameters) {
  // Segments are aligned across representations, so any segment index will do.
  for (RepresentationHolder representationHolder : representationHolders) {
    if (representationHolder.segmentIndex != null) {
      long segmentNum = representationHolder.getSegmentNum(positionUs);
      long firstSyncUs = representationHolder.getSegmentStartTimeUs(segmentNum);
      long secondSyncUs =
          firstSyncUs < positionUs && segmentNum < representationHolder.getSegmentCount() - 1
              ? representationHolder.getSegmentStartTimeUs(segmentNum + 1)
              : firstSyncUs;
      return Util.resolveSeekPositionUs(positionUs, seekParameters, firstSyncUs, secondSyncUs);
    }
  }
  // We don't have a segment index to adjust the seek position with yet.
  return positionUs;
}
 
Example #10
Source File: ClippingMediaPeriod.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
private SeekParameters clipSeekParameters(long positionUs, SeekParameters seekParameters) {
  long toleranceBeforeUs =
      Util.constrainValue(
          seekParameters.toleranceBeforeUs, /* min= */ 0, /* max= */ positionUs - startUs);
  long toleranceAfterUs =
      Util.constrainValue(
          seekParameters.toleranceAfterUs,
          /* min= */ 0,
          /* max= */ endUs == C.TIME_END_OF_SOURCE ? Long.MAX_VALUE : endUs - positionUs);
  if (toleranceBeforeUs == seekParameters.toleranceBeforeUs
      && toleranceAfterUs == seekParameters.toleranceAfterUs) {
    return seekParameters;
  } else {
    return new SeekParameters(toleranceBeforeUs, toleranceAfterUs);
  }
}
 
Example #11
Source File: ProgressiveMediaPeriod.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
@Override
public long getAdjustedSeekPositionUs(long positionUs, SeekParameters seekParameters) {
  SeekMap seekMap = getPreparedState().seekMap;
  if (!seekMap.isSeekable()) {
    // Treat all seeks into non-seekable media as being to t=0.
    return 0;
  }
  SeekPoints seekPoints = seekMap.getSeekPoints(positionUs);
  return Util.resolveSeekPositionUs(
      positionUs, seekParameters, seekPoints.first.timeUs, seekPoints.second.timeUs);
}
 
Example #12
Source File: ExtractorMediaPeriod.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public long getAdjustedSeekPositionUs(long positionUs, SeekParameters seekParameters) {
  if (!seekMap.isSeekable()) {
    // Treat all seeks into non-seekable media as being to t=0.
    return 0;
  }
  SeekPoints seekPoints = seekMap.getSeekPoints(positionUs);
  return Util.resolveSeekPositionUs(
      positionUs, seekParameters, seekPoints.first.timeUs, seekPoints.second.timeUs);
}
 
Example #13
Source File: ClippingMediaPeriod.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public long getAdjustedSeekPositionUs(long positionUs, SeekParameters seekParameters) {
  if (positionUs == startUs) {
    // Never adjust seeks to the start of the clipped view.
    return startUs;
  }
  SeekParameters clippedSeekParameters = clipSeekParameters(positionUs, seekParameters);
  return mediaPeriod.getAdjustedSeekPositionUs(positionUs, clippedSeekParameters);
}
 
Example #14
Source File: DefaultSsChunkSource.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public long getAdjustedSeekPositionUs(long positionUs, SeekParameters seekParameters) {
  StreamElement streamElement = manifest.streamElements[streamElementIndex];
  int chunkIndex = streamElement.getChunkIndex(positionUs);
  long firstSyncUs = streamElement.getStartTimeUs(chunkIndex);
  long secondSyncUs =
      firstSyncUs < positionUs && chunkIndex < streamElement.chunkCount - 1
          ? streamElement.getStartTimeUs(chunkIndex + 1)
          : firstSyncUs;
  return Util.resolveSeekPositionUs(positionUs, seekParameters, firstSyncUs, secondSyncUs);
}
 
Example #15
Source File: SsMediaPeriod.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public long getAdjustedSeekPositionUs(long positionUs, SeekParameters seekParameters) {
  for (ChunkSampleStream<SsChunkSource> sampleStream : sampleStreams) {
    if (sampleStream.primaryTrackType == C.TRACK_TYPE_VIDEO) {
      return sampleStream.getAdjustedSeekPositionUs(positionUs, seekParameters);
    }
  }
  return positionUs;
}
 
Example #16
Source File: Util.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Resolves a seek given the requested seek position, a {@link SeekParameters} and two candidate
 * sync points.
 *
 * @param positionUs The requested seek position, in microseocnds.
 * @param seekParameters The {@link SeekParameters}.
 * @param firstSyncUs The first candidate seek point, in micrseconds.
 * @param secondSyncUs The second candidate seek point, in microseconds. May equal {@code
 *     firstSyncUs} if there's only one candidate.
 * @return The resolved seek position, in microseconds.
 */
public static long resolveSeekPositionUs(
    long positionUs, SeekParameters seekParameters, long firstSyncUs, long secondSyncUs) {
  if (SeekParameters.EXACT.equals(seekParameters)) {
    return positionUs;
  }
  long minPositionUs =
      subtractWithOverflowDefault(positionUs, seekParameters.toleranceBeforeUs, Long.MIN_VALUE);
  long maxPositionUs =
      addWithOverflowDefault(positionUs, seekParameters.toleranceAfterUs, Long.MAX_VALUE);
  boolean firstSyncPositionValid = minPositionUs <= firstSyncUs && firstSyncUs <= maxPositionUs;
  boolean secondSyncPositionValid =
      minPositionUs <= secondSyncUs && secondSyncUs <= maxPositionUs;
  if (firstSyncPositionValid && secondSyncPositionValid) {
    if (Math.abs(firstSyncUs - positionUs) <= Math.abs(secondSyncUs - positionUs)) {
      return firstSyncUs;
    } else {
      return secondSyncUs;
    }
  } else if (firstSyncPositionValid) {
    return firstSyncUs;
  } else if (secondSyncPositionValid) {
    return secondSyncUs;
  } else {
    return minPositionUs;
  }
}
 
Example #17
Source File: SsMediaPeriod.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public long getAdjustedSeekPositionUs(long positionUs, SeekParameters seekParameters) {
  for (ChunkSampleStream<SsChunkSource> sampleStream : sampleStreams) {
    if (sampleStream.primaryTrackType == C.TRACK_TYPE_VIDEO) {
      return sampleStream.getAdjustedSeekPositionUs(positionUs, seekParameters);
    }
  }
  return positionUs;
}
 
Example #18
Source File: DashMediaPeriod.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public long getAdjustedSeekPositionUs(long positionUs, SeekParameters seekParameters) {
  for (ChunkSampleStream<DashChunkSource> sampleStream : sampleStreams) {
    if (sampleStream.primaryTrackType == C.TRACK_TYPE_VIDEO) {
      return sampleStream.getAdjustedSeekPositionUs(positionUs, seekParameters);
    }
  }
  return positionUs;
}
 
Example #19
Source File: Util.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Resolves a seek given the requested seek position, a {@link SeekParameters} and two candidate
 * sync points.
 *
 * @param positionUs The requested seek position, in microseocnds.
 * @param seekParameters The {@link SeekParameters}.
 * @param firstSyncUs The first candidate seek point, in micrseconds.
 * @param secondSyncUs The second candidate seek point, in microseconds. May equal {@code
 *     firstSyncUs} if there's only one candidate.
 * @return The resolved seek position, in microseconds.
 */
public static long resolveSeekPositionUs(
    long positionUs, SeekParameters seekParameters, long firstSyncUs, long secondSyncUs) {
  if (SeekParameters.EXACT.equals(seekParameters)) {
    return positionUs;
  }
  long minPositionUs =
      subtractWithOverflowDefault(positionUs, seekParameters.toleranceBeforeUs, Long.MIN_VALUE);
  long maxPositionUs =
      addWithOverflowDefault(positionUs, seekParameters.toleranceAfterUs, Long.MAX_VALUE);
  boolean firstSyncPositionValid = minPositionUs <= firstSyncUs && firstSyncUs <= maxPositionUs;
  boolean secondSyncPositionValid =
      minPositionUs <= secondSyncUs && secondSyncUs <= maxPositionUs;
  if (firstSyncPositionValid && secondSyncPositionValid) {
    if (Math.abs(firstSyncUs - positionUs) <= Math.abs(secondSyncUs - positionUs)) {
      return firstSyncUs;
    } else {
      return secondSyncUs;
    }
  } else if (firstSyncPositionValid) {
    return firstSyncUs;
  } else if (secondSyncPositionValid) {
    return secondSyncUs;
  } else {
    return minPositionUs;
  }
}
 
Example #20
Source File: Util.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Resolves a seek given the requested seek position, a {@link SeekParameters} and two candidate
 * sync points.
 *
 * @param positionUs The requested seek position, in microseocnds.
 * @param seekParameters The {@link SeekParameters}.
 * @param firstSyncUs The first candidate seek point, in micrseconds.
 * @param secondSyncUs The second candidate seek point, in microseconds. May equal {@code
 *     firstSyncUs} if there's only one candidate.
 * @return The resolved seek position, in microseconds.
 */
public static long resolveSeekPositionUs(
    long positionUs, SeekParameters seekParameters, long firstSyncUs, long secondSyncUs) {
  if (SeekParameters.EXACT.equals(seekParameters)) {
    return positionUs;
  }
  long minPositionUs =
      subtractWithOverflowDefault(positionUs, seekParameters.toleranceBeforeUs, Long.MIN_VALUE);
  long maxPositionUs =
      addWithOverflowDefault(positionUs, seekParameters.toleranceAfterUs, Long.MAX_VALUE);
  boolean firstSyncPositionValid = minPositionUs <= firstSyncUs && firstSyncUs <= maxPositionUs;
  boolean secondSyncPositionValid =
      minPositionUs <= secondSyncUs && secondSyncUs <= maxPositionUs;
  if (firstSyncPositionValid && secondSyncPositionValid) {
    if (Math.abs(firstSyncUs - positionUs) <= Math.abs(secondSyncUs - positionUs)) {
      return firstSyncUs;
    } else {
      return secondSyncUs;
    }
  } else if (firstSyncPositionValid) {
    return firstSyncUs;
  } else if (secondSyncPositionValid) {
    return secondSyncUs;
  } else {
    return minPositionUs;
  }
}
 
Example #21
Source File: DashMediaPeriod.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public long getAdjustedSeekPositionUs(long positionUs, SeekParameters seekParameters) {
  for (ChunkSampleStream<DashChunkSource> sampleStream : sampleStreams) {
    if (sampleStream.primaryTrackType == C.TRACK_TYPE_VIDEO) {
      return sampleStream.getAdjustedSeekPositionUs(positionUs, seekParameters);
    }
  }
  return positionUs;
}
 
Example #22
Source File: ProgressiveMediaPeriod.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public long getAdjustedSeekPositionUs(long positionUs, SeekParameters seekParameters) {
  SeekMap seekMap = getPreparedState().seekMap;
  if (!seekMap.isSeekable()) {
    // Treat all seeks into non-seekable media as being to t=0.
    return 0;
  }
  SeekPoints seekPoints = seekMap.getSeekPoints(positionUs);
  return Util.resolveSeekPositionUs(
      positionUs, seekParameters, seekPoints.first.timeUs, seekPoints.second.timeUs);
}
 
Example #23
Source File: DefaultSsChunkSource.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public long getAdjustedSeekPositionUs(long positionUs, SeekParameters seekParameters) {
  StreamElement streamElement = manifest.streamElements[streamElementIndex];
  int chunkIndex = streamElement.getChunkIndex(positionUs);
  long firstSyncUs = streamElement.getStartTimeUs(chunkIndex);
  long secondSyncUs =
      firstSyncUs < positionUs && chunkIndex < streamElement.chunkCount - 1
          ? streamElement.getStartTimeUs(chunkIndex + 1)
          : firstSyncUs;
  return Util.resolveSeekPositionUs(positionUs, seekParameters, firstSyncUs, secondSyncUs);
}
 
Example #24
Source File: SsMediaPeriod.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public long getAdjustedSeekPositionUs(long positionUs, SeekParameters seekParameters) {
  for (ChunkSampleStream<SsChunkSource> sampleStream : sampleStreams) {
    if (sampleStream.primaryTrackType == C.TRACK_TYPE_VIDEO) {
      return sampleStream.getAdjustedSeekPositionUs(positionUs, seekParameters);
    }
  }
  return positionUs;
}
 
Example #25
Source File: Util.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Resolves a seek given the requested seek position, a {@link SeekParameters} and two candidate
 * sync points.
 *
 * @param positionUs The requested seek position, in microseocnds.
 * @param seekParameters The {@link SeekParameters}.
 * @param firstSyncUs The first candidate seek point, in micrseconds.
 * @param secondSyncUs The second candidate seek point, in microseconds. May equal {@code
 *     firstSyncUs} if there's only one candidate.
 * @return The resolved seek position, in microseconds.
 */
public static long resolveSeekPositionUs(
    long positionUs, SeekParameters seekParameters, long firstSyncUs, long secondSyncUs) {
  if (SeekParameters.EXACT.equals(seekParameters)) {
    return positionUs;
  }
  long minPositionUs =
      subtractWithOverflowDefault(positionUs, seekParameters.toleranceBeforeUs, Long.MIN_VALUE);
  long maxPositionUs =
      addWithOverflowDefault(positionUs, seekParameters.toleranceAfterUs, Long.MAX_VALUE);
  boolean firstSyncPositionValid = minPositionUs <= firstSyncUs && firstSyncUs <= maxPositionUs;
  boolean secondSyncPositionValid =
      minPositionUs <= secondSyncUs && secondSyncUs <= maxPositionUs;
  if (firstSyncPositionValid && secondSyncPositionValid) {
    if (Math.abs(firstSyncUs - positionUs) <= Math.abs(secondSyncUs - positionUs)) {
      return firstSyncUs;
    } else {
      return secondSyncUs;
    }
  } else if (firstSyncPositionValid) {
    return firstSyncUs;
  } else if (secondSyncPositionValid) {
    return secondSyncUs;
  } else {
    return minPositionUs;
  }
}
 
Example #26
Source File: ClippingMediaPeriod.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public long getAdjustedSeekPositionUs(long positionUs, SeekParameters seekParameters) {
  if (positionUs == startUs) {
    // Never adjust seeks to the start of the clipped view.
    return startUs;
  }
  SeekParameters clippedSeekParameters = clipSeekParameters(positionUs, seekParameters);
  return mediaPeriod.getAdjustedSeekPositionUs(positionUs, clippedSeekParameters);
}
 
Example #27
Source File: DashMediaPeriod.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public long getAdjustedSeekPositionUs(long positionUs, SeekParameters seekParameters) {
  for (ChunkSampleStream<DashChunkSource> sampleStream : sampleStreams) {
    if (sampleStream.primaryTrackType == C.TRACK_TYPE_VIDEO) {
      return sampleStream.getAdjustedSeekPositionUs(positionUs, seekParameters);
    }
  }
  return positionUs;
}
 
Example #28
Source File: ProgressiveMediaPeriod.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public long getAdjustedSeekPositionUs(long positionUs, SeekParameters seekParameters) {
  SeekMap seekMap = getPreparedState().seekMap;
  if (!seekMap.isSeekable()) {
    // Treat all seeks into non-seekable media as being to t=0.
    return 0;
  }
  SeekPoints seekPoints = seekMap.getSeekPoints(positionUs);
  return Util.resolveSeekPositionUs(
      positionUs, seekParameters, seekPoints.first.timeUs, seekPoints.second.timeUs);
}
 
Example #29
Source File: DefaultSsChunkSource.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public long getAdjustedSeekPositionUs(long positionUs, SeekParameters seekParameters) {
  StreamElement streamElement = manifest.streamElements[streamElementIndex];
  int chunkIndex = streamElement.getChunkIndex(positionUs);
  long firstSyncUs = streamElement.getStartTimeUs(chunkIndex);
  long secondSyncUs =
      firstSyncUs < positionUs && chunkIndex < streamElement.chunkCount - 1
          ? streamElement.getStartTimeUs(chunkIndex + 1)
          : firstSyncUs;
  return Util.resolveSeekPositionUs(positionUs, seekParameters, firstSyncUs, secondSyncUs);
}
 
Example #30
Source File: SsMediaPeriod.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public long getAdjustedSeekPositionUs(long positionUs, SeekParameters seekParameters) {
  for (ChunkSampleStream<SsChunkSource> sampleStream : sampleStreams) {
    if (sampleStream.primaryTrackType == C.TRACK_TYPE_VIDEO) {
      return sampleStream.getAdjustedSeekPositionUs(positionUs, seekParameters);
    }
  }
  return positionUs;
}