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
4145273b
authored
Jan 17, 2022
by
hschlueter
Committed by
tonihei
Jan 17, 2022
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Revise TransformationRequest MIME type validation.
PiperOrigin-RevId: 422333929
parent
2e7ca0b7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
11 deletions
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/TransformationRequest.java
library/transformer/src/test/java/com/google/android/exoplayer2/transformer/TransformationRequestBuilderTest.java
library/transformer/src/test/java/com/google/android/exoplayer2/transformer/TransformerBuilderTest.java
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/TransformationRequest.java
View file @
4145273b
...
@@ -16,6 +16,8 @@
...
@@ -16,6 +16,8 @@
package
com
.
google
.
android
.
exoplayer2
.
transformer
;
package
com
.
google
.
android
.
exoplayer2
.
transformer
;
import
static
com
.
google
.
android
.
exoplayer2
.
util
.
Assertions
.
checkArgument
;
import
android.graphics.Matrix
;
import
android.graphics.Matrix
;
import
androidx.annotation.Nullable
;
import
androidx.annotation.Nullable
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.C
;
...
@@ -128,6 +130,7 @@ public final class TransformationRequest {
...
@@ -128,6 +130,7 @@ public final class TransformationRequest {
*
*
* @param outputHeight The output height in pixels.
* @param outputHeight The output height in pixels.
* @return This builder.
* @return This builder.
* @throws IllegalArgumentException If the {@code outputHeight} is not supported.
*/
*/
public
Builder
setResolution
(
int
outputHeight
)
{
public
Builder
setResolution
(
int
outputHeight
)
{
// TODO(b/209781577): Define outputHeight in the javadoc as height can be ambiguous for videos
// TODO(b/209781577): Define outputHeight in the javadoc as height can be ambiguous for videos
...
@@ -135,9 +138,9 @@ public final class TransformationRequest {
...
@@ -135,9 +138,9 @@ public final class TransformationRequest {
// TODO(b/201293185): Restructure to input a Presentation class.
// TODO(b/201293185): Restructure to input a Presentation class.
// TODO(b/201293185): Check encoder codec capabilities in order to allow arbitrary
// TODO(b/201293185): Check encoder codec capabilities in order to allow arbitrary
// resolutions and reasonable fallbacks.
// resolutions and reasonable fallbacks.
if
(
outputHeight
!=
C
.
LENGTH_UNSET
&&
!
SUPPORTED_OUTPUT_HEIGHTS
.
contains
(
outputHeight
))
{
checkArgument
(
throw
new
IllegalArgumentException
(
"Unsupported outputHeight: "
+
outputHeight
);
outputHeight
==
C
.
LENGTH_UNSET
||
SUPPORTED_OUTPUT_HEIGHTS
.
contains
(
outputHeight
),
}
"Unsupported outputHeight: "
+
outputHeight
);
this
.
outputHeight
=
outputHeight
;
this
.
outputHeight
=
outputHeight
;
return
this
;
return
this
;
}
}
...
@@ -155,10 +158,13 @@ public final class TransformationRequest {
...
@@ -155,10 +158,13 @@ public final class TransformationRequest {
*
*
* @param videoMimeType The MIME type of the video samples in the output.
* @param videoMimeType The MIME type of the video samples in the output.
* @return This builder.
* @return This builder.
* @throws IllegalArgumentException If the {@code videoMimeType} is non-null but not a video
* {@link MimeTypes MIME type}.
*/
*/
public
Builder
setVideoMimeType
(
@Nullable
String
videoMimeType
)
{
public
Builder
setVideoMimeType
(
@Nullable
String
videoMimeType
)
{
// TODO(b/209469847): Validate videoMimeType here once deprecated
checkArgument
(
// Transformer.Builder#setOuputMimeType(String) has been removed.
videoMimeType
==
null
||
MimeTypes
.
isVideo
(
videoMimeType
),
"Not a video MIME type: "
+
videoMimeType
);
this
.
videoMimeType
=
videoMimeType
;
this
.
videoMimeType
=
videoMimeType
;
return
this
;
return
this
;
}
}
...
@@ -175,10 +181,13 @@ public final class TransformationRequest {
...
@@ -175,10 +181,13 @@ public final class TransformationRequest {
*
*
* @param audioMimeType The MIME type of the audio samples in the output.
* @param audioMimeType The MIME type of the audio samples in the output.
* @return This builder.
* @return This builder.
* @throws IllegalArgumentException If the {@code audioMimeType} is non-null but not an audio
* {@link MimeTypes MIME type}.
*/
*/
public
Builder
setAudioMimeType
(
@Nullable
String
audioMimeType
)
{
public
Builder
setAudioMimeType
(
@Nullable
String
audioMimeType
)
{
// TODO(b/209469847): Validate audioMimeType here once deprecated
checkArgument
(
// Transformer.Builder#setOuputMimeType(String) has been removed.
audioMimeType
==
null
||
MimeTypes
.
isAudio
(
audioMimeType
),
"Not an audio MIME type: "
+
audioMimeType
);
this
.
audioMimeType
=
audioMimeType
;
this
.
audioMimeType
=
audioMimeType
;
return
this
;
return
this
;
}
}
...
...
library/transformer/src/test/java/com/google/android/exoplayer2/transformer/TransformationRequestBuilderTest.java
0 → 100644
View file @
4145273b
/*
* Copyright 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com
.
google
.
android
.
exoplayer2
.
transformer
;
import
static
org
.
junit
.
Assert
.
assertThrows
;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
/** Unit test for {@link TransformationRequest.Builder}. */
@RunWith
(
AndroidJUnit4
.
class
)
public
class
TransformationRequestBuilderTest
{
@Test
public
void
setAudioMimeType_withVideoMimeType_throws
()
{
assertThrows
(
IllegalArgumentException
.
class
,
()
->
new
TransformationRequest
.
Builder
().
setAudioMimeType
(
MimeTypes
.
VIDEO_H264
));
}
@Test
public
void
setVideoMimeType_withAudioMimeType_throws
()
{
assertThrows
(
IllegalArgumentException
.
class
,
()
->
new
TransformationRequest
.
Builder
().
setVideoMimeType
(
MimeTypes
.
AUDIO_AAC
));
}
}
library/transformer/src/test/java/com/google/android/exoplayer2/transformer/TransformerBuilderTest.java
View file @
4145273b
...
@@ -52,8 +52,6 @@ public class TransformerBuilderTest {
...
@@ -52,8 +52,6 @@ public class TransformerBuilderTest {
()
->
new
Transformer
.
Builder
(
context
).
setRemoveAudio
(
true
).
setRemoveVideo
(
true
).
build
());
()
->
new
Transformer
.
Builder
(
context
).
setRemoveAudio
(
true
).
setRemoveVideo
(
true
).
build
());
}
}
// TODO(b/209469847): Move this test to TransformationRequestBuilderTest once deprecated
// Transformer.Builder#setOuputMimeType(String) has been removed.
@Test
@Test
public
void
build_withUnsupportedAudioMimeType_throws
()
{
public
void
build_withUnsupportedAudioMimeType_throws
()
{
Context
context
=
ApplicationProvider
.
getApplicationContext
();
Context
context
=
ApplicationProvider
.
getApplicationContext
();
...
@@ -68,8 +66,6 @@ public class TransformerBuilderTest {
...
@@ -68,8 +66,6 @@ public class TransformerBuilderTest {
.
build
());
.
build
());
}
}
// TODO(b/209469847): Move this test to TransformationRequestBuilderTest once deprecated
// Transformer.Builder#setOuputMimeType(String) has been removed.
@Test
@Test
public
void
build_withUnsupportedVideoMimeType_throws
()
{
public
void
build_withUnsupportedVideoMimeType_throws
()
{
Context
context
=
ApplicationProvider
.
getApplicationContext
();
Context
context
=
ApplicationProvider
.
getApplicationContext
();
...
...
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