de.humatic.dsj
Class DSFilter

java.lang.Object
  extended by de.humatic.dsj.DSFilter
Direct Known Subclasses:
CompressedJavaSource, DSCapture.CaptureDevice, JavaOverlayFilter, JavaSourceFilter

public class DSFilter
extends java.lang.Object

DSFilter references a DirectShow Filter that has beem added to the filtergraph.


Nested Class Summary
 class DSFilter.DSPin
           
 
Field Summary
static int PINDIR_INPUT
           
static int PINDIR_OUTPUT
           
 
Method Summary
 void applyPropPageSettings()
          Applies changes made similiar to clicking an eventual "Apply" button on a native dialog.
 void closePropPage()
          Closes an embedded properties page (and applies changes made).
 boolean connectDownstream(DSFilter.DSPin sourcePin, DSFilter.DSPin destPin, boolean direct)
          Tries to connect the given output on this filter to an input on another filter.
 void disconnect(DSFilter.DSPin pin)
          Disconnects the given pin
 void dumpConnections()
          Prints information on the filter and its connections to other filters in the graph to the current log stream.
 boolean embedPropertiesPage(java.awt.Window parent, java.awt.Point origin, int pageIndex)
          Embeds the filter's native Properties Page into the given java Window at the given Point.
 java.lang.String getCLSID()
           
 DSFiltergraph getFiltergraph()
           
 DSFilterInfo getFilterInfo()
          Returns the DSFilterInfo that describes this Filter.
 byte[] getFilterState()
           
 long getID()
           
 DSFilter.DSPin[] getInputs()
           
 java.lang.String getName()
          Returns the filter's "friendly name"
 DSFilter.DSPin[] getOutputs()
           
 DSFilter.DSPin getPin(int dir, int index)
          Gets the nth input (DSFilterInfo.DSPinInfo.PINDIR_INPUT or 1) or output (DSFilterInfo.DSPinInfo.PINDIR_OUTPUT or 0) pin
 DSFilter.DSPin getPin(int dir, int majorType, boolean connected, int index)
          Returns the pin at %index (zero based) into the filters pins with the given characteristics.
 DSFilter.DSPin getPin(java.lang.String pinName)
           
 DSFilter.DSPin[] getPins()
           
 int getPropPageCount()
          Returns the number of properties pages.
 int[] getPropPageSize(int atIndex)
          Returns an int[2] containing the required width and height of the properties page at the given index or null if the filter has no properties page.
 java.lang.String[] getPropPageTitles()
           
 void loadFilterState(java.lang.String fromFile)
          Tries to reload a previously saved filterstate.
 boolean renderEx(DSFilter.DSPin pin)
          Renders the given output (see renderPin), taking only renderer filters into account that are already in the graph.
 boolean renderPin(DSFilter.DSPin pin)
          Attempts to create the required filterchain needed to render the given output pin's media.
 void saveFilterState(java.lang.String toFile)
          Tries to save a filter's state to a file at %toFile.
 void setParameter(java.lang.String param, java.lang.String paramValue)
          Set a filter parameter.
 void showPropertiesDialog()
          Brings up the native properties page of the filter, given it exposes one.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PINDIR_OUTPUT

public static final int PINDIR_OUTPUT
See Also:
Constant Field Values

PINDIR_INPUT

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

getFiltergraph

public DSFiltergraph getFiltergraph()

getFilterInfo

public DSFilterInfo getFilterInfo()
Returns the DSFilterInfo that describes this Filter.


getName

public java.lang.String getName()
Returns the filter's "friendly name"


getCLSID

public java.lang.String getCLSID()

saveFilterState

public void saveFilterState(java.lang.String toFile)
                     throws DSJException
Tries to save a filter's state to a file at %toFile. This depends on dsj being able to retrieve the IPersistStream interface from the filter, which does not only depend on the filter implementing the interface, but also on the current graph state etc. An exception is thrown, when the interface is not available.
The method will overwrite any existing file at %toFile.

Throws:
DSJException

getFilterState

public byte[] getFilterState()
                      throws DSJException
Throws:
DSJException

loadFilterState

public void loadFilterState(java.lang.String fromFile)
                     throws DSJException
Tries to reload a previously saved filterstate. Like the coresponding save method this depends on dsj being able to retrieve the IPersistStream interface from the filter. An exception is thrown, when the interface is not available.

Throws:
DSJException

connectDownstream

public boolean connectDownstream(DSFilter.DSPin sourcePin,
                                 DSFilter.DSPin destPin,
                                 boolean direct)
                          throws DSJException
Tries to connect the given output on this filter to an input on another filter.

Throws:
DSJException

disconnect

public void disconnect(DSFilter.DSPin pin)
                throws DSJException
Disconnects the given pin

Throws:
DSJException

getPins

public DSFilter.DSPin[] getPins()

getPin

public DSFilter.DSPin getPin(java.lang.String pinName)

getInputs

public DSFilter.DSPin[] getInputs()

getOutputs

public DSFilter.DSPin[] getOutputs()

getPin

public DSFilter.DSPin getPin(int dir,
                             int index)
Gets the nth input (DSFilterInfo.DSPinInfo.PINDIR_INPUT or 1) or output (DSFilterInfo.DSPinInfo.PINDIR_OUTPUT or 0) pin


getPin

public DSFilter.DSPin getPin(int dir,
                             int majorType,
                             boolean connected,
                             int index)
Returns the pin at %index (zero based) into the filters pins with the given characteristics. If %index is < 0 the first pin meeting the given criteria will be returned. Returns null when no matching pin is found.


setParameter

public void setParameter(java.lang.String param,
                         java.lang.String paramValue)
Set a filter parameter. The only parameter really supported in the moment is "src" (when the filter implements either the IFileSource or IFileSink interface). Instead of passing a fully qualified path string you can set %paramValue to either "LOAD" or "SAVE" to make dsj bring up a standard java FileDialog.
Some filters may support parameter type "data", taking a hex string representation of a serialized filter state.


renderPin

public boolean renderPin(DSFilter.DSPin pin)
                  throws DSJException
Attempts to create the required filterchain needed to render the given output pin's media. This will use DirectShow's "Intelligent Connect" functionality and automatically pull in all additional filters needed to do what either:
- DirectShow thinks should be done with the pin passed as an argument
- you suggest to DirectShow by the filters added manually before calling this.
Like with most "robot" functions the outcome will sometimes not be what the caller expected it to be..

Throws:
DSJException

renderEx

public boolean renderEx(DSFilter.DSPin pin)
                 throws DSJException
Renders the given output (see renderPin), taking only renderer filters into account that are already in the graph. You can use this method to integrate hardware renderers.

Throws:
DSJException

showPropertiesDialog

public void showPropertiesDialog()
Brings up the native properties page of the filter, given it exposes one. The dialog shown will be a native modal dialog, placed in the upper left corner of the filtergraph's display component and may eventually be blocking data flow in the part of the filtergraph, that its filter is in.


embedPropertiesPage

public boolean embedPropertiesPage(java.awt.Window parent,
                                   java.awt.Point origin,
                                   int pageIndex)
                            throws DSJException
Embeds the filter's native Properties Page into the given java Window at the given Point. Before calling this you should use getPropPageInfo() to see if there is a PropPage and to get the space required by the page. Then adjust your layout to that and pass in the coordinate of the area you want the page to fill plus eventually the index into the filter's pages to show (given there are more than 1, if not use 0).
Returns true on success. in which case you SHOULD close the properties page when you are done with it by calling closeEmbededPropertiesPage()!
Properties pages shown by this method are non-modal and non-blocking.
Only one page per filter can be up at a time.

Throws:
DSJException

getPropPageCount

public int getPropPageCount()
Returns the number of properties pages.


getPropPageTitles

public java.lang.String[] getPropPageTitles()

getPropPageSize

public int[] getPropPageSize(int atIndex)
Returns an int[2] containing the required width and height of the properties page at the given index or null if the filter has no properties page.


applyPropPageSettings

public void applyPropPageSettings()
Applies changes made similiar to clicking an eventual "Apply" button on a native dialog. Some filters may want the properties page closed before changes take effect.


closePropPage

public void closePropPage()
Closes an embedded properties page (and applies changes made). This method is important to call when a properties page has been shown and you are done with it. dsj tries to track shown pages, but it is recommended that application code cleans up behind itself. Failure to do so may result in deadlocks or crashes on graph disposal.
Note that it is not necessary to call this for the modal native dialogs brought up by showPropertiesDialog().


dumpConnections

public void dumpConnections()
Prints information on the filter and its connections to other filters in the graph to the current log stream.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getID

public long getID()