Java Code Examples for com.google.android.exoplayer2.util.Util#removeRange()

The following examples show how to use com.google.android.exoplayer2.util.Util#removeRange() . 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: ConcatenatingMediaSource.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
@GuardedBy("this")
private void removePublicMediaSources(
    int fromIndex,
    int toIndex,
    @Nullable Handler handler,
    @Nullable Runnable onCompletionAction) {
  Assertions.checkArgument((handler == null) == (onCompletionAction == null));
  Handler playbackThreadHandler = this.playbackThreadHandler;
  Util.removeRange(mediaSourcesPublic, fromIndex, toIndex);
  if (playbackThreadHandler != null) {
    HandlerAndRunnable callbackAction = createOnCompletionAction(handler, onCompletionAction);
    playbackThreadHandler
        .obtainMessage(MSG_REMOVE, new MessageData<>(fromIndex, toIndex, callbackAction))
        .sendToTarget();
  } else if (onCompletionAction != null && handler != null) {
    handler.post(onCompletionAction);
  }
}
 
Example 2
Source File: ConcatenatingMediaSource.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
@GuardedBy("this")
private void removePublicMediaSources(
    int fromIndex,
    int toIndex,
    @Nullable Handler handler,
    @Nullable Runnable onCompletionAction) {
  Assertions.checkArgument((handler == null) == (onCompletionAction == null));
  Handler playbackThreadHandler = this.playbackThreadHandler;
  Util.removeRange(mediaSourcesPublic, fromIndex, toIndex);
  if (playbackThreadHandler != null) {
    HandlerAndRunnable callbackAction = createOnCompletionAction(handler, onCompletionAction);
    playbackThreadHandler
        .obtainMessage(MSG_REMOVE, new MessageData<>(fromIndex, toIndex, callbackAction))
        .sendToTarget();
  } else if (onCompletionAction != null && handler != null) {
    handler.post(onCompletionAction);
  }
}
 
Example 3
Source File: ConcatenatingMediaSource.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
@GuardedBy("this")
private void removePublicMediaSources(
    int fromIndex,
    int toIndex,
    @Nullable Handler handler,
    @Nullable Runnable onCompletionAction) {
  Assertions.checkArgument((handler == null) == (onCompletionAction == null));
  Handler playbackThreadHandler = this.playbackThreadHandler;
  Util.removeRange(mediaSourcesPublic, fromIndex, toIndex);
  if (playbackThreadHandler != null) {
    HandlerAndRunnable callbackAction = createOnCompletionAction(handler, onCompletionAction);
    playbackThreadHandler
        .obtainMessage(MSG_REMOVE, new MessageData<>(fromIndex, toIndex, callbackAction))
        .sendToTarget();
  } else if (onCompletionAction != null && handler != null) {
    handler.post(onCompletionAction);
  }
}
 
Example 4
Source File: ChunkSampleStream.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
private void discardDownstreamMediaChunks(int discardToSampleIndex) {
  int discardToMediaChunkIndex =
      primarySampleIndexToMediaChunkIndex(discardToSampleIndex, /* minChunkIndex= */ 0);
  // Don't discard any chunks that we haven't reported the primary format change for yet.
  discardToMediaChunkIndex =
      Math.min(discardToMediaChunkIndex, nextNotifyPrimaryFormatMediaChunkIndex);
  if (discardToMediaChunkIndex > 0) {
    Util.removeRange(mediaChunks, /* fromIndex= */ 0, /* toIndex= */ discardToMediaChunkIndex);
    nextNotifyPrimaryFormatMediaChunkIndex -= discardToMediaChunkIndex;
  }
}
 
Example 5
Source File: ChunkSampleStream.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
/**
 * Discard upstream media chunks from {@code chunkIndex} and corresponding samples from sample
 * queues.
 *
 * @param chunkIndex The index of the first chunk to discard.
 * @return The chunk at given index.
 */
private BaseMediaChunk discardUpstreamMediaChunksFromIndex(int chunkIndex) {
  BaseMediaChunk firstRemovedChunk = mediaChunks.get(chunkIndex);
  Util.removeRange(mediaChunks, /* fromIndex= */ chunkIndex, /* toIndex= */ mediaChunks.size());
  nextNotifyPrimaryFormatMediaChunkIndex =
      Math.max(nextNotifyPrimaryFormatMediaChunkIndex, mediaChunks.size());
  primarySampleQueue.discardUpstreamSamples(firstRemovedChunk.getFirstSampleIndex(0));
  for (int i = 0; i < embeddedSampleQueues.length; i++) {
    embeddedSampleQueues[i].discardUpstreamSamples(firstRemovedChunk.getFirstSampleIndex(i + 1));
  }
  return firstRemovedChunk;
}
 
Example 6
Source File: ChunkSampleStream.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private void discardDownstreamMediaChunks(int discardToPrimaryStreamIndex) {
  int discardToMediaChunkIndex =
      primaryStreamIndexToMediaChunkIndex(discardToPrimaryStreamIndex, /* minChunkIndex= */ 0);
  if (discardToMediaChunkIndex > 0) {
    Util.removeRange(mediaChunks, /* fromIndex= */ 0, /* toIndex= */ discardToMediaChunkIndex);
  }
}
 
Example 7
Source File: ChunkSampleStream.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Discard upstream media chunks from {@code chunkIndex} and corresponding samples from sample
 * queues.
 *
 * @param chunkIndex The index of the first chunk to discard.
 * @return The chunk at given index.
 */
private BaseMediaChunk discardUpstreamMediaChunksFromIndex(int chunkIndex) {
  BaseMediaChunk firstRemovedChunk = mediaChunks.get(chunkIndex);
  Util.removeRange(mediaChunks, /* fromIndex= */ chunkIndex, /* toIndex= */ mediaChunks.size());
  primarySampleQueue.discardUpstreamSamples(firstRemovedChunk.getFirstSampleIndex(0));
  for (int i = 0; i < embeddedSampleQueues.length; i++) {
    embeddedSampleQueues[i].discardUpstreamSamples(firstRemovedChunk.getFirstSampleIndex(i + 1));
  }
  return firstRemovedChunk;
}
 
Example 8
Source File: ChunkSampleStream.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private void discardDownstreamMediaChunks(int discardToPrimaryStreamIndex) {
  int discardToMediaChunkIndex =
      primaryStreamIndexToMediaChunkIndex(discardToPrimaryStreamIndex, /* minChunkIndex= */ 0);
  if (discardToMediaChunkIndex > 0) {
    Util.removeRange(mediaChunks, /* fromIndex= */ 0, /* toIndex= */ discardToMediaChunkIndex);
  }
}
 
Example 9
Source File: ChunkSampleStream.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Discard upstream media chunks from {@code chunkIndex} and corresponding samples from sample
 * queues.
 *
 * @param chunkIndex The index of the first chunk to discard.
 * @return The chunk at given index.
 */
private BaseMediaChunk discardUpstreamMediaChunksFromIndex(int chunkIndex) {
  BaseMediaChunk firstRemovedChunk = mediaChunks.get(chunkIndex);
  Util.removeRange(mediaChunks, /* fromIndex= */ chunkIndex, /* toIndex= */ mediaChunks.size());
  primarySampleQueue.discardUpstreamSamples(firstRemovedChunk.getFirstSampleIndex(0));
  for (int i = 0; i < embeddedSampleQueues.length; i++) {
    embeddedSampleQueues[i].discardUpstreamSamples(firstRemovedChunk.getFirstSampleIndex(i + 1));
  }
  return firstRemovedChunk;
}
 
Example 10
Source File: ChunkSampleStream.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private void discardDownstreamMediaChunks(int discardToSampleIndex) {
  int discardToMediaChunkIndex =
      primarySampleIndexToMediaChunkIndex(discardToSampleIndex, /* minChunkIndex= */ 0);
  // Don't discard any chunks that we haven't reported the primary format change for yet.
  discardToMediaChunkIndex =
      Math.min(discardToMediaChunkIndex, nextNotifyPrimaryFormatMediaChunkIndex);
  if (discardToMediaChunkIndex > 0) {
    Util.removeRange(mediaChunks, /* fromIndex= */ 0, /* toIndex= */ discardToMediaChunkIndex);
    nextNotifyPrimaryFormatMediaChunkIndex -= discardToMediaChunkIndex;
  }
}
 
Example 11
Source File: ChunkSampleStream.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Discard upstream media chunks from {@code chunkIndex} and corresponding samples from sample
 * queues.
 *
 * @param chunkIndex The index of the first chunk to discard.
 * @return The chunk at given index.
 */
private BaseMediaChunk discardUpstreamMediaChunksFromIndex(int chunkIndex) {
  BaseMediaChunk firstRemovedChunk = mediaChunks.get(chunkIndex);
  Util.removeRange(mediaChunks, /* fromIndex= */ chunkIndex, /* toIndex= */ mediaChunks.size());
  nextNotifyPrimaryFormatMediaChunkIndex =
      Math.max(nextNotifyPrimaryFormatMediaChunkIndex, mediaChunks.size());
  primarySampleQueue.discardUpstreamSamples(firstRemovedChunk.getFirstSampleIndex(0));
  for (int i = 0; i < embeddedSampleQueues.length; i++) {
    embeddedSampleQueues[i].discardUpstreamSamples(firstRemovedChunk.getFirstSampleIndex(i + 1));
  }
  return firstRemovedChunk;
}
 
Example 12
Source File: ChunkSampleStream.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private void discardDownstreamMediaChunks(int discardToSampleIndex) {
  int discardToMediaChunkIndex =
      primarySampleIndexToMediaChunkIndex(discardToSampleIndex, /* minChunkIndex= */ 0);
  // Don't discard any chunks that we haven't reported the primary format change for yet.
  discardToMediaChunkIndex =
      Math.min(discardToMediaChunkIndex, nextNotifyPrimaryFormatMediaChunkIndex);
  if (discardToMediaChunkIndex > 0) {
    Util.removeRange(mediaChunks, /* fromIndex= */ 0, /* toIndex= */ discardToMediaChunkIndex);
    nextNotifyPrimaryFormatMediaChunkIndex -= discardToMediaChunkIndex;
  }
}
 
Example 13
Source File: ChunkSampleStream.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Discard upstream media chunks from {@code chunkIndex} and corresponding samples from sample
 * queues.
 *
 * @param chunkIndex The index of the first chunk to discard.
 * @return The chunk at given index.
 */
private BaseMediaChunk discardUpstreamMediaChunksFromIndex(int chunkIndex) {
  BaseMediaChunk firstRemovedChunk = mediaChunks.get(chunkIndex);
  Util.removeRange(mediaChunks, /* fromIndex= */ chunkIndex, /* toIndex= */ mediaChunks.size());
  nextNotifyPrimaryFormatMediaChunkIndex =
      Math.max(nextNotifyPrimaryFormatMediaChunkIndex, mediaChunks.size());
  primarySampleQueue.discardUpstreamSamples(firstRemovedChunk.getFirstSampleIndex(0));
  for (int i = 0; i < embeddedSampleQueues.length; i++) {
    embeddedSampleQueues[i].discardUpstreamSamples(firstRemovedChunk.getFirstSampleIndex(i + 1));
  }
  return firstRemovedChunk;
}