de.humatic.dsj.src
Class Source

java.lang.Object
  extended by de.humatic.dsj.src.Source
Direct Known Subclasses:
NetworkSource, TSFileSource

public class Source
extends java.lang.Object

Baseclass for source objects, that work with the CompressedJavaSource filter.


Field Summary
static int ASYNC
          Data transport mode
static int AUTO_GC
           
static int DIRECT
          Data transport mode
static int ES
          Source types
static int FILTER_SETUP_ERROR
          Source errors
static int FLV
          Source types
static int HTTP
          Source types
static int HTTP_AUDIO
          Source types
static int JAS
          Source types
static int MJPG
          Source types
static int MKV
          Source types
static int MP4
          Source types
static int PSNET
          Source types
static int PULL
          Data transport mode
static int PUSH
          Data transport mode
static int RAW
          Source types
static int RTMP
          Source types
static int RTP
          Source types
static int RTSP
          Source types
static int SHOUTCAST
          Source types
static int SS_CLOSED
          Source states as transferred to listeners in SOURCE_STATE_CHANGED events during setup.
static int SS_CONNECT
          Source states as transferred to listeners in SOURCE_STATE_CHANGED events during setup.
static int SS_CONNECTED
          Source states as transferred to listeners in SOURCE_STATE_CHANGED events during setup.
static int SS_DONE
          Source states as transferred to listeners in SOURCE_STATE_CHANGED events during setup.
static int SS_EOS
          Source states as transferred to listeners in SOURCE_STATE_CHANGED events during setup.
static int SS_FORMAT_READ
          Source states as transferred to listeners in SOURCE_STATE_CHANGED events during setup.
static int SS_RUNNING
          Source states as transferred to listeners in SOURCE_STATE_CHANGED events during setup.
static int SS_SEEKING
          Source states as transferred to listeners in SOURCE_STATE_CHANGED events during setup.
static int SS_SETUP
          Source states as transferred to listeners in SOURCE_STATE_CHANGED events during setup.
static int SS_STREAMS_READ
          Source states as transferred to listeners in SOURCE_STATE_CHANGED events during setup.
static int SS_TCP_ROLLOVER
          Source states as transferred to listeners in SOURCE_STATE_CHANGED events during setup.
static int TIMEOUT
           
static int TSFILE
          Source types
static int TSNET
          Source types
static int UNKNOWN
          Source types
 
Constructor Summary
Source()
          Empty constructor, does nothing.
Source(int numChannels)
           
 
Method Summary
 void addSourceFilter(CompressedJavaSource cjs)
           
 byte[] asyncRead(int numBytes)
          Called by async sources on a DSFiltergraph internal dispatch thread.
 boolean canSeek()
           
 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.
 void createSourceFilter_async(int srcFlags, DSMediaType mediaType)
           
 CompressedJavaSource createSourceFilter(int srcFlags, 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 getAvailable()
          Returns the available number of bytes a pull source can access or 0 if unknown.
 boolean getBuffered()
           
 DSGraph getGraph()
           
 int getID()
           
 int getMaxTimeLoaded()
           
 DSMediaType[] getMediaTypes()
          Returns the media types created by this source.
 int getMinBufferTime()
          Returns this Source's minimum buffer requirements in msec worth of data.
 int getNumChannels()
          Returns the number of media channels this source delivers (and thus the number of CompressedJavaSource filters it will create).
 int getOffsetTime(int mediaMajorType)
           
 java.lang.String getPath()
           
 int getSourceDuration()
          Returns duration of the source's media if known, 0 otherwise
 CompressedJavaSource getSourceFilter(int mediaMajorType)
           
 CompressedJavaSource[] getSourceFilters()
          Returns all the CompressedJavaSource filters, that the Source created.
 int getSourceFlags()
           
 int getSourceTime()
           
 int getTransport()
          Depending on implementation, returns either Source.PUSH, PULL or ASYNC.
 int getType()
           
 boolean isLive()
           
 void notifyChannelFailure(int severity, int channelNr, int cause, java.lang.String desc)
           
 int queryParameter_int(int parameter)
           
 byte[] read()
          When in PULL mode, the source filter calls this method to pull data from the source.
 void sendEvent(int flag)
           
 void setOffsetTime(DSMediaType forType, int time)
           
 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.
 boolean streamSeek(int toPos)
          Instructs the Source implementation to reposition its read pointer in the incoming stream to the requested byte position.
 byte[] syncRead(int numBytes)
          Called by async sources on a native DirectShow thread during stream investigation (the MPEG splitter continues to use this method also during normal playback).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PUSH

public static final int PUSH
Data transport mode

See Also:
Constant Field Values

PULL

public static final int PULL
Data transport mode

See Also:
Constant Field Values

ASYNC

public static final int ASYNC
Data transport mode

See Also:
Constant Field Values

DIRECT

public static final int DIRECT
Data transport mode

See Also:
Constant Field Values

AUTO_GC

public static final int AUTO_GC
See Also:
Constant Field Values

TIMEOUT

public static int TIMEOUT

SS_EOS

public static final int SS_EOS
Source states as transferred to listeners in SOURCE_STATE_CHANGED events during setup.

See Also:
Constant Field Values

SS_CONNECT

public static final int SS_CONNECT
Source states as transferred to listeners in SOURCE_STATE_CHANGED events during setup.

See Also:
Constant Field Values

SS_CONNECTED

public static final int SS_CONNECTED
Source states as transferred to listeners in SOURCE_STATE_CHANGED events during setup.

See Also:
Constant Field Values

SS_TCP_ROLLOVER

public static final int SS_TCP_ROLLOVER
Source states as transferred to listeners in SOURCE_STATE_CHANGED events during setup.

See Also:
Constant Field Values

SS_SETUP

public static final int SS_SETUP
Source states as transferred to listeners in SOURCE_STATE_CHANGED events during setup.

See Also:
Constant Field Values

SS_STREAMS_READ

public static final int SS_STREAMS_READ
Source states as transferred to listeners in SOURCE_STATE_CHANGED events during setup.

See Also:
Constant Field Values

SS_FORMAT_READ

public static final int SS_FORMAT_READ
Source states as transferred to listeners in SOURCE_STATE_CHANGED events during setup.

See Also:
Constant Field Values

SS_RUNNING

public static final int SS_RUNNING
Source states as transferred to listeners in SOURCE_STATE_CHANGED events during setup.

See Also:
Constant Field Values

SS_SEEKING

public static final int SS_SEEKING
Source states as transferred to listeners in SOURCE_STATE_CHANGED events during setup.

See Also:
Constant Field Values

SS_DONE

public static final int SS_DONE
Source states as transferred to listeners in SOURCE_STATE_CHANGED events during setup.

See Also:
Constant Field Values

SS_CLOSED

public static final int SS_CLOSED
Source states as transferred to listeners in SOURCE_STATE_CHANGED events during setup.

See Also:
Constant Field Values

UNKNOWN

public static final int UNKNOWN
Source types

See Also:
Constant Field Values

TSNET

public static final int TSNET
Source types

See Also:
Constant Field Values

PSNET

public static final int PSNET
Source types

See Also:
Constant Field Values

TSFILE

public static final int TSFILE
Source types

See Also:
Constant Field Values

MJPG

public static final int MJPG
Source types

See Also:
Constant Field Values

RTSP

public static final int RTSP
Source types

See Also:
Constant Field Values

RTMP

public static final int RTMP
Source types

See Also:
Constant Field Values

JAS

public static final int JAS
Source types

See Also:
Constant Field Values

RTP

public static final int RTP
Source types

See Also:
Constant Field Values

MP4

public static final int MP4
Source types

See Also:
Constant Field Values

FLV

public static final int FLV
Source types

See Also:
Constant Field Values

HTTP

public static final int HTTP
Source types

See Also:
Constant Field Values

HTTP_AUDIO

public static final int HTTP_AUDIO
Source types

See Also:
Constant Field Values

SHOUTCAST

public static final int SHOUTCAST
Source types

See Also:
Constant Field Values

MKV

public static final int MKV
Source types

See Also:
Constant Field Values

ES

public static final int ES
Source types

See Also:
Constant Field Values

RAW

public static final int RAW
Source types

See Also:
Constant Field Values

FILTER_SETUP_ERROR

public static final int FILTER_SETUP_ERROR
Source errors

See Also:
Constant Field Values
Constructor Detail

Source

public Source()
       throws java.lang.Exception
Empty constructor, does nothing. You need to subclass this class or use the existing implementations.

Throws:
java.lang.Exception

Source

public Source(int numChannels)
       throws java.lang.Exception
Throws:
java.lang.Exception
Method Detail

getType

public int getType()

getID

public int getID()

createGraph

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


createGraph

public 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. 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!).


getNumChannels

public int getNumChannels()
Returns the number of media channels this source delivers (and thus the number of CompressedJavaSource filters it will create). For an audio/video RTSP stream this will be two, while for a transport stream it will be only one as demultiplexing is done on the native side.


createSourceFilter

public CompressedJavaSource createSourceFilter(int srcFlags,
                                               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(...). The method is public for package design reasons and usually not called by application code.


createSourceFilter_async

public void createSourceFilter_async(int srcFlags,
                                     DSMediaType mediaType)

addSourceFilter

public void addSourceFilter(CompressedJavaSource cjs)

getSourceFilters

public CompressedJavaSource[] getSourceFilters()
Returns all the CompressedJavaSource filters, that the Source created.


getSourceFilter

public CompressedJavaSource getSourceFilter(int mediaMajorType)

getSourceFlags

public int getSourceFlags()

getSourceDuration

public int getSourceDuration()
Returns duration of the source's media if known, 0 otherwise


setSourceTime

public void setSourceTime(int time)
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.


getSourceTime

public int getSourceTime()

canSeek

public boolean canSeek()

setSourceRate

public void setSourceRate(float rate)
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.


getTransport

public int getTransport()
Depending on implementation, returns either Source.PUSH, PULL or ASYNC.


getMediaTypes

public DSMediaType[] getMediaTypes()
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.


closeSource

public void closeSource(boolean terminate)
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.


sendEvent

public void sendEvent(int flag)

getPath

public java.lang.String getPath()

notifyChannelFailure

public void notifyChannelFailure(int severity,
                                 int channelNr,
                                 int cause,
                                 java.lang.String desc)

isLive

public boolean isLive()

getAvailable

public int getAvailable()
Returns the available number of bytes a pull source can access or 0 if unknown.


read

public byte[] read()
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).


syncRead

public byte[] syncRead(int numBytes)
Called by async sources on a native DirectShow thread during stream investigation (the MPEG splitter continues to use this method also during normal playback). Will attempt to read %numBytes bytes. The byte[] to be returned is allocated by the source (usually allocated once and then reused).


asyncRead

public byte[] asyncRead(int numBytes)
Called by async sources on a DSFiltergraph internal dispatch thread. Data read by this call will be intermediately buffered by the java part of the CompressedJavaSourceFilter and then get picked up by its native counterpart. The byte[] to be returned is allocated by the source (usually allocated once and then reused).


streamSeek

public boolean streamSeek(int toPos)
Instructs the Source implementation to reposition its read pointer in the incoming stream to the requested byte position. Called on a native DirectShow thread and usually immediately followed by the next read call.


getMinBufferTime

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


getGraph

public DSGraph getGraph()

getMaxTimeLoaded

public int getMaxTimeLoaded()

getBuffered

public boolean getBuffered()

queryParameter_int

public int queryParameter_int(int parameter)

setOffsetTime

public void setOffsetTime(DSMediaType forType,
                          int time)

getOffsetTime

public int getOffsetTime(int mediaMajorType)