Commit 991a22ec by hschlueter Committed by tonihei

Convert PlaybackExceptions to TransformationExceptions.

Transformer uses ExoPlayer for reading input. Apps using Transformer
do not need to know this. So, PlaybackExceptions are converted to
TransformationExceptions with the same message, cause and error code.

The corresponding IO error codes are copied from PlaybackException.

PiperOrigin-RevId: 416793741
parent e76925c6
......@@ -847,7 +847,7 @@ public final class Transformer {
handleTransformationEnded(
cause instanceof TransformationException
? (TransformationException) cause
: TransformationException.createForUnexpected(error));
: TransformationException.createForPlaybackException(error));
}
private void handleTransformationEnded(@Nullable TransformationException exception) {
......
......@@ -36,7 +36,6 @@ import androidx.annotation.Nullable;
import androidx.media3.common.MediaItem;
import androidx.media3.common.MimeTypes;
import androidx.media3.common.util.Util;
import androidx.media3.exoplayer.ExoPlaybackException;
import androidx.media3.test.utils.DumpFileAsserts;
import androidx.media3.test.utils.FakeClock;
import androidx.test.core.app.ApplicationProvider;
......@@ -295,15 +294,14 @@ public final class TransformerTest {
}
@Test
public void startTransformation_withPlayerError_completesWithError() throws Exception {
public void startTransformation_withIoError_completesWithError() throws Exception {
Transformer transformer = new Transformer.Builder(context).setClock(clock).build();
MediaItem mediaItem = MediaItem.fromUri("asset:///non-existing-path.mp4");
transformer.startTransformation(mediaItem, outputPath);
TransformationException exception = TransformerTestRunner.runUntilError(transformer);
assertThat(exception).hasCauseThat().isInstanceOf(ExoPlaybackException.class);
assertThat(exception).hasCauseThat().hasCauseThat().isInstanceOf(IOException.class);
assertThat(exception).hasCauseThat().isInstanceOf(IOException.class);
}
@Test
......
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