Commit f2d337c3 by hschlueter Committed by Ian Baker

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 9d463725
...@@ -845,7 +845,7 @@ public final class Transformer { ...@@ -845,7 +845,7 @@ public final class Transformer {
handleTransformationEnded( handleTransformationEnded(
cause instanceof TransformationException cause instanceof TransformationException
? (TransformationException) cause ? (TransformationException) cause
: TransformationException.createForUnexpected(error)); : TransformationException.createForPlaybackException(error));
} }
private void handleTransformationEnded(@Nullable TransformationException exception) { private void handleTransformationEnded(@Nullable TransformationException exception) {
......
...@@ -35,7 +35,6 @@ import android.view.Surface; ...@@ -35,7 +35,6 @@ import android.view.Surface;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.test.core.app.ApplicationProvider; import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.MediaItem; import com.google.android.exoplayer2.MediaItem;
import com.google.android.exoplayer2.testutil.DumpFileAsserts; import com.google.android.exoplayer2.testutil.DumpFileAsserts;
import com.google.android.exoplayer2.testutil.FakeClock; import com.google.android.exoplayer2.testutil.FakeClock;
...@@ -295,15 +294,14 @@ public final class TransformerTest { ...@@ -295,15 +294,14 @@ public final class TransformerTest {
} }
@Test @Test
public void startTransformation_withPlayerError_completesWithError() throws Exception { public void startTransformation_withIoError_completesWithError() throws Exception {
Transformer transformer = new Transformer.Builder(context).setClock(clock).build(); Transformer transformer = new Transformer.Builder(context).setClock(clock).build();
MediaItem mediaItem = MediaItem.fromUri("asset:///non-existing-path.mp4"); MediaItem mediaItem = MediaItem.fromUri("asset:///non-existing-path.mp4");
transformer.startTransformation(mediaItem, outputPath); transformer.startTransformation(mediaItem, outputPath);
TransformationException exception = TransformerTestRunner.runUntilError(transformer); TransformationException exception = TransformerTestRunner.runUntilError(transformer);
assertThat(exception).hasCauseThat().isInstanceOf(ExoPlaybackException.class); assertThat(exception).hasCauseThat().isInstanceOf(IOException.class);
assertThat(exception).hasCauseThat().hasCauseThat().isInstanceOf(IOException.class);
} }
@Test @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