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
da656e6f
authored
Apr 11, 2015
by
Oliver Woodman
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
More steps towards unified extractors.
parent
53a47524
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
14 deletions
library/src/main/java/com/google/android/exoplayer/extractor/DefaultTrackOutput.java
library/src/main/java/com/google/android/exoplayer/extractor/RollingSampleBuffer.java
library/src/main/java/com/google/android/exoplayer/hls/HlsExtractorWrapper.java
library/src/main/java/com/google/android/exoplayer/hls/HlsSampleSource.java
library/src/main/java/com/google/android/exoplayer/extractor/DefaultTrackOutput.java
View file @
da656e6f
...
...
@@ -24,9 +24,8 @@ import com.google.android.exoplayer.util.ParsableByteArray;
import
java.io.IOException
;
/**
* Wraps a {@link RollingSampleBuffer}, adding higher level functionality such as enforcing that
* the first sample returned from the queue is a keyframe, allowing splicing to another queue, and
* so on.
* A {@link TrackOutput} that buffers extracted samples in a queue, and allows for consumption from
* that queue.
*/
public
final
class
DefaultTrackOutput
implements
TrackOutput
{
...
...
@@ -51,27 +50,60 @@ public final class DefaultTrackOutput implements TrackOutput {
largestParsedTimestampUs
=
Long
.
MIN_VALUE
;
}
public
void
release
()
{
rollingBuffer
.
release
();
// Called by the consuming thread, but only when there is no loading thread.
/**
* Clears the queue, returning all allocations to the allocator.
*/
public
void
clear
()
{
rollingBuffer
.
clear
();
needKeyframe
=
true
;
lastReadTimeUs
=
Long
.
MIN_VALUE
;
spliceOutTimeUs
=
Long
.
MIN_VALUE
;
largestParsedTimestampUs
=
Long
.
MIN_VALUE
;
}
/**
* Returns the current absolute write index.
*/
public
int
getWriteIndex
()
{
return
rollingBuffer
.
getWriteIndex
();
}
// Called by the consuming thread.
/**
* Returns the current absolute read index.
*/
public
int
getReadIndex
()
{
return
rollingBuffer
.
getReadIndex
();
}
/**
* True if the output has received a format. False otherwise.
*/
public
boolean
hasFormat
()
{
return
format
!=
null
;
}
/**
* The format most recently received by the output, or null if a format has yet to be received.
*/
public
MediaFormat
getFormat
()
{
return
format
;
}
/**
* The largest timestamp of any sample received by the output, or {@link Long#MIN_VALUE} if a
* sample has yet to be received.
*/
public
long
getLargestParsedTimestampUs
()
{
return
largestParsedTimestampUs
;
}
/**
* True if at least one sample can be read from the queue. False otherwise.
*/
public
boolean
isEmpty
()
{
return
!
advanceToEligibleSample
();
}
...
...
library/src/main/java/com/google/android/exoplayer/extractor/RollingSampleBuffer.java
View file @
da656e6f
This diff is collapsed.
Click to expand it.
library/src/main/java/com/google/android/exoplayer/hls/HlsExtractorWrapper.java
View file @
da656e6f
...
...
@@ -125,13 +125,11 @@ public final class HlsExtractorWrapper implements ExtractorOutput {
}
/**
* Releases the extractor, recycling any pending or incomplete samples to the sample pool.
* <p>
* This method should not be called whilst {@link #read(ExtractorInput)} is also being invoked.
* Clears queues for all tracks, returning all allocations to the buffer pool.
*/
public
void
release
()
{
public
void
clear
()
{
for
(
int
i
=
0
;
i
<
sampleQueues
.
size
();
i
++)
{
sampleQueues
.
valueAt
(
i
).
release
();
sampleQueues
.
valueAt
(
i
).
clear
();
}
}
...
...
@@ -140,7 +138,7 @@ public final class HlsExtractorWrapper implements ExtractorOutput {
*
* @return The largest timestamp, or {@link Long#MIN_VALUE} if no samples have been parsed.
*/
public
long
getLargest
SampleTimestamp
()
{
public
long
getLargest
ParsedTimestampUs
()
{
long
largestParsedTimestampUs
=
Long
.
MIN_VALUE
;
for
(
int
i
=
0
;
i
<
sampleQueues
.
size
();
i
++)
{
largestParsedTimestampUs
=
Math
.
max
(
largestParsedTimestampUs
,
...
...
library/src/main/java/com/google/android/exoplayer/hls/HlsSampleSource.java
View file @
da656e6f
...
...
@@ -261,7 +261,7 @@ public class HlsSampleSource implements SampleSource, Loader.Callback {
}
else
if
(
loadingFinished
)
{
return
TrackRenderer
.
END_OF_TRACK_US
;
}
else
{
long
largestSampleTimestamp
=
extractors
.
getLast
().
getLargest
SampleTimestamp
();
long
largestSampleTimestamp
=
extractors
.
getLast
().
getLargest
ParsedTimestampUs
();
return
largestSampleTimestamp
==
Long
.
MIN_VALUE
?
downstreamPositionUs
:
largestSampleTimestamp
;
}
...
...
@@ -333,7 +333,7 @@ public class HlsSampleSource implements SampleSource, Loader.Callback {
HlsExtractorWrapper
extractor
=
extractors
.
getFirst
();
while
(
extractors
.
size
()
>
1
&&
!
haveSamplesForEnabledTracks
(
extractor
))
{
// We're finished reading from the extractor for all tracks, and so can discard it.
extractors
.
removeFirst
().
release
();
extractors
.
removeFirst
().
clear
();
extractor
=
extractors
.
getFirst
();
}
return
extractor
;
...
...
@@ -382,7 +382,7 @@ public class HlsSampleSource implements SampleSource, Loader.Callback {
private
void
clearState
()
{
for
(
int
i
=
0
;
i
<
extractors
.
size
();
i
++)
{
extractors
.
get
(
i
).
release
();
extractors
.
get
(
i
).
clear
();
}
extractors
.
clear
();
clearCurrentLoadable
();
...
...
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