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
300bee5f
authored
Sep 25, 2020
by
christosts
Committed by
Oliver Woodman
Oct 17, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Bring back setRenderTimeLimitMs
PiperOrigin-RevId: 333712782
parent
973d2354
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
2 deletions
library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java
library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java
View file @
300bee5f
...
@@ -363,6 +363,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
...
@@ -363,6 +363,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
@Nullable
private
DrmSession
sourceDrmSession
;
@Nullable
private
DrmSession
sourceDrmSession
;
@Nullable
private
MediaCrypto
mediaCrypto
;
@Nullable
private
MediaCrypto
mediaCrypto
;
private
boolean
mediaCryptoRequiresSecureDecoder
;
private
boolean
mediaCryptoRequiresSecureDecoder
;
private
long
renderTimeLimitMs
;
private
float
operatingRate
;
private
float
operatingRate
;
@Nullable
private
MediaCodec
codec
;
@Nullable
private
MediaCodec
codec
;
@Nullable
private
MediaCodecAdapter
codecAdapter
;
@Nullable
private
MediaCodecAdapter
codecAdapter
;
...
@@ -442,6 +443,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
...
@@ -442,6 +443,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
outputBufferInfo
=
new
MediaCodec
.
BufferInfo
();
outputBufferInfo
=
new
MediaCodec
.
BufferInfo
();
operatingRate
=
1
f
;
operatingRate
=
1
f
;
mediaCodecOperationMode
=
OPERATION_MODE_SYNCHRONOUS
;
mediaCodecOperationMode
=
OPERATION_MODE_SYNCHRONOUS
;
renderTimeLimitMs
=
C
.
TIME_UNSET
;
pendingOutputStreamStartPositionsUs
=
new
long
[
MAX_PENDING_OUTPUT_STREAM_OFFSET_COUNT
];
pendingOutputStreamStartPositionsUs
=
new
long
[
MAX_PENDING_OUTPUT_STREAM_OFFSET_COUNT
];
pendingOutputStreamOffsetsUs
=
new
long
[
MAX_PENDING_OUTPUT_STREAM_OFFSET_COUNT
];
pendingOutputStreamOffsetsUs
=
new
long
[
MAX_PENDING_OUTPUT_STREAM_OFFSET_COUNT
];
pendingOutputStreamSwitchTimesUs
=
new
long
[
MAX_PENDING_OUTPUT_STREAM_OFFSET_COUNT
];
pendingOutputStreamSwitchTimesUs
=
new
long
[
MAX_PENDING_OUTPUT_STREAM_OFFSET_COUNT
];
...
@@ -452,6 +454,19 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
...
@@ -452,6 +454,19 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
}
}
/**
/**
* Set a limit on the time a single {@link #render(long, long)} call can spend draining and
* filling the decoder.
*
* <p>This method should be called right after creating an instance of this class.
*
* @param renderTimeLimitMs The render time limit in milliseconds, or {@link C#TIME_UNSET} for no
* limit.
*/
public
void
setRenderTimeLimitMs
(
long
renderTimeLimitMs
)
{
this
.
renderTimeLimitMs
=
renderTimeLimitMs
;
}
/**
* Set the mode of operation of the underlying {@link MediaCodec}.
* Set the mode of operation of the underlying {@link MediaCodec}.
*
*
* <p>This method is experimental, and will be renamed or removed in a future release. It should
* <p>This method is experimental, and will be renamed or removed in a future release. It should
...
@@ -837,9 +852,11 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
...
@@ -837,9 +852,11 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
while
(
bypassRender
(
positionUs
,
elapsedRealtimeUs
))
{}
while
(
bypassRender
(
positionUs
,
elapsedRealtimeUs
))
{}
TraceUtil
.
endSection
();
TraceUtil
.
endSection
();
}
else
if
(
codec
!=
null
)
{
}
else
if
(
codec
!=
null
)
{
long
renderStartTimeMs
=
SystemClock
.
elapsedRealtime
();
TraceUtil
.
beginSection
(
"drainAndFeed"
);
TraceUtil
.
beginSection
(
"drainAndFeed"
);
while
(
drainOutputBuffer
(
positionUs
,
elapsedRealtimeUs
))
{}
while
(
drainOutputBuffer
(
positionUs
,
elapsedRealtimeUs
)
while
(
feedInputBuffer
())
{}
&&
shouldContinueRendering
(
renderStartTimeMs
))
{}
while
(
feedInputBuffer
()
&&
shouldContinueRendering
(
renderStartTimeMs
))
{}
TraceUtil
.
endSection
();
TraceUtil
.
endSection
();
}
else
{
}
else
{
decoderCounters
.
skippedInputBufferCount
+=
skipSource
(
positionUs
);
decoderCounters
.
skippedInputBufferCount
+=
skipSource
(
positionUs
);
...
@@ -1171,6 +1188,11 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
...
@@ -1171,6 +1188,11 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
onCodecInitialized
(
codecName
,
codecInitializedTimestamp
,
elapsed
);
onCodecInitialized
(
codecName
,
codecInitializedTimestamp
,
elapsed
);
}
}
private
boolean
shouldContinueRendering
(
long
renderStartTimeMs
)
{
return
renderTimeLimitMs
==
C
.
TIME_UNSET
||
SystemClock
.
elapsedRealtime
()
-
renderStartTimeMs
<
renderTimeLimitMs
;
}
private
void
getCodecBuffers
(
MediaCodec
codec
)
{
private
void
getCodecBuffers
(
MediaCodec
codec
)
{
if
(
Util
.
SDK_INT
<
21
)
{
if
(
Util
.
SDK_INT
<
21
)
{
inputBuffers
=
codec
.
getInputBuffers
();
inputBuffers
=
codec
.
getInputBuffers
();
...
...
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