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
397fe8f3
authored
Sep 25, 2020
by
christosts
Committed by
kim-vde
Sep 25, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Bring back setRenderTimeLimitMs
PiperOrigin-RevId: 333712782
parent
9b39268e
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 @
397fe8f3
...
@@ -323,6 +323,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
...
@@ -323,6 +323,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
;
...
@@ -401,6 +402,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
...
@@ -401,6 +402,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
decodeOnlyPresentationTimestamps
=
new
ArrayList
<>();
decodeOnlyPresentationTimestamps
=
new
ArrayList
<>();
outputBufferInfo
=
new
MediaCodec
.
BufferInfo
();
outputBufferInfo
=
new
MediaCodec
.
BufferInfo
();
operatingRate
=
1
f
;
operatingRate
=
1
f
;
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
];
...
@@ -411,6 +413,19 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
...
@@ -411,6 +413,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
;
}
/**
* Enable asynchronous input buffer queueing.
* Enable asynchronous input buffer queueing.
*
*
* <p>Operates the underlying {@link MediaCodec} in asynchronous mode and submits input buffers
* <p>Operates the underlying {@link MediaCodec} in asynchronous mode and submits input buffers
...
@@ -784,9 +799,11 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
...
@@ -784,9 +799,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
);
...
@@ -1110,6 +1127,11 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
...
@@ -1110,6 +1127,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