de.humatic.dsj
Class JavaSourceFilter

java.lang.Object
  extended by de.humatic.dsj.DSFilter
      extended by de.humatic.dsj.JavaSourceFilter

public class JavaSourceFilter
extends DSFilter

Custom DSFilter object representing the dsj_JavaSourceFilter which will allow dsj to inject the results of java drawing commands into a DirectShow filtergraph. Simply spoken this lets you draw your own wmv or do the Ken Burns effect with your family pics straight into an WindowsMEdia or avi file from java. The filter has also proven to work with DirectShow compatible hardware renderers like Blackmagic Decklink boards. That is: it can be used to do film or on air television graphics in java.
The underlying DirectShow filter is a PushSource, i.e. the first and data originating filter in its filtergraph. To draw over video originating from another source use the JavaOverlayFilter.
A 32bit version is available upon request.
As of dsj 0_8_4 the filter can also be used for audio and offers various modes of operation, determined by the srcFlags parameter in DSGraph.createJavaSourceGraph(...) and insertJavaSourceFilter(...). In RUNNING mode java code should submit frames to the filter "in time", i.e. matching the desired framerate. The filter will generate duplicates or drop frames when data arrives early or late. In BLOCKING mode, the filter blocks the graph until data has been submitted, so application code can take its time to generate the next frame. This will however not block forever, but will continue after app. 10 times the normal frametime. The BLOCK_STRICT flag can be used to enable indefinite blocking, but special care needs to be taken to not create deadlocks upon dispose or when issueing transport commands to the graph.
CALLBACK is | combineable with all modes and will make the filter send PropertyChangeEvents of type DSFiltergraph.VIDEO (or AUDIO)_BUFFER_REQUEST when it wants the next frame to be delivered.
Especially when compressing on the fly, the callback way should be used, as the encoding will dynamically alter the rate the graph is running at.


Nested Class Summary
 
Nested classes/interfaces inherited from class de.humatic.dsj.DSFilter
DSFilter.DSPin
 
Field Summary
static int BLOCK_STRICT
          Source flags for use in DSGraph.createJavaSourceGraph(...)
static int BLOCKING
          Source flags for use in DSGraph.createJavaSourceGraph(...)
static int CALLBACK
          Source flags for use in DSGraph.createJavaSourceGraph(...)
static int RUNNING
          Source flags for use in DSGraph.createJavaSourceGraph(...)
 
Fields inherited from class de.humatic.dsj.DSFilter
PINDIR_INPUT, PINDIR_OUTPUT
 
Method Summary
 int drawJavaImage(int[] srcCoords)
          Do a partial redraw of a frame composited in the Graphics2D as returned from getDrawingSurface().
 int getAudioFrameTime()
          Returns milliseconds per audioframe, when set up for audio.
 int getBufferSize()
          Returns the size (in bytes) of the buffer, that the filter wants to be fed with when set up for audio..
 java.awt.Graphics2D getDrawingSurface()
          Returns a Graphics2D Object an application can use to draw into.
 int getVideoFrameTime()
          Returns milliseconds per videoframe, when set up for video.
 int setJavaAudio(byte[] audioData)
          Sends audio bytes to the filter.
 int setJavaImage()
          Send a frame composited in the Graphics2D as returned from getDrawingSurface() to DirectShow.
 int setJavaImage(byte[] data)
          The filter expects to be fed with 24bit BGR data.
 void stop()
           
 
Methods inherited from class de.humatic.dsj.DSFilter
applyPropPageSettings, closePropPage, connectDownstream, disconnect, dumpConnections, embedPropertiesPage, getCLSID, getFiltergraph, getFilterInfo, getFilterState, getID, getInputs, getName, getOutputs, getPin, getPin, getPin, getPins, getPropPageCount, getPropPageSize, getPropPageTitles, loadFilterState, renderEx, renderPin, saveFilterState, setParameter, showPropertiesDialog, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

RUNNING

public static final int RUNNING
Source flags for use in DSGraph.createJavaSourceGraph(...)

See Also:
Constant Field Values

BLOCKING

public static final int BLOCKING
Source flags for use in DSGraph.createJavaSourceGraph(...)

See Also:
Constant Field Values

CALLBACK

public static final int CALLBACK
Source flags for use in DSGraph.createJavaSourceGraph(...)

See Also:
Constant Field Values

BLOCK_STRICT

public static final int BLOCK_STRICT
Source flags for use in DSGraph.createJavaSourceGraph(...)

See Also:
Constant Field Values
Method Detail

getDrawingSurface

public java.awt.Graphics2D getDrawingSurface()
Returns a Graphics2D Object an application can use to draw into. When using this call the "no argument" setJavaImage() version to submit your frame. Alternatively you can construct the drawing environment yourself and make use of setJavaImage(byte[] imgData) instead.


getVideoFrameTime

public int getVideoFrameTime()
Returns milliseconds per videoframe, when set up for video.


getBufferSize

public int getBufferSize()
Returns the size (in bytes) of the buffer, that the filter wants to be fed with when set up for audio..


getAudioFrameTime

public int getAudioFrameTime()
Returns milliseconds per audioframe, when set up for audio.


stop

public void stop()

setJavaImage

public int setJavaImage(byte[] data)
The filter expects to be fed with 24bit BGR data. When not using the JavaSourceGraph helper class, create your graphics 2D object from a BufferedImage of type 3BYTE_BGR, get its DataBuffer byte[] and submit it to the filtergraph on every drawing cycle using this method..


setJavaImage

public int setJavaImage()
Send a frame composited in the Graphics2D as returned from getDrawingSurface() to DirectShow.


drawJavaImage

public int drawJavaImage(int[] srcCoords)
Do a partial redraw of a frame composited in the Graphics2D as returned from getDrawingSurface(). %srcCoords - an int[4], specifying x, y, width and height of the rectangle to refresh.


setJavaAudio

public int setJavaAudio(byte[] audioData)
                 throws DSJException
Sends audio bytes to the filter. The passed array should be of getBufferSize() size.

Throws:
DSJException