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
ebe9ae6b
authored
Jul 16, 2015
by
Oliver Woodman
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
In continueBuffering, return whether a particular track has samples.
Issue: #595
parent
17c1b630
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
44 additions
and
46 deletions
extensions/opus/src/main/java/com/google/android/exoplayer/ext/opus/LibopusAudioTrackRenderer.java
extensions/vp9/src/main/java/com/google/android/exoplayer/ext/vp9/LibvpxVideoTrackRenderer.java
library/src/main/java/com/google/android/exoplayer/FrameworkSampleSource.java
library/src/main/java/com/google/android/exoplayer/MediaCodecTrackRenderer.java
library/src/main/java/com/google/android/exoplayer/SampleSource.java
library/src/main/java/com/google/android/exoplayer/chunk/ChunkSampleSource.java
library/src/main/java/com/google/android/exoplayer/extractor/ExtractorSampleSource.java
library/src/main/java/com/google/android/exoplayer/hls/HlsSampleSource.java
library/src/main/java/com/google/android/exoplayer/metadata/MetadataTrackRenderer.java
library/src/main/java/com/google/android/exoplayer/text/TextTrackRenderer.java
library/src/main/java/com/google/android/exoplayer/text/eia608/Eia608TrackRenderer.java
extensions/opus/src/main/java/com/google/android/exoplayer/ext/opus/LibopusAudioTrackRenderer.java
View file @
ebe9ae6b
...
...
@@ -153,7 +153,7 @@ public class LibopusAudioTrackRenderer extends TrackRenderer implements MediaClo
return
;
}
try
{
sourceIsReady
=
source
.
continueBuffering
(
positionUs
);
sourceIsReady
=
source
.
continueBuffering
(
trackIndex
,
positionUs
);
checkForDiscontinuity
();
if
(
format
==
null
)
{
readFormat
();
...
...
extensions/vp9/src/main/java/com/google/android/exoplayer/ext/vp9/LibvpxVideoTrackRenderer.java
View file @
ebe9ae6b
...
...
@@ -179,7 +179,7 @@ public class LibvpxVideoTrackRenderer extends TrackRenderer {
return
;
}
try
{
sourceIsReady
=
source
.
continueBuffering
(
positionUs
);
sourceIsReady
=
source
.
continueBuffering
(
trackIndex
,
positionUs
);
checkForDiscontinuity
(
positionUs
);
if
(
format
==
null
)
{
readFormat
(
positionUs
);
...
...
library/src/main/java/com/google/android/exoplayer/FrameworkSampleSource.java
View file @
ebe9ae6b
...
...
@@ -174,7 +174,7 @@ public final class FrameworkSampleSource implements SampleSource, SampleSourceRe
}
@Override
public
boolean
continueBuffering
(
long
positionUs
)
{
public
boolean
continueBuffering
(
int
track
,
long
positionUs
)
{
// MediaExtractor takes care of buffering and blocks until it has samples, so we can always
// return true here. Although note that the blocking behavior is itself as bug, as per the
// TODO further up this file. This method will need to return something else as part of fixing
...
...
library/src/main/java/com/google/android/exoplayer/MediaCodecTrackRenderer.java
View file @
ebe9ae6b
...
...
@@ -490,7 +490,7 @@ public abstract class MediaCodecTrackRenderer extends TrackRenderer {
@Override
protected
void
doSomeWork
(
long
positionUs
,
long
elapsedRealtimeUs
)
throws
ExoPlaybackException
{
try
{
sourceState
=
source
.
continueBuffering
(
positionUs
)
sourceState
=
source
.
continueBuffering
(
trackIndex
,
positionUs
)
?
(
sourceState
==
SOURCE_STATE_NOT_READY
?
SOURCE_STATE_READY
:
sourceState
)
:
SOURCE_STATE_NOT_READY
;
checkForDiscontinuity
(
positionUs
);
...
...
library/src/main/java/com/google/android/exoplayer/SampleSource.java
View file @
ebe9ae6b
...
...
@@ -117,14 +117,15 @@ public interface SampleSource {
public
void
disable
(
int
track
);
/**
* Indicates to the source that it should still be buffering data.
* Indicates to the source that it should still be buffering data
for the specified track
.
*
* @param track The track to continue buffering.
* @param positionUs The current playback position.
* @return True if the
source
has available samples, or if the end of the stream has been
* @return True if the
track
has available samples, or if the end of the stream has been
* reached. False if more data needs to be buffered for samples to become available.
* @throws IOException If an error occurred reading from the source.
*/
public
boolean
continueBuffering
(
long
positionUs
)
throws
IOException
;
public
boolean
continueBuffering
(
int
track
,
long
positionUs
)
throws
IOException
;
/**
* Attempts to read either a sample, a new format or or a discontinuity from the source.
...
...
library/src/main/java/com/google/android/exoplayer/chunk/ChunkSampleSource.java
View file @
ebe9ae6b
...
...
@@ -188,8 +188,9 @@ public class ChunkSampleSource implements SampleSource, SampleSourceReader, Load
}
@Override
public
boolean
continueBuffering
(
long
positionUs
)
throws
IOException
{
public
boolean
continueBuffering
(
int
track
,
long
positionUs
)
throws
IOException
{
Assertions
.
checkState
(
state
==
STATE_ENABLED
);
Assertions
.
checkState
(
track
==
0
);
downstreamPositionUs
=
positionUs
;
chunkSource
.
continueBuffering
(
positionUs
);
updateLoadControl
();
...
...
library/src/main/java/com/google/android/exoplayer/extractor/ExtractorSampleSource.java
View file @
ebe9ae6b
...
...
@@ -180,7 +180,7 @@ public class ExtractorSampleSource implements SampleSource, SampleSourceReader,
loader
=
new
Loader
(
"Loader:ExtractorSampleSource"
);
}
continueBufferingInternal
();
maybeStartLoading
();
if
(
seekMap
!=
null
&&
tracksBuilt
&&
haveFormatsForAllTracks
())
{
int
trackCount
=
sampleQueues
.
size
();
...
...
@@ -246,12 +246,23 @@ public class ExtractorSampleSource implements SampleSource, SampleSourceReader,
}
@Override
public
boolean
continueBuffering
(
long
playbackPositionUs
)
throws
IOException
{
public
boolean
continueBuffering
(
int
track
,
long
playbackPositionUs
)
throws
IOException
{
Assertions
.
checkState
(
prepared
);
Assertions
.
checkState
(
enabledTrackCount
>
0
);
Assertions
.
checkState
(
trackEnabledStates
[
track
]
);
downstreamPositionUs
=
playbackPositionUs
;
discardSamplesForDisabledTracks
(
downstreamPositionUs
);
return
loadingFinished
||
continueBufferingInternal
();
if
(
loadingFinished
)
{
return
true
;
}
maybeStartLoading
();
if
(
isPendingReset
())
{
return
false
;
}
if
(
sampleQueues
.
valueAt
(
track
).
isEmpty
())
{
maybeThrowLoadableException
();
return
false
;
}
return
true
;
}
@Override
...
...
@@ -411,18 +422,6 @@ public class ExtractorSampleSource implements SampleSource, SampleSourceReader,
// Internal stuff.
private
boolean
continueBufferingInternal
()
throws
IOException
{
maybeStartLoading
();
if
(
isPendingReset
())
{
return
false
;
}
boolean
haveSamples
=
prepared
&&
haveSampleForOneEnabledTrack
();
if
(!
haveSamples
)
{
maybeThrowLoadableException
();
}
return
haveSamples
;
}
private
void
restartFrom
(
long
positionUs
)
{
pendingResetPositionUs
=
positionUs
;
loadingFinished
=
false
;
...
...
@@ -532,15 +531,6 @@ public class ExtractorSampleSource implements SampleSource, SampleSourceReader,
return
true
;
}
private
boolean
haveSampleForOneEnabledTrack
()
{
for
(
int
i
=
0
;
i
<
trackEnabledStates
.
length
;
i
++)
{
if
(
trackEnabledStates
[
i
]
&&
!
sampleQueues
.
valueAt
(
i
).
isEmpty
())
{
return
true
;
}
}
return
false
;
}
private
void
discardSamplesForDisabledTracks
(
long
timeUs
)
{
for
(
int
i
=
0
;
i
<
trackEnabledStates
.
length
;
i
++)
{
if
(!
trackEnabledStates
[
i
])
{
...
...
library/src/main/java/com/google/android/exoplayer/hls/HlsSampleSource.java
View file @
ebe9ae6b
...
...
@@ -218,26 +218,32 @@ public class HlsSampleSource implements SampleSource, SampleSourceReader, Loader
}
@Override
public
boolean
continueBuffering
(
long
playbackPositionUs
)
throws
IOException
{
public
boolean
continueBuffering
(
int
track
,
long
playbackPositionUs
)
throws
IOException
{
Assertions
.
checkState
(
prepared
);
Assertions
.
checkState
(
enabledTrackCount
>
0
);
Assertions
.
checkState
(
trackEnabledStates
[
track
]
);
downstreamPositionUs
=
playbackPositionUs
;
if
(!
extractors
.
isEmpty
())
{
discardSamplesForDisabledTracks
(
getCurrentExtractor
(),
downstreamPositionUs
);
}
return
loadingFinished
||
continueBufferingInternal
();
}
private
boolean
continueBufferingInternal
()
throws
IOException
{
if
(
loadingFinished
)
{
return
true
;
}
maybeStartLoading
();
if
(
isPendingReset
()
||
extractors
.
isEmpty
())
{
return
false
;
}
boolean
haveSamples
=
prepared
&&
haveSamplesForEnabledTracks
(
getCurrentExtractor
());
if
(!
haveSamples
)
{
maybeThrowLoadableException
();
for
(
int
extractorIndex
=
0
;
extractorIndex
<
extractors
.
size
();
extractorIndex
++)
{
HlsExtractorWrapper
extractor
=
extractors
.
get
(
extractorIndex
);
if
(!
extractor
.
isPrepared
())
{
break
;
}
if
(
extractor
.
hasSamples
(
track
))
{
return
true
;
}
}
return
haveSamples
;
maybeThrowLoadableException
();
return
false
;
}
@Override
...
...
library/src/main/java/com/google/android/exoplayer/metadata/MetadataTrackRenderer.java
View file @
ebe9ae6b
...
...
@@ -129,7 +129,7 @@ public class MetadataTrackRenderer<T> extends TrackRenderer implements Callback
protected
void
doSomeWork
(
long
positionUs
,
long
elapsedRealtimeUs
)
throws
ExoPlaybackException
{
try
{
source
.
continueBuffering
(
positionUs
);
source
.
continueBuffering
(
trackIndex
,
positionUs
);
}
catch
(
IOException
e
)
{
throw
new
ExoPlaybackException
(
e
);
}
...
...
library/src/main/java/com/google/android/exoplayer/text/TextTrackRenderer.java
View file @
ebe9ae6b
...
...
@@ -129,7 +129,7 @@ public class TextTrackRenderer extends TrackRenderer implements Callback {
@Override
protected
void
doSomeWork
(
long
positionUs
,
long
elapsedRealtimeUs
)
throws
ExoPlaybackException
{
try
{
source
.
continueBuffering
(
positionUs
);
source
.
continueBuffering
(
trackIndex
,
positionUs
);
}
catch
(
IOException
e
)
{
throw
new
ExoPlaybackException
(
e
);
}
...
...
library/src/main/java/com/google/android/exoplayer/text/eia608/Eia608TrackRenderer.java
View file @
ebe9ae6b
...
...
@@ -134,7 +134,7 @@ public class Eia608TrackRenderer extends TrackRenderer implements Callback {
@Override
protected
void
doSomeWork
(
long
positionUs
,
long
elapsedRealtimeUs
)
throws
ExoPlaybackException
{
try
{
source
.
continueBuffering
(
positionUs
);
source
.
continueBuffering
(
trackIndex
,
positionUs
);
}
catch
(
IOException
e
)
{
throw
new
ExoPlaybackException
(
e
);
}
...
...
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