de.humatic.dsj.src
Class RTSPSource

java.lang.Object
  extended by de.humatic.dsj.src.Source
      extended by de.humatic.dsj.src.NetworkSource
          extended by de.humatic.dsj.src.RTSPSource

public class RTSPSource
extends NetworkSource

Source for all kinds of rtsp negotiated or sdp described rtp streams following the standards laid out in RFC2326 (rtsp) and RFC1889 (rtp).
As of dsj 0_8_61 the source also supports rtsp tunnelled via http as specified by Apple in Letters from the icefloe, dispatch 28
The RTSPSource uses a number of helper classes: For each payload in the stream a RTPChannel object will be created, which will load a payload specific RTPHandler. Additionally an RTCPHandler is created.

   ___________ java __________
   |  RTPChannel - RTPHandler -->  |
__________________ native DS ___________________
|  CompressedJavaSource - Demultiplexers / Decoders etc  |
Network ->RTSP Source =>
   |  RTPChannel - RTPHandler -->  | |  CompressedJavaSource - Demultiplexers / Decoders etc  |



ASF streams from WindowsMedia servers are supported by this class (as well as by DSMovie), but dsj will use WindowsMedia components to play them, The above flow chart is only valid for streams coming from standards compliant servers.


Field Summary
static int FORCE_MULTICAST
          RTSP specific setup flags
static int FORCE_SDP_FRAMERATE
          RTSP specific setup flags
static int FORCE_SDP_IP
          RTSP specific setup flags
static int FORCE_TCP
          RTSP specific setup flags
static int IGNORE_PKT_SSRC
          RTSP specific setup flags
static int NO_RTCP
          RTSP specific setup flags
 
Fields inherited from class de.humatic.dsj.src.NetworkSource
BUFFER_OVERFLOW, CONNECTION_TIMEOUT, FASTSTART, H264_FASTSTART, H264_FORCE_INLINE_SPS, H264_OMMIT_SPS, H264_PASS_INLINE_SPS, IDLE_TIMEOUT, KF_NOTIFY, LIVE_SRC, MAX_BUFFER_TIME, MAX_DURATION, MAX_FRAME_TIME, NO_USER_PROMPT, READ_USER_DATA, RECEIVE_TIMEOUT, RTCP_RECEIVE_ERROR, SEEK_FAILURE, SOCKET_ERROR, STARVING, UDP_UNCONNECTED
 
Fields inherited from class de.humatic.dsj.src.Source
ASYNC, AUTO_GC, DIRECT, ES, FILTER_SETUP_ERROR, FLV, HTTP, HTTP_AUDIO, JAS, MJPG, MKV, MP4, PSNET, PULL, PUSH, RAW, RTMP, RTP, RTSP, SHOUTCAST, SS_CLOSED, SS_CONNECT, SS_CONNECTED, SS_DONE, SS_EOS, SS_FORMAT_READ, SS_RUNNING, SS_SEEKING, SS_SETUP, SS_STREAMS_READ, SS_TCP_ROLLOVER, TIMEOUT, TSFILE, TSNET, UNKNOWN
 
Constructor Summary
RTSPSource(java.lang.String rtspURL, int flags, java.beans.PropertyChangeListener listener)
          Initialize a rtsp session with the media server at the given url.
RTSPSource(java.lang.String rtspURL, java.beans.PropertyChangeListener listener)
          Initialize a rtsp session with the media server at the given url.
RTSPSource(java.lang.String rtspURL, java.lang.String userName, java.lang.String passWord, int flags, java.beans.PropertyChangeListener listener)
          Initialize a rtsp session with the media server at the given url passing the given credentials for authorization (if these are null or invalid a password dialog will be brought up).
The constructor performs some asynchronous connection and setup operations behind the scenes, that will be caught by a subsequent call to RTSPSource.createGraph(..).
As an alternative to using a standard rtsp:// url you can pass the path to an .sdp file or use a string like "SAP"+(://optionalNonDefaultSAP_IPandPort).
 
Method Summary
 void closeSource(boolean terminate)
          Closes down the source.
 DSGraph createGraph(int graphFlags)
          Use this to create a filtergraph from the source.
 DSGraph createGraph(int graphFlags, DSFilterInfo videoDecoder, DSFilterInfo audioDecoder)
          Creates a filtergraph with the given decoders from the source.
 CompressedJavaSource createSourceFilter(int sf, DSMediaType mediaType)
          This is called by the various source implementations once they have determined, what kind of media they deal with etc.
It basically calls through to DSGraph.insertCompressedSourceFilter(...).
 int getLocalPort()
           
 DSMediaType[] getMediaTypes()
          Returns the media types created by this source.
 int getMinBufferTime()
          Returns this Source's minimum buffer requirements in msec worth of data.
 CompressedJavaSource[] getSourceFilters()
          Returns all the CompressedJavaSource filters, that the Source created.
 int getSourceTime()
           
 void notifyChannelFailure(int severity, int chNr, int cause, java.lang.String desc)
           
static java.lang.String parseReferenceMovie(java.lang.String myPath)
          Reads rtsp URL from a "Quicktime reference movie".
static void setLocalPort(int lp)
           
static void setMinBufferTime(int time)
           
static void setReceiveBufferSize(int socketReceiveBufferSize)
           
 void setSourceRate(float rate)
          Starts and pauses the source, application code should rather not use this method directly, but stick with DSFiltergraph methods.
 void setSourceTime(int time)
          Repositions the source, application code should rather not use this method directly, but stick with DSFiltergraph methods.
static void setTCPRolloverTimeout(int msec)
          RTP communication in principle prefers UDP connections, however in most usecases this will be blocked by firewalls etc, so that data needs to be sent via TCP.
 
Methods inherited from class de.humatic.dsj.src.NetworkSource
configurePasswordDialog, getDefaultInterfaceAddress, getPasswordDialogOptions, getServerInfo, getTimeConstraint, setConnectionTimeout, setHTTPConnector, setNetworkInterface, setSocketFactory, setTimeConstraint, setUserAgent
 
Methods inherited from class de.humatic.dsj.src.Source
addSourceFilter, asyncRead, canSeek, createSourceFilter_async, getAvailable, getBuffered, getGraph, getID, getMaxTimeLoaded, getNumChannels, getOffsetTime, getPath, getSourceDuration, getSourceFilter, getSourceFlags, getTransport, getType, isLive, queryParameter_int, read, sendEvent, setOffsetTime, streamSeek, syncRead
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FORCE_TCP

public static final int FORCE_TCP
RTSP specific setup flags

See Also:
Constant Field Values

FORCE_MULTICAST

public static final int FORCE_MULTICAST
RTSP specific setup flags

See Also:
Constant Field Values

NO_RTCP

public static final int NO_RTCP
RTSP specific setup flags

See Also:
Constant Field Values

FORCE_SDP_FRAMERATE

public static final int FORCE_SDP_FRAMERATE
RTSP specific setup flags

See Also:
Constant Field Values

FORCE_SDP_IP

public static final int FORCE_SDP_IP
RTSP specific setup flags

See Also:
Constant Field Values

IGNORE_PKT_SSRC

public static final int IGNORE_PKT_SSRC
RTSP specific setup flags

See Also:
Constant Field Values
Constructor Detail

RTSPSource

public RTSPSource(java.lang.String rtspURL,
                  java.beans.PropertyChangeListener listener)
           throws java.lang.Exception
Initialize a rtsp session with the media server at the given url. If the stream requires authorization a password dialog will be brought up. Alternatively credentials can be given with the url, either as a query string (rtsp://...?username=xyz&password=abc) or in VLC style (rtsp://username:password@...)
The constructor performs some asynchronous connection and setup operations behind the scenes, that will be caught by a subsequent call to RTSPSource.createGraph(..).
Alternatively to using a standard rtsp:// url you can pass the path to an .sdp file or use a string like "SAP"+(://optionalNonDefaultSAP_IPandPort) to listen for SAP announcements.

Throws:
java.lang.Exception

RTSPSource

public RTSPSource(java.lang.String rtspURL,
                  int flags,
                  java.beans.PropertyChangeListener listener)
           throws java.lang.Exception
Initialize a rtsp session with the media server at the given url. If the stream requires authorization a password dialog will be brought up. Alternatively credentials can be given with the url, either as a query string (rtsp://...?username=xyz&password=abc) or in VLC style (rtsp://username:password@...)
The constructor performs some asynchronous connection and setup operations behind the scenes, that will be caught by a subsequent call to RTSPSource.createGraph(..).
As an alternative to using a standard rtsp:// url you can pass the path to an .sdp file or use a string like "SAP"+(://optionalNonDefaultSAP_IPandPort). to listen for SAP announcements.
See last constructor for valid fields in the flags parameter.

Throws:
java.lang.Exception

RTSPSource

public RTSPSource(java.lang.String rtspURL,
                  java.lang.String userName,
                  java.lang.String passWord,
                  int flags,
                  java.beans.PropertyChangeListener listener)
           throws java.lang.Exception
Initialize a rtsp session with the media server at the given url passing the given credentials for authorization (if these are null or invalid a password dialog will be brought up).
The constructor performs some asynchronous connection and setup operations behind the scenes, that will be caught by a subsequent call to RTSPSource.createGraph(..).
As an alternative to using a standard rtsp:// url you can pass the path to an .sdp file or use a string like "SAP"+(://optionalNonDefaultSAP_IPandPort). to listen for SAP announcements.
Valid fields for the flags parameter include:
RTSPSource.FORCE_TCP - to skip UDP connection attempts
RTSPSource.FORCE_MULTICAST - to request multicast communication in SETUP calls to the server (supported by Axis & Bosch IP cameras and possibly other hardware)
RTSPSource.FORCE_SDP_FRAMERATE - skip timing determination from stream and rely on info given in sdp (if any). Can speed up source and graph construction.
NetworkSource.LIVE_SRC - can be used to signal a stream's "live" character if no range=now- or range=0- or eq. is given in sdp
NetworkSource.KF_NOTIFY - request notification on keyframes through PropertyChangeEvents of type DSFiltergraph.KF_NOTIFY
NetworkSource.READ_USER_DATA - request notification on user data in MP4V and H264 video streams through PropertyChangeEvents of type DSFiltergraph.SOURCE_USER_DATA. Data will be passed as byte[][] in the oldValue field.
NetworkSource.NO_USER_PROMPT - throw an exception rather then bringing up password dialogs on protected streams.
NetworkSource.UDP_UNCONNECTED - do not bind to ports announced in sdp, but rather read source ports from incoming packets.

Throws:
java.lang.Exception
Method Detail

setLocalPort

public static void setLocalPort(int lp)

getLocalPort

public int getLocalPort()

setMinBufferTime

public static void setMinBufferTime(int time)

getMinBufferTime

public int getMinBufferTime()
Description copied from class: Source
Returns this Source's minimum buffer requirements in msec worth of data. Usually only PUSH mode network sources work with buffers.

Overrides:
getMinBufferTime in class Source

setReceiveBufferSize

public static void setReceiveBufferSize(int socketReceiveBufferSize)

setTCPRolloverTimeout

public static void setTCPRolloverTimeout(int msec)
RTP communication in principle prefers UDP connections, however in most usecases this will be blocked by firewalls etc, so that data needs to be sent via TCP. This method sets the ammount of time the Source will wait for UDP data to arrive, before switching to TCP. The default is 3000 msec and it is not strictly required to ever call this method. If you want to change the timeout call this before constructing the RTSPSource.


closeSource

public void closeSource(boolean terminate)
Description copied from class: Source
Closes down the source. When %terminate is true, all socket and stream resources etc. will also be freed. This method is called internally when disposing off the graph that was using this source and is not normally used by application code.

Overrides:
closeSource in class Source

getSourceTime

public int getSourceTime()
Overrides:
getSourceTime in class Source

setSourceTime

public void setSourceTime(int time)
Description copied from class: Source
Repositions the source, application code should rather not use this method directly, but stick with DSFiltergraph methods. The DSGraph created by a Source knows best when and how to interfere with the javaside data reading.

Overrides:
setSourceTime in class Source

setSourceRate

public void setSourceRate(float rate)
Description copied from class: Source
Starts and pauses the source, application code should rather not use this method directly, but stick with DSFiltergraph methods. The DSGraph created by a Source knows best when to change the state of the javaside implementation.

Overrides:
setSourceRate in class Source

createGraph

public DSGraph createGraph(int graphFlags)
                    throws DSJException
Use this to create a filtergraph from the source. This is a blocking call, that will not return before the asynchronous constructor has finished setting up the rtsp session.

Overrides:
createGraph in class Source
Throws:
DSJException

createGraph

public DSGraph createGraph(int graphFlags,
                           DSFilterInfo videoDecoder,
                           DSFilterInfo audioDecoder)
                    throws DSJException
Creates a filtergraph with the given decoders from the source. Please also see the superclass's documentation for further information.
This is a blocking call, that will not return before the asynchronous constructor has finished setting up the rtsp session.

Overrides:
createGraph in class Source
Throws:
DSJException

createSourceFilter

public CompressedJavaSource createSourceFilter(int sf,
                                               DSMediaType mediaType)
Description copied from class: Source
This is called by the various source implementations once they have determined, what kind of media they deal with etc.
It basically calls through to DSGraph.insertCompressedSourceFilter(...). The method is public for package design reasons and usually not called by application code.

Overrides:
createSourceFilter in class Source

getSourceFilters

public CompressedJavaSource[] getSourceFilters()
Description copied from class: Source
Returns all the CompressedJavaSource filters, that the Source created.

Overrides:
getSourceFilters in class Source

getMediaTypes

public DSMediaType[] getMediaTypes()
Description copied from class: Source
Returns the media types created by this source. Depending on the time of calling, this method needs to be taken with care as during format negotiation mediatype information may not yet or only be partially available.

Overrides:
getMediaTypes in class Source

notifyChannelFailure

public void notifyChannelFailure(int severity,
                                 int chNr,
                                 int cause,
                                 java.lang.String desc)
Overrides:
notifyChannelFailure in class Source

parseReferenceMovie

public static java.lang.String parseReferenceMovie(java.lang.String myPath)
Reads rtsp URL from a "Quicktime reference movie". Quicktime has a number of concepts for linking one movie to another. URLs of actual streams are often hidden away in so called "Poster movies" or short dummy files that are used for bandwidth detection. This method extracts the first rtsp stream url from such files. For more information see the Quicktime file format documentation.