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
5c0745ce
authored
Sep 07, 2015
by
Oliver Woodman
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add some generally useful error propagation logic for HLS.
Issue #765
parent
fb8f0113
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
0 deletions
library/src/main/java/com/google/android/exoplayer/hls/HlsChunkSource.java
library/src/main/java/com/google/android/exoplayer/hls/HlsSampleSource.java
library/src/main/java/com/google/android/exoplayer/hls/HlsChunkSource.java
View file @
5c0745ce
...
@@ -138,6 +138,7 @@ public class HlsChunkSource {
...
@@ -138,6 +138,7 @@ public class HlsChunkSource {
private
byte
[]
scratchSpace
;
private
byte
[]
scratchSpace
;
private
boolean
live
;
private
boolean
live
;
private
long
durationUs
;
private
long
durationUs
;
private
IOException
fatalError
;
private
Uri
encryptionKeyUri
;
private
Uri
encryptionKeyUri
;
private
byte
[]
encryptionKey
;
private
byte
[]
encryptionKey
;
...
@@ -224,6 +225,18 @@ public class HlsChunkSource {
...
@@ -224,6 +225,18 @@ public class HlsChunkSource {
}
}
/**
/**
* If the source is currently having difficulty providing chunks, then this method throws the
* underlying error. Otherwise does nothing.
*
* @throws IOException The underlying error.
*/
public
void
maybeThrowError
()
throws
IOException
{
if
(
fatalError
!=
null
)
{
throw
fatalError
;
}
}
/**
* Returns the next {@link Chunk} that should be loaded.
* Returns the next {@link Chunk} that should be loaded.
*
*
* @param previousTsChunk The previously loaded chunk that the next chunk should follow.
* @param previousTsChunk The previously loaded chunk that the next chunk should follow.
...
@@ -262,9 +275,15 @@ public class HlsChunkSource {
...
@@ -262,9 +275,15 @@ public class HlsChunkSource {
chunkMediaSequence
=
switchingVariantSpliced
chunkMediaSequence
=
switchingVariantSpliced
?
previousTsChunk
.
chunkIndex
:
previousTsChunk
.
chunkIndex
+
1
;
?
previousTsChunk
.
chunkIndex
:
previousTsChunk
.
chunkIndex
+
1
;
if
(
chunkMediaSequence
<
mediaPlaylist
.
mediaSequence
)
{
if
(
chunkMediaSequence
<
mediaPlaylist
.
mediaSequence
)
{
// TODO: Decide what we want to do with: https://github.com/google/ExoPlayer/issues/765
// if (allowSkipAhead) {
// If the chunk is no longer in the playlist. Skip ahead and start again.
// If the chunk is no longer in the playlist. Skip ahead and start again.
chunkMediaSequence
=
getLiveStartChunkMediaSequence
(
nextVariantIndex
);
chunkMediaSequence
=
getLiveStartChunkMediaSequence
(
nextVariantIndex
);
liveDiscontinuity
=
true
;
liveDiscontinuity
=
true
;
// } else {
// fatalError = new BehindLiveWindowException();
// return null;
// }
}
}
}
}
}
else
{
}
else
{
...
@@ -414,6 +433,10 @@ public class HlsChunkSource {
...
@@ -414,6 +433,10 @@ public class HlsChunkSource {
return
false
;
return
false
;
}
}
public
void
reset
()
{
fatalError
=
null
;
}
private
int
getNextVariantIndex
(
TsChunk
previousTsChunk
,
long
playbackPositionUs
)
{
private
int
getNextVariantIndex
(
TsChunk
previousTsChunk
,
long
playbackPositionUs
)
{
clearStaleBlacklistedVariants
();
clearStaleBlacklistedVariants
();
long
bitrateEstimate
=
bandwidthMeter
.
getBitrateEstimate
();
long
bitrateEstimate
=
bandwidthMeter
.
getBitrateEstimate
();
...
...
library/src/main/java/com/google/android/exoplayer/hls/HlsSampleSource.java
View file @
5c0745ce
...
@@ -206,6 +206,7 @@ public final class HlsSampleSource implements SampleSource, SampleSourceReader,
...
@@ -206,6 +206,7 @@ public final class HlsSampleSource implements SampleSource, SampleSourceReader,
enabledTrackCount
--;
enabledTrackCount
--;
trackEnabledStates
[
track
]
=
false
;
trackEnabledStates
[
track
]
=
false
;
if
(
enabledTrackCount
==
0
)
{
if
(
enabledTrackCount
==
0
)
{
chunkSource
.
reset
();
downstreamPositionUs
=
Long
.
MIN_VALUE
;
downstreamPositionUs
=
Long
.
MIN_VALUE
;
if
(
loadControlRegistered
)
{
if
(
loadControlRegistered
)
{
loadControl
.
unregister
(
this
);
loadControl
.
unregister
(
this
);
...
@@ -317,6 +318,8 @@ public final class HlsSampleSource implements SampleSource, SampleSourceReader,
...
@@ -317,6 +318,8 @@ public final class HlsSampleSource implements SampleSource, SampleSourceReader,
public
void
maybeThrowError
()
throws
IOException
{
public
void
maybeThrowError
()
throws
IOException
{
if
(
currentLoadableException
!=
null
&&
currentLoadableExceptionCount
>
minLoadableRetryCount
)
{
if
(
currentLoadableException
!=
null
&&
currentLoadableExceptionCount
>
minLoadableRetryCount
)
{
throw
currentLoadableException
;
throw
currentLoadableException
;
}
else
if
(
currentLoadable
==
null
)
{
chunkSource
.
maybeThrowError
();
}
}
}
}
...
...
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