Commit 349144f6 by samrobinson Committed by Rohit Singh

Change TransformerInternal durationMs to durationUs.

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

PiperOrigin-RevId: 491670359
parent 18280723
......@@ -41,14 +41,13 @@ import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.text.TextOutput;
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
import com.google.android.exoplayer2.util.Clock;
import com.google.android.exoplayer2.util.Util;
import com.google.android.exoplayer2.video.VideoRendererEventListener;
/* package */ final class ExoPlayerAssetLoader {
public interface Listener {
void onDurationMs(long durationMs);
void onDurationUs(long durationUs);
void onTrackRegistered();
......@@ -174,7 +173,7 @@ import com.google.android.exoplayer2.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;
}
}
......
......@@ -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;
});
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment