Deprecate LoadErrorHandlingPolicy methods without loadTaskId

Issue: #7309
PiperOrigin-RevId: 312115330
This commit is contained in:
aquilescanta 2020-05-18 19:08:06 +01:00 committed by Oliver Woodman
parent cccb9e1ae8
commit ba33f60485
3 changed files with 25 additions and 39 deletions

View file

@ -26,6 +26,11 @@
average video frame processing offset.
* Add playlist API
([#6161](https://github.com/google/ExoPlayer/issues/6161)).
* Attach an identifier and extra information to load error events passed
to `LoadErrorHandlingPolicy`. `LoadErrorHandlingPolicy` implementations
must migrate to overriding the non-deprecated methods of the interface
in preparation for deprecated methods' removal in a future ExoPlayer
version ([#7309](https://github.com/google/ExoPlayer/issues/7309)).
* Add `play` and `pause` methods to `Player`.
* Add `Player.getCurrentLiveOffset` to conveniently return the live
offset.

View file

@ -65,8 +65,8 @@ public class DefaultLoadErrorHandlingPolicy implements LoadErrorHandlingPolicy {
* code HTTP 404 or 410. The duration of the blacklisting is {@link #DEFAULT_TRACK_BLACKLIST_MS}.
*/
@Override
public long getBlacklistDurationMsFor(
int dataType, long loadDurationMs, IOException exception, int errorCount) {
public long getBlacklistDurationMsFor(LoadErrorInfo loadErrorInfo) {
IOException exception = loadErrorInfo.exception;
if (exception instanceof InvalidResponseCodeException) {
int responseCode = ((InvalidResponseCodeException) exception).responseCode;
return responseCode == 404 // HTTP 404 Not Found.
@ -84,13 +84,13 @@ public class DefaultLoadErrorHandlingPolicy implements LoadErrorHandlingPolicy {
* {@code Math.min((errorCount - 1) * 1000, 5000)}.
*/
@Override
public long getRetryDelayMsFor(
int dataType, long loadDurationMs, IOException exception, int errorCount) {
public long getRetryDelayMsFor(LoadErrorInfo loadErrorInfo) {
IOException exception = loadErrorInfo.exception;
return exception instanceof ParserException
|| exception instanceof FileNotFoundException
|| exception instanceof UnexpectedLoaderException
? C.TIME_UNSET
: Math.min((errorCount - 1) * 1000, 5000);
: Math.min((loadErrorInfo.errorCount - 1) * 1000, 5000);
}
/**

View file

@ -65,21 +65,12 @@ public interface LoadErrorHandlingPolicy {
}
}
/**
* Returns the number of milliseconds for which a resource associated to a provided load error
* should be blacklisted, or {@link C#TIME_UNSET} if the resource should not be blacklisted.
*
* @param dataType One of the {@link C C.DATA_TYPE_*} constants indicating the type of data to
* load.
* @param loadDurationMs The duration in milliseconds of the load from the start of the first load
* attempt up to the point at which the error occurred.
* @param exception The load error.
* @param errorCount The number of errors this load has encountered, including this one.
* @return The blacklist duration in milliseconds, or {@link C#TIME_UNSET} if the resource should
* not be blacklisted.
*/
long getBlacklistDurationMsFor(
int dataType, long loadDurationMs, IOException exception, int errorCount);
/** @deprecated Implement {@link #getBlacklistDurationMsFor(LoadErrorInfo)} instead. */
@Deprecated
default long getBlacklistDurationMsFor(
int dataType, long loadDurationMs, IOException exception, int errorCount) {
throw new UnsupportedOperationException();
}
/**
* Returns the number of milliseconds for which a resource associated to a provided load error
@ -89,6 +80,7 @@ public interface LoadErrorHandlingPolicy {
* @return The blacklist duration in milliseconds, or {@link C#TIME_UNSET} if the resource should
* not be blacklisted.
*/
@SuppressWarnings("deprecation")
default long getBlacklistDurationMsFor(LoadErrorInfo loadErrorInfo) {
return getBlacklistDurationMsFor(
loadErrorInfo.mediaLoadData.dataType,
@ -97,25 +89,13 @@ public interface LoadErrorHandlingPolicy {
loadErrorInfo.errorCount);
}
/**
* Returns the number of milliseconds to wait before attempting the load again, or {@link
* C#TIME_UNSET} if the error is fatal and should not be retried.
*
* <p>{@link Loader} clients may ignore the retry delay returned by this method in order to wait
* for a specific event before retrying. However, the load is retried if and only if this method
* does not return {@link C#TIME_UNSET}.
*
* @param dataType One of the {@link C C.DATA_TYPE_*} constants indicating the type of data to
* load.
* @param loadDurationMs The duration in milliseconds of the load from the start of the first load
* attempt up to the point at which the error occurred.
* @param exception The load error.
* @param errorCount The number of errors this load has encountered, including this one.
* @return The number of milliseconds to wait before attempting the load again, or {@link
* C#TIME_UNSET} if the error is fatal and should not be retried.
*/
long getRetryDelayMsFor(int dataType, long loadDurationMs, IOException exception, int errorCount);
/** @deprecated Implement {@link #getRetryDelayMsFor(LoadErrorInfo)} instead. */
@Deprecated
default long getRetryDelayMsFor(
int dataType, long loadDurationMs, IOException exception, int errorCount) {
throw new UnsupportedOperationException();
}
/**
* Returns the number of milliseconds to wait before attempting the load again, or {@link
* C#TIME_UNSET} if the error is fatal and should not be retried.
@ -128,6 +108,7 @@ public interface LoadErrorHandlingPolicy {
* @return The number of milliseconds to wait before attempting the load again, or {@link
* C#TIME_UNSET} if the error is fatal and should not be retried.
*/
@SuppressWarnings("deprecation")
default long getRetryDelayMsFor(LoadErrorInfo loadErrorInfo) {
return getRetryDelayMsFor(
loadErrorInfo.mediaLoadData.dataType,