Change TransformerInternal durationMs to durationUs.

Follow-up CLs will use this duration for silent audio.

PiperOrigin-RevId: 491670359
This commit is contained in:
samrobinson 2022-11-29 18:08:45 +00:00 committed by Rohit Singh
parent 4033013ff8
commit a8e9d158cd
2 changed files with 7 additions and 8 deletions

View file

@ -32,7 +32,6 @@ import androidx.media3.common.Player;
import androidx.media3.common.Timeline;
import androidx.media3.common.Tracks;
import androidx.media3.common.util.Clock;
import androidx.media3.common.util.Util;
import androidx.media3.exoplayer.DefaultLoadControl;
import androidx.media3.exoplayer.ExoPlayer;
import androidx.media3.exoplayer.Renderer;
@ -48,7 +47,7 @@ import androidx.media3.exoplayer.video.VideoRendererEventListener;
public interface Listener {
void onDurationMs(long durationMs);
void onDurationUs(long durationUs);
void onTrackRegistered();
@ -174,7 +173,7 @@ import androidx.media3.exoplayer.video.VideoRendererEventListener;
Timeline.Window window = new Timeline.Window();
timeline.getWindow(/* windowIndex= */ 0, window);
if (!window.isPlaceholder) {
listener.onDurationMs(Util.usToMs(window.durationUs));
listener.onDurationUs(window.durationUs);
hasSentDuration = true;
}
}

View file

@ -116,7 +116,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
private boolean isDrainingPipelines;
private @Transformer.ProgressState int progressState;
private long progressPositionMs;
private long durationMs;
private long durationUs;
private @MonotonicNonNull RuntimeException cancelException;
private volatile boolean released;
@ -189,7 +189,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
public @Transformer.ProgressState int getProgress(ProgressHolder progressHolder) {
if (progressState == PROGRESS_STATE_AVAILABLE) {
progressHolder.progress = min((int) (progressPositionMs * 100 / durationMs), 99);
progressHolder.progress = min((int) (progressPositionMs * 100 / Util.usToMs(durationUs)), 99);
}
return progressState;
}
@ -371,17 +371,17 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
// ExoPlayerAssetLoader.Listener implementation.
@Override
public void onDurationMs(long durationMs) {
public void onDurationUs(long durationUs) {
applicationHandler.post(
() -> {
// Make progress permanently unavailable if the duration is unknown, so that it doesn't
// jump to a high value at the end of the transformation if the duration is set once the
// media is entirely loaded.
progressState =
durationMs <= 0 || durationMs == C.TIME_UNSET
durationUs <= 0 || durationUs == C.TIME_UNSET
? PROGRESS_STATE_UNAVAILABLE
: PROGRESS_STATE_AVAILABLE;
TransformerInternal.this.durationMs = durationMs;
TransformerInternal.this.durationUs = durationUs;
});
}