Skip to content

Commit bc3aef0

Browse files
SheenaChhabramicrokatz
authored andcommitted
Change UnsupportedEncodingException to IllegalArgumentException
In startTransformation method we were throwing UnsupportedEncodingException (IOException) when mediaItem with unsupported arguments is passed. Changed this to IllegalArgumentException which seems more logical here. PiperOrigin-RevId: 487259296 (cherry picked from commit 818bf4a)
1 parent 707c2d8 commit bc3aef0

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

libraries/transformer/src/main/java/androidx/media3/transformer/Transformer.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@
5050
import com.google.common.collect.ImmutableList;
5151
import com.google.errorprone.annotations.CanIgnoreReturnValue;
5252
import java.io.File;
53-
import java.io.IOException;
54-
import java.io.UnsupportedEncodingException;
5553
import java.lang.annotation.Documented;
5654
import java.lang.annotation.Retention;
5755
import java.lang.annotation.RetentionPolicy;
@@ -671,17 +669,11 @@ public void removeAllListeners() {
671669
* @param mediaItem The {@link MediaItem} to transform.
672670
* @param path The path to the output file.
673671
* @throws IllegalArgumentException If the path is invalid.
672+
* @throws IllegalArgumentException If the {@link MediaItem} is not supported.
674673
* @throws IllegalStateException If this method is called from the wrong thread.
675674
* @throws IllegalStateException If a transformation is already in progress.
676-
* @throws IOException If {@link MediaItem} is not supported.
677675
*/
678-
public void startTransformation(MediaItem mediaItem, String path) throws IOException {
679-
if (!mediaItem.clippingConfiguration.equals(MediaItem.ClippingConfiguration.UNSET)
680-
&& transformationRequest.flattenForSlowMotion) {
681-
// TODO(b/233986762): Support clipping with SEF flattening.
682-
throw new UnsupportedEncodingException(
683-
"Clipping is not supported when slow motion flattening is requested");
684-
}
676+
public void startTransformation(MediaItem mediaItem, String path) {
685677
this.outputPath = path;
686678
this.outputParcelFileDescriptor = null;
687679
startTransformationInternal(mediaItem);
@@ -705,6 +697,7 @@ public void startTransformation(MediaItem mediaItem, String path) throws IOExcep
705697
* transformation is completed. It is the responsibility of the caller to close the
706698
* ParcelFileDescriptor. This can be done after this method returns.
707699
* @throws IllegalArgumentException If the file descriptor is invalid.
700+
* @throws IllegalArgumentException If the {@link MediaItem} is not supported.
708701
* @throws IllegalStateException If this method is called from the wrong thread.
709702
* @throws IllegalStateException If a transformation is already in progress.
710703
*/
@@ -716,6 +709,12 @@ public void startTransformation(MediaItem mediaItem, ParcelFileDescriptor parcel
716709
}
717710

718711
private void startTransformationInternal(MediaItem mediaItem) {
712+
if (!mediaItem.clippingConfiguration.equals(MediaItem.ClippingConfiguration.UNSET)
713+
&& transformationRequest.flattenForSlowMotion) {
714+
// TODO(b/233986762): Support clipping with SEF flattening.
715+
throw new IllegalArgumentException(
716+
"Clipping is not supported when slow motion flattening is requested");
717+
}
719718
verifyApplicationThread();
720719
if (transformationInProgress) {
721720
throw new IllegalStateException("There is already a transformation in progress.");

libraries/transformer/src/test/java/androidx/media3/transformer/TransformerEndToEndTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,8 +581,6 @@ public void startTransformation_fromWrongThread_throwsError() throws Exception {
581581
() -> {
582582
try {
583583
transformer.startTransformation(mediaItem, outputPath);
584-
} catch (IOException e) {
585-
// Do nothing.
586584
} catch (IllegalStateException e) {
587585
illegalStateException.set(e);
588586
} finally {

0 commit comments

Comments
 (0)