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
6b43f156
authored
Dec 17, 2020
by
christosts
Committed by
Oliver Woodman
Dec 23, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Reduce length of test data in UdpDataSourceContractTest
PiperOrigin-RevId: 348011243
parent
9d2855c3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
8 deletions
library/core/src/test/java/com/google/android/exoplayer2/upstream/UdpDataSourceContractTest.java
library/core/src/test/java/com/google/android/exoplayer2/upstream/UdpDataSourceContractTest.java
View file @
6b43f156
...
@@ -43,11 +43,7 @@ public class UdpDataSourceContractTest extends DataSourceContractTest {
...
@@ -43,11 +43,7 @@ public class UdpDataSourceContractTest extends DataSourceContractTest {
@Before
@Before
public
void
setUp
()
{
public
void
setUp
()
{
udpDataSource
=
new
UdpDataSource
();
udpDataSource
=
new
UdpDataSource
();
// UDP is unreliable: it may lose, duplicate or re-order packets. We want to transmit more than
data
=
TestUtil
.
buildTestData
(
/* length= */
256
);
// one UDP packets to thoroughly test the UDP data source. We assume that UDP delivery within
// the same host is reliable.
int
dataLength
=
(
10
*
1024
)
+
512
;
// 10.5 KiB, not a round number by intention
data
=
TestUtil
.
buildTestData
(
dataLength
);
PacketTrasmitterTransferListener
transferListener
=
new
PacketTrasmitterTransferListener
(
data
);
PacketTrasmitterTransferListener
transferListener
=
new
PacketTrasmitterTransferListener
(
data
);
udpDataSource
.
addTransferListener
(
transferListener
);
udpDataSource
.
addTransferListener
(
transferListener
);
}
}
...
@@ -116,9 +112,11 @@ public class UdpDataSourceContractTest extends DataSourceContractTest {
...
@@ -116,9 +112,11 @@ public class UdpDataSourceContractTest extends DataSourceContractTest {
String
host
=
dataSpec
.
uri
.
getHost
();
String
host
=
dataSpec
.
uri
.
getHost
();
int
port
=
dataSpec
.
uri
.
getPort
();
int
port
=
dataSpec
.
uri
.
getPort
();
try
(
DatagramSocket
socket
=
new
DatagramSocket
())
{
try
(
DatagramSocket
socket
=
new
DatagramSocket
())
{
// Split data in packets of up to 1024 bytes.
// Split data in packets of up to 64 bytes: UDP is unreliable, it may lose, duplicate or
for
(
int
offset
=
0
;
offset
<
data
.
length
;
offset
+=
1024
)
{
// re-order packets. However, we want to transmit more than one UDP packets to thoroughly
int
packetLength
=
min
(
1024
,
data
.
length
-
offset
);
// test the UDP data source. We assume that UDP delivery within the same host is reliable.
for
(
int
offset
=
0
;
offset
<
data
.
length
;
offset
+=
64
)
{
int
packetLength
=
min
(
64
,
data
.
length
-
offset
);
DatagramPacket
packet
=
DatagramPacket
packet
=
new
DatagramPacket
(
data
,
offset
,
packetLength
,
InetAddress
.
getByName
(
host
),
port
);
new
DatagramPacket
(
data
,
offset
,
packetLength
,
InetAddress
.
getByName
(
host
),
port
);
socket
.
send
(
packet
);
socket
.
send
(
packet
);
...
...
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