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
d4725838
authored
Oct 13, 2020
by
olly
Committed by
kim-vde
Oct 13, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Remove reflection and call Surface.setFrameRate directly
PiperOrigin-RevId: 336838201
parent
5e1c96ad
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
32 deletions
library/core/src/main/java/com/google/android/exoplayer2/video/MediaCodecVideoRenderer.java
library/core/src/main/java/com/google/android/exoplayer2/video/MediaCodecVideoRenderer.java
View file @
d4725838
...
...
@@ -60,7 +60,6 @@ import com.google.android.exoplayer2.util.MimeTypes;
import
com.google.android.exoplayer2.util.TraceUtil
;
import
com.google.android.exoplayer2.util.Util
;
import
com.google.android.exoplayer2.video.VideoRendererEventListener.EventDispatcher
;
import
java.lang.reflect.Method
;
import
java.nio.ByteBuffer
;
import
java.util.Collections
;
import
java.util.List
;
...
...
@@ -104,24 +103,6 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
/** Magic frame render timestamp that indicates the EOS in tunneling mode. */
private
static
final
long
TUNNELING_EOS_PRESENTATION_TIME_US
=
Long
.
MAX_VALUE
;
// TODO: Remove reflection once we target API level 30.
@Nullable
private
static
final
Method
surfaceSetFrameRateMethod
;
static
{
@Nullable
Method
setFrameRateMethod
=
null
;
if
(
Util
.
SDK_INT
>=
30
)
{
try
{
setFrameRateMethod
=
Surface
.
class
.
getMethod
(
"setFrameRate"
,
float
.
class
,
int
.
class
);
}
catch
(
NoSuchMethodException
e
)
{
// Do nothing.
}
}
surfaceSetFrameRateMethod
=
setFrameRateMethod
;
}
// TODO: Remove these constants and use those defined by Surface once we target API level 30.
private
static
final
int
SURFACE_FRAME_RATE_COMPATIBILITY_DEFAULT
=
0
;
private
static
final
int
SURFACE_FRAME_RATE_COMPATIBILITY_FIXED_SOURCE
=
1
;
private
static
boolean
evaluatedDeviceNeedsSetOutputSurfaceWorkaround
;
private
static
boolean
deviceNeedsSetOutputSurfaceWorkaround
;
...
...
@@ -136,9 +117,9 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
private
boolean
codecNeedsSetOutputSurfaceWorkaround
;
private
boolean
codecHandlesHdr10PlusOutOfBandMetadata
;
private
Surface
surface
;
@Nullable
private
Surface
surface
;
private
float
surfaceFrameRate
;
private
Surface
dummySurface
;
@Nullable
private
Surface
dummySurface
;
private
boolean
haveReportedFirstFrameRenderedForCurrentSurface
;
@VideoScalingMode
private
int
scalingMode
;
private
boolean
renderedFirstFrameAfterReset
;
...
...
@@ -1116,19 +1097,12 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
}
@RequiresApi
(
30
)
private
void
setSurfaceFrameRateV30
(
Surface
surface
,
float
frameRate
)
{
if
(
surfaceSetFrameRateMethod
==
null
)
{
Log
.
e
(
TAG
,
"Failed to call Surface.setFrameRate (method does not exist)"
);
}
private
static
void
setSurfaceFrameRateV30
(
Surface
surface
,
float
frameRate
)
{
int
compatibility
=
frameRate
==
0
?
SURFACE_FRAME_RATE_COMPATIBILITY_DEFAULT
:
SURFACE_FRAME_RATE_COMPATIBILITY_FIXED_SOURCE
;
try
{
surfaceSetFrameRateMethod
.
invoke
(
surface
,
frameRate
,
compatibility
);
}
catch
(
Exception
e
)
{
Log
.
e
(
TAG
,
"Failed to call Surface.setFrameRate"
,
e
);
}
?
Surface
.
FRAME_RATE_COMPATIBILITY_DEFAULT
:
Surface
.
FRAME_RATE_COMPATIBILITY_FIXED_SOURCE
;
surface
.
setFrameRate
(
frameRate
,
compatibility
);
}
private
boolean
shouldUseDummySurface
(
MediaCodecInfo
codecInfo
)
{
...
...
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