use of com.google.android.exoplayer2.transformer.Transformer in project ExoPlayer by google.
the class TransformerEndToEndTest method startTransformation_removeAudio_completesSuccessfully.
@Test
public void startTransformation_removeAudio_completesSuccessfully() throws Exception {
Transformer transformer = createTransformerBuilder().setRemoveAudio(true).build();
MediaItem mediaItem = MediaItem.fromUri(URI_PREFIX + FILE_AUDIO_VIDEO);
transformer.startTransformation(mediaItem, outputPath);
TransformerTestRunner.runUntilCompleted(transformer);
DumpFileAsserts.assertOutput(context, testMuxer, getDumpFileName(FILE_AUDIO_VIDEO + ".noaudio"));
}
use of com.google.android.exoplayer2.transformer.Transformer 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);
}
use of com.google.android.exoplayer2.transformer.Transformer 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);
}
use of com.google.android.exoplayer2.transformer.Transformer in project ExoPlayer by google.
the class TransformerEndToEndTest method startTransformation_afterCancellation_completesSuccessfully.
// TODO(b/214012830): Add a test to check that the correct exception is thrown when the muxer
// doesn't support the output sample MIME type inferred from the input once it is possible to
// disable fallback.
@Test
public void startTransformation_afterCancellation_completesSuccessfully() throws Exception {
Transformer transformer = createTransformerBuilder().build();
MediaItem mediaItem = MediaItem.fromUri(URI_PREFIX + FILE_AUDIO_VIDEO);
transformer.startTransformation(mediaItem, outputPath);
transformer.cancel();
Files.delete(Paths.get(outputPath));
// This would throw if the previous transformation had not been cancelled.
transformer.startTransformation(mediaItem, outputPath);
TransformerTestRunner.runUntilCompleted(transformer);
DumpFileAsserts.assertOutput(context, testMuxer, getDumpFileName(FILE_AUDIO_VIDEO));
}
use of com.google.android.exoplayer2.transformer.Transformer in project ExoPlayer by google.
the class TransformerEndToEndTest method startTransformation_audioAndVideo_completesSuccessfully.
@Test
public void startTransformation_audioAndVideo_completesSuccessfully() throws Exception {
Transformer transformer = createTransformerBuilder().build();
MediaItem mediaItem = MediaItem.fromUri(URI_PREFIX + FILE_AUDIO_VIDEO);
transformer.startTransformation(mediaItem, outputPath);
TransformerTestRunner.runUntilCompleted(transformer);
DumpFileAsserts.assertOutput(context, testMuxer, getDumpFileName(FILE_AUDIO_VIDEO));
}
Aggregations