de.humatic.dsj.src
Class TSNetworkSource

java.lang.Object
  extended by de.humatic.dsj.src.Source
      extended by de.humatic.dsj.src.NetworkSource
          extended by de.humatic.dsj.src.TSNetworkSource
All Implemented Interfaces:
MPEGSource

public class TSNetworkSource
extends NetworkSource
implements MPEGSource

TSNetworkSource reads MPEG transport streams from udp or tcp network connections. The class performs initial streamparsing, gathering all information necessary to configure the DirectShow MPEG2 Demultiplexer. Streams are not limited to carrying MPEG2 content as both this source class as well as the stock demultiplexer can equally handle mpeg1 and mpeg4 in transport streams. Note that some AVC-HD streams may not work with Windows' demultiplexer, but may require Elecard's Push Demultiplexer. Also AAC audio in transportstreams will not work with all AAC decoders. See HTTPStreamingSource.


Field Summary
static int MONITOR_PAT
          source flags
static int RECORD
          source flags
static int VPS
          source 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, 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
 
Fields inherited from interface de.humatic.dsj.util.MPEGSource
NO_AUDIO, RESOLVE
 
Constructor Summary
TSNetworkSource(java.lang.String ip, int port, int[] pidsAndStreamTypes, int srcFlags, java.beans.PropertyChangeListener listener)
          Opens a transport stream from a udp connection, using the given PMT and elementary stream PIDs and streamtypes.
TSNetworkSource(java.lang.String ip, int port, int srcFlags, java.beans.PropertyChangeListener listener)
          Opens a transport stream from a udp connection.
TSNetworkSource(java.lang.String ip, int port, MPEGProgram prg, int srcFlags, java.beans.PropertyChangeListener listener)
          Opens a transport stream, transmitted via udp, optionally tuneing to the specified program in a broadcast stream.(%prg can be null)
See comments in first constructor for possible srcFlags values.
TSNetworkSource(java.net.URL url, int srcFlags, java.beans.PropertyChangeListener listener)
          Opens a transport stream transmitted via http.
 
Method Summary
 void broadcast(java.lang.String baseIP, MPEGProgram[] prgs, int flags)
          Relays the received transport stream to the network.
 void closeSource(boolean terminate)
          Closes down the source.
 DSGraph createGraph(int graphFlags)
          Creates a DSGraph object with CompressedJavaSource filters that are fed from this source.
 DSGraph createGraph(int graphFlags, DSFilterInfo videoDecoder, DSFilterInfo audioDecoder)
          Creates a DSGraph object with CompressedJavaSource filters, fed from this source and the given video and audio decoders.
 DSMediaType[] getMediaTypes()
          Returns the media types created by this source.
 int getPMT_PID()
          Returns the PMT PID of the currently playing program.
 int[] getProgramPIDs()
          Returns the elementary stream PIDs of the currently playing program.
 MPEGProgram[] getPrograms()
          Returns an array of all programs seen in a stream.
 java.lang.String getServerInfo()
           
 int[] getStreamTypes()
          Returns the elementary streamtypes of the currently playing program.
 byte[] read()
          When in PULL mode, the source filter calls this method to pull data from the source.
static void setBufferSizes(int socketReceiveBufferSize, int reqPacketSize)
          Utility to change the default buffer size used on the socket and in data transfer to DirectShow.
 
Methods inherited from class de.humatic.dsj.src.NetworkSource
configurePasswordDialog, getDefaultInterfaceAddress, getPasswordDialogOptions, getTimeConstraint, setConnectionTimeout, setHTTPConnector, setNetworkInterface, setSocketFactory, setTimeConstraint, setUserAgent
 
Methods inherited from class de.humatic.dsj.src.Source
addSourceFilter, asyncRead, canSeek, createSourceFilter_async, createSourceFilter, getAvailable, getBuffered, getGraph, getID, getMaxTimeLoaded, getMinBufferTime, getNumChannels, getOffsetTime, getPath, getSourceDuration, getSourceFilter, getSourceFilters, getSourceFlags, getSourceTime, getTransport, getType, isLive, notifyChannelFailure, queryParameter_int, sendEvent, setOffsetTime, setSourceRate, setSourceTime, streamSeek, syncRead
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MONITOR_PAT

public static final int MONITOR_PAT
source flags

See Also:
Constant Field Values

RECORD

public static final int RECORD
source flags

See Also:
Constant Field Values

VPS

public static final int VPS
source flags

See Also:
Constant Field Values
Constructor Detail

TSNetworkSource

public TSNetworkSource(java.lang.String ip,
                       int port,
                       int srcFlags,
                       java.beans.PropertyChangeListener listener)
                throws java.lang.Exception
Opens a transport stream from a udp connection. This should handle both single program and broadcast streams (as for example coming from a DVB receiver). In case of multi-program boadcasts, which program will be played is a matter of which PMT table is read first. To target a specific stream use the second constructor and specify the desired program.
Valid values for the srcFlags parameter include:
TSNetworkSource.MONITOR_PAT. When this is set, the source will continue reading PAT tables and reconfigure the demultiplexer when program PIDs change. Should only be used with single program streams where the data's source may change the program (like for example popular DVB programs may do)
MPEGSource.RESOLVE - will make the source try to uncover all stream PIDs and types from all programs in a multi program broadcast initially.
MPEGSource.NO_AUDIO - will make the source not try to find audio PIDs and ignore any audio streams on rendering.

Throws:
java.lang.Exception

TSNetworkSource

public TSNetworkSource(java.lang.String ip,
                       int port,
                       MPEGProgram prg,
                       int srcFlags,
                       java.beans.PropertyChangeListener listener)
                throws java.lang.Exception
Opens a transport stream, transmitted via udp, optionally tuneing to the specified program in a broadcast stream.(%prg can be null)
See comments in first constructor for possible srcFlags values.

Throws:
java.lang.Exception

TSNetworkSource

public TSNetworkSource(java.net.URL url,
                       int srcFlags,
                       java.beans.PropertyChangeListener listener)
                throws java.lang.Exception
Opens a transport stream transmitted via http. See comments in first constructor for possible srcFlags values.

Throws:
java.lang.Exception

TSNetworkSource

public TSNetworkSource(java.lang.String ip,
                       int port,
                       int[] pidsAndStreamTypes,
                       int srcFlags,
                       java.beans.PropertyChangeListener listener)
                throws java.lang.Exception
Opens a transport stream from a udp connection, using the given PMT and elementary stream PIDs and streamtypes. This is for special cases like broken streams with missing or broken PAT (and maybe PMT) tables.
The pidsAndStreamTypes argument should be a minimum 4 slot array giving:
0 - PMT PID (can be <= 0)
1 - reserved, set to 0
2 - video PID
3 - video streamtype
4 - audio PID
5 - audio streamtype
For example: {0, 0, 0x21, 0x1b} would configure the demultiplexer for H264 video (streamtype 0x1b) on PID 33.

Throws:
java.lang.Exception
Method Detail

setBufferSizes

public static void setBufferSizes(int socketReceiveBufferSize,
                                  int reqPacketSize)
Utility to change the default buffer size used on the socket and in data transfer to DirectShow. It should basically not be necessary to use this. However if you experience receiving problems you can try changing buffers before calling the constructor.


createGraph

public DSGraph createGraph(int graphFlags)
Description copied from class: Source
Creates a DSGraph object with CompressedJavaSource filters that are fed from this source.

Overrides:
createGraph in class Source

createGraph

public DSGraph createGraph(int graphFlags,
                           DSFilterInfo videoDecoder,
                           DSFilterInfo audioDecoder)
Description copied from class: Source
Creates a DSGraph object with CompressedJavaSource filters, fed from this source and the given video and audio decoders. This is for special use cases where you know exactly what media formats to expect. Any decoder you do not want to specify may be null or DSFilterInfo.doNotRender(). Failure to put a given decoder into the graph will be announced via GRAPH_ERROR events and dsj will try to automatically pick an alternative (no exception will be thrown!).

Overrides:
createGraph in class Source

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

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

getPMT_PID

public int getPMT_PID()
Description copied from interface: MPEGSource
Returns the PMT PID of the currently playing program.

Specified by:
getPMT_PID in interface MPEGSource

getProgramPIDs

public int[] getProgramPIDs()
Description copied from interface: MPEGSource
Returns the elementary stream PIDs of the currently playing program.

Specified by:
getProgramPIDs in interface MPEGSource

getStreamTypes

public int[] getStreamTypes()
Description copied from interface: MPEGSource
Returns the elementary streamtypes of the currently playing program.

Specified by:
getStreamTypes in interface MPEGSource

getPrograms

public MPEGProgram[] getPrograms()
Description copied from interface: MPEGSource
Returns an array of all programs seen in a stream. This is primarily used with multi program broadcasts. Only the playing stream may have all fields set unless the source class has been instructed to uncover all stream PIDs and types.

Specified by:
getPrograms in interface MPEGSource

broadcast

public void broadcast(java.lang.String baseIP,
                      MPEGProgram[] prgs,
                      int flags)
               throws java.lang.Exception
Relays the received transport stream to the network. If the stream contains more than one program, the combination of baseIP and prgs parameters lets you determine what to do with those in a rather flexible manner. %baseIP sets the default target destination, it takes a string giving ip address and port in xx.xx.xx.xx:yyyy form. Now when %prgs is null the entire stream will be pushed to that destination. If %prgs is non null only those programs given in the array will be extracted and relayed. Any program in the array that has a dedicated destination set for itself using MPEGProgram.setIPDestination(..), will not be directed to the address given in baseIP, but to that individual address.
This method makes use of the TSNetworkSink class under the hood. Refer to that class for more information.

Throws:
java.lang.Exception

getServerInfo

public java.lang.String getServerInfo()
Overrides:
getServerInfo in class NetworkSource

read

public byte[] read()
Description copied from class: Source
When in PULL mode, the source filter calls this method to pull data from the source. This method is called by non-async sources, that read a fix number of bytes on every read. The byte[] is allocated by the source (usually allocated once and then reused).

Overrides:
read in class Source