de.humatic.dsj.sink
Class RTPSink

java.lang.Object
  extended by de.humatic.dsj.sink.JSink
      extended by de.humatic.dsj.sink.RTPSink
All Implemented Interfaces:
java.beans.PropertyChangeListener, java.util.EventListener

public class RTPSink
extends JSink

Streamsink for streaming audio and videodata via RTP unicast or multicast or for publishing to a Darwin server.
The class handles the RTP packaging of samples received from DirectShow encoder filters and generates sdp announcements as either .sdp files, via SAP or through the streaming server.
It currently supports MP4V and H264 video and AAC, AMR and mp3 audio, dsj 0_8_62 adds support for ulaw & alaw audio. In order to use this class you must make sure that the desired encoders are installed on the host system, dsj itself does not bring encoders, nor does it license you to use 3rd party components. alaw & ulaw encoders ship with Windows.
To configure media encoding the SHOW_ENC_DLG and SHOW_DLG_SAVE flags can be set to make dsj bring up the filters' properties pages. Alternatively pass DSFilterInfos as returned by DSFilterInfo.filterInfoForCodecState to set previously saved settings (no guarantees that all encoders support this).
This functionality has been written and tested with the following encoders (others may work as well, but your mileage will vary. Feedback is welcome):
MP4V - Elecard MPEG-4 Video Encoder SD
- ffdShow, libavcodec
- ffdShow, xvid
- Lead MPEG4 Encoder (2.0)
H264 - Elecard AVC Video Encoder SD
- ffdShow, x264
- Lead H264 Encoder (4.0), iPod/PSP mode only
- MainConcept AVC/H.264 Video Encoder
MP3 - MPEG Layer-3 (built into Windows XP)
- Elecard MPEG Audio Encoder
- LAME Audio Encoder (recommended)
- Lead MPEG Audio Encoder (2.0)
AAC - Elecard AAC Audio Encoder
- Monogram AAC Encoder (may only work w/o preview and require properly timestamped input)
- MainCocept AAC Encoder
AMR - Monogram AMR Encoder
- Lead AMR Encoder
ULAW - Windows ACM Codec ("CCITT u-Law")
ALAW - Windows ACM Codec ("CCITT a-Law")

When streaming from live sources / capture devices aspects like how the source is timestamping samples and how a particular encoder handles it will affect the operation. You will find combinations that do not work together.
Mediatype and compression used are read from encoder outputs and / or the bitstream on setup. There's no need to specify those in any other place, with one exception: If you want LATM packetization for AAC audio, OR combine the flags paramter with RTPSink.LATM.
This class is new in 0_8_6 and will lack implementation details.


Field Summary
static int FORCE_TCP
           
static int LATM
           
static int NO_RTCP
           
static int RECORD
           
 
Fields inherited from class de.humatic.dsj.sink.JSink
AV_SYNC_IN, BUFFER_OVERFLOW, CLOSED, CONNECT, CONNECTED, CONNECTION_TIMEOUT, DISPLAY_LOCAL, DUMP, ERROR, HTTP_AUDIO, LOCAL, MAX_BT_DROP, MAX_BT_WARN, MAX_DURATION, MIN_BT, MJPG, MKV, NO_AUDIO, NO_VIDEO, OFFSET_TIME_IN, OFFSET_TIME_OUT, OPT_PKT_SIZE, PIPE_SIZE, pipeSize, PREVIEW, RTMP, RTP, SHOW_DLG_SAVE, SHOW_ENC_DLG, SOCKET_ERROR, SOCKET_SBS, socketSendBufferSize, STARVING, TSNET, UNCONNECTED
 
Constructor Summary
RTPSink(DSFiltergraph grf, java.lang.String[] targetURLs, DSFilterInfo videoEncoder, DSFilterInfo audioEncoder, StreamAnnouncement sa, int flags)
          Constructs an RTPSink and connects it to the given filtergraph.
%targetURLs - a min 1, max.
 
Method Summary
 void close()
          Shuts down the sink and frees all resources it allocated.
 void connect()
          When constructing the sink with the JSink.UNCONNECTED flag set, call this after encoders are configured.
 void propertyChange(java.beans.PropertyChangeEvent pe)
           
 void sampleReceived(SampleBuffer inBuffer)
          Called from SampleAccessFilters used by this sink.
static void setLocalPort(int port)
           
 
Methods inherited from class de.humatic.dsj.sink.JSink
create, getID, getOutputBufferSize, getOutputMediaType, setNetworkInterface, setSinkOption, setSocketOption
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_RTCP

public static final int NO_RTCP
See Also:
Constant Field Values

FORCE_TCP

public static final int FORCE_TCP
See Also:
Constant Field Values

RECORD

public static final int RECORD
See Also:
Constant Field Values

LATM

public static final int LATM
See Also:
Constant Field Values
Constructor Detail

RTPSink

public RTPSink(DSFiltergraph grf,
               java.lang.String[] targetURLs,
               DSFilterInfo videoEncoder,
               DSFilterInfo audioEncoder,
               StreamAnnouncement sa,
               int flags)
        throws java.lang.Exception
Constructs an RTPSink and connects it to the given filtergraph.
%targetURLs - a min 1, max. 2 entry String array, giving IPs and ports (like "230.0.0.1:1234") as target addresses for the streams delivered by the filtergraph. If only 1 address is given, this will be used on a session basis, with an eventual second stream using port+2. This parameter can be null with DARWIN_PUSH announcements. Publishing points will then be picked by the server.
%video- and audioEncoder determine the formats delivered by this sink. See the above discussion for what is supported.
%sa - determines how the stream is announced. See the StreamAnnouncement class.
%flags - bitwise combination of additional options. RTPSink currently makes use of JSink.LOCAL, SHOW_ENC_DLG and SHOW_DLG_SAVE, JSink.UNCONNECTED and RTPSink.LATM.
For DARWIN_PUSH publishing the following flags can also be used:
RTPSink.RECORD - will use RECORD and mode=record instead of PLAY and mode=receive in RTSP announcement. This seems to be required by Wowza.
RTPSink.NO_RTCP - don't send and receive RTCP
RTPSink.FORCE_TCP - force streaming via tcp in interleaved mode.

Throws:
java.lang.Exception
Method Detail

connect

public void connect()
             throws java.lang.Exception
When constructing the sink with the JSink.UNCONNECTED flag set, call this after encoders are configured. Without the flag set, this will be called automatically.

Throws:
java.lang.Exception

sampleReceived

public void sampleReceived(SampleBuffer inBuffer)
Description copied from class: JSink
Called from SampleAccessFilters used by this sink.

Overrides:
sampleReceived in class JSink

setLocalPort

public static void setLocalPort(int port)

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent pe)
Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Overrides:
propertyChange in class JSink

close

public void close()
Description copied from class: JSink
Shuts down the sink and frees all resources it allocated. This method is called internally when disposing off the graph that was using this sink and is not normally used by application code.

Overrides:
close in class JSink