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
4001592c
authored
Oct 26, 2021
by
Sebastian Roth
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add a test
parent
c14a9c09
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
77 additions
and
0 deletions
library/rtsp/src/test/java/com/google/android/exoplayer2/source/rtsp/RtspClientTest.java
library/rtsp/src/test/java/com/google/android/exoplayer2/source/rtsp/RtspClientTest.java
View file @
4001592c
...
@@ -27,8 +27,12 @@ import com.google.android.exoplayer2.source.rtsp.RtspClient.SessionInfoListener;
...
@@ -27,8 +27,12 @@ import com.google.android.exoplayer2.source.rtsp.RtspClient.SessionInfoListener;
import
com.google.android.exoplayer2.source.rtsp.RtspMediaSource.RtspPlaybackException
;
import
com.google.android.exoplayer2.source.rtsp.RtspMediaSource.RtspPlaybackException
;
import
com.google.android.exoplayer2.util.Util
;
import
com.google.android.exoplayer2.util.Util
;
import
com.google.common.collect.ImmutableList
;
import
com.google.common.collect.ImmutableList
;
import
java.io.IOException
;
import
java.net.InetAddress
;
import
java.net.Socket
;
import
java.util.concurrent.atomic.AtomicBoolean
;
import
java.util.concurrent.atomic.AtomicBoolean
;
import
java.util.concurrent.atomic.AtomicReference
;
import
java.util.concurrent.atomic.AtomicReference
;
import
javax.net.SocketFactory
;
import
org.junit.After
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.Test
;
...
@@ -78,6 +82,79 @@ public final class RtspClientTest {
...
@@ -78,6 +82,79 @@ public final class RtspClientTest {
}
}
@Test
@Test
public
void
connectServerAndClient_usesCustomSocketFactory
()
throws
Exception
{
class
ResponseProvider
implements
RtspServer
.
ResponseProvider
{
@Override
public
RtspResponse
getOptionsResponse
()
{
return
new
RtspResponse
(
/* status= */
200
,
new
RtspHeaders
.
Builder
().
add
(
RtspHeaders
.
PUBLIC
,
"OPTIONS, DESCRIBE"
).
build
());
}
@Override
public
RtspResponse
getDescribeResponse
(
Uri
requestedUri
)
{
return
RtspTestUtils
.
newDescribeResponseWithSdpMessage
(
SESSION_DESCRIPTION
,
rtpPacketStreamDumps
,
requestedUri
);
}
}
rtspServer
=
new
RtspServer
(
new
ResponseProvider
());
final
AtomicReference
<
Boolean
>
didCallCreateSocket
=
new
AtomicReference
<>();
final
SocketFactory
socketFactory
=
new
SocketFactory
()
{
@Override
public
Socket
createSocket
(
String
host
,
int
port
)
throws
IOException
{
didCallCreateSocket
.
set
(
true
);
return
SocketFactory
.
getDefault
().
createSocket
(
host
,
port
);
}
@Override
public
Socket
createSocket
(
String
s
,
int
i
,
InetAddress
inetAddress
,
int
i1
)
throws
IOException
{
return
SocketFactory
.
getDefault
().
createSocket
(
s
,
i
,
inetAddress
,
i1
);
}
@Override
public
Socket
createSocket
(
InetAddress
inetAddress
,
int
i
)
throws
IOException
{
return
SocketFactory
.
getDefault
().
createSocket
(
inetAddress
,
i
);
}
@Override
public
Socket
createSocket
(
InetAddress
inetAddress
,
int
i
,
InetAddress
inetAddress1
,
int
i1
)
throws
IOException
{
return
SocketFactory
.
getDefault
().
createSocket
(
inetAddress
,
i
,
inetAddress1
,
i1
);
}
};
AtomicReference
<
ImmutableList
<
RtspMediaTrack
>>
tracksInSession
=
new
AtomicReference
<>();
rtspClient
=
new
RtspClient
(
new
SessionInfoListener
()
{
@Override
public
void
onSessionTimelineUpdated
(
RtspSessionTiming
timing
,
ImmutableList
<
RtspMediaTrack
>
tracks
)
{
tracksInSession
.
set
(
tracks
);
}
@Override
public
void
onSessionTimelineRequestFailed
(
String
message
,
@Nullable
Throwable
cause
)
{}
},
EMPTY_PLAYBACK_LISTENER
,
/* userAgent= */
"ExoPlayer:RtspClientTest"
,
RtspTestUtils
.
getTestUri
(
rtspServer
.
startAndGetPortNumber
()),
/* debugLoggingEnabled= */
false
,
socketFactory
);
rtspClient
.
start
();
RobolectricUtil
.
runMainLooperUntil
(()
->
tracksInSession
.
get
()
!=
null
);
assertThat
(
didCallCreateSocket
.
get
()).
isTrue
();
}
@Test
public
void
connectServerAndClient_serverSupportsDescribe_updatesSessionTimeline
()
public
void
connectServerAndClient_serverSupportsDescribe_updatesSessionTimeline
()
throws
Exception
{
throws
Exception
{
class
ResponseProvider
implements
RtspServer
.
ResponseProvider
{
class
ResponseProvider
implements
RtspServer
.
ResponseProvider
{
...
...
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