Make AssetLoader progress not Transformer specific
To do that, rename PROGRESS_STATE_NO_TRANSFORMATION to PROGRESS_STATE_NOT_STARTED and update Javadoc of ProgressState to not be Transformer specific. PiperOrigin-RevId: 496653460
This commit is contained in:
parent
d848d3358a
commit
97e49ac312
@ -18,6 +18,7 @@ package androidx.media3.demo.transformer;
|
||||
import static android.Manifest.permission.READ_EXTERNAL_STORAGE;
|
||||
import static androidx.media3.common.util.Assertions.checkNotNull;
|
||||
import static androidx.media3.common.util.Assertions.checkState;
|
||||
import static androidx.media3.transformer.Transformer.PROGRESS_STATE_NOT_STARTED;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
@ -211,8 +212,7 @@ public final class TransformerActivity extends AppCompatActivity {
|
||||
@Override
|
||||
public void run() {
|
||||
if (transformer != null
|
||||
&& transformer.getProgress(progressHolder)
|
||||
!= Transformer.PROGRESS_STATE_NO_TRANSFORMATION) {
|
||||
&& transformer.getProgress(progressHolder) != PROGRESS_STATE_NOT_STARTED) {
|
||||
progressIndicator.setProgress(progressHolder.progress);
|
||||
informationTextView.setText(
|
||||
getString(
|
||||
|
@ -22,7 +22,7 @@ import static androidx.media3.exoplayer.DefaultLoadControl.DEFAULT_BUFFER_FOR_PL
|
||||
import static androidx.media3.exoplayer.DefaultLoadControl.DEFAULT_MAX_BUFFER_MS;
|
||||
import static androidx.media3.exoplayer.DefaultLoadControl.DEFAULT_MIN_BUFFER_MS;
|
||||
import static androidx.media3.transformer.Transformer.PROGRESS_STATE_AVAILABLE;
|
||||
import static androidx.media3.transformer.Transformer.PROGRESS_STATE_NO_TRANSFORMATION;
|
||||
import static androidx.media3.transformer.Transformer.PROGRESS_STATE_NOT_STARTED;
|
||||
import static androidx.media3.transformer.Transformer.PROGRESS_STATE_UNAVAILABLE;
|
||||
import static androidx.media3.transformer.Transformer.PROGRESS_STATE_WAITING_FOR_AVAILABILITY;
|
||||
import static java.lang.Math.min;
|
||||
@ -229,7 +229,7 @@ public final class ExoPlayerAssetLoader implements AssetLoader {
|
||||
player = playerBuilder.build();
|
||||
player.addListener(new PlayerListener(listener));
|
||||
|
||||
progressState = PROGRESS_STATE_NO_TRANSFORMATION;
|
||||
progressState = PROGRESS_STATE_NOT_STARTED;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -253,7 +253,7 @@ public final class ExoPlayerAssetLoader implements AssetLoader {
|
||||
@Override
|
||||
public void release() {
|
||||
player.release();
|
||||
progressState = PROGRESS_STATE_NO_TRANSFORMATION;
|
||||
progressState = PROGRESS_STATE_NOT_STARTED;
|
||||
}
|
||||
|
||||
private static final class RenderersFactoryImpl implements RenderersFactory {
|
||||
|
@ -553,32 +553,32 @@ public final class Transformer {
|
||||
}
|
||||
|
||||
/**
|
||||
* Progress state. One of {@link #PROGRESS_STATE_WAITING_FOR_AVAILABILITY}, {@link
|
||||
* #PROGRESS_STATE_AVAILABLE}, {@link #PROGRESS_STATE_UNAVAILABLE}, {@link
|
||||
* #PROGRESS_STATE_NO_TRANSFORMATION}
|
||||
* Progress state. One of {@link #PROGRESS_STATE_NOT_STARTED}, {@link
|
||||
* #PROGRESS_STATE_WAITING_FOR_AVAILABILITY}, {@link #PROGRESS_STATE_AVAILABLE} or {@link
|
||||
* #PROGRESS_STATE_UNAVAILABLE}.
|
||||
*/
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@Target(TYPE_USE)
|
||||
@IntDef({
|
||||
PROGRESS_STATE_NOT_STARTED,
|
||||
PROGRESS_STATE_WAITING_FOR_AVAILABILITY,
|
||||
PROGRESS_STATE_AVAILABLE,
|
||||
PROGRESS_STATE_UNAVAILABLE,
|
||||
PROGRESS_STATE_NO_TRANSFORMATION
|
||||
PROGRESS_STATE_UNAVAILABLE
|
||||
})
|
||||
public @interface ProgressState {}
|
||||
|
||||
/** Indicates that the corresponding operation hasn't been started. */
|
||||
public static final int PROGRESS_STATE_NOT_STARTED = 0;
|
||||
/**
|
||||
* Indicates that the progress is unavailable for the current transformation, but might become
|
||||
* available.
|
||||
* @deprecated Use {@link #PROGRESS_STATE_NOT_STARTED} instead.
|
||||
*/
|
||||
public static final int PROGRESS_STATE_WAITING_FOR_AVAILABILITY = 0;
|
||||
@Deprecated public static final int PROGRESS_STATE_NO_TRANSFORMATION = PROGRESS_STATE_NOT_STARTED;
|
||||
/** Indicates that the progress is currently unavailable, but might become available. */
|
||||
public static final int PROGRESS_STATE_WAITING_FOR_AVAILABILITY = 1;
|
||||
/** Indicates that the progress is available. */
|
||||
public static final int PROGRESS_STATE_AVAILABLE = 1;
|
||||
/** Indicates that the progress is permanently unavailable for the current transformation. */
|
||||
public static final int PROGRESS_STATE_UNAVAILABLE = 2;
|
||||
/** Indicates that there is no current transformation. */
|
||||
public static final int PROGRESS_STATE_NO_TRANSFORMATION = 4;
|
||||
public static final int PROGRESS_STATE_AVAILABLE = 2;
|
||||
/** Indicates that the progress is permanently unavailable. */
|
||||
public static final int PROGRESS_STATE_UNAVAILABLE = 3;
|
||||
|
||||
@VisibleForTesting /* package */ final Codec.DecoderFactory decoderFactory;
|
||||
@VisibleForTesting /* package */ final Codec.EncoderFactory encoderFactory;
|
||||
@ -797,8 +797,7 @@ public final class Transformer {
|
||||
* progress if it is {@link #PROGRESS_STATE_AVAILABLE available}.
|
||||
*
|
||||
* <p>After a transformation {@linkplain Listener#onTransformationCompleted(MediaItem,
|
||||
* TransformationResult) completes}, this method returns {@link
|
||||
* #PROGRESS_STATE_NO_TRANSFORMATION}.
|
||||
* TransformationResult) completes}, this method returns {@link #PROGRESS_STATE_NOT_STARTED}.
|
||||
*
|
||||
* @param progressHolder A {@link ProgressHolder}, updated to hold the percentage progress if
|
||||
* {@link #PROGRESS_STATE_AVAILABLE available}.
|
||||
@ -808,7 +807,7 @@ public final class Transformer {
|
||||
public @ProgressState int getProgress(ProgressHolder progressHolder) {
|
||||
verifyApplicationThread();
|
||||
return transformerInternal == null
|
||||
? PROGRESS_STATE_NO_TRANSFORMATION
|
||||
? PROGRESS_STATE_NOT_STARTED
|
||||
: transformerInternal.getProgress(progressHolder);
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
package androidx.media3.transformer;
|
||||
|
||||
import static androidx.media3.transformer.TransformationException.ERROR_CODE_MUXING_FAILED;
|
||||
import static androidx.media3.transformer.Transformer.PROGRESS_STATE_NO_TRANSFORMATION;
|
||||
import static androidx.media3.transformer.Transformer.PROGRESS_STATE_NOT_STARTED;
|
||||
import static java.lang.annotation.ElementType.TYPE_USE;
|
||||
|
||||
import android.content.Context;
|
||||
@ -184,7 +184,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
|
||||
public @Transformer.ProgressState int getProgress(ProgressHolder progressHolder) {
|
||||
if (released) {
|
||||
return PROGRESS_STATE_NO_TRANSFORMATION;
|
||||
return PROGRESS_STATE_NOT_STARTED;
|
||||
}
|
||||
internalHandler.obtainMessage(MSG_UPDATE_PROGRESS, progressHolder).sendToTarget();
|
||||
// TODO: figure out why calling clock.onThreadBlocked() here makes the tests fail.
|
||||
|
@ -17,7 +17,7 @@
|
||||
package androidx.media3.transformer;
|
||||
|
||||
import static androidx.media3.transformer.Transformer.PROGRESS_STATE_AVAILABLE;
|
||||
import static androidx.media3.transformer.Transformer.PROGRESS_STATE_NO_TRANSFORMATION;
|
||||
import static androidx.media3.transformer.Transformer.PROGRESS_STATE_NOT_STARTED;
|
||||
import static androidx.media3.transformer.Transformer.PROGRESS_STATE_UNAVAILABLE;
|
||||
import static androidx.media3.transformer.Transformer.PROGRESS_STATE_WAITING_FOR_AVAILABILITY;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
@ -658,8 +658,8 @@ public final class TransformerEndToEndTest {
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case PROGRESS_STATE_NO_TRANSFORMATION:
|
||||
if (progressState != PROGRESS_STATE_NO_TRANSFORMATION) {
|
||||
case PROGRESS_STATE_NOT_STARTED:
|
||||
if (progressState != PROGRESS_STATE_NOT_STARTED) {
|
||||
foundInconsistentState.set(true);
|
||||
return;
|
||||
}
|
||||
@ -689,7 +689,7 @@ public final class TransformerEndToEndTest {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
@Transformer.ProgressState int progressState = transformer.getProgress(progressHolder);
|
||||
if (progressState == PROGRESS_STATE_NO_TRANSFORMATION) {
|
||||
if (progressState == PROGRESS_STATE_NOT_STARTED) {
|
||||
return;
|
||||
}
|
||||
if (progressState != PROGRESS_STATE_WAITING_FOR_AVAILABILITY
|
||||
@ -724,8 +724,8 @@ public final class TransformerEndToEndTest {
|
||||
TransformerTestRunner.runUntilCompleted(transformer);
|
||||
@Transformer.ProgressState int stateAfterTransform = transformer.getProgress(progressHolder);
|
||||
|
||||
assertThat(stateBeforeTransform).isEqualTo(Transformer.PROGRESS_STATE_NO_TRANSFORMATION);
|
||||
assertThat(stateAfterTransform).isEqualTo(Transformer.PROGRESS_STATE_NO_TRANSFORMATION);
|
||||
assertThat(stateBeforeTransform).isEqualTo(PROGRESS_STATE_NOT_STARTED);
|
||||
assertThat(stateAfterTransform).isEqualTo(PROGRESS_STATE_NOT_STARTED);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -750,8 +750,8 @@ public final class TransformerEndToEndTest {
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case PROGRESS_STATE_NO_TRANSFORMATION:
|
||||
if (progressState != PROGRESS_STATE_NO_TRANSFORMATION) {
|
||||
case PROGRESS_STATE_NOT_STARTED:
|
||||
if (progressState != PROGRESS_STATE_NOT_STARTED) {
|
||||
foundInconsistentState.set(true);
|
||||
return;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user