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
90de454e
authored
Feb 03, 2023
by
kimvde
Committed by
microkatz
Feb 08, 2023
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Adapt TransformationResult for multi-asset
PiperOrigin-RevId: 506898392
parent
937fcf9c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
113 additions
and
42 deletions
library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/AndroidTestUtil.java
library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/TransformationTestResult.java
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/CompositeAssetLoader.java
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/TransformationResult.java
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/TransformerInternal.java
library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/AndroidTestUtil.java
View file @
90de454e
...
...
@@ -26,6 +26,7 @@ import android.os.Build;
import
androidx.annotation.Nullable
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.Format
;
import
com.google.android.exoplayer2.MediaItem
;
import
com.google.android.exoplayer2.mediacodec.MediaCodecInfo
;
import
com.google.android.exoplayer2.mediacodec.MediaCodecUtil
;
import
com.google.android.exoplayer2.util.Log
;
...
...
@@ -36,6 +37,7 @@ import com.google.common.collect.ImmutableList;
import
java.io.File
;
import
java.io.FileWriter
;
import
java.io.IOException
;
import
org.json.JSONArray
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
...
...
@@ -502,6 +504,31 @@ public final class AndroidTestUtil {
}
/**
* Creates a {@link JSONArray} from {@link TransformationResult.ProcessedInput processed inputs}.
*
* @param processedInputs The list of {@link TransformationResult.ProcessedInput} instances.
* @return A {@link JSONArray} containing {@link JSONObject} instances representing the {@link
* TransformationResult.ProcessedInput} instances.
*/
public
static
JSONArray
processedInputsAsJsonArray
(
ImmutableList
<
TransformationResult
.
ProcessedInput
>
processedInputs
)
throws
JSONException
{
JSONArray
jsonArray
=
new
JSONArray
();
for
(
int
i
=
0
;
i
<
processedInputs
.
size
();
i
++)
{
TransformationResult
.
ProcessedInput
processedInput
=
processedInputs
.
get
(
i
);
JSONObject
jsonObject
=
new
JSONObject
();
@Nullable
MediaItem
.
LocalConfiguration
localConfiguration
=
processedInput
.
mediaItem
.
localConfiguration
;
if
(
localConfiguration
!=
null
)
{
jsonObject
.
put
(
"mediaItemUri"
,
localConfiguration
.
uri
);
}
jsonObject
.
putOpt
(
"audioDecoderName"
,
processedInput
.
audioDecoderName
);
jsonObject
.
putOpt
(
"videoDecoderName"
,
processedInput
.
videoDecoderName
);
jsonArray
.
put
(
jsonObject
);
}
return
jsonArray
;
}
/**
* Creates a {@link JSONObject} from the {@link Exception}.
*
* <p>If the exception is a {@link TransformationException}, {@code errorCode} is included.
...
...
library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/TransformationTestResult.java
View file @
90de454e
...
...
@@ -16,6 +16,7 @@
package
com
.
google
.
android
.
exoplayer2
.
transformer
;
import
static
com
.
google
.
android
.
exoplayer2
.
transformer
.
AndroidTestUtil
.
exceptionAsJsonObject
;
import
static
com
.
google
.
android
.
exoplayer2
.
transformer
.
AndroidTestUtil
.
processedInputsAsJsonArray
;
import
androidx.annotation.Nullable
;
import
com.google.android.exoplayer2.C
;
...
...
@@ -156,19 +157,22 @@ public class TransformationTestResult {
public
JSONObject
asJsonObject
()
throws
JSONException
{
JSONObject
jsonObject
=
new
JSONObject
()
.
putOpt
(
"audioDecoderName"
,
transformationResult
.
audioDecoderName
)
.
putOpt
(
"audioEncoderName"
,
transformationResult
.
audioEncoderName
)
.
putOpt
(
"fallbackDetails"
,
fallbackDetails
!=
null
?
fallbackDetails
.
asJsonObject
()
:
null
)
.
putOpt
(
"filePath"
,
filePath
)
.
putOpt
(
"colorInfo"
,
transformationResult
.
colorInfo
)
.
putOpt
(
"videoDecoderName"
,
transformationResult
.
videoDecoderName
)
.
putOpt
(
"videoEncoderName"
,
transformationResult
.
videoEncoderName
)
.
putOpt
(
"testException"
,
exceptionAsJsonObject
(
transformationResult
.
transformationException
))
.
putOpt
(
"analysisException"
,
exceptionAsJsonObject
(
analysisException
));
if
(!
transformationResult
.
processedInputs
.
isEmpty
())
{
jsonObject
.
put
(
"processedInputs"
,
processedInputsAsJsonArray
(
transformationResult
.
processedInputs
));
}
if
(
transformationResult
.
averageAudioBitrate
!=
C
.
RATE_UNSET_INT
)
{
jsonObject
.
put
(
"averageAudioBitrate"
,
transformationResult
.
averageAudioBitrate
);
}
...
...
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/CompositeAssetLoader.java
View file @
90de454e
...
...
@@ -32,6 +32,7 @@ import com.google.android.exoplayer2.util.Clock;
import
com.google.android.exoplayer2.util.HandlerWrapper
;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
com.google.android.exoplayer2.video.ColorInfo
;
import
com.google.common.collect.ImmutableList
;
import
com.google.common.collect.ImmutableMap
;
import
java.util.HashMap
;
import
java.util.List
;
...
...
@@ -52,10 +53,12 @@ import java.util.concurrent.atomic.AtomicLong;
private
final
Listener
compositeAssetLoaderListener
;
private
final
Map
<
Integer
,
SampleConsumer
>
sampleConsumersByTrackType
;
private
final
Map
<
Integer
,
OnMediaItemChangedListener
>
mediaItemChangedListenersByTrackType
;
private
final
ImmutableList
.
Builder
<
TransformationResult
.
ProcessedInput
>
processedInputsBuilder
;
private
final
AtomicLong
totalDurationUs
;
private
final
AtomicInteger
nonEndedTracks
;
private
AssetLoader
currentAssetLoader
;
private
int
processedInputsSize
;
private
volatile
long
currentDurationUs
;
...
...
@@ -72,6 +75,7 @@ import java.util.concurrent.atomic.AtomicLong;
handler
=
clock
.
createHandler
(
looper
,
/* callback= */
null
);
sampleConsumersByTrackType
=
new
HashMap
<>();
mediaItemChangedListenersByTrackType
=
new
HashMap
<>();
processedInputsBuilder
=
new
ImmutableList
.
Builder
<>();
totalDurationUs
=
new
AtomicLong
();
nonEndedTracks
=
new
AtomicInteger
();
// It's safe to use "this" because we don't start the AssetLoader before exiting the
...
...
@@ -105,10 +109,18 @@ import java.util.concurrent.atomic.AtomicLong;
@Override
public
ImmutableMap
<
Integer
,
String
>
getDecoderNames
()
{
// TODO(b/252537210): update TransformationResult to contain all the decoders used.
return
currentAssetLoader
.
getDecoderNames
();
}
/**
* Returns the partially or entirely {@linkplain TransformationResult.ProcessedInput processed
* inputs}.
*/
public
ImmutableList
<
TransformationResult
.
ProcessedInput
>
getProcessedInputs
()
{
addCurrentProcessedInput
();
return
processedInputsBuilder
.
build
();
}
@Override
public
void
release
()
{
currentAssetLoader
.
release
();
...
...
@@ -193,6 +205,18 @@ import java.util.concurrent.atomic.AtomicLong;
compositeAssetLoaderListener
.
onError
(
exception
);
}
private
void
addCurrentProcessedInput
()
{
int
currentMediaItemIndex
=
this
.
currentMediaItemIndex
.
get
();
if
(
currentMediaItemIndex
>=
processedInputsSize
)
{
MediaItem
mediaItem
=
editedMediaItems
.
get
(
currentMediaItemIndex
).
mediaItem
;
ImmutableMap
<
Integer
,
String
>
decoders
=
currentAssetLoader
.
getDecoderNames
();
processedInputsBuilder
.
add
(
new
TransformationResult
.
ProcessedInput
(
mediaItem
,
decoders
.
get
(
C
.
TRACK_TYPE_AUDIO
),
decoders
.
get
(
C
.
TRACK_TYPE_VIDEO
)));
processedInputsSize
++;
}
}
private
final
class
SampleConsumerWrapper
implements
SampleConsumer
{
private
final
SampleConsumer
sampleConsumer
;
...
...
@@ -270,6 +294,7 @@ import java.util.concurrent.atomic.AtomicLong;
totalDurationUs
.
addAndGet
(
currentDurationUs
);
handler
.
post
(
()
->
{
addCurrentProcessedInput
();
currentAssetLoader
.
release
();
EditedMediaItem
editedMediaItem
=
editedMediaItems
.
get
(
currentMediaItemIndex
.
incrementAndGet
());
...
...
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/TransformationResult.java
View file @
90de454e
This diff is collapsed.
Click to expand it.
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/TransformerInternal.java
View file @
90de454e
...
...
@@ -43,7 +43,7 @@ import com.google.android.exoplayer2.util.Effect;
import
com.google.android.exoplayer2.util.HandlerWrapper
;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
com.google.android.exoplayer2.util.Size
;
import
com.google.common.collect.Immutable
Map
;
import
com.google.common.collect.Immutable
List
;
import
java.lang.annotation.Documented
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
...
...
@@ -243,10 +243,10 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
private
void
endInternal
(
@EndReason
int
endReason
,
@Nullable
TransformationException
transformationException
)
{
ImmutableMap
<
Integer
,
String
>
decoderNames
=
compositeAssetLoader
.
getDecoderNames
();
ImmutableList
<
TransformationResult
.
ProcessedInput
>
processedInputs
=
compositeAssetLoader
.
getProcessedInputs
();
transformationResultBuilder
.
setAudioDecoderName
(
decoderNames
.
get
(
C
.
TRACK_TYPE_AUDIO
))
.
setVideoDecoderName
(
decoderNames
.
get
(
C
.
TRACK_TYPE_VIDEO
))
.
setProcessedInputs
(
processedInputs
)
.
setAudioEncoderName
(
encoderFactory
.
getAudioEncoderName
())
.
setVideoEncoderName
(
encoderFactory
.
getVideoEncoderName
());
...
...
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