Java Code Examples for com.google.android.exoplayer2.extractor.SeekMap#Unseekable

The following examples show how to use com.google.android.exoplayer2.extractor.SeekMap#Unseekable . 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: AmrExtractor.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private void maybeOutputSeekMap(long inputLength, int sampleReadResult) {
  if (hasOutputSeekMap) {
    return;
  }

  if ((flags & FLAG_ENABLE_CONSTANT_BITRATE_SEEKING) == 0
      || inputLength == C.LENGTH_UNSET
      || (firstSampleSize != C.LENGTH_UNSET && firstSampleSize != currentSampleSize)) {
    seekMap = new SeekMap.Unseekable(C.TIME_UNSET);
    extractorOutput.seekMap(seekMap);
    hasOutputSeekMap = true;
  } else if (numSamplesWithSameSize >= NUM_SAME_SIZE_CONSTANT_BIT_RATE_THRESHOLD
      || sampleReadResult == RESULT_END_OF_INPUT) {
    seekMap = getConstantBitrateSeekMap(inputLength);
    extractorOutput.seekMap(seekMap);
    hasOutputSeekMap = true;
  }
}
 
Example 2
Source File: AmrExtractor.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
private void maybeOutputSeekMap(long inputLength, int sampleReadResult) {
  if (hasOutputSeekMap) {
    return;
  }

  if ((flags & FLAG_ENABLE_CONSTANT_BITRATE_SEEKING) == 0
      || inputLength == C.LENGTH_UNSET
      || (firstSampleSize != C.LENGTH_UNSET && firstSampleSize != currentSampleSize)) {
    seekMap = new SeekMap.Unseekable(C.TIME_UNSET);
    extractorOutput.seekMap(seekMap);
    hasOutputSeekMap = true;
  } else if (numSamplesWithSameSize >= NUM_SAME_SIZE_CONSTANT_BIT_RATE_THRESHOLD
      || sampleReadResult == RESULT_END_OF_INPUT) {
    seekMap = getConstantBitrateSeekMap(inputLength);
    extractorOutput.seekMap(seekMap);
    hasOutputSeekMap = true;
  }
}
 
Example 3
Source File: FlacExtractor.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Outputs a {@link SeekMap} and returns a {@link FlacBinarySearchSeeker} if one is required to
 * handle seeks.
 */
@Nullable
private static FlacBinarySearchSeeker outputSeekMap(
    FlacDecoderJni decoderJni,
    FlacStreamMetadata streamMetadata,
    long streamLength,
    ExtractorOutput output) {
  boolean haveSeekTable = decoderJni.getSeekPoints(/* timeUs= */ 0) != null;
  FlacBinarySearchSeeker binarySearchSeeker = null;
  SeekMap seekMap;
  if (haveSeekTable) {
    seekMap = new FlacSeekMap(streamMetadata.durationUs(), decoderJni);
  } else if (streamLength != C.LENGTH_UNSET) {
    long firstFramePosition = decoderJni.getDecodePosition();
    binarySearchSeeker =
        new FlacBinarySearchSeeker(streamMetadata, firstFramePosition, streamLength, decoderJni);
    seekMap = binarySearchSeeker.getSeekMap();
  } else {
    seekMap = new SeekMap.Unseekable(streamMetadata.durationUs());
  }
  output.seekMap(seekMap);
  return binarySearchSeeker;
}
 
Example 4
Source File: AmrExtractor.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private void maybeOutputSeekMap(long inputLength, int sampleReadResult) {
  if (hasOutputSeekMap) {
    return;
  }

  if ((flags & FLAG_ENABLE_CONSTANT_BITRATE_SEEKING) == 0
      || inputLength == C.LENGTH_UNSET
      || (firstSampleSize != C.LENGTH_UNSET && firstSampleSize != currentSampleSize)) {
    seekMap = new SeekMap.Unseekable(C.TIME_UNSET);
    extractorOutput.seekMap(seekMap);
    hasOutputSeekMap = true;
  } else if (numSamplesWithSameSize >= NUM_SAME_SIZE_CONSTANT_BIT_RATE_THRESHOLD
      || sampleReadResult == RESULT_END_OF_INPUT) {
    seekMap = getConstantBitrateSeekMap(inputLength);
    extractorOutput.seekMap(seekMap);
    hasOutputSeekMap = true;
  }
}
 
Example 5
Source File: AmrExtractor.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private void maybeOutputSeekMap(long inputLength, int sampleReadResult) {
  if (hasOutputSeekMap) {
    return;
  }

  if ((flags & FLAG_ENABLE_CONSTANT_BITRATE_SEEKING) == 0
      || inputLength == C.LENGTH_UNSET
      || (firstSampleSize != C.LENGTH_UNSET && firstSampleSize != currentSampleSize)) {
    seekMap = new SeekMap.Unseekable(C.TIME_UNSET);
    extractorOutput.seekMap(seekMap);
    hasOutputSeekMap = true;
  } else if (numSamplesWithSameSize >= NUM_SAME_SIZE_CONSTANT_BIT_RATE_THRESHOLD
      || sampleReadResult == RESULT_END_OF_INPUT) {
    seekMap = getConstantBitrateSeekMap(inputLength);
    extractorOutput.seekMap(seekMap);
    hasOutputSeekMap = true;
  }
}
 
Example 6
Source File: FlacExtractor.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Outputs a {@link SeekMap} and returns a {@link FlacBinarySearchSeeker} if one is required to
 * handle seeks.
 */
@Nullable
private static FlacBinarySearchSeeker outputSeekMap(
    FlacDecoderJni decoderJni,
    FlacStreamMetadata streamMetadata,
    long streamLength,
    ExtractorOutput output) {
  boolean haveSeekTable = decoderJni.getSeekPoints(/* timeUs= */ 0) != null;
  FlacBinarySearchSeeker binarySearchSeeker = null;
  SeekMap seekMap;
  if (haveSeekTable) {
    seekMap = new FlacSeekMap(streamMetadata.durationUs(), decoderJni);
  } else if (streamLength != C.LENGTH_UNSET) {
    long firstFramePosition = decoderJni.getDecodePosition();
    binarySearchSeeker =
        new FlacBinarySearchSeeker(streamMetadata, firstFramePosition, streamLength, decoderJni);
    seekMap = binarySearchSeeker.getSeekMap();
  } else {
    seekMap = new SeekMap.Unseekable(streamMetadata.durationUs());
  }
  output.seekMap(seekMap);
  return binarySearchSeeker;
}
 
Example 7
Source File: AmrExtractor.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private void maybeOutputSeekMap(long inputLength, int sampleReadResult) {
  if (hasOutputSeekMap) {
    return;
  }

  if ((flags & FLAG_ENABLE_CONSTANT_BITRATE_SEEKING) == 0
      || inputLength == C.LENGTH_UNSET
      || (firstSampleSize != C.LENGTH_UNSET && firstSampleSize != currentSampleSize)) {
    seekMap = new SeekMap.Unseekable(C.TIME_UNSET);
    extractorOutput.seekMap(seekMap);
    hasOutputSeekMap = true;
  } else if (numSamplesWithSameSize >= NUM_SAME_SIZE_CONSTANT_BIT_RATE_THRESHOLD
      || sampleReadResult == RESULT_END_OF_INPUT) {
    seekMap = getConstantBitrateSeekMap(inputLength);
    extractorOutput.seekMap(seekMap);
    hasOutputSeekMap = true;
  }
}
 
Example 8
Source File: FlacExtractor.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private SeekMap getSeekMapForNonSeekTableFlac(ExtractorInput input, FlacStreamInfo streamInfo) {
  long inputLength = input.getLength();
  if (inputLength != C.LENGTH_UNSET) {
    long firstFramePosition = decoderJni.getDecodePosition();
    flacBinarySearchSeeker =
        new FlacBinarySearchSeeker(streamInfo, firstFramePosition, inputLength, decoderJni);
    return flacBinarySearchSeeker.getSeekMap();
  } else { // can't seek at all, because there's no SeekTable and the input length is unknown.
    return new SeekMap.Unseekable(streamInfo.durationUs());
  }
}
 
Example 9
Source File: MatroskaExtractor.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Builds a {@link SeekMap} from the recently gathered Cues information.
 *
 * @return The built {@link SeekMap}. The returned {@link SeekMap} may be unseekable if cues
 *     information was missing or incomplete.
 */
private SeekMap buildSeekMap() {
  if (segmentContentPosition == C.POSITION_UNSET || durationUs == C.TIME_UNSET
      || cueTimesUs == null || cueTimesUs.size() == 0
      || cueClusterPositions == null || cueClusterPositions.size() != cueTimesUs.size()) {
    // Cues information is missing or incomplete.
    cueTimesUs = null;
    cueClusterPositions = null;
    return new SeekMap.Unseekable(durationUs);
  }
  int cuePointsSize = cueTimesUs.size();
  int[] sizes = new int[cuePointsSize];
  long[] offsets = new long[cuePointsSize];
  long[] durationsUs = new long[cuePointsSize];
  long[] timesUs = new long[cuePointsSize];
  for (int i = 0; i < cuePointsSize; i++) {
    timesUs[i] = cueTimesUs.get(i);
    offsets[i] = segmentContentPosition + cueClusterPositions.get(i);
  }
  for (int i = 0; i < cuePointsSize - 1; i++) {
    sizes[i] = (int) (offsets[i + 1] - offsets[i]);
    durationsUs[i] = timesUs[i + 1] - timesUs[i];
  }
  sizes[cuePointsSize - 1] =
      (int) (segmentContentPosition + segmentContentSize - offsets[cuePointsSize - 1]);
  durationsUs[cuePointsSize - 1] = durationUs - timesUs[cuePointsSize - 1];
  cueTimesUs = null;
  cueClusterPositions = null;
  return new ChunkIndex(sizes, offsets, durationsUs, timesUs);
}
 
Example 10
Source File: MatroskaExtractor.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Builds a {@link SeekMap} from the recently gathered Cues information.
 *
 * @return The built {@link SeekMap}. The returned {@link SeekMap} may be unseekable if cues
 *     information was missing or incomplete.
 */
private SeekMap buildSeekMap() {
  if (segmentContentPosition == C.POSITION_UNSET || durationUs == C.TIME_UNSET
      || cueTimesUs == null || cueTimesUs.size() == 0
      || cueClusterPositions == null || cueClusterPositions.size() != cueTimesUs.size()) {
    // Cues information is missing or incomplete.
    cueTimesUs = null;
    cueClusterPositions = null;
    return new SeekMap.Unseekable(durationUs);
  }
  int cuePointsSize = cueTimesUs.size();
  int[] sizes = new int[cuePointsSize];
  long[] offsets = new long[cuePointsSize];
  long[] durationsUs = new long[cuePointsSize];
  long[] timesUs = new long[cuePointsSize];
  for (int i = 0; i < cuePointsSize; i++) {
    timesUs[i] = cueTimesUs.get(i);
    offsets[i] = segmentContentPosition + cueClusterPositions.get(i);
  }
  for (int i = 0; i < cuePointsSize - 1; i++) {
    sizes[i] = (int) (offsets[i + 1] - offsets[i]);
    durationsUs[i] = timesUs[i + 1] - timesUs[i];
  }
  sizes[cuePointsSize - 1] =
      (int) (segmentContentPosition + segmentContentSize - offsets[cuePointsSize - 1]);
  durationsUs[cuePointsSize - 1] = durationUs - timesUs[cuePointsSize - 1];
  cueTimesUs = null;
  cueClusterPositions = null;
  return new ChunkIndex(sizes, offsets, durationsUs, timesUs);
}
 
Example 11
Source File: MatroskaExtractor.java    From K-Sonic with MIT License 5 votes vote down vote up
/**
 * Builds a {@link SeekMap} from the recently gathered Cues information.
 *
 * @return The built {@link SeekMap}. The returned {@link SeekMap} may be unseekable if cues
 *     information was missing or incomplete.
 */
private SeekMap buildSeekMap() {
  if (segmentContentPosition == C.POSITION_UNSET || durationUs == C.TIME_UNSET
      || cueTimesUs == null || cueTimesUs.size() == 0
      || cueClusterPositions == null || cueClusterPositions.size() != cueTimesUs.size()) {
    // Cues information is missing or incomplete.
    cueTimesUs = null;
    cueClusterPositions = null;
    return new SeekMap.Unseekable(durationUs);
  }
  int cuePointsSize = cueTimesUs.size();
  int[] sizes = new int[cuePointsSize];
  long[] offsets = new long[cuePointsSize];
  long[] durationsUs = new long[cuePointsSize];
  long[] timesUs = new long[cuePointsSize];
  for (int i = 0; i < cuePointsSize; i++) {
    timesUs[i] = cueTimesUs.get(i);
    offsets[i] = segmentContentPosition + cueClusterPositions.get(i);
  }
  for (int i = 0; i < cuePointsSize - 1; i++) {
    sizes[i] = (int) (offsets[i + 1] - offsets[i]);
    durationsUs[i] = timesUs[i + 1] - timesUs[i];
  }
  sizes[cuePointsSize - 1] =
      (int) (segmentContentPosition + segmentContentSize - offsets[cuePointsSize - 1]);
  durationsUs[cuePointsSize - 1] = durationUs - timesUs[cuePointsSize - 1];
  cueTimesUs = null;
  cueClusterPositions = null;
  return new ChunkIndex(sizes, offsets, durationsUs, timesUs);
}
 
Example 12
Source File: MatroskaExtractor.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Builds a {@link SeekMap} from the recently gathered Cues information.
 *
 * @return The built {@link SeekMap}. The returned {@link SeekMap} may be unseekable if cues
 *     information was missing or incomplete.
 */
private SeekMap buildSeekMap() {
  if (segmentContentPosition == C.POSITION_UNSET || durationUs == C.TIME_UNSET
      || cueTimesUs == null || cueTimesUs.size() == 0
      || cueClusterPositions == null || cueClusterPositions.size() != cueTimesUs.size()) {
    // Cues information is missing or incomplete.
    cueTimesUs = null;
    cueClusterPositions = null;
    return new SeekMap.Unseekable(durationUs);
  }
  int cuePointsSize = cueTimesUs.size();
  int[] sizes = new int[cuePointsSize];
  long[] offsets = new long[cuePointsSize];
  long[] durationsUs = new long[cuePointsSize];
  long[] timesUs = new long[cuePointsSize];
  for (int i = 0; i < cuePointsSize; i++) {
    timesUs[i] = cueTimesUs.get(i);
    offsets[i] = segmentContentPosition + cueClusterPositions.get(i);
  }
  for (int i = 0; i < cuePointsSize - 1; i++) {
    sizes[i] = (int) (offsets[i + 1] - offsets[i]);
    durationsUs[i] = timesUs[i + 1] - timesUs[i];
  }
  sizes[cuePointsSize - 1] =
      (int) (segmentContentPosition + segmentContentSize - offsets[cuePointsSize - 1]);
  durationsUs[cuePointsSize - 1] = durationUs - timesUs[cuePointsSize - 1];
  cueTimesUs = null;
  cueClusterPositions = null;
  return new ChunkIndex(sizes, offsets, durationsUs, timesUs);
}
 
Example 13
Source File: FlacExtractor.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private SeekMap getSeekMapForNonSeekTableFlac(ExtractorInput input, FlacStreamInfo streamInfo) {
  long inputLength = input.getLength();
  if (inputLength != C.LENGTH_UNSET) {
    long firstFramePosition = decoderJni.getDecodePosition();
    flacBinarySearchSeeker =
        new FlacBinarySearchSeeker(streamInfo, firstFramePosition, inputLength, decoderJni);
    return flacBinarySearchSeeker.getSeekMap();
  } else { // can't seek at all, because there's no SeekTable and the input length is unknown.
    return new SeekMap.Unseekable(streamInfo.durationUs());
  }
}
 
Example 14
Source File: MatroskaExtractor.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Builds a {@link SeekMap} from the recently gathered Cues information.
 *
 * @return The built {@link SeekMap}. The returned {@link SeekMap} may be unseekable if cues
 *     information was missing or incomplete.
 */
private SeekMap buildSeekMap() {
  if (segmentContentPosition == C.POSITION_UNSET || durationUs == C.TIME_UNSET
      || cueTimesUs == null || cueTimesUs.size() == 0
      || cueClusterPositions == null || cueClusterPositions.size() != cueTimesUs.size()) {
    // Cues information is missing or incomplete.
    cueTimesUs = null;
    cueClusterPositions = null;
    return new SeekMap.Unseekable(durationUs);
  }
  int cuePointsSize = cueTimesUs.size();
  int[] sizes = new int[cuePointsSize];
  long[] offsets = new long[cuePointsSize];
  long[] durationsUs = new long[cuePointsSize];
  long[] timesUs = new long[cuePointsSize];
  for (int i = 0; i < cuePointsSize; i++) {
    timesUs[i] = cueTimesUs.get(i);
    offsets[i] = segmentContentPosition + cueClusterPositions.get(i);
  }
  for (int i = 0; i < cuePointsSize - 1; i++) {
    sizes[i] = (int) (offsets[i + 1] - offsets[i]);
    durationsUs[i] = timesUs[i + 1] - timesUs[i];
  }
  sizes[cuePointsSize - 1] =
      (int) (segmentContentPosition + segmentContentSize - offsets[cuePointsSize - 1]);
  durationsUs[cuePointsSize - 1] = durationUs - timesUs[cuePointsSize - 1];
  cueTimesUs = null;
  cueClusterPositions = null;
  return new ChunkIndex(sizes, offsets, durationsUs, timesUs);
}
 
Example 15
Source File: MatroskaExtractor.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
/**
 * Builds a {@link SeekMap} from the recently gathered Cues information.
 *
 * @return The built {@link SeekMap}. The returned {@link SeekMap} may be unseekable if cues
 *     information was missing or incomplete.
 */
private SeekMap buildSeekMap() {
  if (segmentContentPosition == C.POSITION_UNSET || durationUs == C.TIME_UNSET
      || cueTimesUs == null || cueTimesUs.size() == 0
      || cueClusterPositions == null || cueClusterPositions.size() != cueTimesUs.size()) {
    // Cues information is missing or incomplete.
    cueTimesUs = null;
    cueClusterPositions = null;
    return new SeekMap.Unseekable(durationUs);
  }
  int cuePointsSize = cueTimesUs.size();
  int[] sizes = new int[cuePointsSize];
  long[] offsets = new long[cuePointsSize];
  long[] durationsUs = new long[cuePointsSize];
  long[] timesUs = new long[cuePointsSize];
  for (int i = 0; i < cuePointsSize; i++) {
    timesUs[i] = cueTimesUs.get(i);
    offsets[i] = segmentContentPosition + cueClusterPositions.get(i);
  }
  for (int i = 0; i < cuePointsSize - 1; i++) {
    sizes[i] = (int) (offsets[i + 1] - offsets[i]);
    durationsUs[i] = timesUs[i + 1] - timesUs[i];
  }
  sizes[cuePointsSize - 1] =
      (int) (segmentContentPosition + segmentContentSize - offsets[cuePointsSize - 1]);
  durationsUs[cuePointsSize - 1] = durationUs - timesUs[cuePointsSize - 1];

  long lastDurationUs = durationsUs[cuePointsSize - 1];
  if (lastDurationUs <= 0) {
    Log.w(TAG, "Discarding last cue point with unexpected duration: " + lastDurationUs);
    sizes = Arrays.copyOf(sizes, sizes.length - 1);
    offsets = Arrays.copyOf(offsets, offsets.length - 1);
    durationsUs = Arrays.copyOf(durationsUs, durationsUs.length - 1);
    timesUs = Arrays.copyOf(timesUs, timesUs.length - 1);
  }

  cueTimesUs = null;
  cueClusterPositions = null;
  return new ChunkIndex(sizes, offsets, durationsUs, timesUs);
}
 
Example 16
Source File: StreamReader.java    From K-Sonic with MIT License 4 votes vote down vote up
@Override
public SeekMap createSeekMap() {
  return new SeekMap.Unseekable(C.TIME_UNSET);
}
 
Example 17
Source File: StreamReader.java    From MediaSDK with Apache License 2.0 4 votes vote down vote up
@Override
public SeekMap createSeekMap() {
  return new SeekMap.Unseekable(C.TIME_UNSET);
}
 
Example 18
Source File: StreamReader.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public SeekMap createSeekMap() {
  return new SeekMap.Unseekable(C.TIME_UNSET);
}
 
Example 19
Source File: StreamReader.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
@Override
public SeekMap createSeekMap() {
  return new SeekMap.Unseekable(C.TIME_UNSET);
}
 
Example 20
Source File: StreamReader.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public SeekMap createSeekMap() {
  return new SeekMap.Unseekable(C.TIME_UNSET);
}