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
8adc145f
authored
Mar 07, 2022
by
samrobinson
Committed by
Ian Baker
Mar 09, 2022
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add regression test forcing encode/decode.
PiperOrigin-RevId: 432928418
parent
e5c229be
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
0 deletions
library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/mh/TransformationTest.java
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/Codec.java
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/TransformerAudioRenderer.java
library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/mh/TransformationTest.java
View file @
8adc145f
...
@@ -23,11 +23,15 @@ import static com.google.android.exoplayer2.transformer.AndroidTestUtil.MP4_REMO
...
@@ -23,11 +23,15 @@ import static com.google.android.exoplayer2.transformer.AndroidTestUtil.MP4_REMO
import
android.content.Context
;
import
android.content.Context
;
import
androidx.test.core.app.ApplicationProvider
;
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.Format
;
import
com.google.android.exoplayer2.transformer.Codec
;
import
com.google.android.exoplayer2.transformer.TransformationException
;
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.transformer.TransformerAndroidTestRunner
;
import
com.google.android.exoplayer2.transformer.TransformerAndroidTestRunner
;
import
com.google.android.exoplayer2.util.Log
;
import
com.google.android.exoplayer2.util.Log
;
import
com.google.android.exoplayer2.util.Util
;
import
com.google.android.exoplayer2.util.Util
;
import
java.util.List
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.junit.runner.RunWith
;
...
@@ -50,6 +54,46 @@ public class TransformationTest {
...
@@ -50,6 +54,46 @@ public class TransformationTest {
}
}
@Test
@Test
public
void
transformWithDecodeEncode
()
throws
Exception
{
final
String
testId
=
TAG
+
"_transformForceCodecUse"
;
Context
context
=
ApplicationProvider
.
getApplicationContext
();
Transformer
transformer
=
new
Transformer
.
Builder
(
context
)
.
setEncoderFactory
(
new
Codec
.
EncoderFactory
()
{
@Override
public
Codec
createForAudioEncoding
(
Format
format
,
List
<
String
>
allowedMimeTypes
)
throws
TransformationException
{
return
Codec
.
EncoderFactory
.
DEFAULT
.
createForAudioEncoding
(
format
,
allowedMimeTypes
);
}
@Override
public
Codec
createForVideoEncoding
(
Format
format
,
List
<
String
>
allowedMimeTypes
)
throws
TransformationException
{
return
Codec
.
EncoderFactory
.
DEFAULT
.
createForVideoEncoding
(
format
,
allowedMimeTypes
);
}
@Override
public
boolean
audioNeedsEncoding
()
{
return
true
;
}
@Override
public
boolean
videoNeedsEncoding
()
{
return
true
;
}
})
.
build
();
new
TransformerAndroidTestRunner
.
Builder
(
context
,
transformer
)
.
setCalculateSsim
(
true
)
.
build
()
.
run
(
testId
,
MP4_ASSET_WITH_INCREASING_TIMESTAMPS_URI_STRING
);
}
@Test
public
void
transform4K60
()
throws
Exception
{
public
void
transform4K60
()
throws
Exception
{
final
String
testId
=
TAG
+
"_transform4K60"
;
final
String
testId
=
TAG
+
"_transform4K60"
;
...
...
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/Codec.java
View file @
8adc145f
...
@@ -105,6 +105,11 @@ public interface Codec {
...
@@ -105,6 +105,11 @@ public interface Codec {
Codec
createForVideoEncoding
(
Format
format
,
List
<
String
>
allowedMimeTypes
)
Codec
createForVideoEncoding
(
Format
format
,
List
<
String
>
allowedMimeTypes
)
throws
TransformationException
;
throws
TransformationException
;
/** Returns whether the audio needs to be encoded because of encoder specific configuration. */
default
boolean
audioNeedsEncoding
()
{
return
false
;
}
/** Returns whether the video needs to be encoded because of encoder specific configuration. */
/** Returns whether the video needs to be encoded because of encoder specific configuration. */
default
boolean
videoNeedsEncoding
()
{
default
boolean
videoNeedsEncoding
()
{
return
false
;
return
false
;
...
...
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/TransformerAudioRenderer.java
View file @
8adc145f
...
@@ -85,6 +85,9 @@ import com.google.android.exoplayer2.source.SampleStream.ReadDataResult;
...
@@ -85,6 +85,9 @@ import com.google.android.exoplayer2.source.SampleStream.ReadDataResult;
}
}
private
boolean
shouldPassthrough
(
Format
inputFormat
)
{
private
boolean
shouldPassthrough
(
Format
inputFormat
)
{
if
(
encoderFactory
.
audioNeedsEncoding
())
{
return
false
;
}
if
(
transformationRequest
.
audioMimeType
!=
null
if
(
transformationRequest
.
audioMimeType
!=
null
&&
!
transformationRequest
.
audioMimeType
.
equals
(
inputFormat
.
sampleMimeType
))
{
&&
!
transformationRequest
.
audioMimeType
.
equals
(
inputFormat
.
sampleMimeType
))
{
return
false
;
return
false
;
...
...
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