Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added getter methods to ContainerMediaChunk & a callback method whenever a load loop is finished #1871

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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