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
758e99e3
authored
May 14, 2020
by
aquilescanta
Committed by
Oliver Woodman
May 14, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Remove last references to old load error handling methods
PiperOrigin-RevId: 311531734
parent
9e35c6c2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
16 deletions
library/core/src/test/java/com/google/android/exoplayer2/upstream/DefaultLoadErrorHandlingPolicyTest.java
library/hls/src/main/java/com/google/android/exoplayer2/source/hls/playlist/DefaultHlsPlaylistTracker.java
library/core/src/test/java/com/google/android/exoplayer2/upstream/DefaultLoadErrorHandlingPolicyTest.java
View file @
758e99e3
...
@@ -21,7 +21,10 @@ import android.net.Uri;
...
@@ -21,7 +21,10 @@ import android.net.Uri;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.ParserException
;
import
com.google.android.exoplayer2.ParserException
;
import
com.google.android.exoplayer2.source.LoadEventInfo
;
import
com.google.android.exoplayer2.source.MediaLoadData
;
import
com.google.android.exoplayer2.upstream.HttpDataSource.InvalidResponseCodeException
;
import
com.google.android.exoplayer2.upstream.HttpDataSource.InvalidResponseCodeException
;
import
com.google.android.exoplayer2.upstream.LoadErrorHandlingPolicy.LoadErrorInfo
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.Collections
;
import
java.util.Collections
;
import
org.junit.Test
;
import
org.junit.Test
;
...
@@ -31,6 +34,18 @@ import org.junit.runner.RunWith;
...
@@ -31,6 +34,18 @@ import org.junit.runner.RunWith;
@RunWith
(
AndroidJUnit4
.
class
)
@RunWith
(
AndroidJUnit4
.
class
)
public
final
class
DefaultLoadErrorHandlingPolicyTest
{
public
final
class
DefaultLoadErrorHandlingPolicyTest
{
private
static
final
LoadEventInfo
PLACEHOLDER_LOAD_EVENT_INFO
=
new
LoadEventInfo
(
LoadEventInfo
.
getNewId
(),
new
DataSpec
(
Uri
.
EMPTY
),
Uri
.
EMPTY
,
/* responseHeaders= */
Collections
.
emptyMap
(),
/* elapsedRealtimeMs= */
5000
,
/* loadDurationMs= */
1000
,
/* bytesLoaded= */
0
);
private
static
final
MediaLoadData
PLACEHOLDER_MEDIA_LOAD_DATA
=
new
MediaLoadData
(
/* dataType= */
C
.
DATA_TYPE_UNKNOWN
);
@Test
@Test
public
void
getBlacklistDurationMsFor_blacklist404
()
{
public
void
getBlacklistDurationMsFor_blacklist404
()
{
InvalidResponseCodeException
exception
=
InvalidResponseCodeException
exception
=
...
@@ -77,13 +92,19 @@ public final class DefaultLoadErrorHandlingPolicyTest {
...
@@ -77,13 +92,19 @@ public final class DefaultLoadErrorHandlingPolicyTest {
}
}
private
static
long
getDefaultPolicyBlacklistOutputFor
(
IOException
exception
)
{
private
static
long
getDefaultPolicyBlacklistOutputFor
(
IOException
exception
)
{
return
new
DefaultLoadErrorHandlingPolicy
()
LoadErrorInfo
loadErrorInfo
=
.
getBlacklistDurationMsFor
(
new
LoadErrorInfo
(
C
.
DATA_TYPE_MEDIA
,
/* loadDurationMs= */
1000
,
exception
,
/* errorCount= */
1
);
PLACEHOLDER_LOAD_EVENT_INFO
,
PLACEHOLDER_MEDIA_LOAD_DATA
,
exception
,
/* errorCount= */
1
);
return
new
DefaultLoadErrorHandlingPolicy
().
getBlacklistDurationMsFor
(
loadErrorInfo
);
}
}
private
static
long
getDefaultPolicyRetryDelayOutputFor
(
IOException
exception
,
int
errorCount
)
{
private
static
long
getDefaultPolicyRetryDelayOutputFor
(
IOException
exception
,
int
errorCount
)
{
return
new
DefaultLoadErrorHandlingPolicy
()
LoadErrorInfo
loadErrorInfo
=
.
getRetryDelayMsFor
(
C
.
DATA_TYPE_MEDIA
,
/* loadDurationMs= */
1000
,
exception
,
errorCount
);
new
LoadErrorInfo
(
PLACEHOLDER_LOAD_EVENT_INFO
,
PLACEHOLDER_MEDIA_LOAD_DATA
,
exception
,
errorCount
);
return
new
DefaultLoadErrorHandlingPolicy
().
getRetryDelayMsFor
(
loadErrorInfo
);
}
}
}
}
library/hls/src/main/java/com/google/android/exoplayer2/source/hls/playlist/DefaultHlsPlaylistTracker.java
View file @
758e99e3
...
@@ -238,12 +238,6 @@ public final class DefaultHlsPlaylistTracker
...
@@ -238,12 +238,6 @@ public final class DefaultHlsPlaylistTracker
primaryMediaPlaylistUrl
=
masterPlaylist
.
variants
.
get
(
0
).
url
;
primaryMediaPlaylistUrl
=
masterPlaylist
.
variants
.
get
(
0
).
url
;
createBundles
(
masterPlaylist
.
mediaPlaylistUrls
);
createBundles
(
masterPlaylist
.
mediaPlaylistUrls
);
MediaPlaylistBundle
primaryBundle
=
playlistBundles
.
get
(
primaryMediaPlaylistUrl
);
MediaPlaylistBundle
primaryBundle
=
playlistBundles
.
get
(
primaryMediaPlaylistUrl
);
if
(
isMediaPlaylist
)
{
// We don't need to load the playlist again. We can use the same result.
primaryBundle
.
processLoadedPlaylist
((
HlsMediaPlaylist
)
result
,
loadDurationMs
);
}
else
{
primaryBundle
.
loadPlaylist
();
}
LoadEventInfo
loadEventInfo
=
LoadEventInfo
loadEventInfo
=
new
LoadEventInfo
(
new
LoadEventInfo
(
loadable
.
loadTaskId
,
loadable
.
loadTaskId
,
...
@@ -253,6 +247,12 @@ public final class DefaultHlsPlaylistTracker
...
@@ -253,6 +247,12 @@ public final class DefaultHlsPlaylistTracker
elapsedRealtimeMs
,
elapsedRealtimeMs
,
loadDurationMs
,
loadDurationMs
,
loadable
.
bytesLoaded
());
loadable
.
bytesLoaded
());
if
(
isMediaPlaylist
)
{
// We don't need to load the playlist again. We can use the same result.
primaryBundle
.
processLoadedPlaylist
((
HlsMediaPlaylist
)
result
,
loadEventInfo
);
}
else
{
primaryBundle
.
loadPlaylist
();
}
loadErrorHandlingPolicy
.
onLoadTaskConcluded
(
loadable
.
loadTaskId
);
loadErrorHandlingPolicy
.
onLoadTaskConcluded
(
loadable
.
loadTaskId
);
eventDispatcher
.
loadCompleted
(
loadEventInfo
,
C
.
DATA_TYPE_MANIFEST
);
eventDispatcher
.
loadCompleted
(
loadEventInfo
,
C
.
DATA_TYPE_MANIFEST
);
}
}
...
@@ -540,15 +540,15 @@ public final class DefaultHlsPlaylistTracker
...
@@ -540,15 +540,15 @@ public final class DefaultHlsPlaylistTracker
elapsedRealtimeMs
,
elapsedRealtimeMs
,
loadDurationMs
,
loadDurationMs
,
loadable
.
bytesLoaded
());
loadable
.
bytesLoaded
());
loadErrorHandlingPolicy
.
onLoadTaskConcluded
(
loadable
.
loadTaskId
);
if
(
result
instanceof
HlsMediaPlaylist
)
{
if
(
result
instanceof
HlsMediaPlaylist
)
{
processLoadedPlaylist
((
HlsMediaPlaylist
)
result
,
load
DurationMs
);
processLoadedPlaylist
((
HlsMediaPlaylist
)
result
,
load
EventInfo
);
eventDispatcher
.
loadCompleted
(
loadEventInfo
,
C
.
DATA_TYPE_MANIFEST
);
eventDispatcher
.
loadCompleted
(
loadEventInfo
,
C
.
DATA_TYPE_MANIFEST
);
}
else
{
}
else
{
playlistError
=
new
ParserException
(
"Loaded playlist has unexpected type."
);
playlistError
=
new
ParserException
(
"Loaded playlist has unexpected type."
);
eventDispatcher
.
loadError
(
eventDispatcher
.
loadError
(
loadEventInfo
,
C
.
DATA_TYPE_MANIFEST
,
playlistError
,
/* wasCanceled= */
true
);
loadEventInfo
,
C
.
DATA_TYPE_MANIFEST
,
playlistError
,
/* wasCanceled= */
true
);
}
}
loadErrorHandlingPolicy
.
onLoadTaskConcluded
(
loadable
.
loadTaskId
);
}
}
@Override
@Override
...
@@ -639,7 +639,8 @@ public final class DefaultHlsPlaylistTracker
...
@@ -639,7 +639,8 @@ public final class DefaultHlsPlaylistTracker
mediaPlaylistLoadable
.
type
);
mediaPlaylistLoadable
.
type
);
}
}
private
void
processLoadedPlaylist
(
HlsMediaPlaylist
loadedPlaylist
,
long
loadDurationMs
)
{
private
void
processLoadedPlaylist
(
HlsMediaPlaylist
loadedPlaylist
,
LoadEventInfo
loadEventInfo
)
{
HlsMediaPlaylist
oldPlaylist
=
playlistSnapshot
;
HlsMediaPlaylist
oldPlaylist
=
playlistSnapshot
;
long
currentTimeMs
=
SystemClock
.
elapsedRealtime
();
long
currentTimeMs
=
SystemClock
.
elapsedRealtime
();
lastSnapshotLoadMs
=
currentTimeMs
;
lastSnapshotLoadMs
=
currentTimeMs
;
...
@@ -661,9 +662,14 @@ public final class DefaultHlsPlaylistTracker
...
@@ -661,9 +662,14 @@ public final class DefaultHlsPlaylistTracker
*
playlistStuckTargetDurationCoefficient
)
{
*
playlistStuckTargetDurationCoefficient
)
{
// TODO: Allow customization of stuck playlists handling.
// TODO: Allow customization of stuck playlists handling.
playlistError
=
new
PlaylistStuckException
(
playlistUrl
);
playlistError
=
new
PlaylistStuckException
(
playlistUrl
);
LoadErrorInfo
loadErrorInfo
=
new
LoadErrorInfo
(
loadEventInfo
,
new
MediaLoadData
(
C
.
DATA_TYPE_MANIFEST
),
playlistError
,
/* errorCount= */
1
);
long
blacklistDurationMs
=
long
blacklistDurationMs
=
loadErrorHandlingPolicy
.
getBlacklistDurationMsFor
(
loadErrorHandlingPolicy
.
getBlacklistDurationMsFor
(
loadErrorInfo
);
C
.
DATA_TYPE_MANIFEST
,
loadDurationMs
,
playlistError
,
/* errorCount= */
1
);
notifyPlaylistError
(
playlistUrl
,
blacklistDurationMs
);
notifyPlaylistError
(
playlistUrl
,
blacklistDurationMs
);
if
(
blacklistDurationMs
!=
C
.
TIME_UNSET
)
{
if
(
blacklistDurationMs
!=
C
.
TIME_UNSET
)
{
blacklistPlaylist
(
blacklistDurationMs
);
blacklistPlaylist
(
blacklistDurationMs
);
...
...
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