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
6035932f
authored
Jul 02, 2021
by
claincly
Committed by
kim-vde
Jul 09, 2021
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Make HttpDataSourceException use PlaybackException error codes.
PiperOrigin-RevId: 382710409
parent
747b0f05
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
115 additions
and
12 deletions
library/common/src/main/java/com/google/android/exoplayer2/PlaybackException.java
library/common/src/main/java/com/google/android/exoplayer2/upstream/HttpDataSource.java
library/common/src/main/java/com/google/android/exoplayer2/PlaybackException.java
View file @
6035932f
...
...
@@ -52,6 +52,7 @@ public class PlaybackException extends Exception implements Bundleable {
ERROR_CODE_IO_NETWORK_CONNECTION_FAILED
,
ERROR_CODE_IO_NETWORK_CONNECTION_TIMEOUT
,
ERROR_CODE_IO_NETWORK_CONNECTION_CLOSED
,
ERROR_CODE_IO_BAD_HTTP_REQUEST
,
ERROR_CODE_IO_BAD_HTTP_STATUS
,
ERROR_CODE_IO_DNS_FAILED
,
ERROR_CODE_IO_FILE_NOT_FOUND
,
...
...
@@ -106,17 +107,19 @@ public class PlaybackException extends Exception implements Bundleable {
public
static
final
int
ERROR_CODE_IO_NETWORK_CONNECTION_TIMEOUT
=
2003
;
/** Caused by an existing connection being unexpectedly closed. */
public
static
final
int
ERROR_CODE_IO_NETWORK_CONNECTION_CLOSED
=
2004
;
/** Caused by creating a malformed HTTP request. */
public
static
final
int
ERROR_CODE_IO_BAD_HTTP_REQUEST
=
2005
;
/** Caused by an HTTP server returning an unexpected HTTP response status code. */
public
static
final
int
ERROR_CODE_IO_BAD_HTTP_STATUS
=
200
5
;
public
static
final
int
ERROR_CODE_IO_BAD_HTTP_STATUS
=
200
6
;
/** Caused by the player failing to resolve a hostname. */
public
static
final
int
ERROR_CODE_IO_DNS_FAILED
=
200
6
;
public
static
final
int
ERROR_CODE_IO_DNS_FAILED
=
200
7
;
/** Caused by a non-existent file. */
public
static
final
int
ERROR_CODE_IO_FILE_NOT_FOUND
=
200
7
;
public
static
final
int
ERROR_CODE_IO_FILE_NOT_FOUND
=
200
8
;
/**
* Caused by lack of permission to perform an IO operation. For example, lack of permission to
* access internet or external storage.
*/
public
static
final
int
ERROR_CODE_IO_NO_PERMISSION
=
200
8
;
public
static
final
int
ERROR_CODE_IO_NO_PERMISSION
=
200
9
;
/**
* Caused by the player trying to access cleartext HTTP traffic (meaning http:// rather than
* https://) when the app's Network Security Configuration does not permit it.
...
...
@@ -124,9 +127,9 @@ public class PlaybackException extends Exception implements Bundleable {
* <p>See <a href="https://exoplayer.dev/issues/cleartext-not-permitted">this corresponding
* troubleshooting topic</a>.
*/
public
static
final
int
ERROR_CODE_IO_CLEARTEXT_NOT_PERMITTED
=
20
09
;
public
static
final
int
ERROR_CODE_IO_CLEARTEXT_NOT_PERMITTED
=
20
10
;
/** Caused by reading data out of the data bound. */
public
static
final
int
ERROR_CODE_IO_READ_POSITION_OUT_OF_RANGE
=
201
0
;
public
static
final
int
ERROR_CODE_IO_READ_POSITION_OUT_OF_RANGE
=
201
1
;
// Content parsing errors (3xxx).
...
...
@@ -217,6 +220,8 @@ public class PlaybackException extends Exception implements Bundleable {
return
"ERROR_CODE_IO_NETWORK_CONNECTION_TIMEOUT"
;
case
ERROR_CODE_IO_NETWORK_CONNECTION_CLOSED:
return
"ERROR_CODE_IO_NETWORK_CONNECTION_CLOSED"
;
case
ERROR_CODE_IO_BAD_HTTP_REQUEST:
return
"ERROR_CODE_IO_BAD_HTTP_REQUEST"
;
case
ERROR_CODE_IO_BAD_HTTP_STATUS:
return
"ERROR_CODE_IO_BAD_HTTP_STATUS"
;
case
ERROR_CODE_IO_DNS_FAILED:
...
...
library/common/src/main/java/com/google/android/exoplayer2/upstream/HttpDataSource.java
View file @
6035932f
...
...
@@ -190,24 +190,113 @@ public interface HttpDataSource extends DataSource {
/** The {@link DataSpec} associated with the current connection. */
public
final
DataSpec
dataSpec
;
/**
* @deprecated Use {@link #HttpDataSourceException(DataSpec, int, int)
* HttpDataSourceException(DataSpec, PlaybackException.ERROR_CODE_IO_UNSPECIFIED, int)}.
*/
@Deprecated
public
HttpDataSourceException
(
DataSpec
dataSpec
,
@Type
int
type
)
{
super
(
PlaybackException
.
ERROR_CODE_IO_UNSPECIFIED
,
type
);
this
(
dataSpec
,
PlaybackException
.
ERROR_CODE_IO_UNSPECIFIED
,
type
);
}
/**
* Constructs an HttpDataSourceException.
*
* @param dataSpec The {@link DataSpec}.
* @param errorCode Reason of the error, should be one of the {@code ERROR_CODE_IO_*} in {@link
* PlaybackException.ErrorCode}.
* @param type See {@link Type}.
*/
public
HttpDataSourceException
(
DataSpec
dataSpec
,
@PlaybackException
.
ErrorCode
int
errorCode
,
@Type
int
type
)
{
super
(
errorCode
,
type
);
this
.
dataSpec
=
dataSpec
;
}
/**
* @deprecated Use {@link #HttpDataSourceException(String, DataSpec, int, int)
* HttpDataSourceException(String, DataSpec, PlaybackException.ERROR_CODE_IO_UNSPECIFIED,
* int)}.
*/
@Deprecated
public
HttpDataSourceException
(
String
message
,
DataSpec
dataSpec
,
@Type
int
type
)
{
super
(
message
,
PlaybackException
.
ERROR_CODE_IO_UNSPECIFIED
,
type
);
this
(
message
,
dataSpec
,
PlaybackException
.
ERROR_CODE_IO_UNSPECIFIED
,
type
);
}
/**
* Constructs an HttpDataSourceException.
*
* @param message The error message.
* @param dataSpec The {@link DataSpec}.
* @param errorCode Reason of the error, should be one of the {@code ERROR_CODE_IO_*} in {@link
* PlaybackException.ErrorCode}.
* @param type See {@link Type}.
*/
public
HttpDataSourceException
(
String
message
,
DataSpec
dataSpec
,
@PlaybackException
.
ErrorCode
int
errorCode
,
@Type
int
type
)
{
super
(
message
,
errorCode
,
type
);
this
.
dataSpec
=
dataSpec
;
}
/**
* @deprecated Use {@link #HttpDataSourceException(IOException, DataSpec, int, int)
* HttpDataSourceException(IOException, DataSpec,
* PlaybackException.ERROR_CODE_IO_UNSPECIFIED, int)}.
*/
@Deprecated
public
HttpDataSourceException
(
IOException
cause
,
DataSpec
dataSpec
,
@Type
int
type
)
{
super
(
cause
,
PlaybackException
.
ERROR_CODE_IO_UNSPECIFIED
,
type
);
this
(
cause
,
dataSpec
,
PlaybackException
.
ERROR_CODE_IO_UNSPECIFIED
,
type
);
}
/**
* Constructs an HttpDataSourceException.
*
* @param cause The error cause.
* @param dataSpec The {@link DataSpec}.
* @param errorCode Reason of the error, should be one of the {@code ERROR_CODE_IO_*} in {@link
* PlaybackException.ErrorCode}.
* @param type See {@link Type}.
*/
public
HttpDataSourceException
(
IOException
cause
,
DataSpec
dataSpec
,
@PlaybackException
.
ErrorCode
int
errorCode
,
@Type
int
type
)
{
super
(
cause
,
errorCode
,
type
);
this
.
dataSpec
=
dataSpec
;
}
/**
* @deprecated Use {@link #HttpDataSourceException(String, IOException, DataSpec, int, int)
* HttpDataSourceException(String, IOException, DataSpec,
* PlaybackException.ERROR_CODE_IO_UNSPECIFIED, int)}.
*/
@Deprecated
public
HttpDataSourceException
(
String
message
,
IOException
cause
,
DataSpec
dataSpec
,
@Type
int
type
)
{
super
(
message
,
cause
,
PlaybackException
.
ERROR_CODE_IO_UNSPECIFIED
,
type
);
this
(
message
,
cause
,
dataSpec
,
PlaybackException
.
ERROR_CODE_IO_UNSPECIFIED
,
type
);
}
/**
* Constructs an HttpDataSourceException.
*
* @param message The error message.
* @param cause The error cause.
* @param dataSpec The {@link DataSpec}.
* @param errorCode Reason of the error, should be one of the {@code ERROR_CODE_IO_*} in {@link
* PlaybackException.ErrorCode}.
* @param type See {@link Type}.
*/
public
HttpDataSourceException
(
String
message
,
IOException
cause
,
DataSpec
dataSpec
,
@PlaybackException
.
ErrorCode
int
errorCode
,
@Type
int
type
)
{
super
(
message
,
cause
,
errorCode
,
type
);
this
.
dataSpec
=
dataSpec
;
}
}
...
...
@@ -226,6 +315,7 @@ public interface HttpDataSource extends DataSource {
+
" https://exoplayer.dev/issues/cleartext-not-permitted"
,
cause
,
dataSpec
,
PlaybackException
.
ERROR_CODE_IO_CLEARTEXT_NOT_PERMITTED
,
TYPE_OPEN
);
}
}
...
...
@@ -236,7 +326,11 @@ public interface HttpDataSource extends DataSource {
public
final
String
contentType
;
public
InvalidContentTypeException
(
String
contentType
,
DataSpec
dataSpec
)
{
super
(
"Invalid content type: "
+
contentType
,
dataSpec
,
TYPE_OPEN
);
super
(
"Invalid content type: "
+
contentType
,
dataSpec
,
PlaybackException
.
ERROR_CODE_IO_BAD_HTTP_REQUEST
,
TYPE_OPEN
);
this
.
contentType
=
contentType
;
}
}
...
...
@@ -295,7 +389,11 @@ public interface HttpDataSource extends DataSource {
Map
<
String
,
List
<
String
>>
headerFields
,
DataSpec
dataSpec
,
byte
[]
responseBody
)
{
super
(
"Response code: "
+
responseCode
,
dataSpec
,
TYPE_OPEN
);
super
(
"Response code: "
+
responseCode
,
dataSpec
,
PlaybackException
.
ERROR_CODE_IO_BAD_HTTP_STATUS
,
TYPE_OPEN
);
this
.
responseCode
=
responseCode
;
this
.
responseMessage
=
responseMessage
;
this
.
headerFields
=
headerFields
;
...
...
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