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
d18c572d
authored
Jan 12, 2022
by
samrobinson
Committed by
Ian Baker
Jan 14, 2022
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add a Builder for TransformationResult.
PiperOrigin-RevId: 421278099
parent
f8d84eec
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
26 deletions
library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/mh/AndroidTestUtil.java
library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/mh/RepeatedTranscodeTransformationTest.java
library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/mh/AndroidTestUtil.java
View file @
d18c572d
...
@@ -43,12 +43,45 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
...
@@ -43,12 +43,45 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
/** Information about the result of successfully running a transformer. */
/** Information about the result of successfully running a transformer. */
public
static
final
class
TransformationResult
{
public
static
final
class
TransformationResult
{
/** A builder for {@link TransformationResult} instances. */
public
static
final
class
Builder
{
private
final
String
testId
;
@Nullable
private
Long
fileSizeBytes
;
public
Builder
(
String
testId
)
{
this
.
testId
=
testId
;
}
public
Builder
setFileSizeBytes
(
long
fileSizeBytes
)
{
this
.
fileSizeBytes
=
fileSizeBytes
;
return
this
;
}
public
TransformationResult
build
()
{
return
new
TransformationResult
(
testId
,
fileSizeBytes
);
}
}
public
final
String
testId
;
public
final
String
testId
;
public
final
long
output
SizeBytes
;
@Nullable
public
final
Long
file
SizeBytes
;
private
TransformationResult
(
String
testId
,
long
output
SizeBytes
)
{
private
TransformationResult
(
String
testId
,
@Nullable
Long
file
SizeBytes
)
{
this
.
testId
=
testId
;
this
.
testId
=
testId
;
this
.
outputSizeBytes
=
outputSizeBytes
;
this
.
fileSizeBytes
=
fileSizeBytes
;
}
/**
* Returns all the analysis data from the test.
*
* <p>If a value was not generated, it will not be part of the return value.
*/
public
String
getFormattedAnalysis
()
{
String
analysis
=
"test="
+
testId
;
if
(
fileSizeBytes
!=
null
)
{
analysis
+=
", fileSizeBytes="
+
fileSizeBytes
;
}
return
analysis
;
}
}
}
}
...
@@ -108,9 +141,10 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
...
@@ -108,9 +141,10 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
if
(
exception
!=
null
)
{
if
(
exception
!=
null
)
{
throw
exception
;
throw
exception
;
}
}
long
outputSizeBytes
=
outputVideoFile
.
length
();
TransformationResult
result
=
new
TransformationResult
(
testId
,
outputSizeBytes
);
TransformationResult
result
=
new
TransformationResult
.
Builder
(
testId
).
setFileSizeBytes
(
outputVideoFile
.
length
()).
build
();
writeTransformationResultToFile
(
context
,
result
);
writeTransformationResultToFile
(
context
,
result
);
return
result
;
return
result
;
}
}
...
@@ -121,16 +155,15 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
...
@@ -121,16 +155,15 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
createExternalCacheFile
(
context
,
/* fileName= */
result
.
testId
+
"-result.txt"
);
createExternalCacheFile
(
context
,
/* fileName= */
result
.
testId
+
"-result.txt"
);
try
(
FileWriter
fileWriter
=
new
FileWriter
(
analysisFile
))
{
try
(
FileWriter
fileWriter
=
new
FileWriter
(
analysisFile
))
{
String
fileContents
=
String
fileContents
=
"test="
result
.
getFormattedAnalysis
()
+
result
.
testId
+
", deviceFingerprint="
+
Build
.
FINGERPRINT
+
", deviceBrand="
+
", deviceBrand="
+
Build
.
MANUFACTURER
+
Build
.
MANUFACTURER
+
", deviceModel="
+
", deviceModel="
+
Build
.
MODEL
+
Build
.
MODEL
+
", sdkVersion="
+
", sdkVersion="
+
Build
.
VERSION
.
SDK_INT
+
Build
.
VERSION
.
SDK_INT
;
+
", outputSizeBytes="
+
result
.
outputSizeBytes
;
fileWriter
.
write
(
fileContents
);
fileWriter
.
write
(
fileContents
);
}
}
}
}
...
...
library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/mh/RepeatedTranscodeTransformationTest.java
View file @
d18c572d
...
@@ -24,16 +24,16 @@ import androidx.test.core.app.ApplicationProvider;
...
@@ -24,16 +24,16 @@ import androidx.test.core.app.ApplicationProvider;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
com.google.android.exoplayer2.transformer.TransformationRequest
;
import
com.google.android.exoplayer2.transformer.TransformationRequest
;
import
com.google.android.exoplayer2.transformer.Transformer
;
import
com.google.android.exoplayer2.transformer.Transformer
;
import
com.google.android.exoplayer2.util.Assertions
;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
java.util.HashSet
;
import
java.util.HashSet
;
import
java.util.Set
;
import
java.util.Set
;
import
org.junit.Ignore
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.junit.runner.RunWith
;
/** Tests repeated transcoding operations (as a stress test and to help reproduce flakiness). */
/** Tests repeated transcoding operations (as a stress test and to help reproduce flakiness). */
@RunWith
(
AndroidJUnit4
.
class
)
@RunWith
(
AndroidJUnit4
.
class
)
@Ignore
(
"Internal - b/206917996"
)
//
@Ignore("Internal - b/206917996")
public
final
class
RepeatedTranscodeTransformationTest
{
public
final
class
RepeatedTranscodeTransformationTest
{
private
static
final
int
TRANSCODE_COUNT
=
10
;
private
static
final
int
TRANSCODE_COUNT
=
10
;
...
@@ -55,14 +55,14 @@ public final class RepeatedTranscodeTransformationTest {
...
@@ -55,14 +55,14 @@ public final class RepeatedTranscodeTransformationTest {
Set
<
Long
>
differentOutputSizesBytes
=
new
HashSet
<>();
Set
<
Long
>
differentOutputSizesBytes
=
new
HashSet
<>();
for
(
int
i
=
0
;
i
<
TRANSCODE_COUNT
;
i
++)
{
for
(
int
i
=
0
;
i
<
TRANSCODE_COUNT
;
i
++)
{
// Use a long video in case an error occurs a while after the start of the video.
// Use a long video in case an error occurs a while after the start of the video.
differentOutputSizesBytes
.
add
(
AndroidTestUtil
.
TransformationResult
result
=
runTransformer
(
runTransformer
(
context
,
context
,
/* testId= */
"repeatedTranscode_givesConsistentLengthOutput"
,
/* testId= */
"repeatedTranscode_givesConsistentLengthOutput_"
+
i
,
transformer
,
transformer
,
AndroidTestUtil
.
REMOTE_MP4_10_SECONDS_URI_STRING
,
AndroidTestUtil
.
REMOTE_MP4_10_SECONDS_URI_STRING
,
/* timeoutSeconds= */
120
)
/* timeoutSeconds= */
120
);
.
outputSizeBytes
);
differentOutputSizesBytes
.
add
(
Assertions
.
checkNotNull
(
result
.
fileSizeBytes
)
);
}
}
assertWithMessage
(
assertWithMessage
(
...
@@ -89,14 +89,14 @@ public final class RepeatedTranscodeTransformationTest {
...
@@ -89,14 +89,14 @@ public final class RepeatedTranscodeTransformationTest {
Set
<
Long
>
differentOutputSizesBytes
=
new
HashSet
<>();
Set
<
Long
>
differentOutputSizesBytes
=
new
HashSet
<>();
for
(
int
i
=
0
;
i
<
TRANSCODE_COUNT
;
i
++)
{
for
(
int
i
=
0
;
i
<
TRANSCODE_COUNT
;
i
++)
{
// Use a long video in case an error occurs a while after the start of the video.
// Use a long video in case an error occurs a while after the start of the video.
differentOutputSizesBytes
.
add
(
AndroidTestUtil
.
TransformationResult
result
=
runTransformer
(
runTransformer
(
context
,
context
,
/* testId= */
"repeatedTranscodeNoAudio_givesConsistentLengthOutput"
,
/* testId= */
"repeatedTranscodeNoAudio_givesConsistentLengthOutput_"
+
i
,
transformer
,
transformer
,
AndroidTestUtil
.
REMOTE_MP4_10_SECONDS_URI_STRING
,
AndroidTestUtil
.
REMOTE_MP4_10_SECONDS_URI_STRING
,
/* timeoutSeconds= */
120
)
/* timeoutSeconds= */
120
);
.
outputSizeBytes
);
differentOutputSizesBytes
.
add
(
Assertions
.
checkNotNull
(
result
.
fileSizeBytes
)
);
}
}
assertWithMessage
(
assertWithMessage
(
...
@@ -108,7 +108,7 @@ public final class RepeatedTranscodeTransformationTest {
...
@@ -108,7 +108,7 @@ public final class RepeatedTranscodeTransformationTest {
@Test
@Test
public
void
repeatedTranscodeNoVideo_givesConsistentLengthOutput
()
throws
Exception
{
public
void
repeatedTranscodeNoVideo_givesConsistentLengthOutput
()
throws
Exception
{
Context
context
=
ApplicationProvider
.
getApplicationContext
();
Context
context
=
ApplicationProvider
.
getApplicationContext
();
Transformer
trans
codingTrans
former
=
Transformer
transformer
=
new
Transformer
.
Builder
(
context
)
new
Transformer
.
Builder
(
context
)
.
setRemoveVideo
(
true
)
.
setRemoveVideo
(
true
)
.
setTransformationRequest
(
.
setTransformationRequest
(
...
@@ -120,14 +120,14 @@ public final class RepeatedTranscodeTransformationTest {
...
@@ -120,14 +120,14 @@ public final class RepeatedTranscodeTransformationTest {
Set
<
Long
>
differentOutputSizesBytes
=
new
HashSet
<>();
Set
<
Long
>
differentOutputSizesBytes
=
new
HashSet
<>();
for
(
int
i
=
0
;
i
<
TRANSCODE_COUNT
;
i
++)
{
for
(
int
i
=
0
;
i
<
TRANSCODE_COUNT
;
i
++)
{
// Use a long video in case an error occurs a while after the start of the video.
// Use a long video in case an error occurs a while after the start of the video.
differentOutputSizesBytes
.
add
(
AndroidTestUtil
.
TransformationResult
result
=
runTransformer
(
runTransformer
(
context
,
context
,
/* testId= */
"repeatedTranscodeNoVideo_givesConsistentLengthOutput"
,
/* testId= */
"repeatedTranscodeNoVideo_givesConsistentLengthOutput_"
+
i
,
transcodingT
ransformer
,
t
ransformer
,
AndroidTestUtil
.
REMOTE_MP4_10_SECONDS_URI_STRING
,
AndroidTestUtil
.
REMOTE_MP4_10_SECONDS_URI_STRING
,
/* timeoutSeconds= */
120
)
/* timeoutSeconds= */
120
);
.
outputSizeBytes
);
differentOutputSizesBytes
.
add
(
Assertions
.
checkNotNull
(
result
.
fileSizeBytes
)
);
}
}
assertWithMessage
(
assertWithMessage
(
...
...
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