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
bbff5f0c
authored
Jul 30, 2021
by
aquilescanta
Committed by
Christos Tsilopoulos
Aug 02, 2021
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Assign missing error codes in UdpDataSource
PiperOrigin-RevId: 387794965
parent
0bf40f89
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
13 deletions
library/core/src/main/java/com/google/android/exoplayer2/upstream/UdpDataSource.java
library/core/src/main/java/com/google/android/exoplayer2/upstream/UdpDataSource.java
View file @
bbff5f0c
...
...
@@ -22,6 +22,7 @@ import androidx.annotation.Nullable;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.PlaybackException
;
import
java.io.IOException
;
import
java.net.BindException
;
import
java.net.DatagramPacket
;
import
java.net.DatagramSocket
;
import
java.net.InetAddress
;
...
...
@@ -30,6 +31,7 @@ import java.net.MulticastSocket;
import
java.net.PortUnreachableException
;
import
java.net.SocketException
;
import
java.net.SocketTimeoutException
;
import
java.net.UnknownHostException
;
/** A UDP {@link DataSource}. */
public
final
class
UdpDataSource
extends
BaseDataSource
{
...
...
@@ -44,7 +46,7 @@ public final class UdpDataSource extends BaseDataSource {
* @param errorCode Reason of the error, should be one of the {@code ERROR_CODE_IO_*} in {@link
* PlaybackException.ErrorCode}.
*/
public
UdpDataSourceException
(
IOException
cause
,
@PlaybackException
.
ErrorCode
int
errorCode
)
{
public
UdpDataSourceException
(
Throwable
cause
,
@PlaybackException
.
ErrorCode
int
errorCode
)
{
super
(
cause
,
errorCode
);
}
}
...
...
@@ -113,6 +115,14 @@ public final class UdpDataSource extends BaseDataSource {
}
else
{
socket
=
new
DatagramSocket
(
socketAddress
);
}
}
catch
(
SecurityException
e
)
{
throw
new
UdpDataSourceException
(
e
,
PlaybackException
.
ERROR_CODE_IO_NO_PERMISSION
);
}
catch
(
UnknownHostException
e
)
{
// TODO (internal b/184262323): Handle the case where UnknownHostException is thrown due to
// lack of network access.
throw
new
UdpDataSourceException
(
e
,
PlaybackException
.
ERROR_CODE_IO_DNS_FAILED
);
}
catch
(
BindException
e
)
{
throw
new
UdpDataSourceException
(
e
,
PlaybackException
.
ERROR_CODE_IO_NETWORK_UNAVAILABLE
);
}
catch
(
IOException
e
)
{
throw
new
UdpDataSourceException
(
e
,
PlaybackException
.
ERROR_CODE_IO_NETWORK_CONNECTION_FAILED
);
...
...
@@ -139,8 +149,13 @@ public final class UdpDataSource extends BaseDataSource {
// We've read all of the data from the current packet. Get another.
try
{
socket
.
receive
(
packet
);
}
catch
(
PortUnreachableException
e
)
{
throw
new
UdpDataSourceException
(
e
,
PlaybackException
.
ERROR_CODE_IO_NETWORK_UNAVAILABLE
);
}
catch
(
SocketTimeoutException
e
)
{
throw
new
UdpDataSourceException
(
e
,
PlaybackException
.
ERROR_CODE_IO_NETWORK_CONNECTION_TIMEOUT
);
}
catch
(
IOException
e
)
{
throw
createReadException
(
e
);
throw
new
UdpDataSourceException
(
e
,
PlaybackException
.
ERROR_CODE_IO_UNSPECIFIED
);
}
packetRemaining
=
packet
.
getLength
();
bytesTransferred
(
packetRemaining
);
...
...
@@ -193,15 +208,4 @@ public final class UdpDataSource extends BaseDataSource {
}
return
socket
.
getLocalPort
();
}
private
static
UdpDataSourceException
createReadException
(
IOException
e
)
{
if
(
e
instanceof
PortUnreachableException
)
{
return
new
UdpDataSourceException
(
e
,
PlaybackException
.
ERROR_CODE_IO_NETWORK_UNAVAILABLE
);
}
else
if
(
e
instanceof
SocketTimeoutException
)
{
return
new
UdpDataSourceException
(
e
,
PlaybackException
.
ERROR_CODE_IO_NETWORK_CONNECTION_TIMEOUT
);
}
else
{
return
new
UdpDataSourceException
(
e
,
PlaybackException
.
ERROR_CODE_IO_UNSPECIFIED
);
}
}
}
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