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
01ff4e37
authored
Dec 07, 2022
by
tofunmi
Committed by
Ian Baker
Dec 12, 2022
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Replace hardcoded selectedEffects indices with `public static final`s.
PiperOrigin-RevId: 493543188
parent
e42a438a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
27 deletions
demos/transformer/src/main/java/com/google/android/exoplayer2/transformerdemo/ConfigurationActivity.java
demos/transformer/src/main/java/com/google/android/exoplayer2/transformerdemo/TransformerActivity.java
demos/transformer/src/main/java/com/google/android/exoplayer2/transformerdemo/ConfigurationActivity.java
View file @
01ff4e37
...
@@ -93,9 +93,32 @@ public final class ConfigurationActivity extends AppCompatActivity {
...
@@ -93,9 +93,32 @@ public final class ConfigurationActivity extends AppCompatActivity {
public
static
final
String
TEXT_OVERLAY_TEXT
=
"text_overlay_text"
;
public
static
final
String
TEXT_OVERLAY_TEXT
=
"text_overlay_text"
;
public
static
final
String
TEXT_OVERLAY_TEXT_COLOR
=
"text_overlay_text_color"
;
public
static
final
String
TEXT_OVERLAY_TEXT_COLOR
=
"text_overlay_text_color"
;
public
static
final
String
TEXT_OVERLAY_ALPHA
=
"text_overlay_alpha"
;
public
static
final
String
TEXT_OVERLAY_ALPHA
=
"text_overlay_alpha"
;
// Video effect selections.
public
static
final
int
DIZZY_CROP_INDEX
=
0
;
public
static
final
int
EDGE_DETECTOR_INDEX
=
1
;
public
static
final
int
COLOR_FILTERS_INDEX
=
2
;
public
static
final
int
MAP_WHITE_TO_GREEN_LUT_INDEX
=
3
;
public
static
final
int
RGB_ADJUSTMENTS_INDEX
=
4
;
public
static
final
int
HSL_ADJUSTMENT_INDEX
=
5
;
public
static
final
int
CONTRAST_INDEX
=
6
;
public
static
final
int
PERIODIC_VIGNETTE_INDEX
=
7
;
public
static
final
int
SPIN_3D_INDEX
=
8
;
public
static
final
int
OVERLAY_LOGO_AND_TIMER_INDEX
=
9
;
public
static
final
int
ZOOM_IN_INDEX
=
10
;
public
static
final
int
BITMAP_OVERLAY_INDEX
=
11
;
public
static
final
int
TEXT_OVERLAY_INDEX
=
12
;
// Audio effect selections.
public
static
final
int
HIGH_PITCHED_INDEX
=
0
;
public
static
final
int
SAMPLE_RATE_INDEX
=
1
;
public
static
final
int
SKIP_SILENCE_INDEX
=
2
;
// Color filter options.
public
static
final
int
COLOR_FILTER_GRAYSCALE
=
0
;
public
static
final
int
COLOR_FILTER_GRAYSCALE
=
0
;
public
static
final
int
COLOR_FILTER_INVERTED
=
1
;
public
static
final
int
COLOR_FILTER_INVERTED
=
1
;
public
static
final
int
COLOR_FILTER_SEPIA
=
2
;
public
static
final
int
COLOR_FILTER_SEPIA
=
2
;
public
static
final
int
FILE_PERMISSION_REQUEST_CODE
=
1
;
public
static
final
int
FILE_PERMISSION_REQUEST_CODE
=
1
;
private
static
final
String
[]
PRESET_FILE_URIS
=
{
private
static
final
String
[]
PRESET_FILE_URIS
=
{
"https://storage.googleapis.com/exoplayer-test-media-1/mp4/android-screens-10s.mp4"
,
"https://storage.googleapis.com/exoplayer-test-media-1/mp4/android-screens-10s.mp4"
,
...
@@ -173,13 +196,6 @@ public final class ConfigurationActivity extends AppCompatActivity {
...
@@ -173,13 +196,6 @@ public final class ConfigurationActivity extends AppCompatActivity {
.
put
(
"YELLOW"
,
Color
.
YELLOW
)
.
put
(
"YELLOW"
,
Color
.
YELLOW
)
.
build
();
.
build
();
private
static
final
String
SAME_AS_INPUT_OPTION
=
"same as input"
;
private
static
final
String
SAME_AS_INPUT_OPTION
=
"same as input"
;
private
static
final
int
COLOR_FILTERS_INDEX
=
2
;
private
static
final
int
RGB_ADJUSTMENTS_INDEX
=
4
;
private
static
final
int
HSL_ADJUSTMENT_INDEX
=
5
;
private
static
final
int
CONTRAST_INDEX
=
6
;
private
static
final
int
PERIODIC_VIGNETTE_INDEX
=
7
;
private
static
final
int
BITMAP_OVERLAY_INDEX
=
11
;
private
static
final
int
TEXT_OVERLAY_INDEX
=
12
;
private
static
final
float
HALF_DIAGONAL
=
1
f
/
(
float
)
Math
.
sqrt
(
2
);
private
static
final
float
HALF_DIAGONAL
=
1
f
/
(
float
)
Math
.
sqrt
(
2
);
private
@MonotonicNonNull
ActivityResultLauncher
<
Intent
>
localFilePickerLauncher
;
private
@MonotonicNonNull
ActivityResultLauncher
<
Intent
>
localFilePickerLauncher
;
...
...
demos/transformer/src/main/java/com/google/android/exoplayer2/transformerdemo/TransformerActivity.java
View file @
01ff4e37
...
@@ -347,21 +347,19 @@ public final class TransformerActivity extends AppCompatActivity {
...
@@ -347,21 +347,19 @@ public final class TransformerActivity extends AppCompatActivity {
ImmutableList
.
Builder
<
AudioProcessor
>
processors
=
new
ImmutableList
.
Builder
<>();
ImmutableList
.
Builder
<
AudioProcessor
>
processors
=
new
ImmutableList
.
Builder
<>();
if
(
selectedAudioEffects
[
0
]
||
selectedAudioEffects
[
1
])
{
if
(
selectedAudioEffects
[
ConfigurationActivity
.
HIGH_PITCHED_INDEX
]
||
selectedAudioEffects
[
ConfigurationActivity
.
SAMPLE_RATE_INDEX
])
{
SonicAudioProcessor
sonicAudioProcessor
=
new
SonicAudioProcessor
();
SonicAudioProcessor
sonicAudioProcessor
=
new
SonicAudioProcessor
();
// High pitched
if
(
selectedAudioEffects
[
ConfigurationActivity
.
HIGH_PITCHED_INDEX
])
{
if
(
selectedAudioEffects
[
0
])
{
sonicAudioProcessor
.
setPitch
(
2
f
);
sonicAudioProcessor
.
setPitch
(
2
f
);
}
}
// 48KHz sample rate.
if
(
selectedAudioEffects
[
ConfigurationActivity
.
SAMPLE_RATE_INDEX
])
{
if
(
selectedAudioEffects
[
1
])
{
sonicAudioProcessor
.
setOutputSampleRateHz
(
48_000
);
sonicAudioProcessor
.
setOutputSampleRateHz
(
48_000
);
}
}
processors
.
add
(
sonicAudioProcessor
);
processors
.
add
(
sonicAudioProcessor
);
}
}
// Skip silence
if
(
selectedAudioEffects
[
ConfigurationActivity
.
SKIP_SILENCE_INDEX
])
{
if
(
selectedAudioEffects
[
2
])
{
SilenceSkippingAudioProcessor
silenceSkippingAudioProcessor
=
SilenceSkippingAudioProcessor
silenceSkippingAudioProcessor
=
new
SilenceSkippingAudioProcessor
();
new
SilenceSkippingAudioProcessor
();
silenceSkippingAudioProcessor
.
setEnabled
(
true
);
silenceSkippingAudioProcessor
.
setEnabled
(
true
);
...
@@ -379,10 +377,10 @@ public final class TransformerActivity extends AppCompatActivity {
...
@@ -379,10 +377,10 @@ public final class TransformerActivity extends AppCompatActivity {
return
ImmutableList
.
of
();
return
ImmutableList
.
of
();
}
}
ImmutableList
.
Builder
<
Effect
>
effects
=
new
ImmutableList
.
Builder
<>();
ImmutableList
.
Builder
<
Effect
>
effects
=
new
ImmutableList
.
Builder
<>();
if
(
selectedEffects
[
0
])
{
if
(
selectedEffects
[
ConfigurationActivity
.
DIZZY_CROP_INDEX
])
{
effects
.
add
(
MatrixTransformationFactory
.
createDizzyCropEffect
());
effects
.
add
(
MatrixTransformationFactory
.
createDizzyCropEffect
());
}
}
if
(
selectedEffects
[
1
])
{
if
(
selectedEffects
[
ConfigurationActivity
.
EDGE_DETECTOR_INDEX
])
{
try
{
try
{
Class
<?>
clazz
=
Class
<?>
clazz
=
Class
.
forName
(
"com.google.android.exoplayer2.transformerdemo.MediaPipeProcessor"
);
Class
.
forName
(
"com.google.android.exoplayer2.transformerdemo.MediaPipeProcessor"
);
...
@@ -415,7 +413,7 @@ public final class TransformerActivity extends AppCompatActivity {
...
@@ -415,7 +413,7 @@ public final class TransformerActivity extends AppCompatActivity {
showToast
(
R
.
string
.
no_media_pipe_error
);
showToast
(
R
.
string
.
no_media_pipe_error
);
}
}
}
}
if
(
selectedEffects
[
2
])
{
if
(
selectedEffects
[
ConfigurationActivity
.
COLOR_FILTERS_INDEX
])
{
switch
(
bundle
.
getInt
(
ConfigurationActivity
.
COLOR_FILTER_SELECTION
))
{
switch
(
bundle
.
getInt
(
ConfigurationActivity
.
COLOR_FILTER_SELECTION
))
{
case
ConfigurationActivity
.
COLOR_FILTER_GRAYSCALE
:
case
ConfigurationActivity
.
COLOR_FILTER_GRAYSCALE
:
effects
.
add
(
RgbFilter
.
createGrayscaleFilter
());
effects
.
add
(
RgbFilter
.
createGrayscaleFilter
());
...
@@ -441,7 +439,7 @@ public final class TransformerActivity extends AppCompatActivity {
...
@@ -441,7 +439,7 @@ public final class TransformerActivity extends AppCompatActivity {
+
bundle
.
getInt
(
ConfigurationActivity
.
COLOR_FILTER_SELECTION
));
+
bundle
.
getInt
(
ConfigurationActivity
.
COLOR_FILTER_SELECTION
));
}
}
}
}
if
(
selectedEffects
[
3
])
{
if
(
selectedEffects
[
ConfigurationActivity
.
MAP_WHITE_TO_GREEN_LUT_INDEX
])
{
int
length
=
3
;
int
length
=
3
;
int
[][][]
mapWhiteToGreenLut
=
new
int
[
length
][
length
][
length
];
int
[][][]
mapWhiteToGreenLut
=
new
int
[
length
][
length
][
length
];
int
scale
=
255
/
(
length
-
1
);
int
scale
=
255
/
(
length
-
1
);
...
@@ -456,7 +454,7 @@ public final class TransformerActivity extends AppCompatActivity {
...
@@ -456,7 +454,7 @@ public final class TransformerActivity extends AppCompatActivity {
mapWhiteToGreenLut
[
length
-
1
][
length
-
1
][
length
-
1
]
=
Color
.
GREEN
;
mapWhiteToGreenLut
[
length
-
1
][
length
-
1
][
length
-
1
]
=
Color
.
GREEN
;
effects
.
add
(
SingleColorLut
.
createFromCube
(
mapWhiteToGreenLut
));
effects
.
add
(
SingleColorLut
.
createFromCube
(
mapWhiteToGreenLut
));
}
}
if
(
selectedEffects
[
4
])
{
if
(
selectedEffects
[
ConfigurationActivity
.
RGB_ADJUSTMENTS_INDEX
])
{
effects
.
add
(
effects
.
add
(
new
RgbAdjustment
.
Builder
()
new
RgbAdjustment
.
Builder
()
.
setRedScale
(
bundle
.
getFloat
(
ConfigurationActivity
.
RGB_ADJUSTMENT_RED_SCALE
))
.
setRedScale
(
bundle
.
getFloat
(
ConfigurationActivity
.
RGB_ADJUSTMENT_RED_SCALE
))
...
@@ -464,7 +462,7 @@ public final class TransformerActivity extends AppCompatActivity {
...
@@ -464,7 +462,7 @@ public final class TransformerActivity extends AppCompatActivity {
.
setBlueScale
(
bundle
.
getFloat
(
ConfigurationActivity
.
RGB_ADJUSTMENT_BLUE_SCALE
))
.
setBlueScale
(
bundle
.
getFloat
(
ConfigurationActivity
.
RGB_ADJUSTMENT_BLUE_SCALE
))
.
build
());
.
build
());
}
}
if
(
selectedEffects
[
5
])
{
if
(
selectedEffects
[
ConfigurationActivity
.
HSL_ADJUSTMENT_INDEX
])
{
effects
.
add
(
effects
.
add
(
new
HslAdjustment
.
Builder
()
new
HslAdjustment
.
Builder
()
.
adjustHue
(
bundle
.
getFloat
(
ConfigurationActivity
.
HSL_ADJUSTMENTS_HUE
))
.
adjustHue
(
bundle
.
getFloat
(
ConfigurationActivity
.
HSL_ADJUSTMENTS_HUE
))
...
@@ -472,10 +470,10 @@ public final class TransformerActivity extends AppCompatActivity {
...
@@ -472,10 +470,10 @@ public final class TransformerActivity extends AppCompatActivity {
.
adjustLightness
(
bundle
.
getFloat
(
ConfigurationActivity
.
HSL_ADJUSTMENTS_LIGHTNESS
))
.
adjustLightness
(
bundle
.
getFloat
(
ConfigurationActivity
.
HSL_ADJUSTMENTS_LIGHTNESS
))
.
build
());
.
build
());
}
}
if
(
selectedEffects
[
6
])
{
if
(
selectedEffects
[
ConfigurationActivity
.
CONTRAST_INDEX
])
{
effects
.
add
(
new
Contrast
(
bundle
.
getFloat
(
ConfigurationActivity
.
CONTRAST_VALUE
)));
effects
.
add
(
new
Contrast
(
bundle
.
getFloat
(
ConfigurationActivity
.
CONTRAST_VALUE
)));
}
}
if
(
selectedEffects
[
7
])
{
if
(
selectedEffects
[
ConfigurationActivity
.
PERIODIC_VIGNETTE_INDEX
])
{
effects
.
add
(
effects
.
add
(
(
GlEffect
)
(
GlEffect
)
(
Context
context
,
boolean
useHdr
)
->
(
Context
context
,
boolean
useHdr
)
->
...
@@ -490,16 +488,16 @@ public final class TransformerActivity extends AppCompatActivity {
...
@@ -490,16 +488,16 @@ public final class TransformerActivity extends AppCompatActivity {
ConfigurationActivity
.
PERIODIC_VIGNETTE_OUTER_RADIUS
),
ConfigurationActivity
.
PERIODIC_VIGNETTE_OUTER_RADIUS
),
bundle
.
getFloat
(
ConfigurationActivity
.
PERIODIC_VIGNETTE_OUTER_RADIUS
)));
bundle
.
getFloat
(
ConfigurationActivity
.
PERIODIC_VIGNETTE_OUTER_RADIUS
)));
}
}
if
(
selectedEffects
[
8
])
{
if
(
selectedEffects
[
ConfigurationActivity
.
SPIN_3D_INDEX
])
{
effects
.
add
(
MatrixTransformationFactory
.
createSpin3dEffect
());
effects
.
add
(
MatrixTransformationFactory
.
createSpin3dEffect
());
}
}
if
(
selectedEffects
[
9
])
{
if
(
selectedEffects
[
ConfigurationActivity
.
OVERLAY_LOGO_AND_TIMER_INDEX
])
{
effects
.
add
((
GlEffect
)
BitmapOverlayProcessor:
:
new
);
effects
.
add
((
GlEffect
)
BitmapOverlayProcessor:
:
new
);
}
}
if
(
selectedEffects
[
10
])
{
if
(
selectedEffects
[
ConfigurationActivity
.
ZOOM_IN_INDEX
])
{
effects
.
add
(
MatrixTransformationFactory
.
createZoomInTransition
());
effects
.
add
(
MatrixTransformationFactory
.
createZoomInTransition
());
}
}
if
(
selectedEffects
[
11
])
{
if
(
selectedEffects
[
ConfigurationActivity
.
BITMAP_OVERLAY_INDEX
])
{
OverlaySettings
overlaySettings
=
OverlaySettings
overlaySettings
=
new
OverlaySettings
.
Builder
()
new
OverlaySettings
.
Builder
()
.
setAlpha
(
.
setAlpha
(
...
@@ -512,7 +510,7 @@ public final class TransformerActivity extends AppCompatActivity {
...
@@ -512,7 +510,7 @@ public final class TransformerActivity extends AppCompatActivity {
overlaySettings
);
overlaySettings
);
effects
.
add
(
new
OverlayEffect
(
ImmutableList
.
of
(
bitmapOverlay
)));
effects
.
add
(
new
OverlayEffect
(
ImmutableList
.
of
(
bitmapOverlay
)));
}
}
if
(
selectedEffects
[
12
])
{
if
(
selectedEffects
[
ConfigurationActivity
.
TEXT_OVERLAY_INDEX
])
{
OverlaySettings
overlaySettings
=
OverlaySettings
overlaySettings
=
new
OverlaySettings
.
Builder
()
new
OverlaySettings
.
Builder
()
.
setAlpha
(
.
setAlpha
(
...
...
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