mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Add IntRange annotation to onTrackCount
PiperOrigin-RevId: 496942702
This commit is contained in:
parent
5c4d85c2ed
commit
f67849afa1
3 changed files with 15 additions and 4 deletions
|
|
@ -18,6 +18,7 @@ package androidx.media3.transformer;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
|
import androidx.annotation.IntRange;
|
||||||
import androidx.media3.common.Format;
|
import androidx.media3.common.Format;
|
||||||
import androidx.media3.common.MediaItem;
|
import androidx.media3.common.MediaItem;
|
||||||
import androidx.media3.common.util.Clock;
|
import androidx.media3.common.util.Clock;
|
||||||
|
|
@ -131,7 +132,7 @@ public interface AssetLoader {
|
||||||
void onDurationUs(long durationUs);
|
void onDurationUs(long durationUs);
|
||||||
|
|
||||||
/** Called when the number of tracks output by the asset loader is known. */
|
/** Called when the number of tracks output by the asset loader is known. */
|
||||||
void onTrackCount(int trackCount);
|
void onTrackCount(@IntRange(from = 1) int trackCount);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the information on a track is known.
|
* Called when the information on a track is known.
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package androidx.media3.transformer;
|
package androidx.media3.transformer;
|
||||||
|
|
||||||
|
import static androidx.media3.common.PlaybackException.ERROR_CODE_FAILED_RUNTIME_CHECK;
|
||||||
import static androidx.media3.common.util.Assertions.checkStateNotNull;
|
import static androidx.media3.common.util.Assertions.checkStateNotNull;
|
||||||
import static androidx.media3.exoplayer.DefaultLoadControl.DEFAULT_BUFFER_FOR_PLAYBACK_AFTER_REBUFFER_MS;
|
import static androidx.media3.exoplayer.DefaultLoadControl.DEFAULT_BUFFER_FOR_PLAYBACK_AFTER_REBUFFER_MS;
|
||||||
import static androidx.media3.exoplayer.DefaultLoadControl.DEFAULT_BUFFER_FOR_PLAYBACK_MS;
|
import static androidx.media3.exoplayer.DefaultLoadControl.DEFAULT_BUFFER_FOR_PLAYBACK_MS;
|
||||||
|
|
@ -350,7 +351,15 @@ public final class ExoPlayerAssetLoader implements AssetLoader {
|
||||||
if (tracks.isTypeSelected(C.TRACK_TYPE_VIDEO)) {
|
if (tracks.isTypeSelected(C.TRACK_TYPE_VIDEO)) {
|
||||||
trackCount++;
|
trackCount++;
|
||||||
}
|
}
|
||||||
assetLoaderListener.onTrackCount(trackCount);
|
if (trackCount == 0) {
|
||||||
|
assetLoaderListener.onError(
|
||||||
|
new PlaybackException(
|
||||||
|
"The asset loader has no track to output.",
|
||||||
|
/* cause= */ null,
|
||||||
|
ERROR_CODE_FAILED_RUNTIME_CHECK));
|
||||||
|
} else {
|
||||||
|
assetLoaderListener.onTrackCount(trackCount);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -401,8 +401,9 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTrackCount(int trackCount) {
|
public void onTrackCount(int trackCount) {
|
||||||
if (trackCount == 0) {
|
if (trackCount <= 0) {
|
||||||
onError(new IllegalStateException("The output does not contain any tracks."));
|
onError(new IllegalStateException("AssetLoader instances must provide at least 1 track."));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
this.trackCount.set(trackCount);
|
this.trackCount.set(trackCount);
|
||||||
if (forceSilentAudio) {
|
if (forceSilentAudio) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue