Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
cdc0e2e6
authored
Dec 14, 2021
by
hschlueter
Committed by
tonihei
Jan 05, 2022
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Use TransformationException for error listener parameter.
PiperOrigin-RevId: 416307600
parent
039b9154
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
15 deletions
libraries/transformer/src/androidTest/java/androidx/media3/transformer/mh/AndroidTestUtil.java
libraries/transformer/src/main/java/androidx/media3/transformer/Transformer.java
libraries/transformer/src/test/java/androidx/media3/transformer/TransformerTest.java
libraries/transformer/src/test/java/androidx/media3/transformer/TransformerTestRunner.java
libraries/transformer/src/androidTest/java/androidx/media3/transformer/mh/AndroidTestUtil.java
View file @
cdc0e2e6
...
...
@@ -24,6 +24,7 @@ import android.net.Uri;
import
android.os.Build
;
import
androidx.annotation.Nullable
;
import
androidx.media3.common.MediaItem
;
import
androidx.media3.transformer.TransformationException
;
import
androidx.media3.transformer.Transformer
;
import
androidx.test.platform.app.InstrumentationRegistry
;
import
java.io.File
;
...
...
@@ -79,7 +80,8 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
}
@Override
public
void
onTransformationError
(
MediaItem
inputMediaItem
,
Exception
exception
)
{
public
void
onTransformationError
(
MediaItem
inputMediaItem
,
TransformationException
exception
)
{
exceptionReference
.
set
(
exception
);
countDownLatch
.
countDown
();
}
...
...
libraries/transformer/src/main/java/androidx/media3/transformer/Transformer.java
View file @
cdc0e2e6
...
...
@@ -468,19 +468,26 @@ public final class Transformer {
public
interface
Listener
{
/**
* Called when the transformation is completed.
* Called when the transformation is completed
successfully
.
*
* @param inputMediaItem The {@link MediaItem} for which the transformation is completed.
*/
default
void
onTransformationCompleted
(
MediaItem
inputMediaItem
)
{}
/** @deprecated Use {@link #onTransformationError(MediaItem, TransformationException)}. */
@Deprecated
default
void
onTransformationError
(
MediaItem
inputMediaItem
,
Exception
exception
)
{
onTransformationError
(
inputMediaItem
,
(
TransformationException
)
exception
);
}
/**
* Called if an e
rror
occurs during the transformation.
* Called if an e
xception
occurs during the transformation.
*
* @param inputMediaItem The {@link MediaItem} for which the e
rror
occurs.
* @param exception The
exception describing the error
.
* @param inputMediaItem The {@link MediaItem} for which the e
xception
occurs.
* @param exception The
{@link TransformationException} describing the exception
.
*/
default
void
onTransformationError
(
MediaItem
inputMediaItem
,
Exception
exception
)
{}
default
void
onTransformationError
(
MediaItem
inputMediaItem
,
TransformationException
exception
)
{}
}
/** Provider for views to show diagnostic information during transformation, for debugging. */
...
...
libraries/transformer/src/test/java/androidx/media3/transformer/TransformerTest.java
View file @
cdc0e2e6
...
...
@@ -238,9 +238,8 @@ public final class TransformerTest {
MediaItem
mediaItem
=
MediaItem
.
fromUri
(
"asset:///non-existing-path.mp4"
);
transformer
.
startTransformation
(
mediaItem
,
outputPath
);
Exception
exception
=
TransformerTestRunner
.
runUntilError
(
transformer
);
Transformation
Exception
exception
=
TransformerTestRunner
.
runUntilError
(
transformer
);
assertThat
(
exception
).
isInstanceOf
(
TransformationException
.
class
);
assertThat
(
exception
).
hasCauseThat
().
isInstanceOf
(
ExoPlaybackException
.
class
);
assertThat
(
exception
).
hasCauseThat
().
hasCauseThat
().
isInstanceOf
(
IOException
.
class
);
}
...
...
@@ -252,9 +251,8 @@ public final class TransformerTest {
MediaItem
mediaItem
=
MediaItem
.
fromUri
(
URI_PREFIX
+
FILE_WITH_ALL_SAMPLE_FORMATS_UNSUPPORTED
);
transformer
.
startTransformation
(
mediaItem
,
outputPath
);
Exception
exception
=
TransformerTestRunner
.
runUntilError
(
transformer
);
Transformation
Exception
exception
=
TransformerTestRunner
.
runUntilError
(
transformer
);
assertThat
(
exception
).
isInstanceOf
(
TransformationException
.
class
);
assertThat
(
exception
).
hasCauseThat
().
isInstanceOf
(
IllegalStateException
.
class
);
}
...
...
libraries/transformer/src/test/java/androidx/media3/transformer/TransformerTestRunner.java
View file @
cdc0e2e6
...
...
@@ -56,8 +56,9 @@ public final class TransformerTestRunner {
* @throws IllegalStateException If the method is not called from the main thread, or if the
* transformation completes without error.
*/
public
static
Exception
runUntilError
(
Transformer
transformer
)
throws
TimeoutException
{
@Nullable
Exception
exception
=
runUntilListenerCalled
(
transformer
);
public
static
TransformationException
runUntilError
(
Transformer
transformer
)
throws
TimeoutException
{
@Nullable
TransformationException
exception
=
runUntilListenerCalled
(
transformer
);
if
(
exception
==
null
)
{
throw
new
IllegalStateException
(
"The transformation completed without error."
);
}
...
...
@@ -65,7 +66,8 @@ public final class TransformerTestRunner {
}
@Nullable
private
static
Exception
runUntilListenerCalled
(
Transformer
transformer
)
throws
TimeoutException
{
private
static
TransformationException
runUntilListenerCalled
(
Transformer
transformer
)
throws
TimeoutException
{
TransformationResult
transformationResult
=
new
TransformationResult
();
Transformer
.
Listener
listener
=
new
Transformer
.
Listener
()
{
...
...
@@ -75,7 +77,8 @@ public final class TransformerTestRunner {
}
@Override
public
void
onTransformationError
(
MediaItem
inputMediaItem
,
Exception
exception
)
{
public
void
onTransformationError
(
MediaItem
inputMediaItem
,
TransformationException
exception
)
{
transformationResult
.
exception
=
exception
;
}
};
...
...
@@ -88,6 +91,6 @@ public final class TransformerTestRunner {
private
static
class
TransformationResult
{
public
boolean
isCompleted
;
@Nullable
public
Exception
exception
;
@Nullable
public
Transformation
Exception
exception
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment