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
dfd5c512
authored
Apr 09, 2020
by
ibaker
Committed by
Ian Baker
Apr 09, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Tweak PassthroughSectionPayloadReader to allow timestamp to change
PiperOrigin-RevId: 305674374
parent
d9a8622b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
15 deletions
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/PassthroughSectionPayloadReader.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/PassthroughSectionPayloadReader.java
View file @
dfd5c512
...
...
@@ -33,10 +33,9 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
*/
public
final
class
PassthroughSectionPayloadReader
implements
SectionPayloadReader
{
private
final
String
mimeType
;
private
Format
format
;
private
@MonotonicNonNull
TimestampAdjuster
timestampAdjuster
;
private
@MonotonicNonNull
TrackOutput
output
;
private
boolean
formatOutputWithTimestampAdjustment
;
/**
* Create a new PassthroughSectionPayloadReader.
...
...
@@ -44,7 +43,7 @@ public final class PassthroughSectionPayloadReader implements SectionPayloadRead
* @param mimeType The MIME type set as {@link Format#sampleMimeType} on the created output track.
*/
public
PassthroughSectionPayloadReader
(
String
mimeType
)
{
this
.
mimeType
=
mimeType
;
this
.
format
=
new
Format
.
Builder
().
setSampleMimeType
(
mimeType
).
build
()
;
}
@Override
...
...
@@ -57,23 +56,20 @@ public final class PassthroughSectionPayloadReader implements SectionPayloadRead
output
=
extractorOutput
.
track
(
idGenerator
.
getTrackId
(),
C
.
TRACK_TYPE_METADATA
);
// Eagerly output an incomplete format (missing timestamp offset) to ensure source preparation
// is not blocked waiting for potentially sparse metadata.
output
.
format
(
new
Format
.
Builder
().
setSampleMimeType
(
mimeType
).
build
()
);
output
.
format
(
format
);
}
@Override
public
void
consume
(
ParsableByteArray
sectionData
)
{
assertInitialized
();
if
(!
formatOutputWithTimestampAdjustment
)
{
if
(
timestampAdjuster
.
getTimestampOffsetUs
()
==
C
.
TIME_UNSET
)
{
// There is not enough information to initialize the timestamp adjuster.
return
;
}
output
.
format
(
new
Format
.
Builder
()
.
setSampleMimeType
(
mimeType
)
.
setSubsampleOffsetUs
(
timestampAdjuster
.
getTimestampOffsetUs
())
.
build
());
formatOutputWithTimestampAdjustment
=
true
;
long
subsampleOffsetUs
=
timestampAdjuster
.
getTimestampOffsetUs
();
if
(
subsampleOffsetUs
==
C
.
TIME_UNSET
)
{
// Don't output samples without a known subsample offset.
return
;
}
if
(
subsampleOffsetUs
!=
format
.
subsampleOffsetUs
)
{
format
=
format
.
buildUpon
().
setSubsampleOffsetUs
(
subsampleOffsetUs
).
build
();
output
.
format
(
format
);
}
int
sampleSize
=
sectionData
.
bytesLeft
();
output
.
sampleData
(
sectionData
,
sampleSize
);
...
...
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