Rename occurrences of transform in lib-transformer

PiperOrigin-RevId: 510118760
This commit is contained in:
kimvde 2023-02-16 13:43:55 +00:00 committed by christosts
parent 5d8a83f924
commit 221c5afb1b
15 changed files with 116 additions and 129 deletions

View File

@ -23,8 +23,7 @@ import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
/** /**
* A test only class for holding the details of what fallbacks were applied during a test * A test only class for holding the details of what fallbacks were applied during a test export.
* transformation.
*/ */
/* package */ final class FallbackDetails { /* package */ final class FallbackDetails {

View File

@ -45,7 +45,7 @@ import org.json.JSONObject;
public class TransformerAndroidTestRunner { public class TransformerAndroidTestRunner {
private static final String TAG = "TransformerAndroidTest"; private static final String TAG = "TransformerAndroidTest";
/** The default transformation timeout value. */ /** The default export timeout value. */
public static final int DEFAULT_TIMEOUT_SECONDS = 120; public static final int DEFAULT_TIMEOUT_SECONDS = 120;
/** A {@link Builder} for {@link TransformerAndroidTestRunner} instances. */ /** A {@link Builder} for {@link TransformerAndroidTestRunner} instances. */
@ -61,7 +61,7 @@ public class TransformerAndroidTestRunner {
* Creates a {@link Builder}. * Creates a {@link Builder}.
* *
* @param context The {@link Context}. * @param context The {@link Context}.
* @param transformer The {@link Transformer} that performs the transformation. * @param transformer The {@link Transformer} that performs the export.
*/ */
public Builder(Context context, Transformer transformer) { public Builder(Context context, Transformer transformer) {
this.context = context; this.context = context;
@ -70,7 +70,7 @@ public class TransformerAndroidTestRunner {
} }
/** /**
* Sets the timeout in seconds for a single transformation. An exception is thrown when this is * Sets the timeout in seconds for a single export. An exception is thrown when this is
* exceeded. * exceeded.
* *
* <p>The default value is {@link #DEFAULT_TIMEOUT_SECONDS}. * <p>The default value is {@link #DEFAULT_TIMEOUT_SECONDS}.
@ -85,7 +85,7 @@ public class TransformerAndroidTestRunner {
} }
/** /**
* Sets whether to calculate the SSIM of the transformation output compared to the input, if * Sets whether to calculate the SSIM of the exported output compared to the input, if
* supported. Calculating SSIM is not supported if the input and output video dimensions don't * supported. Calculating SSIM is not supported if the input and output video dimensions don't
* match, or if the input video is trimmed. * match, or if the input video is trimmed.
* *
@ -104,8 +104,8 @@ public class TransformerAndroidTestRunner {
} }
/** /**
* Sets whether to suppress failures that occurs as a result of post-transformation analysis, * Sets whether to suppress failures that occurs as a result of post-export analysis, such as
* such as SSIM calculation. * SSIM calculation.
* *
* <p>Regardless of this value, analysis exceptions are attached to the analysis file. * <p>Regardless of this value, analysis exceptions are attached to the analysis file.
* *
@ -124,13 +124,13 @@ public class TransformerAndroidTestRunner {
} }
/** /**
* Sets a {@link Map} of transformer input values, which are propagated to the transformation * Sets a {@link Map} of transformer input values, which are propagated to the export summary
* summary JSON file. * JSON file.
* *
* <p>Values in the map should be convertible according to {@link JSONObject#wrap(Object)} to be * <p>Values in the map should be convertible according to {@link JSONObject#wrap(Object)} to be
* recorded properly in the summary file. * recorded properly in the summary file.
* *
* @param inputValues A {@link Map} of values to be written to the transformation summary. * @param inputValues A {@link Map} of values to be written to the export summary.
* @return This {@link Builder}. * @return This {@link Builder}.
*/ */
@CanIgnoreReturnValue @CanIgnoreReturnValue
@ -337,7 +337,7 @@ public class TransformerAndroidTestRunner {
.build(); .build();
} }
// No exceptions raised, transformation has succeeded. // No exceptions raised, export has succeeded.
ExportTestResult.Builder testResultBuilder = ExportTestResult.Builder testResultBuilder =
new ExportTestResult.Builder( new ExportTestResult.Builder(
checkNotNull(exportResultReference.get()) checkNotNull(exportResultReference.get())

View File

@ -69,8 +69,8 @@ public class HdrEditingTest {
.build(); .build();
@Test @Test
public void transform_noRequestedTranscode_hdr10File_transformsOrThrows() throws Exception { public void export_noRequestedTranscode_hdr10File_exportsOrThrows() throws Exception {
String testId = "transform_noRequestedTranscode_hdr10File_transformsOrThrows"; String testId = "export_noRequestedTranscode_hdr10File_exportsOrThrows";
Context context = ApplicationProvider.getApplicationContext(); Context context = ApplicationProvider.getApplicationContext();
Transformer transformer = new Transformer.Builder(context).build(); Transformer transformer = new Transformer.Builder(context).build();
@ -81,7 +81,7 @@ public class HdrEditingTest {
new TransformerAndroidTestRunner.Builder(context, transformer) new TransformerAndroidTestRunner.Builder(context, transformer)
.build() .build()
.run(testId, mediaItem); .run(testId, mediaItem);
Log.i(TAG, "Transformed."); Log.i(TAG, "Exported.");
assertFileHasColorTransfer(exportTestResult.filePath, C.COLOR_TRANSFER_ST2084); assertFileHasColorTransfer(exportTestResult.filePath, C.COLOR_TRANSFER_ST2084);
} catch (ExportException exception) { } catch (ExportException exception) {
Log.i(TAG, checkNotNull(exception.getCause()).toString()); Log.i(TAG, checkNotNull(exception.getCause()).toString());
@ -94,8 +94,8 @@ public class HdrEditingTest {
} }
@Test @Test
public void transform_noRequestedTranscode_hlg10File_transformsOrThrows() throws Exception { public void export_noRequestedTranscode_hlg10File_exportsOrThrows() throws Exception {
String testId = "transform_noRequestedTranscode_hlg10File_transformsOrThrows"; String testId = "export_noRequestedTranscode_hlg10File_exportsOrThrows";
Context context = ApplicationProvider.getApplicationContext(); Context context = ApplicationProvider.getApplicationContext();
Transformer transformer = new Transformer.Builder(context).build(); Transformer transformer = new Transformer.Builder(context).build();
@ -106,7 +106,7 @@ public class HdrEditingTest {
new TransformerAndroidTestRunner.Builder(context, transformer) new TransformerAndroidTestRunner.Builder(context, transformer)
.build() .build()
.run(testId, mediaItem); .run(testId, mediaItem);
Log.i(TAG, "Transformed."); Log.i(TAG, "Exported.");
assertFileHasColorTransfer(exportTestResult.filePath, C.COLOR_TRANSFER_HLG); assertFileHasColorTransfer(exportTestResult.filePath, C.COLOR_TRANSFER_HLG);
} catch (ExportException exception) { } catch (ExportException exception) {
Log.i(TAG, checkNotNull(exception.getCause()).toString()); Log.i(TAG, checkNotNull(exception.getCause()).toString());
@ -119,9 +119,8 @@ public class HdrEditingTest {
} }
@Test @Test
public void transformAndTranscode_hdr10File_whenHdrEditingIsSupported_transforms() public void exportAndTranscode_hdr10File_whenHdrEditingIsSupported_exports() throws Exception {
throws Exception { String testId = "exportAndTranscode_hdr10File_whenHdrEditingIsSupported_exports";
String testId = "transformAndTranscode_hdr10File_whenHdrEditingIsSupported_transforms";
Context context = ApplicationProvider.getApplicationContext(); Context context = ApplicationProvider.getApplicationContext();
if (!deviceSupportsHdrEditing(VIDEO_H265, HDR10_DEFAULT_COLOR_INFO)) { if (!deviceSupportsHdrEditing(VIDEO_H265, HDR10_DEFAULT_COLOR_INFO)) {
recordTestSkipped(context, testId, /* reason= */ "Device lacks HDR10 editing support."); recordTestSkipped(context, testId, /* reason= */ "Device lacks HDR10 editing support.");
@ -144,9 +143,8 @@ public class HdrEditingTest {
} }
@Test @Test
public void transformAndTranscode_hlg10File_whenHdrEditingIsSupported_transforms() public void exportAndTranscode_hlg10File_whenHdrEditingIsSupported_exports() throws Exception {
throws Exception { String testId = "exportAndTranscode_hlg10File_whenHdrEditingIsSupported_exports";
String testId = "transformAndTranscode_hlg10File_whenHdrEditingIsSupported_transforms";
Context context = ApplicationProvider.getApplicationContext(); Context context = ApplicationProvider.getApplicationContext();
if (!deviceSupportsHdrEditing(VIDEO_H265, HLG10_DEFAULT_COLOR_INFO)) { if (!deviceSupportsHdrEditing(VIDEO_H265, HLG10_DEFAULT_COLOR_INFO)) {
recordTestSkipped(context, testId, /* reason= */ "Device lacks HLG10 editing support."); recordTestSkipped(context, testId, /* reason= */ "Device lacks HLG10 editing support.");
@ -169,9 +167,9 @@ public class HdrEditingTest {
} }
@Test @Test
public void transformAndTranscode_hdr10File_whenHdrEditingUnsupported_toneMapsOrThrows() public void exportAndTranscode_hdr10File_whenHdrEditingUnsupported_toneMapsOrThrows()
throws Exception { throws Exception {
String testId = "transformAndTranscode_hdr10File_whenHdrEditingUnsupported_toneMapsOrThrows"; String testId = "exportAndTranscode_hdr10File_whenHdrEditingUnsupported_toneMapsOrThrows";
Context context = ApplicationProvider.getApplicationContext(); Context context = ApplicationProvider.getApplicationContext();
if (deviceSupportsHdrEditing(VIDEO_H265, HDR10_DEFAULT_COLOR_INFO)) { if (deviceSupportsHdrEditing(VIDEO_H265, HDR10_DEFAULT_COLOR_INFO)) {
recordTestSkipped(context, testId, /* reason= */ "Device supports HDR10 editing."); recordTestSkipped(context, testId, /* reason= */ "Device supports HDR10 editing.");
@ -223,9 +221,9 @@ public class HdrEditingTest {
} }
@Test @Test
public void transformAndTranscode_hlg10File_whenHdrEditingUnsupported_toneMapsOrThrows() public void exportAndTranscode_hlg10File_whenHdrEditingUnsupported_toneMapsOrThrows()
throws Exception { throws Exception {
String testId = "transformAndTranscode_hlg10File_whenHdrEditingUnsupported_toneMapsOrThrows"; String testId = "exportAndTranscode_hlg10File_whenHdrEditingUnsupported_toneMapsOrThrows";
Context context = ApplicationProvider.getApplicationContext(); Context context = ApplicationProvider.getApplicationContext();
if (deviceSupportsHdrEditing(VIDEO_H265, HLG10_DEFAULT_COLOR_INFO)) { if (deviceSupportsHdrEditing(VIDEO_H265, HLG10_DEFAULT_COLOR_INFO)) {
recordTestSkipped(context, testId, /* reason= */ "Device supports HLG10 editing."); recordTestSkipped(context, testId, /* reason= */ "Device supports HLG10 editing.");
@ -277,8 +275,8 @@ public class HdrEditingTest {
} }
@Test @Test
public void transformUnexpectedColorInfo() throws Exception { public void exportUnexpectedColorInfo() throws Exception {
String testId = "transformUnexpectedColorInfo"; String testId = "exportUnexpectedColorInfo";
Context context = ApplicationProvider.getApplicationContext(); Context context = ApplicationProvider.getApplicationContext();
if (Util.SDK_INT < 29) { if (Util.SDK_INT < 29) {
recordTestSkipped( recordTestSkipped(

View File

@ -51,8 +51,8 @@ public class ToneMapHdrToSdrUsingMediaCodecTest {
public static final String TAG = "ToneMapHdrToSdrUsingMediaCodecTest"; public static final String TAG = "ToneMapHdrToSdrUsingMediaCodecTest";
@Test @Test
public void transform_toneMapNoRequestedTranscode_hdr10File_toneMapsOrThrows() throws Exception { public void export_toneMapNoRequestedTranscode_hdr10File_toneMapsOrThrows() throws Exception {
String testId = "transform_toneMapNoRequestedTranscode_hdr10File_toneMapsOrThrows"; String testId = "export_toneMapNoRequestedTranscode_hdr10File_toneMapsOrThrows";
Context context = ApplicationProvider.getApplicationContext(); Context context = ApplicationProvider.getApplicationContext();
Transformer transformer = Transformer transformer =
@ -93,8 +93,8 @@ public class ToneMapHdrToSdrUsingMediaCodecTest {
} }
@Test @Test
public void transform_toneMapNoRequestedTranscode_hlg10File_toneMapsOrThrows() throws Exception { public void export_toneMapNoRequestedTranscode_hlg10File_toneMapsOrThrows() throws Exception {
String testId = "transform_toneMapNoRequestedTranscode_hlg10File_toneMapsOrThrows"; String testId = "export_toneMapNoRequestedTranscode_hlg10File_toneMapsOrThrows";
Context context = ApplicationProvider.getApplicationContext(); Context context = ApplicationProvider.getApplicationContext();
Transformer transformer = Transformer transformer =
@ -135,8 +135,8 @@ public class ToneMapHdrToSdrUsingMediaCodecTest {
} }
@Test @Test
public void transform_toneMapAndTranscode_hdr10File_toneMapsOrThrows() throws Exception { public void export_toneMapAndTranscode_hdr10File_toneMapsOrThrows() throws Exception {
String testId = "transform_toneMapAndTranscode_hdr10File_toneMapsOrThrows"; String testId = "export_toneMapAndTranscode_hdr10File_toneMapsOrThrows";
Context context = ApplicationProvider.getApplicationContext(); Context context = ApplicationProvider.getApplicationContext();
Transformer transformer = Transformer transformer =
@ -182,8 +182,8 @@ public class ToneMapHdrToSdrUsingMediaCodecTest {
} }
@Test @Test
public void transform_toneMapAndTranscode_hlg10File_toneMapsOrThrows() throws Exception { public void export_toneMapAndTranscode_hlg10File_toneMapsOrThrows() throws Exception {
String testId = "transform_toneMapAndTranscode_hlg10File_toneMapsOrThrows"; String testId = "export_toneMapAndTranscode_hlg10File_toneMapsOrThrows";
Context context = ApplicationProvider.getApplicationContext(); Context context = ApplicationProvider.getApplicationContext();
Transformer transformer = Transformer transformer =

View File

@ -50,8 +50,8 @@ public class ToneMapHdrToSdrUsingOpenGlTest {
public static final String TAG = "ToneMapHdrToSdrUsingOpenGlTest"; public static final String TAG = "ToneMapHdrToSdrUsingOpenGlTest";
@Test @Test
public void transform_toneMap_hlg10File_toneMapsOrThrows() throws Exception { public void export_toneMap_hlg10File_toneMapsOrThrows() throws Exception {
String testId = "transform_glToneMap_hlg10File_toneMapsOrThrows"; String testId = "export_glToneMap_hlg10File_toneMapsOrThrows";
if (Util.SDK_INT < 29) { if (Util.SDK_INT < 29) {
recordTestSkipped( recordTestSkipped(
@ -100,8 +100,8 @@ public class ToneMapHdrToSdrUsingOpenGlTest {
} }
@Test @Test
public void transform_toneMap_hdr10File_toneMapsOrThrows() throws Exception { public void export_toneMap_hdr10File_toneMapsOrThrows() throws Exception {
String testId = "transform_glToneMap_hdr10File_toneMapsOrThrows"; String testId = "export_glToneMap_hdr10File_toneMapsOrThrows";
if (Util.SDK_INT < 29) { if (Util.SDK_INT < 29) {
recordTestSkipped( recordTestSkipped(

View File

@ -39,7 +39,7 @@ import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class) @RunWith(AndroidJUnit4.class)
public final class TranscodeQualityTest { public final class TranscodeQualityTest {
@Test @Test
public void transformHighQualityTargetingAvcToAvc1920x1080_ssimIsGreaterThan95Percent() public void exportHighQualityTargetingAvcToAvc1920x1080_ssimIsGreaterThan95Percent()
throws Exception { throws Exception {
Context context = ApplicationProvider.getApplicationContext(); Context context = ApplicationProvider.getApplicationContext();
String testId = "transformHighQualityTargetingAvcToAvc1920x1080_ssim"; String testId = "transformHighQualityTargetingAvcToAvc1920x1080_ssim";

View File

@ -158,7 +158,7 @@ public class SsimMapperTest {
private static final String TAG = "SsimBinarySearcher"; private static final String TAG = "SsimBinarySearcher";
private static final double SSIM_ACCEPTABLE_TOLERANCE = 0.005; private static final double SSIM_ACCEPTABLE_TOLERANCE = 0.005;
private static final double SSIM_TARGET = 0.95; private static final double SSIM_TARGET = 0.95;
private static final int MAX_TRANSFORMATIONS = 12; private static final int MAX_EXPORTS = 12;
private final Context context; private final Context context;
private final String testIdPrefix; private final String testIdPrefix;
@ -166,7 +166,7 @@ public class SsimMapperTest {
private final Format format; private final Format format;
private final String outputMimeType; private final String outputMimeType;
private int transformationsLeft; private int exportsLeft;
private double ssimLowerBound; private double ssimLowerBound;
private double ssimUpperBound; private double ssimUpperBound;
private int bitrateLowerBound; private int bitrateLowerBound;
@ -187,7 +187,7 @@ public class SsimMapperTest {
this.testIdPrefix = testIdPrefix; this.testIdPrefix = testIdPrefix;
this.videoUri = videoUri; this.videoUri = videoUri;
this.outputMimeType = outputMimeType; this.outputMimeType = outputMimeType;
transformationsLeft = MAX_TRANSFORMATIONS; exportsLeft = MAX_EXPORTS;
format = AndroidTestUtil.getFormatForTestFile(videoUri); format = AndroidTestUtil.getFormatForTestFile(videoUri);
} }
@ -208,7 +208,7 @@ public class SsimMapperTest {
int maxBitrateToCheck = currentBitrate * 32; int maxBitrateToCheck = currentBitrate * 32;
do { do {
double currentSsim = transformAndGetSsim(currentBitrate); double currentSsim = exportAndGetSsim(currentBitrate);
if (isSsimAcceptable(currentSsim)) { if (isSsimAcceptable(currentSsim)) {
return false; return false;
} }
@ -228,10 +228,9 @@ public class SsimMapperTest {
return false; return false;
} }
} }
} while ((ssimLowerBound == SSIM_UNSET || ssimUpperBound == SSIM_UNSET) } while ((ssimLowerBound == SSIM_UNSET || ssimUpperBound == SSIM_UNSET) && exportsLeft > 0);
&& transformationsLeft > 0);
return transformationsLeft > 0; return exportsLeft > 0;
} }
/** /**
@ -240,19 +239,19 @@ public class SsimMapperTest {
* <p>Performs a binary search of the bitrate between the {@link #bitrateLowerBound} and {@link * <p>Performs a binary search of the bitrate between the {@link #bitrateLowerBound} and {@link
* #bitrateUpperBound}. * #bitrateUpperBound}.
* *
* <p>Runs until the target SSIM is found or the maximum number of transformations is reached. * <p>Runs until the target SSIM is found or the maximum number of exports is reached.
*/ */
public void search() throws Exception { public void search() throws Exception {
if (!setupBinarySearchBounds()) { if (!setupBinarySearchBounds()) {
return; return;
} }
while (transformationsLeft > 0) { while (exportsLeft > 0) {
// At this point, we have under and over bitrate bounds, with associated SSIMs. // At this point, we have under and over bitrate bounds, with associated SSIMs.
// Go between the two, and replace either the under or the over. // Go between the two, and replace either the under or the over.
int currentBitrate = (bitrateUpperBound + bitrateLowerBound) / 2; int currentBitrate = (bitrateUpperBound + bitrateLowerBound) / 2;
double currentSsim = transformAndGetSsim(currentBitrate); double currentSsim = exportAndGetSsim(currentBitrate);
if (isSsimAcceptable(currentSsim)) { if (isSsimAcceptable(currentSsim)) {
return; return;
} }
@ -272,7 +271,7 @@ public class SsimMapperTest {
} }
} }
private double transformAndGetSsim(int bitrate) throws Exception { private double exportAndGetSsim(int bitrate) throws Exception {
// TODO(b/238094555): Force specific encoders to be used. // TODO(b/238094555): Force specific encoders to be used.
String fileName = checkNotNull(getLast(FORWARD_SLASH_SPLITTER.split(videoUri))); String fileName = checkNotNull(getLast(FORWARD_SLASH_SPLITTER.split(videoUri)));
@ -305,7 +304,7 @@ public class SsimMapperTest {
.setRemoveAudio(true) .setRemoveAudio(true)
.build(); .build();
transformationsLeft--; exportsLeft--;
double ssim = double ssim =
new TransformerAndroidTestRunner.Builder(context, transformer) new TransformerAndroidTestRunner.Builder(context, transformer)

View File

@ -47,7 +47,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
private final AssetLoader.Listener assetLoaderListener; private final AssetLoader.Listener assetLoaderListener;
private final DecoderInputBuffer decoderInputBuffer; private final DecoderInputBuffer decoderInputBuffer;
private boolean isTransformationRunning; private boolean isRunning;
private long streamStartPositionUs; private long streamStartPositionUs;
public ExoAssetLoaderBaseRenderer( public ExoAssetLoaderBaseRenderer(
@ -92,7 +92,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
@Override @Override
public void render(long positionUs, long elapsedRealtimeUs) { public void render(long positionUs, long elapsedRealtimeUs) {
try { try {
if (!isTransformationRunning || isEnded() || !ensureConfigured()) { if (!isRunning || isEnded() || !ensureConfigured()) {
return; return;
} }
@ -102,7 +102,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
while (feedConsumerFromInput()) {} while (feedConsumerFromInput()) {}
} }
} catch (ExportException e) { } catch (ExportException e) {
isTransformationRunning = false; isRunning = false;
assetLoaderListener.onError(e); assetLoaderListener.onError(e);
} }
} }
@ -120,12 +120,12 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
@Override @Override
protected void onStarted() { protected void onStarted() {
isTransformationRunning = true; isRunning = true;
} }
@Override @Override
protected void onStopped() { protected void onStopped() {
isTransformationRunning = false; isRunning = false;
} }
@Override @Override

View File

@ -144,7 +144,7 @@ public final class ExoPlayerAssetLoader implements AssetLoader {
.setForceHighestSupportedBitrate(true) .setForceHighestSupportedBitrate(true)
.build()); .build());
// Arbitrarily decrease buffers for playback so that samples start being sent earlier to the // Arbitrarily decrease buffers for playback so that samples start being sent earlier to the
// pipelines (rebuffers are less problematic for the transformation use case). // pipelines (rebuffers are less problematic for the export use case).
DefaultLoadControl loadControl = DefaultLoadControl loadControl =
new DefaultLoadControl.Builder() new DefaultLoadControl.Builder()
.setBufferDurationsMs( .setBufferDurationsMs(
@ -282,7 +282,7 @@ public final class ExoPlayerAssetLoader implements AssetLoader {
if (!window.isPlaceholder) { if (!window.isPlaceholder) {
long durationUs = window.durationUs; long durationUs = window.durationUs;
// Make progress permanently unavailable if the duration is unknown, so that it doesn't jump // Make progress permanently unavailable if the duration is unknown, so that it doesn't jump
// to a high value at the end of the transformation if the duration is set once the media is // to a high value at the end of the export if the duration is set once the media is
// entirely loaded. // entirely loaded.
progressState = progressState =
durationUs <= 0 || durationUs == C.TIME_UNSET durationUs <= 0 || durationUs == C.TIME_UNSET

View File

@ -41,7 +41,7 @@ import androidx.media3.common.util.Util;
/** /**
* Creates a new instance. * Creates a new instance.
* *
* @param composition The {@link Composition} to transform. * @param composition The {@link Composition} to export.
* @param transformerListeners The {@linkplain Transformer.Listener listeners} to call {@link * @param transformerListeners The {@linkplain Transformer.Listener listeners} to call {@link
* Transformer.Listener#onFallbackApplied} on. * Transformer.Listener#onFallbackApplied} on.
* @param transformerListenerHandler The {@link HandlerWrapper} to call {@link * @param transformerListenerHandler The {@link HandlerWrapper} to call {@link

View File

@ -204,7 +204,7 @@ import java.nio.ByteBuffer;
try { try {
stopMuxer(mediaMuxer); stopMuxer(mediaMuxer);
} catch (RuntimeException e) { } catch (RuntimeException e) {
// It doesn't matter that stopping the muxer throws if the transformation is being cancelled. // It doesn't matter that stopping the muxer throws if the export is being cancelled.
if (!forCancellation) { if (!forCancellation) {
throw new MuxerException("Failed to stop the muxer", e); throw new MuxerException("Failed to stop the muxer", e);
} }

View File

@ -93,7 +93,7 @@ public interface Muxer {
* *
* <p>The muxer cannot be used anymore once this method has been called. * <p>The muxer cannot be used anymore once this method has been called.
* *
* @param forCancellation Whether the reason for releasing the resources is the transformation * @param forCancellation Whether the reason for releasing the resources is the export
* cancellation. * cancellation.
* @throws MuxerException If the muxer fails to finish writing the output and {@code * @throws MuxerException If the muxer fails to finish writing the output and {@code
* forCancellation} is false. * forCancellation} is false.
@ -107,8 +107,8 @@ public interface Muxer {
* <p>This is the maximum delay between samples of any track. They can be of the same or of * <p>This is the maximum delay between samples of any track. They can be of the same or of
* different track types. * different track types.
* *
* <p>This value is used to abort the transformation when the maximum delay is reached. Note that * <p>This value is used to abort the export when the maximum delay is reached. Note that there is
* there is no guarantee that the transformation will be aborted exactly at that time. * no guarantee that the export will be aborted exactly at that time.
*/ */
long getMaxDelayBetweenSamplesMs(); long getMaxDelayBetweenSamplesMs();
} }

View File

@ -61,19 +61,19 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
} }
/** /**
* Represents a reason for ending a transformation. May be one of {@link #END_REASON_COMPLETED}, * Represents a reason for ending an export. May be one of {@link #END_REASON_COMPLETED}, {@link
* {@link #END_REASON_CANCELLED} or {@link #END_REASON_ERROR}. * #END_REASON_CANCELLED} or {@link #END_REASON_ERROR}.
*/ */
@Documented @Documented
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@Target(TYPE_USE) @Target(TYPE_USE)
@IntDef({END_REASON_COMPLETED, END_REASON_CANCELLED, END_REASON_ERROR}) @IntDef({END_REASON_COMPLETED, END_REASON_CANCELLED, END_REASON_ERROR})
private @interface EndReason {} private @interface EndReason {}
/** The transformation completed successfully. */ /** The export completed successfully. */
private static final int END_REASON_COMPLETED = 0; private static final int END_REASON_COMPLETED = 0;
/** The transformation was cancelled. */ /** The export was cancelled. */
private static final int END_REASON_CANCELLED = 1; private static final int END_REASON_CANCELLED = 1;
/** An error occurred during the transformation. */ /** An error occurred during the export. */
private static final int END_REASON_ERROR = 2; private static final int END_REASON_ERROR = 2;
// Internal messages. // Internal messages.

View File

@ -131,7 +131,7 @@ public final class TransformerEndToEndTest {
} }
@Test @Test
public void startTransformation_videoOnlyPassthrough_completesSuccessfully() throws Exception { public void start_videoOnlyPassthrough_completesSuccessfully() throws Exception {
Transformer transformer = createTransformerBuilder(/* enableFallback= */ false).build(); Transformer transformer = createTransformerBuilder(/* enableFallback= */ false).build();
MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_VIDEO_ONLY); MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_VIDEO_ONLY);
@ -142,7 +142,7 @@ public final class TransformerEndToEndTest {
} }
@Test @Test
public void startTransformation_audioOnlyPassthrough_completesSuccessfully() throws Exception { public void start_audioOnlyPassthrough_completesSuccessfully() throws Exception {
Transformer transformer = createTransformerBuilder(/* enableFallback= */ false).build(); Transformer transformer = createTransformerBuilder(/* enableFallback= */ false).build();
MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_AUDIO_UNSUPPORTED_BY_ENCODER); MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_AUDIO_UNSUPPORTED_BY_ENCODER);
@ -154,7 +154,7 @@ public final class TransformerEndToEndTest {
} }
@Test @Test
public void startTransformation_audioOnlyTranscoding_completesSuccessfully() throws Exception { public void start_audioOnlyTranscoding_completesSuccessfully() throws Exception {
Transformer transformer = Transformer transformer =
createTransformerBuilder(/* enableFallback= */ false) createTransformerBuilder(/* enableFallback= */ false)
.setTransformationRequest( .setTransformationRequest(
@ -172,7 +172,7 @@ public final class TransformerEndToEndTest {
} }
@Test @Test
public void startTransformation_audioAndVideo_completesSuccessfully() throws Exception { public void start_audioAndVideo_completesSuccessfully() throws Exception {
Transformer transformer = createTransformerBuilder(/* enableFallback= */ false).build(); Transformer transformer = createTransformerBuilder(/* enableFallback= */ false).build();
MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_AUDIO_VIDEO); MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_AUDIO_VIDEO);
@ -183,7 +183,7 @@ public final class TransformerEndToEndTest {
} }
@Test @Test
public void startTransformation_audioAndVideo_withClippingStartAtKeyFrame_completesSuccessfully() public void start_audioAndVideo_withClippingStartAtKeyFrame_completesSuccessfully()
throws Exception { throws Exception {
Transformer transformer = createTransformerBuilder(/* enableFallback= */ false).build(); Transformer transformer = createTransformerBuilder(/* enableFallback= */ false).build();
MediaItem mediaItem = MediaItem mediaItem =
@ -207,7 +207,7 @@ public final class TransformerEndToEndTest {
} }
@Test @Test
public void startTransformation_withSubtitles_completesSuccessfully() throws Exception { public void start_withSubtitles_completesSuccessfully() throws Exception {
Transformer transformer = Transformer transformer =
createTransformerBuilder(/* enableFallback= */ false) createTransformerBuilder(/* enableFallback= */ false)
.setTransformationRequest( .setTransformationRequest(
@ -222,8 +222,7 @@ public final class TransformerEndToEndTest {
} }
@Test @Test
public void startTransformation_successiveTransformations_completesSuccessfully() public void start_successiveExports_completesSuccessfully() throws Exception {
throws Exception {
Transformer transformer = createTransformerBuilder(/* enableFallback= */ false).build(); Transformer transformer = createTransformerBuilder(/* enableFallback= */ false).build();
MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_AUDIO_VIDEO); MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_AUDIO_VIDEO);
@ -240,7 +239,7 @@ public final class TransformerEndToEndTest {
} }
@Test @Test
public void startTransformation_concurrentTransformations_throwsError() { public void start_concurrentExports_throwsError() {
Transformer transformer = createTransformerBuilder(/* enableFallback= */ false).build(); Transformer transformer = createTransformerBuilder(/* enableFallback= */ false).build();
MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_VIDEO_ONLY); MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_VIDEO_ONLY);
@ -250,7 +249,7 @@ public final class TransformerEndToEndTest {
} }
@Test @Test
public void startTransformation_removeAudio_completesSuccessfully() throws Exception { public void start_removeAudio_completesSuccessfully() throws Exception {
Transformer transformer = createTransformerBuilder(/* enableFallback= */ false).build(); Transformer transformer = createTransformerBuilder(/* enableFallback= */ false).build();
EditedMediaItem editedMediaItem = EditedMediaItem editedMediaItem =
new EditedMediaItem.Builder(MediaItem.fromUri(ASSET_URI_PREFIX + FILE_AUDIO_VIDEO)) new EditedMediaItem.Builder(MediaItem.fromUri(ASSET_URI_PREFIX + FILE_AUDIO_VIDEO))
@ -265,7 +264,7 @@ public final class TransformerEndToEndTest {
} }
@Test @Test
public void startTransformation_removeVideo_completesSuccessfully() throws Exception { public void start_removeVideo_completesSuccessfully() throws Exception {
Transformer transformer = createTransformerBuilder(/* enableFallback= */ false).build(); Transformer transformer = createTransformerBuilder(/* enableFallback= */ false).build();
EditedMediaItem editedMediaItem = EditedMediaItem editedMediaItem =
new EditedMediaItem.Builder(MediaItem.fromUri(ASSET_URI_PREFIX + FILE_AUDIO_VIDEO)) new EditedMediaItem.Builder(MediaItem.fromUri(ASSET_URI_PREFIX + FILE_AUDIO_VIDEO))
@ -280,7 +279,7 @@ public final class TransformerEndToEndTest {
} }
@Test @Test
public void startTransformation_silentAudioOnAudioOnly_isIgnored() throws Exception { public void start_silentAudioOnAudioOnly_isIgnored() throws Exception {
Transformer transformer = Transformer transformer =
createTransformerBuilder(/* enableFallback= */ false) createTransformerBuilder(/* enableFallback= */ false)
.experimentalSetGenerateSilentAudio(true) .experimentalSetGenerateSilentAudio(true)
@ -295,7 +294,7 @@ public final class TransformerEndToEndTest {
} }
@Test @Test
public void startTransformation_silentAudioOnAudioVideo_isIgnored() throws Exception { public void start_silentAudioOnAudioVideo_isIgnored() throws Exception {
Transformer transformer = Transformer transformer =
createTransformerBuilder(/* enableFallback= */ false) createTransformerBuilder(/* enableFallback= */ false)
.experimentalSetGenerateSilentAudio(true) .experimentalSetGenerateSilentAudio(true)
@ -309,7 +308,7 @@ public final class TransformerEndToEndTest {
} }
@Test @Test
public void startTransformation_silentAudioRemoveAudio_completesSuccessfully() throws Exception { public void start_silentAudioRemoveAudio_completesSuccessfully() throws Exception {
Transformer transformer = Transformer transformer =
createTransformerBuilder(/* enableFallback= */ false) createTransformerBuilder(/* enableFallback= */ false)
.experimentalSetGenerateSilentAudio(true) .experimentalSetGenerateSilentAudio(true)
@ -327,7 +326,7 @@ public final class TransformerEndToEndTest {
} }
@Test @Test
public void startTransformation_silentAudioRemoveVideo_isIgnored() throws Exception { public void start_silentAudioRemoveVideo_isIgnored() throws Exception {
Transformer transformer = Transformer transformer =
createTransformerBuilder(/* enableFallback= */ false) createTransformerBuilder(/* enableFallback= */ false)
.experimentalSetGenerateSilentAudio(true) .experimentalSetGenerateSilentAudio(true)
@ -344,7 +343,7 @@ public final class TransformerEndToEndTest {
} }
@Test @Test
public void startTransformation_silentAudioOnVideoOnly_completesSuccessfully() throws Exception { public void start_silentAudioOnVideoOnly_completesSuccessfully() throws Exception {
Transformer transformer = Transformer transformer =
createTransformerBuilder(/* enableFallback= */ false) createTransformerBuilder(/* enableFallback= */ false)
.experimentalSetGenerateSilentAudio(true) .experimentalSetGenerateSilentAudio(true)
@ -359,7 +358,7 @@ public final class TransformerEndToEndTest {
} }
@Test @Test
public void startTransformation_adjustSampleRate_completesSuccessfully() throws Exception { public void start_adjustSampleRate_completesSuccessfully() throws Exception {
SonicAudioProcessor sonicAudioProcessor = new SonicAudioProcessor(); SonicAudioProcessor sonicAudioProcessor = new SonicAudioProcessor();
sonicAudioProcessor.setOutputSampleRateHz(48000); sonicAudioProcessor.setOutputSampleRateHz(48000);
Transformer transformer = createTransformerBuilder(/* enableFallback= */ false).build(); Transformer transformer = createTransformerBuilder(/* enableFallback= */ false).build();
@ -377,8 +376,7 @@ public final class TransformerEndToEndTest {
} }
@Test @Test
public void startTransformation_concatenateMediaItemsWithSameFormat_completesSuccessfully() public void start_concatenateMediaItemsWithSameFormat_completesSuccessfully() throws Exception {
throws Exception {
Transformer transformer = Transformer transformer =
createTransformerBuilder(/* enableFallback= */ false).setTransmux(true).build(); createTransformerBuilder(/* enableFallback= */ false).setTransmux(true).build();
MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_AUDIO_VIDEO); MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_AUDIO_VIDEO);
@ -397,9 +395,8 @@ public final class TransformerEndToEndTest {
} }
@Test @Test
public void public void start_concatenateMediaItemsWithSameFormatAndEffects_completesSuccessfully()
startTransformation_concatenateMediaItemsWithSameFormatAndEffects_completesSuccessfully() throws Exception {
throws Exception {
Transformer transformer = createTransformerBuilder(/* enableFallback= */ false).build(); Transformer transformer = createTransformerBuilder(/* enableFallback= */ false).build();
MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_AUDIO_VIDEO); MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_AUDIO_VIDEO);
AudioProcessor audioProcessor = new SilenceSkippingAudioProcessor(); AudioProcessor audioProcessor = new SilenceSkippingAudioProcessor();
@ -425,7 +422,7 @@ public final class TransformerEndToEndTest {
} }
@Test @Test
public void startTransformation_singleMediaItemAndTransmux_ignoresTransmux() throws Exception { public void start_singleMediaItemAndTransmux_ignoresTransmux() throws Exception {
SonicAudioProcessor sonicAudioProcessor = new SonicAudioProcessor(); SonicAudioProcessor sonicAudioProcessor = new SonicAudioProcessor();
sonicAudioProcessor.setOutputSampleRateHz(48000); sonicAudioProcessor.setOutputSampleRateHz(48000);
Transformer transformer = Transformer transformer =
@ -444,8 +441,7 @@ public final class TransformerEndToEndTest {
} }
@Test @Test
public void startTransformation_multipleMediaItemsWithEffectsAndTransmux_ignoresTransmux() public void start_multipleMediaItemsWithEffectsAndTransmux_ignoresTransmux() throws Exception {
throws Exception {
Transformer transformer = Transformer transformer =
createTransformerBuilder(/* enableFallback= */ false).setTransmux(true).build(); createTransformerBuilder(/* enableFallback= */ false).setTransmux(true).build();
MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_AUDIO_VIDEO); MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_AUDIO_VIDEO);
@ -470,7 +466,7 @@ public final class TransformerEndToEndTest {
} }
@Test @Test
public void startTransformation_withMultipleListeners_callsEachOnCompletion() throws Exception { public void start_withMultipleListeners_callsEachOnCompletion() throws Exception {
Transformer.Listener mockListener1 = mock(Transformer.Listener.class); Transformer.Listener mockListener1 = mock(Transformer.Listener.class);
Transformer.Listener mockListener2 = mock(Transformer.Listener.class); Transformer.Listener mockListener2 = mock(Transformer.Listener.class);
Transformer.Listener mockListener3 = mock(Transformer.Listener.class); Transformer.Listener mockListener3 = mock(Transformer.Listener.class);
@ -492,7 +488,7 @@ public final class TransformerEndToEndTest {
} }
@Test @Test
public void startTransformation_withMultipleListeners_callsEachOnError() { public void start_withMultipleListeners_callsEachOnError() {
Transformer.Listener mockListener1 = mock(Transformer.Listener.class); Transformer.Listener mockListener1 = mock(Transformer.Listener.class);
Transformer.Listener mockListener2 = mock(Transformer.Listener.class); Transformer.Listener mockListener2 = mock(Transformer.Listener.class);
Transformer.Listener mockListener3 = mock(Transformer.Listener.class); Transformer.Listener mockListener3 = mock(Transformer.Listener.class);
@ -517,7 +513,7 @@ public final class TransformerEndToEndTest {
} }
@Test @Test
public void startTransformation_withMultipleListeners_callsEachOnFallback() throws Exception { public void start_withMultipleListeners_callsEachOnFallback() throws Exception {
Transformer.Listener mockListener1 = mock(Transformer.Listener.class); Transformer.Listener mockListener1 = mock(Transformer.Listener.class);
Transformer.Listener mockListener2 = mock(Transformer.Listener.class); Transformer.Listener mockListener2 = mock(Transformer.Listener.class);
Transformer.Listener mockListener3 = mock(Transformer.Listener.class); Transformer.Listener mockListener3 = mock(Transformer.Listener.class);
@ -551,7 +547,7 @@ public final class TransformerEndToEndTest {
} }
@Test @Test
public void startTransformation_success_callsDeprecatedCompletionCallbacks() throws Exception { public void start_success_callsDeprecatedCompletionCallbacks() throws Exception {
AtomicBoolean deprecatedFallbackCalled1 = new AtomicBoolean(); AtomicBoolean deprecatedFallbackCalled1 = new AtomicBoolean();
AtomicBoolean deprecatedFallbackCalled2 = new AtomicBoolean(); AtomicBoolean deprecatedFallbackCalled2 = new AtomicBoolean();
Transformer transformer = Transformer transformer =
@ -582,7 +578,7 @@ public final class TransformerEndToEndTest {
} }
@Test @Test
public void startTransformation_withError_callsDeprecatedErrorCallbacks() throws Exception { public void start_withError_callsDeprecatedErrorCallbacks() throws Exception {
AtomicBoolean deprecatedFallbackCalled1 = new AtomicBoolean(); AtomicBoolean deprecatedFallbackCalled1 = new AtomicBoolean();
AtomicBoolean deprecatedFallbackCalled2 = new AtomicBoolean(); AtomicBoolean deprecatedFallbackCalled2 = new AtomicBoolean();
AtomicBoolean deprecatedFallbackCalled3 = new AtomicBoolean(); AtomicBoolean deprecatedFallbackCalled3 = new AtomicBoolean();
@ -629,7 +625,7 @@ public final class TransformerEndToEndTest {
} }
@Test @Test
public void startTransformation_withFallback_callsDeprecatedFallbackCallbacks() throws Exception { public void start_withFallback_callsDeprecatedFallbackCallbacks() throws Exception {
AtomicBoolean deprecatedFallbackCalled = new AtomicBoolean(); AtomicBoolean deprecatedFallbackCalled = new AtomicBoolean();
Transformer transformer = Transformer transformer =
createTransformerBuilder(/* enableFallback= */ true) createTransformerBuilder(/* enableFallback= */ true)
@ -653,7 +649,7 @@ public final class TransformerEndToEndTest {
} }
@Test @Test
public void startTransformation_afterBuildUponWithListenerRemoved_onlyCallsRemainingListeners() public void start_afterBuildUponWithListenerRemoved_onlyCallsRemainingListeners()
throws Exception { throws Exception {
Transformer.Listener mockListener1 = mock(Transformer.Listener.class); Transformer.Listener mockListener1 = mock(Transformer.Listener.class);
Transformer.Listener mockListener2 = mock(Transformer.Listener.class); Transformer.Listener mockListener2 = mock(Transformer.Listener.class);
@ -676,7 +672,7 @@ public final class TransformerEndToEndTest {
} }
@Test @Test
public void startTransformation_flattenForSlowMotion_completesSuccessfully() throws Exception { public void start_flattenForSlowMotion_completesSuccessfully() throws Exception {
Transformer transformer = createTransformerBuilder(/* enableFallback= */ false).build(); Transformer transformer = createTransformerBuilder(/* enableFallback= */ false).build();
EditedMediaItem editedMediaItem = EditedMediaItem editedMediaItem =
new EditedMediaItem.Builder(MediaItem.fromUri(ASSET_URI_PREFIX + FILE_WITH_SEF_SLOW_MOTION)) new EditedMediaItem.Builder(MediaItem.fromUri(ASSET_URI_PREFIX + FILE_WITH_SEF_SLOW_MOTION))
@ -690,7 +686,7 @@ public final class TransformerEndToEndTest {
} }
@Test @Test
public void startTransformation_completesWithValidBitrate() throws Exception { public void start_completesWithValidBitrate() throws Exception {
Transformer transformer = createTransformerBuilder(/* enableFallback= */ false).build(); Transformer transformer = createTransformerBuilder(/* enableFallback= */ false).build();
MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_AUDIO_VIDEO); MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_AUDIO_VIDEO);
@ -702,7 +698,7 @@ public final class TransformerEndToEndTest {
} }
@Test @Test
public void startTransformation_withAudioEncoderFormatUnsupported_completesWithError() { public void start_withAudioEncoderFormatUnsupported_completesWithError() {
Transformer transformer = Transformer transformer =
createTransformerBuilder(/* enableFallback= */ false) createTransformerBuilder(/* enableFallback= */ false)
.setTransformationRequest( .setTransformationRequest(
@ -722,7 +718,7 @@ public final class TransformerEndToEndTest {
} }
@Test @Test
public void startTransformation_withAudioDecoderFormatUnsupported_completesWithError() { public void start_withAudioDecoderFormatUnsupported_completesWithError() {
Transformer transformer = Transformer transformer =
createTransformerBuilder(/* enableFallback= */ false) createTransformerBuilder(/* enableFallback= */ false)
.setTransformationRequest( .setTransformationRequest(
@ -741,7 +737,7 @@ public final class TransformerEndToEndTest {
} }
@Test @Test
public void startTransformation_withIoError_completesWithError() { public void start_withIoError_completesWithError() {
Transformer transformer = createTransformerBuilder(/* enableFallback= */ false).build(); Transformer transformer = createTransformerBuilder(/* enableFallback= */ false).build();
MediaItem mediaItem = MediaItem.fromUri("asset:///non-existing-path.mp4"); MediaItem mediaItem = MediaItem.fromUri("asset:///non-existing-path.mp4");
@ -753,8 +749,7 @@ public final class TransformerEndToEndTest {
} }
@Test @Test
public void startTransformation_withAudioMuxerFormatUnsupported_completesSuccessfully() public void start_withAudioMuxerFormatUnsupported_completesSuccessfully() throws Exception {
throws Exception {
// Test succeeds because MIME type fallback is mandatory. // Test succeeds because MIME type fallback is mandatory.
Transformer.Listener mockListener = mock(Transformer.Listener.class); Transformer.Listener mockListener = mock(Transformer.Listener.class);
TransformationRequest originalTransformationRequest = TransformationRequest originalTransformationRequest =
@ -778,8 +773,7 @@ public final class TransformerEndToEndTest {
} }
@Test @Test
public void startTransformation_withAudioMuxerFormatFallback_completesSuccessfully() public void start_withAudioMuxerFormatFallback_completesSuccessfully() throws Exception {
throws Exception {
Transformer.Listener mockListener = mock(Transformer.Listener.class); Transformer.Listener mockListener = mock(Transformer.Listener.class);
TransformationRequest originalTransformationRequest = TransformationRequest originalTransformationRequest =
new TransformationRequest.Builder().build(); new TransformationRequest.Builder().build();
@ -802,7 +796,7 @@ public final class TransformerEndToEndTest {
} }
@Test @Test
public void startTransformation_withSlowOutputSampleRate_completesWithError() { public void start_withSlowOutputSampleRate_completesWithError() {
MediaSource.Factory mediaSourceFactory = MediaSource.Factory mediaSourceFactory =
new DefaultMediaSourceFactory( new DefaultMediaSourceFactory(
context, new SlowExtractorsFactory(/* delayBetweenReadsMs= */ 10)); context, new SlowExtractorsFactory(/* delayBetweenReadsMs= */ 10));
@ -825,8 +819,7 @@ public final class TransformerEndToEndTest {
} }
@Test @Test
public void startTransformation_withUnsetMaxDelayBetweenSamples_completesSuccessfully() public void start_withUnsetMaxDelayBetweenSamples_completesSuccessfully() throws Exception {
throws Exception {
Muxer.Factory muxerFactory = new TestMuxerFactory(/* maxDelayBetweenSamplesMs= */ C.TIME_UNSET); Muxer.Factory muxerFactory = new TestMuxerFactory(/* maxDelayBetweenSamplesMs= */ C.TIME_UNSET);
Transformer transformer = Transformer transformer =
createTransformerBuilder(/* enableFallback= */ false).setMuxerFactory(muxerFactory).build(); createTransformerBuilder(/* enableFallback= */ false).setMuxerFactory(muxerFactory).build();
@ -839,7 +832,7 @@ public final class TransformerEndToEndTest {
} }
@Test @Test
public void startTransformation_afterCancellation_completesSuccessfully() throws Exception { public void start_afterCancellation_completesSuccessfully() throws Exception {
Transformer transformer = createTransformerBuilder(/* enableFallback= */ false).build(); Transformer transformer = createTransformerBuilder(/* enableFallback= */ false).build();
MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_AUDIO_VIDEO); MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_AUDIO_VIDEO);
@ -847,16 +840,16 @@ public final class TransformerEndToEndTest {
transformer.cancel(); transformer.cancel();
Files.delete(Paths.get(outputPath)); Files.delete(Paths.get(outputPath));
// This would throw if the previous transformation had not been cancelled. // This would throw if the previous export had not been cancelled.
transformer.start(mediaItem, outputPath); transformer.start(mediaItem, outputPath);
ExportResult exportResult = TransformerTestRunner.runLooper(transformer); ExportResult exportResult = TransformerTestRunner.runLooper(transformer);
// TODO(b/264974805): Make transformation output deterministic and check it against dump file. // TODO(b/264974805): Make export output deterministic and check it against dump file.
assertThat(exportResult.exportException).isNull(); assertThat(exportResult.exportException).isNull();
} }
@Test @Test
public void startTransformation_fromSpecifiedThread_completesSuccessfully() throws Exception { public void start_fromSpecifiedThread_completesSuccessfully() throws Exception {
HandlerThread anotherThread = new HandlerThread("AnotherThread"); HandlerThread anotherThread = new HandlerThread("AnotherThread");
anotherThread.start(); anotherThread.start();
Looper looper = anotherThread.getLooper(); Looper looper = anotherThread.getLooper();
@ -885,7 +878,7 @@ public final class TransformerEndToEndTest {
} }
@Test @Test
public void startTransformation_fromWrongThread_throwsError() throws Exception { public void start_fromWrongThread_throwsError() throws Exception {
Transformer transformer = createTransformerBuilder(/* enableFallback= */ false).build(); Transformer transformer = createTransformerBuilder(/* enableFallback= */ false).build();
MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_AUDIO_VIDEO); MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_AUDIO_VIDEO);
HandlerThread anotherThread = new HandlerThread("AnotherThread"); HandlerThread anotherThread = new HandlerThread("AnotherThread");
@ -910,8 +903,7 @@ public final class TransformerEndToEndTest {
} }
@Test @Test
public void startTransformation_withAssetLoaderAlwaysDecoding_pipelineExpectsDecoded() public void start_withAssetLoaderAlwaysDecoding_pipelineExpectsDecoded() throws Exception {
throws Exception {
AtomicReference<SampleConsumer> sampleConsumerRef = new AtomicReference<>(); AtomicReference<SampleConsumer> sampleConsumerRef = new AtomicReference<>();
Transformer transformer = Transformer transformer =
createTransformerBuilder(/* enableFallback= */ false) createTransformerBuilder(/* enableFallback= */ false)
@ -927,7 +919,7 @@ public final class TransformerEndToEndTest {
} }
@Test @Test
public void startTransformation_withAssetLoaderNotDecodingAndDecodingNeeded_completesWithError() { public void start_withAssetLoaderNotDecodingAndDecodingNeeded_completesWithError() {
Transformer transformer = Transformer transformer =
createTransformerBuilder(/* enableFallback= */ false) createTransformerBuilder(/* enableFallback= */ false)
.setAssetLoaderFactory( .setAssetLoaderFactory(
@ -948,7 +940,7 @@ public final class TransformerEndToEndTest {
} }
@Test @Test
public void startTransformation_withNoOpEffects_transmuxes() throws Exception { public void start_withNoOpEffects_transmuxes() throws Exception {
Transformer transformer = createTransformerBuilder(/* enableFallback= */ false).build(); Transformer transformer = createTransformerBuilder(/* enableFallback= */ false).build();
MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_VIDEO_ONLY); MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_VIDEO_ONLY);
int mediaItemHeightPixels = 720; int mediaItemHeightPixels = 720;
@ -1041,15 +1033,14 @@ public final class TransformerEndToEndTest {
assertThat(progresses).isInOrder(); assertThat(progresses).isInOrder();
if (!progresses.isEmpty()) { if (!progresses.isEmpty()) {
// The progress list could be empty if the transformation ends before any progress can be // The progress list could be empty if the export ends before any progress can be retrieved.
// retrieved.
assertThat(progresses.get(0)).isAtLeast(0); assertThat(progresses.get(0)).isAtLeast(0);
assertThat(Iterables.getLast(progresses)).isLessThan(100); assertThat(Iterables.getLast(progresses)).isLessThan(100);
} }
} }
@Test @Test
public void getProgress_noCurrentTransformation_returnsNoTransformation() throws Exception { public void getProgress_noCurrentExport_returnsNotStarted() throws Exception {
Transformer transformer = createTransformerBuilder(/* enableFallback= */ false).build(); Transformer transformer = createTransformerBuilder(/* enableFallback= */ false).build();
MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_VIDEO_ONLY); MediaItem mediaItem = MediaItem.fromUri(ASSET_URI_PREFIX + FILE_VIDEO_ONLY);

View File

@ -36,7 +36,7 @@ public final class TransformerTestRunner {
* *
* @param transformer The {@link Transformer}. * @param transformer The {@link Transformer}.
* @return The {@link ExportResult}. * @return The {@link ExportResult}.
* @throws ExportException If the transformation threw an exception. * @throws ExportException If the export threw an exception.
* @throws TimeoutException If the {@link RobolectricUtil#DEFAULT_TIMEOUT_MS default timeout} is * @throws TimeoutException If the {@link RobolectricUtil#DEFAULT_TIMEOUT_MS default timeout} is
* exceeded. * exceeded.
* @throws IllegalStateException If the method is not called from the main thread. * @throws IllegalStateException If the method is not called from the main thread.