Skip to content

Commit

Permalink
Added getter methods to ContainerMediaChunk & a callback method whene…
Browse files Browse the repository at this point in the history
…ver a load loop is finished
  • Loading branch information
colinkho committed Nov 8, 2024
1 parent 53953dd commit 50b2d82
Showing 1 changed file with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ public final void load() throws IOException {
nextLoadPosition = input.getPosition() - dataSpec.position;
}
} finally {
onLoadIterationEnded();
DataSourceUtil.closeQuietly(dataSource);
}
loadCompleted = !loadCanceled;
Expand All @@ -151,6 +152,30 @@ protected TrackOutputProvider getTrackOutputProvider(BaseMediaChunkOutput baseMe
return baseMediaChunkOutput;
}

/**
* Method that is called to signal that a {@link #load()} has concluded. This is called in both
* successful and error scenarios.
*/
protected void onLoadIterationEnded() {}

/**
* Returns whether the current chunk's load has been canceled from {@link #cancelLoad()}
*
* @return true if {@link #cancelLoad()} was invoked
*/
public final boolean isLoadCanceled() {
return loadCanceled;
}

/**
* Retrieves the next position to load in the chunk on a {@link #load()}
*
* @return the position to load from
*/
public final long getNextLoadPosition() {
return nextLoadPosition;
}

private void maybeWriteEmptySamples(BaseMediaChunkOutput output) {
if (!MimeTypes.isImage(trackFormat.containerMimeType)) {
return;
Expand Down

0 comments on commit 50b2d82

Please sign in to comment.