Search in sources :

Example 11 with TransformationException

use of com.google.android.exoplayer2.transformer.TransformationException in project ExoPlayer by google.

the class TransformerEndToEndTest method startTransformation_withAudioDecoderFormatUnsupported_completesWithError.

@Test
public void startTransformation_withAudioDecoderFormatUnsupported_completesWithError() throws Exception {
    Transformer transformer = createTransformerBuilder().setTransformationRequest(new TransformationRequest.Builder().setAudioMimeType(// supported by encoder and muxer
    MimeTypes.AUDIO_AAC).build()).build();
    MediaItem mediaItem = MediaItem.fromUri(URI_PREFIX + FILE_AUDIO_UNSUPPORTED_BY_DECODER);
    transformer.startTransformation(mediaItem, outputPath);
    TransformationException exception = TransformerTestRunner.runUntilError(transformer);
    assertThat(exception).hasCauseThat().isInstanceOf(IllegalArgumentException.class);
    assertThat(exception.errorCode).isEqualTo(TransformationException.ERROR_CODE_DECODING_FORMAT_UNSUPPORTED);
}
Also used : MediaItem(com.google.android.exoplayer2.MediaItem) Test(org.junit.Test)

Example 12 with TransformationException

use of com.google.android.exoplayer2.transformer.TransformationException in project ExoPlayer by google.

the class TransformerEndToEndTest method startTransformation_withMultipleListeners_callsEachOnError.

@Test
public void startTransformation_withMultipleListeners_callsEachOnError() throws Exception {
    Transformer.Listener mockListener1 = mock(Transformer.Listener.class);
    Transformer.Listener mockListener2 = mock(Transformer.Listener.class);
    Transformer.Listener mockListener3 = mock(Transformer.Listener.class);
    Transformer transformer = createTransformerBuilder().addListener(mockListener1).addListener(mockListener2).addListener(mockListener3).setTransformationRequest(new TransformationRequest.Builder().setAudioMimeType(MimeTypes.AUDIO_AAC).build()).build();
    MediaItem mediaItem = MediaItem.fromUri(URI_PREFIX + FILE_AUDIO_UNSUPPORTED_BY_DECODER);
    transformer.startTransformation(mediaItem, outputPath);
    TransformationException exception = TransformerTestRunner.runUntilError(transformer);
    verify(mockListener1, times(1)).onTransformationError(mediaItem, exception);
    verify(mockListener2, times(1)).onTransformationError(mediaItem, exception);
    verify(mockListener3, times(1)).onTransformationError(mediaItem, exception);
}
Also used : MediaItem(com.google.android.exoplayer2.MediaItem) Test(org.junit.Test)

Example 13 with TransformationException

use of com.google.android.exoplayer2.transformer.TransformationException in project ExoPlayer by google.

the class TransformerEndToEndTest method startTransformation_withAudioEncoderFormatUnsupported_completesWithError.

@Test
public void startTransformation_withAudioEncoderFormatUnsupported_completesWithError() throws Exception {
    Transformer transformer = createTransformerBuilder().setTransformationRequest(new TransformationRequest.Builder().setAudioMimeType(// unsupported by encoder, supported by muxer
    MimeTypes.AUDIO_AMR_NB).build()).build();
    MediaItem mediaItem = MediaItem.fromUri(URI_PREFIX + FILE_AUDIO_UNSUPPORTED_BY_MUXER);
    transformer.startTransformation(mediaItem, outputPath);
    TransformationException exception = TransformerTestRunner.runUntilError(transformer);
    assertThat(exception).hasCauseThat().isInstanceOf(IllegalArgumentException.class);
    assertThat(exception.errorCode).isEqualTo(TransformationException.ERROR_CODE_OUTPUT_FORMAT_UNSUPPORTED);
}
Also used : MediaItem(com.google.android.exoplayer2.MediaItem) Test(org.junit.Test)

Aggregations

MediaItem (com.google.android.exoplayer2.MediaItem)7 Nullable (androidx.annotation.Nullable)6 Test (org.junit.Test)5 Format (com.google.android.exoplayer2.Format)4 RequiresNonNull (org.checkerframework.checker.nullness.qual.RequiresNonNull)4 ReadDataResult (com.google.android.exoplayer2.source.SampleStream.ReadDataResult)3 FormatHolder (com.google.android.exoplayer2.FormatHolder)2 DecoderInputBuffer (com.google.android.exoplayer2.decoder.DecoderInputBuffer)2 IOException (java.io.IOException)2 SuppressLint (android.annotation.SuppressLint)1 Matrix (android.graphics.Matrix)1 MediaCodecInfo (android.media.MediaCodecInfo)1 MediaFormat (android.media.MediaFormat)1 Uri (android.net.Uri)1 EGLContext (android.opengl.EGLContext)1 EGLDisplay (android.opengl.EGLDisplay)1 EGLSurface (android.opengl.EGLSurface)1 SurfaceView (android.view.SurfaceView)1 TransformationException (com.google.android.exoplayer2.transformer.TransformationException)1 TransformationRequest (com.google.android.exoplayer2.transformer.TransformationRequest)1