public final class RtspClient
extends java.lang.Object
RtspClient
- JUV RTSP/RTP Client.
Note:
- RtspClient.Configuration#SOCKET
defines RTSP TCP/IP socket configuration.
- RtspClient.Configuration#DATAGRAM
defines RTP UDP/IP datagram socket configuration.
- RTCP UDP/IP datagram socket uses default configuration.
Modifier and Type | Class and Description |
---|---|
static class |
RtspClient.Configuration
Configuration - RtspClient configuration constants. |
static interface |
RtspClient.IListener
IListener - RTSP Client listener. |
static interface |
RtspClient.IRtcpHandler
IRtcpHandler - RTCP handler. |
static class |
RtspClient.ListenerAdapter
ListenerAdapter - RtspClient.IListener adapter. |
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_JITTER_BUFFER_MARGIN
DEFAULT_JITTER_BUFFER_MARGIN - default jitter buffer margin = 8. |
static int |
STATE_DISCONNECTED
STATE_DISCONNECTED - 0 |
static int |
STATE_INIT
STATE_INIT - 1 |
static int |
STATE_PLAYING
STATE_PLAYING - 3 |
static int |
STATE_READY
STATE_READY - 2 |
static int |
STATE_RECORDING
STATE_RECORDING - 4 |
Constructor and Description |
---|
RtspClient()
Constructor.
|
RtspClient(java.util.concurrent.ExecutorService dispatcher,
java.util.concurrent.ScheduledExecutorService scheduler)
Constructor.
|
RtspClient(java.util.Map<java.lang.String,java.lang.Object> configuration)
Constructor.
|
RtspClient(java.util.Map<java.lang.String,java.lang.Object> configuration,
java.util.concurrent.ExecutorService dispatcher,
java.util.concurrent.ScheduledExecutorService scheduler)
Constructor.
|
RtspClient(java.util.Map<java.lang.String,java.lang.Object> configuration,
java.util.concurrent.ExecutorService dispatcher,
java.util.concurrent.ScheduledExecutorService scheduler,
RtpUdpSessionManager sessionManager)
Constructor.
|
RtspClient(RtspClient client)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addListener(RtspClient.IListener listener)
Adds a new
listener . |
RtspRecordSession |
announce(IPresentation presentation)
Announces
presentation record. |
void |
close()
Closes the connection.
|
void |
close(java.lang.String reason)
Closes the connection.
|
java.util.Map<java.lang.String,java.lang.Object> |
configuration()
Returns configuration.
|
void |
connect(java.lang.String url)
Connects to the server and requests supported options.
|
static IPresentation |
createPartOfPresentation(IPresentation presentation,
int[] media)
Creates part of presentation that contains only
media indices
of the presentation . |
static IPresentation |
createPartOfPresentationAudioOnly(IPresentation presentation)
Creates audio only
presentation part. |
static IPresentation |
createPartOfPresentationVideoOnly(IPresentation presentation)
Creates video only
presentation part. |
RtspPlaySession |
createPlaySession(IPresentation presentation)
Creates a RTSP session for the
presentation playback. |
static java.lang.String |
createRangeNpt(int start)
Creates 'Range' header.
|
static java.lang.String |
createRangeNpt(int start,
int duration)
Creates 'Range' header.
|
RtpMulticastPlaySession |
createRtpMulticastPlaySession(IPresentation presentation)
Creates RTP multicast session for the
presentation playback. |
static IPresentation |
createSdpPresentation(byte[] sdp)
Creates SDP
IPresentation from sdp bytes. |
static IPresentation |
createSdpPresentation(java.lang.String sdp)
Creates SDP
IPresentation from sdp string. |
static IPresentation |
createSdpPresentation(java.lang.String contentBase,
byte[] sdp)
Creates SDP
IPresentation from sdp bytes. |
static IPresentation |
createSdpPresentation(java.lang.String contentBase,
MediaTrackInfo[] tracks)
Creates SDP
IPresentation from tracks . |
IPresentation |
describe(java.lang.String url)
Retrieves
url presentation description. |
java.lang.String |
getParameter(java.lang.String parameter)
Retrieves server parameter value.
|
static long |
getPresentationDuration(IPresentation presentation)
Returns
presentation duration (in milliseconds). |
static MediaTrackInfo[] |
getPresentationTracks(IPresentation presentation)
Returns
presentation media tracks. |
ProtocolLayerInfo |
getRtspInfo()
Returns RTSP connection info (read/written bytes/packets).
|
int |
getState()
Returns client state (one of STATE_* constants).
|
static java.lang.String |
getStateDescription(int state)
Returns state description by state id.
|
java.lang.String[] |
getSupportedOptions()
Returns options supported by server.
|
static boolean |
isLivePresentation(IPresentation presentation)
Checks
presentation status ("live" or "recorded"). |
static boolean |
isOK(int[] status)
Checks
status codes. |
UnicastUdpTransport |
prepareUnicastUdpTransport()
Prepares unicast UDP transport.
|
UnicastUdpTransport |
prepareUnicastUdpTransport(int ports)
Prepares unicast UDP transport.
|
void |
release()
Releases the resources.
|
void |
removeListener(RtspClient.IListener listener)
Removes the
listener . |
static void |
setLicenseKey(byte[] key)
Sets license key.
|
void |
setParameter(java.lang.String parameter,
java.lang.String value)
Sets server parameter value.
|
void |
setReleaseOnDisconnection(boolean release)
Sets flag to release resources on disconnection.
|
public static final int STATE_DISCONNECTED
STATE_DISCONNECTED
- 0public static final int STATE_INIT
STATE_INIT
- 1public static final int STATE_READY
STATE_READY
- 2public static final int STATE_PLAYING
STATE_PLAYING
- 3public static final int STATE_RECORDING
STATE_RECORDING
- 4public static final int DEFAULT_JITTER_BUFFER_MARGIN
DEFAULT_JITTER_BUFFER_MARGIN
- default jitter buffer margin = 8.public RtspClient()
public RtspClient(RtspClient client)
client
- public RtspClient(java.util.Map<java.lang.String,java.lang.Object> configuration)
configuration
- public RtspClient(java.util.concurrent.ExecutorService dispatcher, java.util.concurrent.ScheduledExecutorService scheduler)
dispatcher
- dispatcherscheduler
- schedulerpublic RtspClient(java.util.Map<java.lang.String,java.lang.Object> configuration, java.util.concurrent.ExecutorService dispatcher, java.util.concurrent.ScheduledExecutorService scheduler)
configuration
- dispatcher
- dispatcherscheduler
- schedulerpublic RtspClient(java.util.Map<java.lang.String,java.lang.Object> configuration, java.util.concurrent.ExecutorService dispatcher, java.util.concurrent.ScheduledExecutorService scheduler, RtpUdpSessionManager sessionManager)
configuration
- dispatcher
- dispatcherscheduler
- schedulersessionManager
- public static java.lang.String getStateDescription(int state)
state
- state idpublic static IPresentation createPartOfPresentation(IPresentation presentation, int[] media)
media
indices
of the presentation
.presentation
- media
- media indices of the presentation
to usepublic static IPresentation createPartOfPresentationAudioOnly(IPresentation presentation)
presentation
part.presentation
- public static IPresentation createPartOfPresentationVideoOnly(IPresentation presentation)
presentation
part.presentation
- public static IPresentation createSdpPresentation(java.lang.String sdp)
IPresentation
from sdp
string.sdp
- public static IPresentation createSdpPresentation(byte[] sdp)
IPresentation
from sdp
bytes.sdp
- public static IPresentation createSdpPresentation(java.lang.String contentBase, byte[] sdp)
IPresentation
from sdp
bytes.contentBase
- sdp
- public static IPresentation createSdpPresentation(java.lang.String contentBase, MediaTrackInfo[] tracks)
IPresentation
from tracks
.contentBase
- tracks
- public static long getPresentationDuration(IPresentation presentation)
presentation
duration (in milliseconds).presentation
- negative
for live presentationpublic static MediaTrackInfo[] getPresentationTracks(IPresentation presentation)
presentation
media tracks.presentation
- public static boolean isLivePresentation(IPresentation presentation)
presentation
status ("live" or "recorded").presentation
- true
for live presentation; false
for recorded presentationpublic static boolean isOK(int[] status)
status
codes.status
- true
if all status
codes are 200; otherwise false
public static java.lang.String createRangeNpt(int start)
start
- start timestamp (in milliseconds)public static java.lang.String createRangeNpt(int start, int duration)
start
- start timestamp (in milliseconds)duration
- duration (in milliseconds)public UnicastUdpTransport prepareUnicastUdpTransport()
UnicastUdpTransport
instancepublic UnicastUdpTransport prepareUnicastUdpTransport(int ports)
ports
- number of UDP ports to openUnicastUdpTransport
instancepublic final ProtocolLayerInfo getRtspInfo()
public final int getState()
public final java.lang.String[] getSupportedOptions()
public java.util.Map<java.lang.String,java.lang.Object> configuration()
RtspClient.Configuration
class constants
for configuration properties.public void addListener(RtspClient.IListener listener)
listener
.listener
- public void removeListener(RtspClient.IListener listener)
listener
.listener
- public void setReleaseOnDisconnection(boolean release)
release
- true
to invoke on release()
on disconnection;
otherwise false
public RtpMulticastPlaySession createRtpMulticastPlaySession(IPresentation presentation)
presentation
playback.presentation
- public void connect(java.lang.String url) throws java.lang.Exception
Note:
- Method blocks until 'OPTIONS' response is received.
url
- server urljava.lang.Exception
- if an exception occurredpublic java.lang.String getParameter(java.lang.String parameter) throws java.lang.IllegalStateException, RtspMethodException
Note:
- Method blocks until 'GET_PARAMETER' response is received.
parameter
- parameter namejava.lang.IllegalStateException
- if connection is not established or closedRtspMethodException
- if response status code is different from 2xx.public void setParameter(java.lang.String parameter, java.lang.String value) throws java.lang.IllegalStateException, RtspMethodException
Note:
- Method blocks until 'SET_PARAMETER' response is received.
parameter
- parameter namevalue
- parameter valuejava.lang.IllegalStateException
- if connection is not established or closedRtspMethodException
- if response status code is different from 2xx.public IPresentation describe(java.lang.String url) throws java.lang.IllegalStateException, RtspMethodException
url
presentation description.
Note:
- Method blocks until 'DESCRIBE' response is received.
url
- java.lang.IllegalStateException
- if connection is not established or closedRtspMethodException
- if response status code is different from 2xx.public RtspPlaySession createPlaySession(IPresentation presentation) throws java.lang.IllegalArgumentException
presentation
playback.presentation
- java.lang.IllegalArgumentException
- if presentation parameter is illegalpublic RtspRecordSession announce(IPresentation presentation) throws java.lang.IllegalStateException, RtspMethodException
presentation
record.presentation
- java.lang.IllegalStateException
- if connection is not established or closedRtspMethodException
- if response status code is different from 2xx.public void close()
public void close(java.lang.String reason)
reason
- public void release()
public static void setLicenseKey(byte[] key)
key
- license key