From 0eb11e269cc34392919a72d8299ce35097cd95c3 Mon Sep 17 00:00:00 2001 From: kimvde Date: Mon, 6 Feb 2023 08:00:56 +0000 Subject: [PATCH] Rename startTransformation to start Also update some Javadoc in Transformer PiperOrigin-RevId: 507395956 --- .../demo/transformer/TransformerActivity.java | 2 +- .../TransformerAndroidTestRunner.java | 6 +- .../media3/transformer/Transformer.java | 150 +++++++++--------- .../transformer/TransformerEndToEndTest.java | 93 ++++++----- 4 files changed, 125 insertions(+), 126 deletions(-) diff --git a/demos/transformer/src/main/java/androidx/media3/demo/transformer/TransformerActivity.java b/demos/transformer/src/main/java/androidx/media3/demo/transformer/TransformerActivity.java index 7f0b28b936..792e3ddb62 100644 --- a/demos/transformer/src/main/java/androidx/media3/demo/transformer/TransformerActivity.java +++ b/demos/transformer/src/main/java/androidx/media3/demo/transformer/TransformerActivity.java @@ -213,7 +213,7 @@ public final class TransformerActivity extends AppCompatActivity { Transformer transformer = createTransformer(bundle, filePath); EditedMediaItem editedMediaItem = createEditedMediaItem(mediaItem, bundle); transformationStopwatch.start(); - transformer.startTransformation(editedMediaItem, filePath); + transformer.start(editedMediaItem, filePath); this.transformer = transformer; } catch (PackageManager.NameNotFoundException e) { throw new IllegalStateException(e); diff --git a/libraries/transformer/src/androidTest/java/androidx/media3/transformer/TransformerAndroidTestRunner.java b/libraries/transformer/src/androidTest/java/androidx/media3/transformer/TransformerAndroidTestRunner.java index cb8219248f..6cf5644b72 100644 --- a/libraries/transformer/src/androidTest/java/androidx/media3/transformer/TransformerAndroidTestRunner.java +++ b/libraries/transformer/src/androidTest/java/androidx/media3/transformer/TransformerAndroidTestRunner.java @@ -231,8 +231,7 @@ public class TransformerAndroidTestRunner { * @param testId An identifier for the test. * @param editedMediaItem The {@link EditedMediaItem} to transform. * @return The {@link TransformationTestResult}. - * @throws IllegalStateException See {@link Transformer#startTransformation(EditedMediaItem, - * String)}. + * @throws IllegalStateException See {@link Transformer#start(EditedMediaItem, String)}. * @throws InterruptedException If the thread is interrupted whilst waiting for transformer to * complete. * @throws IOException If an error occurs opening the output file for writing. @@ -313,8 +312,7 @@ public class TransformerAndroidTestRunner { .runOnMainSync( () -> { try { - testTransformer.startTransformation( - editedMediaItem, outputVideoFile.getAbsolutePath()); + testTransformer.start(editedMediaItem, outputVideoFile.getAbsolutePath()); // Catch all exceptions to report. Exceptions thrown here and not caught will NOT // propagate. } catch (Exception e) { diff --git a/libraries/transformer/src/main/java/androidx/media3/transformer/Transformer.java b/libraries/transformer/src/main/java/androidx/media3/transformer/Transformer.java index 1465d36b65..6b2e34b073 100644 --- a/libraries/transformer/src/main/java/androidx/media3/transformer/Transformer.java +++ b/libraries/transformer/src/main/java/androidx/media3/transformer/Transformer.java @@ -42,6 +42,7 @@ import androidx.media3.effect.GlEffectsFrameProcessor; import androidx.media3.exoplayer.source.DefaultMediaSourceFactory; import com.google.common.collect.ImmutableList; import com.google.errorprone.annotations.CanIgnoreReturnValue; +import com.google.errorprone.annotations.InlineMe; import java.lang.annotation.Documented; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -50,9 +51,9 @@ import java.util.List; import org.checkerframework.checker.nullness.qual.MonotonicNonNull; /** - * A transformer to transform media inputs. + * A transformer to export media inputs. * - *

The same Transformer instance can be used to transform multiple inputs (sequentially, not + *

The same Transformer instance can be used to export multiple inputs (sequentially, not * concurrently). * *

Transformer instances must be accessed from a single application thread. For the vast majority @@ -149,8 +150,7 @@ public final class Transformer { /** * @deprecated Set the {@linkplain AudioProcessor audio processors} in an {@link - * EditedMediaItem}, and pass it to {@link #startTransformation(EditedMediaItem, String)} - * instead. + * EditedMediaItem}, and pass it to {@link #start(EditedMediaItem, String)} instead. */ @CanIgnoreReturnValue @Deprecated @@ -161,7 +161,7 @@ public final class Transformer { /** * @deprecated Set the {@linkplain Effect video effects} in an {@link EditedMediaItem}, and pass - * it to {@link #startTransformation(EditedMediaItem, String)} instead. + * it to {@link #start(EditedMediaItem, String)} instead. */ @CanIgnoreReturnValue @Deprecated @@ -172,8 +172,8 @@ public final class Transformer { /** * @deprecated Use {@link EditedMediaItem.Builder#setRemoveAudio(boolean)} to remove the audio - * from the {@link EditedMediaItem} passed to {@link #startTransformation(EditedMediaItem, - * String)} instead. + * from the {@link EditedMediaItem} passed to {@link #start(EditedMediaItem, String)} + * instead. */ @CanIgnoreReturnValue @Deprecated @@ -184,8 +184,8 @@ public final class Transformer { /** * @deprecated Use {@link EditedMediaItem.Builder#setRemoveVideo(boolean)} to remove the video - * from the {@link EditedMediaItem} passed to {@link #startTransformation(EditedMediaItem, - * String)} instead. + * from the {@link EditedMediaItem} passed to {@link #start(EditedMediaItem, String)} + * instead. */ @CanIgnoreReturnValue @Deprecated @@ -196,8 +196,7 @@ public final class Transformer { /** * @deprecated Use {@link EditedMediaItem.Builder#setFlattenForSlowMotion(boolean)} to flatten - * the {@link EditedMediaItem} passed to {@link #startTransformation(EditedMediaItem, - * String)} instead. + * the {@link EditedMediaItem} passed to {@link #start(EditedMediaItem, String)} instead. */ @CanIgnoreReturnValue @Deprecated @@ -260,7 +259,7 @@ public final class Transformer { } /** - * Sets the {@link AssetLoader.Factory} to be used to retrieve the samples to transform. + * Sets the {@link AssetLoader.Factory} to be used to retrieve the samples to export. * *

The default value is a {@link DefaultAssetLoaderFactory} built with a {@link * DefaultMediaSourceFactory} and a {@link DefaultDecoderFactory}. @@ -276,7 +275,7 @@ public final class Transformer { /** * @deprecated Set the {@link FrameProcessor.Factory} in an {@link EditedMediaItem}, and pass it - * to {@link #startTransformation(EditedMediaItem, String)} instead. + * to {@link #start(EditedMediaItem, String)} instead. */ @CanIgnoreReturnValue @Deprecated @@ -331,13 +330,12 @@ public final class Transformer { } /** - * Sets a provider for views to show diagnostic information (if available) during - * transformation. + * Sets a provider for views to show diagnostic information (if available) during export. * *

This is intended for debugging. The default value is {@link DebugViewProvider#NONE}, which * doesn't show any debug info. * - *

Not all transformations will result in debug views being populated. + *

Not all exports will result in debug views being populated. * * @param debugViewProvider Provider for debug views. * @return This builder. @@ -371,7 +369,7 @@ public final class Transformer { * *

To replace existing audio with silence, {@linkplain * EditedMediaItem.Builder#setRemoveAudio(boolean) remove the audio} from the {@link - * EditedMediaItem} to transform. + * EditedMediaItem} to export. * *

Audio properties/format: * @@ -382,10 +380,9 @@ public final class Transformer { *

  • Sample rate will be {@code 44100} hz. This can be modified by creating a {@link * SonicAudioProcessor}, setting its {@linkplain * SonicAudioProcessor#setOutputSampleRateHz(int) sample rate}, and passing it to the - * {@link EditedMediaItem} used to start the transformation. + * {@link EditedMediaItem} used to start the export. *
  • Channel count will be {@code 2}. This can be modified by implementing a custom {@link - * AudioProcessor} and passing it to the {@link EditedMediaItem} used to start the - * transformation. + * AudioProcessor} and passing it to the {@link EditedMediaItem} used to start the export. * * * @param generateSilentAudio Whether to generate silent audio for the output file if there is @@ -678,12 +675,12 @@ public final class Transformer { } /** - * Starts an asynchronous operation to transform the given {@link MediaItem}. + * Starts an asynchronous operation to export the given {@link EditedMediaItem}. * - *

    The transformation state is notified through the {@linkplain Builder#addListener(Listener) + *

    The export state is notified through the {@linkplain Builder#addListener(Listener) * listener}. * - *

    Concurrent transformations on the same Transformer object are not allowed. + *

    Concurrent exports on the same Transformer object are not allowed. * *

    If no custom {@link Muxer.Factory} is specified, the output is an MP4 file. * @@ -695,62 +692,17 @@ public final class Transformer { * swapped if the height is larger than the width. This is to improve compatibility among * different device encoders. * - * @param editedMediaItem The {@link MediaItem} to transform, with the transformations to apply to + * @param editedMediaItem The {@link MediaItem} to export, with the transformations to apply to * it. * @param path The path to the output file. * @throws IllegalArgumentException If the path is invalid. * @throws IllegalStateException If this method is called from the wrong thread. - * @throws IllegalStateException If a transformation is already in progress. + * @throws IllegalStateException If an export is already in progress. */ - public void startTransformation(EditedMediaItem editedMediaItem, String path) { - startTransformationInternal(editedMediaItem, path); - } - - /** - * Starts an asynchronous operation to transform the given {@link MediaItem}. - * - *

    The transformation state is notified through the {@linkplain Builder#addListener(Listener) - * listener}. - * - *

    Concurrent transformations on the same Transformer object are not allowed. - * - *

    If no custom {@link Muxer.Factory} is specified, the output is an MP4 file. - * - *

    The output can contain at most one video track and one audio track. Other track types are - * ignored. For adaptive bitrate, if no custom {@link AssetLoader.Factory} is specified, the - * highest bitrate video and audio streams are selected. - * - *

    If encoding the output's video track is needed, the output frames' dimensions will be - * swapped if the height is larger than the width. This is to improve compatibility among - * different device encoders. - * - * @param mediaItem The {@link MediaItem} to transform. - * @param path The path to the output file. - * @throws IllegalArgumentException If the path is invalid. - * @throws IllegalArgumentException If the {@link MediaItem} is not supported. - * @throws IllegalStateException If this method is called from the wrong thread. - * @throws IllegalStateException If a transformation is already in progress. - */ - public void startTransformation(MediaItem mediaItem, String path) { - if (!mediaItem.clippingConfiguration.equals(MediaItem.ClippingConfiguration.UNSET) - && flattenForSlowMotion) { - throw new IllegalArgumentException( - "Clipping is not supported when slow motion flattening is requested"); - } - EditedMediaItem editedMediaItem = - new EditedMediaItem.Builder(mediaItem) - .setRemoveAudio(removeAudio) - .setRemoveVideo(removeVideo) - .setFlattenForSlowMotion(flattenForSlowMotion) - .setEffects(new Effects(audioProcessors, videoEffects, frameProcessorFactory)) - .build(); - startTransformationInternal(editedMediaItem, path); - } - - private void startTransformationInternal(EditedMediaItem editedMediaItem, String path) { + public void start(EditedMediaItem editedMediaItem, String path) { verifyApplicationThread(); if (transformerInternal != null) { - throw new IllegalStateException("There is already a transformation in progress."); + throw new IllegalStateException("There is already a export in progress."); } EditedMediaItemSequence sequence = new EditedMediaItemSequence(ImmutableList.of(editedMediaItem)); @@ -778,6 +730,56 @@ public final class Transformer { transformerInternal.start(); } + /** + * Starts an asynchronous operation to export the given {@link MediaItem}. + * + *

    The export state is notified through the {@linkplain Builder#addListener(Listener) + * listener}. + * + *

    Concurrent exports on the same Transformer object are not allowed. + * + *

    If no custom {@link Muxer.Factory} is specified, the output is an MP4 file. + * + *

    The output can contain at most one video track and one audio track. Other track types are + * ignored. For adaptive bitrate, if no custom {@link AssetLoader.Factory} is specified, the + * highest bitrate video and audio streams are selected. + * + *

    If encoding the output's video track is needed, the output frames' dimensions will be + * swapped if the height is larger than the width. This is to improve compatibility among + * different device encoders. + * + * @param mediaItem The {@link MediaItem} to export. + * @param path The path to the output file. + * @throws IllegalArgumentException If the path is invalid. + * @throws IllegalArgumentException If the {@link MediaItem} is not supported. + * @throws IllegalStateException If this method is called from the wrong thread. + * @throws IllegalStateException If an export is already in progress. + */ + public void start(MediaItem mediaItem, String path) { + if (!mediaItem.clippingConfiguration.equals(MediaItem.ClippingConfiguration.UNSET) + && flattenForSlowMotion) { + throw new IllegalArgumentException( + "Clipping is not supported when slow motion flattening is requested"); + } + EditedMediaItem editedMediaItem = + new EditedMediaItem.Builder(mediaItem) + .setRemoveAudio(removeAudio) + .setRemoveVideo(removeVideo) + .setFlattenForSlowMotion(flattenForSlowMotion) + .setEffects(new Effects(audioProcessors, videoEffects, frameProcessorFactory)) + .build(); + start(editedMediaItem, path); + } + + /** + * @deprecated Use {@link #start(MediaItem, String)} instead. + */ + @Deprecated + @InlineMe(replacement = "this.start(mediaItem, path)") + public void startTransformation(MediaItem mediaItem, String path) { + start(mediaItem, path); + } + /** * Returns the {@link Looper} associated with the application thread that's used to access the * transformer and on which transformer events are received. @@ -790,7 +792,7 @@ public final class Transformer { * Returns the current {@link ProgressState} and updates {@code progressHolder} with the current * progress if it is {@link #PROGRESS_STATE_AVAILABLE available}. * - *

    After a transformation {@linkplain Listener#onCompleted(Composition, TransformationResult) + *

    After an export {@linkplain Listener#onCompleted(Composition,TransformationResult) * completes}, this method returns {@link #PROGRESS_STATE_NOT_STARTED}. * * @param progressHolder A {@link ProgressHolder}, updated to hold the percentage progress if @@ -806,7 +808,7 @@ public final class Transformer { } /** - * Cancels the transformation that is currently in progress, if any. + * Cancels the export that is currently in progress, if any. * * @throws IllegalStateException If this method is called from the wrong thread. */ diff --git a/libraries/transformer/src/test/java/androidx/media3/transformer/TransformerEndToEndTest.java b/libraries/transformer/src/test/java/androidx/media3/transformer/TransformerEndToEndTest.java index 66b91280f2..4644b6dbd4 100644 --- a/libraries/transformer/src/test/java/androidx/media3/transformer/TransformerEndToEndTest.java +++ b/libraries/transformer/src/test/java/androidx/media3/transformer/TransformerEndToEndTest.java @@ -134,7 +134,7 @@ public final class TransformerEndToEndTest { Transformer transformer = createTransformerBuilder(/* enableFallback= */ false).build(); MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_VIDEO_ONLY); - transformer.startTransformation(mediaItem, outputPath); + transformer.start(mediaItem, outputPath); TransformerTestRunner.runLooper(transformer); DumpFileAsserts.assertOutput(context, testMuxer, getDumpFileName(FILE_VIDEO_ONLY)); @@ -145,7 +145,7 @@ public final class TransformerEndToEndTest { Transformer transformer = createTransformerBuilder(/* enableFallback= */ false).build(); MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_AUDIO_UNSUPPORTED_BY_ENCODER); - transformer.startTransformation(mediaItem, outputPath); + transformer.start(mediaItem, outputPath); TransformerTestRunner.runLooper(transformer); DumpFileAsserts.assertOutput( @@ -163,7 +163,7 @@ public final class TransformerEndToEndTest { .build(); MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_AUDIO_UNSUPPORTED_BY_ENCODER); - transformer.startTransformation(mediaItem, outputPath); + transformer.start(mediaItem, outputPath); TransformerTestRunner.runLooper(transformer); DumpFileAsserts.assertOutput( @@ -175,7 +175,7 @@ public final class TransformerEndToEndTest { Transformer transformer = createTransformerBuilder(/* enableFallback= */ false).build(); MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_AUDIO_VIDEO); - transformer.startTransformation(mediaItem, outputPath); + transformer.start(mediaItem, outputPath); TransformerTestRunner.runLooper(transformer); DumpFileAsserts.assertOutput(context, testMuxer, getDumpFileName(FILE_AUDIO_VIDEO)); @@ -196,7 +196,7 @@ public final class TransformerEndToEndTest { .build()) .build(); - transformer.startTransformation(mediaItem, outputPath); + transformer.start(mediaItem, outputPath); TransformerTestRunner.runLooper(transformer); DumpFileAsserts.assertOutput( @@ -214,7 +214,7 @@ public final class TransformerEndToEndTest { .build(); MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_WITH_SUBTITLES); - transformer.startTransformation(mediaItem, outputPath); + transformer.start(mediaItem, outputPath); TransformerTestRunner.runLooper(transformer); DumpFileAsserts.assertOutput(context, testMuxer, getDumpFileName(FILE_WITH_SUBTITLES)); @@ -227,12 +227,12 @@ public final class TransformerEndToEndTest { MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_AUDIO_VIDEO); // Transform first media item. - transformer.startTransformation(mediaItem, outputPath); + transformer.start(mediaItem, outputPath); TransformerTestRunner.runLooper(transformer); Files.delete(Paths.get(outputPath)); // Transform second media item. - transformer.startTransformation(mediaItem, outputPath); + transformer.start(mediaItem, outputPath); TransformerTestRunner.runLooper(transformer); DumpFileAsserts.assertOutput(context, testMuxer, getDumpFileName(FILE_AUDIO_VIDEO)); @@ -243,10 +243,9 @@ public final class TransformerEndToEndTest { Transformer transformer = createTransformerBuilder(/* enableFallback= */ false).build(); MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_VIDEO_ONLY); - transformer.startTransformation(mediaItem, outputPath); + transformer.start(mediaItem, outputPath); - assertThrows( - IllegalStateException.class, () -> transformer.startTransformation(mediaItem, outputPath)); + assertThrows(IllegalStateException.class, () -> transformer.start(mediaItem, outputPath)); } @Test @@ -257,7 +256,7 @@ public final class TransformerEndToEndTest { .setRemoveAudio(true) .build(); - transformer.startTransformation(editedMediaItem, outputPath); + transformer.start(editedMediaItem, outputPath); TransformerTestRunner.runLooper(transformer); DumpFileAsserts.assertOutput( @@ -272,7 +271,7 @@ public final class TransformerEndToEndTest { .setRemoveVideo(true) .build(); - transformer.startTransformation(editedMediaItem, outputPath); + transformer.start(editedMediaItem, outputPath); TransformerTestRunner.runLooper(transformer); DumpFileAsserts.assertOutput( @@ -287,7 +286,7 @@ public final class TransformerEndToEndTest { .build(); MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_AUDIO_UNSUPPORTED_BY_ENCODER); - transformer.startTransformation(mediaItem, outputPath); + transformer.start(mediaItem, outputPath); TransformerTestRunner.runLooper(transformer); DumpFileAsserts.assertOutput( @@ -302,7 +301,7 @@ public final class TransformerEndToEndTest { .build(); MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_AUDIO_VIDEO); - transformer.startTransformation(mediaItem, outputPath); + transformer.start(mediaItem, outputPath); TransformerTestRunner.runLooper(transformer); DumpFileAsserts.assertOutput(context, testMuxer, getDumpFileName(FILE_AUDIO_VIDEO)); @@ -319,7 +318,7 @@ public final class TransformerEndToEndTest { .setRemoveAudio(true) .build(); - transformer.startTransformation(editedMediaItem, outputPath); + transformer.start(editedMediaItem, outputPath); TransformerTestRunner.runLooper(transformer); DumpFileAsserts.assertOutput( @@ -337,7 +336,7 @@ public final class TransformerEndToEndTest { .setRemoveVideo(true) .build(); - transformer.startTransformation(editedMediaItem, outputPath); + transformer.start(editedMediaItem, outputPath); TransformerTestRunner.runLooper(transformer); DumpFileAsserts.assertOutput( context, testMuxer, getDumpFileName(FILE_AUDIO_VIDEO + ".novideo")); @@ -351,7 +350,7 @@ public final class TransformerEndToEndTest { .build(); MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_VIDEO_ONLY); - transformer.startTransformation(mediaItem, outputPath); + transformer.start(mediaItem, outputPath); TransformerTestRunner.runLooper(transformer); DumpFileAsserts.assertOutput( @@ -369,7 +368,7 @@ public final class TransformerEndToEndTest { EditedMediaItem editedMediaItem = new EditedMediaItem.Builder(mediaItem).setEffects(effects).build(); - transformer.startTransformation(editedMediaItem, outputPath); + transformer.start(editedMediaItem, outputPath); TransformerTestRunner.runLooper(transformer); DumpFileAsserts.assertOutput( @@ -389,7 +388,7 @@ public final class TransformerEndToEndTest { .build(); MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_AUDIO_VIDEO); - transformer.startTransformation(mediaItem, outputPath); + transformer.start(mediaItem, outputPath); TransformerTestRunner.runLooper(transformer); verify(mockListener1).onCompleted(compositionArgumentCaptor.capture(), any()); @@ -413,7 +412,7 @@ public final class TransformerEndToEndTest { .build(); MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_AUDIO_UNSUPPORTED_BY_DECODER); - transformer.startTransformation(mediaItem, outputPath); + transformer.start(mediaItem, outputPath); TransformationException exception = assertThrows( TransformationException.class, () -> TransformerTestRunner.runLooper(transformer)); @@ -441,7 +440,7 @@ public final class TransformerEndToEndTest { .build(); MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_AUDIO_UNSUPPORTED_BY_MUXER); - transformer.startTransformation(mediaItem, outputPath); + transformer.start(mediaItem, outputPath); TransformerTestRunner.runLooper(transformer); verify(mockListener1) @@ -482,7 +481,7 @@ public final class TransformerEndToEndTest { .build(); MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_AUDIO_VIDEO); - transformer.startTransformation(mediaItem, outputPath); + transformer.start(mediaItem, outputPath); TransformerTestRunner.runLooper(transformer); assertThat(deprecatedFallbackCalled1.get()).isTrue(); @@ -524,7 +523,7 @@ public final class TransformerEndToEndTest { .build(); MediaItem mediaItem = MediaItem.fromUri("invalid.uri"); - transformer.startTransformation(mediaItem, outputPath); + transformer.start(mediaItem, outputPath); try { TransformerTestRunner.runLooper(transformer); } catch (TransformationException transformationException) { @@ -554,7 +553,7 @@ public final class TransformerEndToEndTest { .build(); MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_AUDIO_UNSUPPORTED_BY_MUXER); - transformer.startTransformation(mediaItem, outputPath); + transformer.start(mediaItem, outputPath); TransformerTestRunner.runLooper(transformer); assertThat(deprecatedFallbackCalled.get()).isTrue(); @@ -575,7 +574,7 @@ public final class TransformerEndToEndTest { Transformer transformer2 = transformer1.buildUpon().removeListener(mockListener2).build(); MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_AUDIO_VIDEO); - transformer2.startTransformation(mediaItem, outputPath); + transformer2.start(mediaItem, outputPath); TransformerTestRunner.runLooper(transformer2); verify(mockListener1).onCompleted(compositionArgumentCaptor.capture(), any()); @@ -591,7 +590,7 @@ public final class TransformerEndToEndTest { .setFlattenForSlowMotion(true) .build(); - transformer.startTransformation(editedMediaItem, outputPath); + transformer.start(editedMediaItem, outputPath); TransformerTestRunner.runLooper(transformer); DumpFileAsserts.assertOutput(context, testMuxer, getDumpFileName(FILE_WITH_SEF_SLOW_MOTION)); @@ -602,7 +601,7 @@ public final class TransformerEndToEndTest { Transformer transformer = createTransformerBuilder(/* enableFallback= */ false).build(); MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_AUDIO_VIDEO); - transformer.startTransformation(mediaItem, outputPath); + transformer.start(mediaItem, outputPath); TransformationResult result = TransformerTestRunner.runLooper(transformer); assertThat(result.averageAudioBitrate).isGreaterThan(0); @@ -621,7 +620,7 @@ public final class TransformerEndToEndTest { .build(); MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_AUDIO_UNSUPPORTED_BY_MUXER); - transformer.startTransformation(mediaItem, outputPath); + transformer.start(mediaItem, outputPath); TransformationException exception = assertThrows( TransformationException.class, () -> TransformerTestRunner.runLooper(transformer)); @@ -641,7 +640,7 @@ public final class TransformerEndToEndTest { .build(); MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_AUDIO_UNSUPPORTED_BY_DECODER); - transformer.startTransformation(mediaItem, outputPath); + transformer.start(mediaItem, outputPath); TransformationException exception = assertThrows( TransformationException.class, () -> TransformerTestRunner.runLooper(transformer)); @@ -655,7 +654,7 @@ public final class TransformerEndToEndTest { Transformer transformer = createTransformerBuilder(/* enableFallback= */ false).build(); MediaItem mediaItem = MediaItem.fromUri("asset:///non-existing-path.mp4"); - transformer.startTransformation(mediaItem, outputPath); + transformer.start(mediaItem, outputPath); TransformationException exception = assertThrows( TransformationException.class, () -> TransformerTestRunner.runLooper(transformer)); @@ -676,7 +675,7 @@ public final class TransformerEndToEndTest { createTransformerBuilder(/* enableFallback= */ false).addListener(mockListener).build(); MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_AUDIO_UNSUPPORTED_BY_MUXER); - transformer.startTransformation(mediaItem, outputPath); + transformer.start(mediaItem, outputPath); TransformerTestRunner.runLooper(transformer); DumpFileAsserts.assertOutput( @@ -700,7 +699,7 @@ public final class TransformerEndToEndTest { createTransformerBuilder(/* enableFallback= */ true).addListener(mockListener).build(); MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_AUDIO_UNSUPPORTED_BY_MUXER); - transformer.startTransformation(mediaItem, outputPath); + transformer.start(mediaItem, outputPath); TransformerTestRunner.runLooper(transformer); DumpFileAsserts.assertOutput( @@ -728,7 +727,7 @@ public final class TransformerEndToEndTest { .build(); MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_AUDIO_VIDEO); - transformer.startTransformation(mediaItem, outputPath); + transformer.start(mediaItem, outputPath); TransformationException exception = assertThrows( TransformationException.class, () -> TransformerTestRunner.runLooper(transformer)); @@ -744,7 +743,7 @@ public final class TransformerEndToEndTest { createTransformerBuilder(/* enableFallback= */ false).setMuxerFactory(muxerFactory).build(); MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_AUDIO_VIDEO); - transformer.startTransformation(mediaItem, outputPath); + transformer.start(mediaItem, outputPath); TransformerTestRunner.runLooper(transformer); DumpFileAsserts.assertOutput(context, testMuxer, getDumpFileName(FILE_AUDIO_VIDEO)); @@ -755,12 +754,12 @@ public final class TransformerEndToEndTest { Transformer transformer = createTransformerBuilder(/* enableFallback= */ false).build(); MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_AUDIO_VIDEO); - transformer.startTransformation(mediaItem, outputPath); + transformer.start(mediaItem, outputPath); transformer.cancel(); Files.delete(Paths.get(outputPath)); // This would throw if the previous transformation had not been cancelled. - transformer.startTransformation(mediaItem, outputPath); + transformer.start(mediaItem, outputPath); TransformationResult transformationResult = TransformerTestRunner.runLooper(transformer); // TODO(b/264974805): Make transformation output deterministic and check it against dump file. @@ -782,7 +781,7 @@ public final class TransformerEndToEndTest { .post( () -> { try { - transformer.startTransformation(mediaItem, outputPath); + transformer.start(mediaItem, outputPath); TransformerTestRunner.runLooper(transformer); } catch (Exception e) { exception.set(e); @@ -809,7 +808,7 @@ public final class TransformerEndToEndTest { .post( () -> { try { - transformer.startTransformation(mediaItem, outputPath); + transformer.start(mediaItem, outputPath); } catch (IllegalStateException e) { illegalStateException.set(e); } finally { @@ -832,7 +831,7 @@ public final class TransformerEndToEndTest { .build(); MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_AUDIO_VIDEO); - transformer.startTransformation(mediaItem, outputPath); + transformer.start(mediaItem, outputPath); runLooperUntil(transformer.getApplicationLooper(), () -> sampleConsumerRef.get() != null); assertThat(sampleConsumerRef.get().expectsDecodedData()).isTrue(); @@ -852,7 +851,7 @@ public final class TransformerEndToEndTest { EditedMediaItem editedMediaItem = new EditedMediaItem.Builder(mediaItem).setEffects(effects).build(); - transformer.startTransformation(editedMediaItem, outputPath); + transformer.start(editedMediaItem, outputPath); TransformationException transformationException = assertThrows( TransformationException.class, () -> TransformerTestRunner.runLooper(transformer)); @@ -873,7 +872,7 @@ public final class TransformerEndToEndTest { EditedMediaItem editedMediaItem = new EditedMediaItem.Builder(mediaItem).setEffects(effects).build(); - transformer.startTransformation(editedMediaItem, outputPath); + transformer.start(editedMediaItem, outputPath); TransformerTestRunner.runLooper(transformer); // Video transcoding in unit tests is not supported. @@ -919,7 +918,7 @@ public final class TransformerEndToEndTest { } }; - transformer.startTransformation(mediaItem, outputPath); + transformer.start(mediaItem, outputPath); progressHandler.sendEmptyMessage(0); TransformerTestRunner.runLooper(transformer); @@ -948,7 +947,7 @@ public final class TransformerEndToEndTest { } }; - transformer.startTransformation(mediaItem, outputPath); + transformer.start(mediaItem, outputPath); progressHandler.sendEmptyMessage(0); TransformerTestRunner.runLooper(transformer); @@ -967,7 +966,7 @@ public final class TransformerEndToEndTest { MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_VIDEO_ONLY); @Transformer.ProgressState int stateBeforeTransform = transformer.getProgress(progressHolder); - transformer.startTransformation(mediaItem, outputPath); + transformer.start(mediaItem, outputPath); TransformerTestRunner.runLooper(transformer); @Transformer.ProgressState int stateAfterTransform = transformer.getProgress(progressHolder); @@ -1011,7 +1010,7 @@ public final class TransformerEndToEndTest { } }; - transformer.startTransformation(mediaItem, outputPath); + transformer.start(mediaItem, outputPath); progressHandler.sendEmptyMessage(0); TransformerTestRunner.runLooper(transformer); @@ -1047,7 +1046,7 @@ public final class TransformerEndToEndTest { Transformer transformer = createTransformerBuilder(/* enableFallback= */ false).build(); MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_VIDEO_ONLY); - transformer.startTransformation(mediaItem, outputPath); + transformer.start(mediaItem, outputPath); TransformerTestRunner.runLooper(transformer); transformer.cancel(); }