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
60681b97
authored
Aug 23, 2021
by
kimvde
Committed by
bachinger
Aug 23, 2021
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add onReset implementation to TransformerTranscodingVideoRenderer
PiperOrigin-RevId: 392468554
parent
2f09ecef
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
10 deletions
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/TransformerTranscodingVideoRenderer.java
library/transformer/src/main/java/com/google/android/exoplayer2/transformer/TransformerTranscodingVideoRenderer.java
View file @
60681b97
...
...
@@ -37,7 +37,7 @@ import java.nio.ByteBuffer;
private
static
final
String
TAG
=
"TransformerTranscodingVideoRenderer"
;
private
final
DecoderInputBuffer
b
uffer
;
private
final
DecoderInputBuffer
decoderInputB
uffer
;
/** The format the encoder is configured to output, may differ from the actual output format. */
private
final
Format
encoderConfigurationOutputFormat
;
...
...
@@ -57,7 +57,7 @@ import java.nio.ByteBuffer;
Format
encoderConfigurationOutputFormat
)
{
super
(
C
.
TRACK_TYPE_VIDEO
,
muxerWrapper
,
mediaClock
,
transformation
);
b
uffer
=
new
DecoderInputBuffer
(
DecoderInputBuffer
.
BUFFER_REPLACEMENT_MODE_DIRECT
);
decoderInputB
uffer
=
new
DecoderInputBuffer
(
DecoderInputBuffer
.
BUFFER_REPLACEMENT_MODE_DIRECT
);
surface
=
MediaCodec
.
createPersistentInputSurface
();
this
.
encoderConfigurationOutputFormat
=
encoderConfigurationOutputFormat
;
}
...
...
@@ -89,6 +89,23 @@ import java.nio.ByteBuffer;
return
muxerWrapperTrackEnded
;
}
@Override
protected
void
onReset
()
{
decoderInputBuffer
.
clear
();
decoderInputBuffer
.
data
=
null
;
surface
.
release
();
if
(
decoder
!=
null
)
{
decoder
.
release
();
decoder
=
null
;
}
if
(
encoder
!=
null
)
{
encoder
.
release
();
encoder
=
null
;
}
hasEncoderActualOutputFormat
=
false
;
muxerWrapperTrackEnded
=
false
;
}
private
boolean
ensureDecoderConfigured
()
throws
ExoPlaybackException
{
if
(
decoder
!=
null
)
{
return
true
;
...
...
@@ -97,7 +114,8 @@ import java.nio.ByteBuffer;
FormatHolder
formatHolder
=
getFormatHolder
();
@SampleStream
.
ReadDataResult
int
result
=
readSource
(
formatHolder
,
buffer
,
/* readFlags= */
SampleStream
.
FLAG_REQUIRE_FORMAT
);
readSource
(
formatHolder
,
decoderInputBuffer
,
/* readFlags= */
SampleStream
.
FLAG_REQUIRE_FORMAT
);
if
(
result
!=
C
.
RESULT_FORMAT_READ
)
{
return
false
;
}
...
...
@@ -133,23 +151,23 @@ import java.nio.ByteBuffer;
private
boolean
feedDecoderFromInput
()
{
MediaCodecAdapterWrapper
decoder
=
checkNotNull
(
this
.
decoder
);
if
(!
decoder
.
maybeDequeueInputBuffer
(
b
uffer
))
{
if
(!
decoder
.
maybeDequeueInputBuffer
(
decoderInputB
uffer
))
{
return
false
;
}
b
uffer
.
clear
();
decoderInputB
uffer
.
clear
();
@SampleStream
.
ReadDataResult
int
result
=
readSource
(
getFormatHolder
(),
b
uffer
,
/* readFlags= */
0
);
int
result
=
readSource
(
getFormatHolder
(),
decoderInputB
uffer
,
/* readFlags= */
0
);
switch
(
result
)
{
case
C
.
RESULT_FORMAT_READ
:
throw
new
IllegalStateException
(
"Format changes are not supported."
);
case
C
.
RESULT_BUFFER_READ
:
mediaClock
.
updateTimeForTrackType
(
getTrackType
(),
b
uffer
.
timeUs
);
ByteBuffer
data
=
checkNotNull
(
b
uffer
.
data
);
mediaClock
.
updateTimeForTrackType
(
getTrackType
(),
decoderInputB
uffer
.
timeUs
);
ByteBuffer
data
=
checkNotNull
(
decoderInputB
uffer
.
data
);
data
.
flip
();
decoder
.
queueInputBuffer
(
b
uffer
);
return
!
b
uffer
.
isEndOfStream
();
decoder
.
queueInputBuffer
(
decoderInputB
uffer
);
return
!
decoderInputB
uffer
.
isEndOfStream
();
case
C
.
RESULT_NOTHING_READ
:
default
:
return
false
;
...
...
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