de.humatic.dsj
Class JavaOverlayFilter

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

public class JavaOverlayFilter
extends DSFilter

Custom DSFilter object representing the dsj_JavaOverlayFilter which enables mixing of java drawing with the video of running DirectShow filtergraphs. The underlying DirectShow filter operates "in graph" and upstream from renderers, so in oposition to the "draw over video" options, that the various RendererControls object in the rc package offer, it can render to file.
The filter accepts 24bit RGB connections only. Depending on the format of the source video, a color space converter filter may be required to put it into a graph (DirectShow will pull the converter in automatically if it is required and installed).
The filter operates with a callback mechanism. It sends PropertyChangeEvents of type DSFiltergraph.OVERLAY_BUFFER_REQUEST with the time data is requested for and waits for data to be delivered (or waittime exceeds frame length). Both this and the actual compositing code inside the filter are not the most efficient, so it is recommended to use this filter for file rendering only and use RendererControls for display only graphics.
The filter should be inserted by calling DSFiltergraph.insertJavaOverlayFilter() before calling any "to File" method (like DSMovie.export(), or DSCapture.setCaptureFile(..)), it will then be moved to the capture branch of filtergraphs during recording.
When working with capture graphs and (File)sinks the filter needs to be inserted after the sink is connected in order to capture the overlay drawing. In this case call connectSink first, then call DSFiltergraph.insertOverlayFilter with the FORCE_CAPTURE_BRANCH bit set in the flags parameter. Some devices may require a short pause between the two method calls.
The filter supports colorkeying and can perform some (fake) alpha blending on the none keyed pixels. However while keying is effective, the alpha implementation is not and should rather not be used for large area alpha compositing.


Nested Class Summary
 
Nested classes/interfaces inherited from class de.humatic.dsj.DSFilter
DSFilter.DSPin
 
Field Summary
static int BLOCKING
          Setup flags for use in DSFiltergraph.insertOverlayFilter(...)
static int CALLBACK
          Setup flags for use in DSFiltergraph.insertOverlayFilter(...)
static int FORCE_CAPTURE_BRANCH
          Setup flags for use in DSFiltergraph.insertOverlayFilter(...)
static int RUNNING
          Setup flags for use in DSFiltergraph.insertOverlayFilter(...)
static int STATIC
           
static int STATIC_ADD
           
 
Fields inherited from class de.humatic.dsj.DSFilter
PINDIR_INPUT, PINDIR_OUTPUT
 
Method Summary
 byte getAlpha()
           
 int getBitDepth()
          Returns the bitdepth of the drawing graphics
 java.awt.Graphics2D getDrawingSurface()
          Returns the Graphics2D an application draws into.
 int getHeight()
          Returns the height of the drawing graphics
 java.awt.Color getKeyColor()
           
 int getWidth()
          Returns the width of the drawing graphics
 void setAlpha(float a)
          Sets the degree in which none keyed pixels will be blended with the underlying video (0 - fully transparent, 1.0 - fully opaque (default)).
 void setKeyColor(java.awt.Color kc)
          Sets the keycolor.
 int submitFrame()
          Submits a frame to the filter for compositing.
 int submitFrame(int flags)
          Submits a frame to the filter for compositing and eventually - with the STATIC bit set in the flags argument - marks this frame as "static", that is: not to be changed until the next frame with that bit unset is submitted.
 void submitPartialFrame(java.awt.Rectangle r, int flags)
          Submits only the region denoted by the Rectangle argument for compositing.
 
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
Setup flags for use in DSFiltergraph.insertOverlayFilter(...)

See Also:
Constant Field Values

BLOCKING

public static final int BLOCKING
Setup flags for use in DSFiltergraph.insertOverlayFilter(...)

See Also:
Constant Field Values

CALLBACK

public static final int CALLBACK
Setup flags for use in DSFiltergraph.insertOverlayFilter(...)

See Also:
Constant Field Values

FORCE_CAPTURE_BRANCH

public static final int FORCE_CAPTURE_BRANCH
Setup flags for use in DSFiltergraph.insertOverlayFilter(...)

See Also:
Constant Field Values

STATIC

public static final int STATIC
See Also:
Constant Field Values

STATIC_ADD

public static final int STATIC_ADD
See Also:
Constant Field Values
Method Detail

setKeyColor

public void setKeyColor(java.awt.Color kc)
Sets the keycolor. Pixels that meet this colorvalue will not be copied into the videostream.


getKeyColor

public java.awt.Color getKeyColor()

setAlpha

public void setAlpha(float a)
Sets the degree in which none keyed pixels will be blended with the underlying video (0 - fully transparent, 1.0 - fully opaque (default)).


getAlpha

public byte getAlpha()

getBitDepth

public int getBitDepth()
Returns the bitdepth of the drawing graphics


getWidth

public int getWidth()
Returns the width of the drawing graphics


getHeight

public int getHeight()
Returns the height of the drawing graphics


getDrawingSurface

public java.awt.Graphics2D getDrawingSurface()
Returns the Graphics2D an application draws into.


submitFrame

public int submitFrame()
                throws java.lang.ArrayIndexOutOfBoundsException,
                       DSJException
Submits a frame to the filter for compositing. This just calls submitFrame(0). See submitFrame(int flags).

Throws:
java.lang.ArrayIndexOutOfBoundsException
DSJException

submitFrame

public int submitFrame(int flags)
                throws java.lang.ArrayIndexOutOfBoundsException,
                       DSJException
Submits a frame to the filter for compositing and eventually - with the STATIC bit set in the flags argument - marks this frame as "static", that is: not to be changed until the next frame with that bit unset is submitted. Once a static frame has been set, the dll will still send callbacks, but application code can return immediately without submiting a new frame. The static image will then be drawn into the videostream from a copy in the dll.

Throws:
java.lang.ArrayIndexOutOfBoundsException
DSJException

submitPartialFrame

public void submitPartialFrame(java.awt.Rectangle r,
                               int flags)
                        throws java.lang.ArrayIndexOutOfBoundsException,
                               DSJException
Submits only the region denoted by the Rectangle argument for compositing. As with full frames you can mark the image as not to be changed for a while by setting the STATIC bit in the flags argument, see submitFrame(). Additionally when using STATIC_ADD the partial image will be added to a previously set static image.

Throws:
java.lang.ArrayIndexOutOfBoundsException
DSJException