use of androidx.media3.transformer.Transformer in project media by androidx.
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);
}
use of androidx.media3.transformer.Transformer in project media by androidx.
the class TransformerEndToEndTest method getProgress_unknownDuration_returnsConsistentStates.
@Test
public void getProgress_unknownDuration_returnsConsistentStates() throws Exception {
Transformer transformer = createTransformerBuilder().build();
MediaItem mediaItem = MediaItem.fromUri(URI_PREFIX + FILE_UNKNOWN_DURATION);
AtomicInteger previousProgressState = new AtomicInteger(PROGRESS_STATE_WAITING_FOR_AVAILABILITY);
AtomicBoolean foundInconsistentState = new AtomicBoolean();
Handler progressHandler = new Handler(Looper.myLooper()) {
@Override
public void handleMessage(Message msg) {
@Transformer.ProgressState int progressState = transformer.getProgress(progressHolder);
switch(previousProgressState.get()) {
case PROGRESS_STATE_WAITING_FOR_AVAILABILITY:
break;
case PROGRESS_STATE_UNAVAILABLE:
case // See [Internal: b/176145097].
PROGRESS_STATE_AVAILABLE:
if (progressState == PROGRESS_STATE_WAITING_FOR_AVAILABILITY) {
foundInconsistentState.set(true);
return;
}
break;
case PROGRESS_STATE_NO_TRANSFORMATION:
if (progressState != PROGRESS_STATE_NO_TRANSFORMATION) {
foundInconsistentState.set(true);
return;
}
break;
default:
throw new IllegalStateException();
}
previousProgressState.set(progressState);
sendEmptyMessage(0);
}
};
transformer.startTransformation(mediaItem, outputPath);
progressHandler.sendEmptyMessage(0);
TransformerTestRunner.runUntilCompleted(transformer);
assertThat(foundInconsistentState.get()).isFalse();
}
use of androidx.media3.transformer.Transformer in project media by androidx.
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 androidx.media3.transformer.Transformer in project media by androidx.
the class TransformerEndToEndTest method startTransformation_audioOnlyPassthrough_completesSuccessfully.
@Test
public void startTransformation_audioOnlyPassthrough_completesSuccessfully() throws Exception {
Transformer transformer = createTransformerBuilder().build();
MediaItem mediaItem = MediaItem.fromUri(URI_PREFIX + FILE_AUDIO_UNSUPPORTED_BY_ENCODER);
transformer.startTransformation(mediaItem, outputPath);
TransformerTestRunner.runUntilCompleted(transformer);
DumpFileAsserts.assertOutput(context, testMuxer, getDumpFileName(FILE_AUDIO_UNSUPPORTED_BY_ENCODER));
}
use of androidx.media3.transformer.Transformer in project media by androidx.
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