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
dda1d373
authored
Jul 01, 2021
by
claincly
Committed by
kim-vde
Jul 09, 2021
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Make HttpDataSourceException subclass DataSourceException.
PiperOrigin-RevId: 382551642
parent
b0ddef5b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
95 additions
and
28 deletions
library/common/src/main/java/com/google/android/exoplayer2/upstream/DataSourceException.java
library/common/src/main/java/com/google/android/exoplayer2/upstream/HttpDataSource.java
library/common/src/main/java/com/google/android/exoplayer2/upstream/DataSourceException.java
View file @
dda1d373
...
@@ -15,11 +15,31 @@
...
@@ -15,11 +15,31 @@
*/
*/
package
com
.
google
.
android
.
exoplayer2
.
upstream
;
package
com
.
google
.
android
.
exoplayer2
.
upstream
;
import
androidx.annotation.IntDef
;
import
androidx.annotation.Nullable
;
import
androidx.annotation.Nullable
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.lang.annotation.Documented
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
/** Used to specify reason of a DataSource error. */
/** Used to specify reason of a DataSource error. */
public
final
class
DataSourceException
extends
IOException
{
public
class
DataSourceException
extends
IOException
{
/**
* The type of operation that produced the error. One of {@link #TYPE_READ}, {@link #TYPE_OPEN}
* {@link #TYPE_CLOSE}.
*/
@Documented
@Retention
(
RetentionPolicy
.
SOURCE
)
@IntDef
({
TYPE_OPEN
,
TYPE_READ
,
TYPE_CLOSE
})
public
@interface
Type
{}
/** The error occurred reading data from a {@link DataSource}. */
public
static
final
int
TYPE_OPEN
=
1
;
/** The error occurred in opening a {@link DataSource}. */
public
static
final
int
TYPE_READ
=
2
;
/** The error occurred in closing a {@link DataSource}. */
public
static
final
int
TYPE_CLOSE
=
3
;
/**
/**
* Returns whether the given {@link IOException} was caused by a {@link DataSourceException} whose
* Returns whether the given {@link IOException} was caused by a {@link DataSourceException} whose
...
@@ -45,17 +65,83 @@ public final class DataSourceException extends IOException {
...
@@ -45,17 +65,83 @@ public final class DataSourceException extends IOException {
*/
*/
public
static
final
int
POSITION_OUT_OF_RANGE
=
0
;
public
static
final
int
POSITION_OUT_OF_RANGE
=
0
;
/** Indicates that the error reason is unknown. */
public
static
final
int
REASON_UNKNOWN
=
1
;
/**
/**
* The reason of this {@link DataSourceException}. It can only be {@link #POSITION_OUT_OF_RANGE}.
* The reason of this {@link DataSourceException}. It can only be {@link #POSITION_OUT_OF_RANGE},
* or {@link #REASON_UNKNOWN}.
*/
*/
public
final
int
reason
;
public
final
int
reason
;
/** The {@link Type} of the operation that caused the playback failure. */
@Type
public
final
int
type
;
/**
/**
* Constructs a DataSourceException.
* Constructs a DataSourceException
with type {@link #TYPE_READ}
.
*
*
* @param reason Reason of the error. It can only be {@link #POSITION_OUT_OF_RANGE}.
* @deprecated Use the constructor {@link #DataSourceException(String, Throwable, int, int)}.
* @param reason Reason of the error. It can only be {@link #POSITION_OUT_OF_RANGE} or {@link
* #REASON_UNKNOWN}.
*/
*/
@Deprecated
public
DataSourceException
(
int
reason
)
{
public
DataSourceException
(
int
reason
)
{
this
.
reason
=
reason
;
this
.
reason
=
reason
;
this
.
type
=
TYPE_READ
;
}
/**
* Constructs a DataSourceException.
*
* @param message The error message.
* @param cause The error cause.
* @param reason Reason of the error. It can only be {@link #POSITION_OUT_OF_RANGE} or {@link
* #REASON_UNKNOWN}.
* @param type See {@link Type}.
*/
public
DataSourceException
(
String
message
,
Throwable
cause
,
int
reason
,
@Type
int
type
)
{
super
(
message
,
cause
);
this
.
reason
=
reason
;
this
.
type
=
type
;
}
/**
* Constructs a DataSourceException.
*
* @param cause The error cause.
* @param reason Reason of the error. It can only be {@link #POSITION_OUT_OF_RANGE} or {@link
* #REASON_UNKNOWN}.
* @param type See {@link Type}.
*/
public
DataSourceException
(
Throwable
cause
,
int
reason
,
@Type
int
type
)
{
super
(
cause
);
this
.
reason
=
reason
;
this
.
type
=
type
;
}
/**
* Constructs a DataSourceException.
*
* @param message The error message.
* @param reason Reason of the error. It can only be {@link #POSITION_OUT_OF_RANGE} or {@link
* #REASON_UNKNOWN}.
* @param type See {@link Type}.
*/
public
DataSourceException
(
String
message
,
int
reason
,
@Type
int
type
)
{
super
(
message
);
this
.
reason
=
reason
;
this
.
type
=
type
;
}
/**
* Constructs a DataSourceException.
*
* @param reason Reason of the error. It can only be {@link #POSITION_OUT_OF_RANGE} or {@link
* #REASON_UNKNOWN}.
* @param type See {@link Type}.
*/
public
DataSourceException
(
int
reason
,
@Type
int
type
)
{
this
.
reason
=
reason
;
this
.
type
=
type
;
}
}
}
}
library/common/src/main/java/com/google/android/exoplayer2/upstream/HttpDataSource.java
View file @
dda1d373
...
@@ -16,15 +16,11 @@
...
@@ -16,15 +16,11 @@
package
com
.
google
.
android
.
exoplayer2
.
upstream
;
package
com
.
google
.
android
.
exoplayer2
.
upstream
;
import
android.text.TextUtils
;
import
android.text.TextUtils
;
import
androidx.annotation.IntDef
;
import
androidx.annotation.Nullable
;
import
androidx.annotation.Nullable
;
import
com.google.android.exoplayer2.util.Util
;
import
com.google.android.exoplayer2.util.Util
;
import
com.google.common.base.Ascii
;
import
com.google.common.base.Ascii
;
import
com.google.common.base.Predicate
;
import
com.google.common.base.Predicate
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.lang.annotation.Documented
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
...
@@ -188,45 +184,30 @@ public interface HttpDataSource extends DataSource {
...
@@ -188,45 +184,30 @@ public interface HttpDataSource extends DataSource {
};
};
/** Thrown when an error is encountered when trying to read from a {@link HttpDataSource}. */
/** Thrown when an error is encountered when trying to read from a {@link HttpDataSource}. */
class
HttpDataSourceException
extends
IOException
{
class
HttpDataSourceException
extends
DataSourceException
{
@Documented
@Retention
(
RetentionPolicy
.
SOURCE
)
@IntDef
({
TYPE_OPEN
,
TYPE_READ
,
TYPE_CLOSE
})
public
@interface
Type
{}
public
static
final
int
TYPE_OPEN
=
1
;
public
static
final
int
TYPE_READ
=
2
;
public
static
final
int
TYPE_CLOSE
=
3
;
@Type
public
final
int
type
;
/** The {@link DataSpec} associated with the current connection. */
/** The {@link DataSpec} associated with the current connection. */
public
final
DataSpec
dataSpec
;
public
final
DataSpec
dataSpec
;
public
HttpDataSourceException
(
DataSpec
dataSpec
,
@Type
int
type
)
{
public
HttpDataSourceException
(
DataSpec
dataSpec
,
@Type
int
type
)
{
super
();
super
(
REASON_UNKNOWN
,
type
);
this
.
dataSpec
=
dataSpec
;
this
.
dataSpec
=
dataSpec
;
this
.
type
=
type
;
}
}
public
HttpDataSourceException
(
String
message
,
DataSpec
dataSpec
,
@Type
int
type
)
{
public
HttpDataSourceException
(
String
message
,
DataSpec
dataSpec
,
@Type
int
type
)
{
super
(
message
);
super
(
message
,
REASON_UNKNOWN
,
type
);
this
.
dataSpec
=
dataSpec
;
this
.
dataSpec
=
dataSpec
;
this
.
type
=
type
;
}
}
public
HttpDataSourceException
(
IOException
cause
,
DataSpec
dataSpec
,
@Type
int
type
)
{
public
HttpDataSourceException
(
IOException
cause
,
DataSpec
dataSpec
,
@Type
int
type
)
{
super
(
cause
);
super
(
cause
,
REASON_UNKNOWN
,
type
);
this
.
dataSpec
=
dataSpec
;
this
.
dataSpec
=
dataSpec
;
this
.
type
=
type
;
}
}
public
HttpDataSourceException
(
public
HttpDataSourceException
(
String
message
,
IOException
cause
,
DataSpec
dataSpec
,
@Type
int
type
)
{
String
message
,
IOException
cause
,
DataSpec
dataSpec
,
@Type
int
type
)
{
super
(
message
,
cause
);
super
(
message
,
cause
,
REASON_UNKNOWN
,
type
);
this
.
dataSpec
=
dataSpec
;
this
.
dataSpec
=
dataSpec
;
this
.
type
=
type
;
}
}
}
}
...
...
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