de.humatic.dsj
Class DSGraph

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Canvas
          extended by de.humatic.dsj.DSFiltergraph
              extended by de.humatic.dsj.DSGraph
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible
Direct Known Subclasses:
JavaSourceGraph

public class DSGraph
extends DSFiltergraph

DSGraph reproduces the DirectShow filtergraph stored in .grf or .xgr files or passed in via streams or strings of raw xml. It also provides ways to give an application an "empty" filtergraph to piece together DirectShow filters in code, using the methods in DSFiltergraph and DSFilter. This aspect of the class is also used by dsj when working with one of the source classes in the de.humatic.dsj.src package.
For standard tasks it is recommended to use the predefined classes (DSMovie to play media files, DSDvd for DVD playback etc).

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class de.humatic.dsj.DSFiltergraph
DSFiltergraph.DSAudioStream
 
Nested classes/interfaces inherited from class java.awt.Canvas
java.awt.Canvas.AccessibleAWTCanvas
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class de.humatic.dsj.DSFiltergraph
ACTIVATING, ANAMORPHIC, ASYNC_BUFFER_GET, ASYNC_BUFFER_REQ, AUDIO_BUFFER_REQUEST, BDA, BDA_PRG_CHANGED, BDA_SCAN_PROGRESS, BDA_SCANNED_FREQ, BDA_SIG_REC, BUFFER_COMPLETE, BUFFERING, CALLER, CAP_STATE_CHANGED, CAPTURE, CLOSED, CLOSING, COMP_AUDIO_BUFFER_REQ, COMP_BUFFER_FILLED, COMP_VIDEO_BUFFER_REQ, D3D9, DD7, DECKLINK, DELIVER_AUDIO, DES_ERROR, DONE, DV, DV_STATE_CHANGED, DVD, DVD_FORMAT_CHANGED, DVD_MENU_ENABLED, E_CANT_PUMP_AUDIO, E_INIT_HEADLESS, EDITABLE, ENTER_FS, EPG, EVR, EXIT_FS, EXPORT_DONE, EXPORT_FINISHING, EXPORT_PROGRESS, EXPORT_STARTED, EXT_API_EVENT, FILTER_CHANGED, FORMAT_CHANGED, FRAME_CALLBACK, FRAME_LOCKED, FRAME_NOTIFY, GD, GE_DEVICE_CONNECTED, GE_DEVICE_LOST, GE_REF_REC_STOPPED, GRAPH, GRAPH_CHANGED, GRAPH_ERROR, GRAPH_EVENT, HDV, HDV_STATE_CHANGED, HEADLESS, INDEXER_DONE, INDEXER_STARTED, INIT_MUTED, INIT_PAUSED, INITIALIZED, IP_READY, J2D, JAVA_AUTODRAW, JAVA_POLL, JAVA_POLL_RGB, JAVASOUND, KEY_EVENT, KF_NOTIFY, LOCK_BUFFER, LOOP, MGD, MOUSE_ENABLED, MOUSE_EVENT, MOVIE, NATIVE_FORCE_GDI, NIO_UPDATE, NO_AMW, NO_SYNC, NULL, ONESHOT, OVERLAY, OVERLAY_BUFFER_REQUEST, PLAYLIST_PARSED, PREVIEW, RENDER_NATIVE, RESTART_REQ, RGB32, RTCP_EVENT, RTMP_EVENT, RTMP_SO_CHANGED, RTMP_STATE_CHANGED, SAMPLE_BUFFER_FILLED, SAVE_DONE, SAVE_STARTED, SBE, SBE_REC_STATE_CHANGED, SERVICE_ERROR, SERVICE_EVENT, SINK_ERROR, SINK_STATE_CHANGED, SIZE_CHANGED, SOURCE_ERROR, SOURCE_STATE_CHANGED, SOURCE_STATE_NOTIFY, SOURCE_USER_DATA, STILL_IMG_RECEIVED, STREAM_SEEK, SUBCLASS_EVENT, SWING, SYNC_BUFFER_REQ, TABLE_RECEIVED, TIME_FORMAT_CHANGED, TRANS_IN_PLACE, TRANSPORT, TS_BUFFER_FILLED, type, VIDEO_BUFFER_REQUEST, VMR_EMBED, VMR7, VMR9, VPJ, YUV, YUV_ORG
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
DSGraph(java.io.InputStream inStream, int flags, java.beans.PropertyChangeListener pcl)
          Creates a DSGraph from XML read from the given InputStream.
DSGraph(java.lang.String path, int flags, java.beans.PropertyChangeListener pcl)
          Creates a DSGraph from either GraphEdit .grf or .xgr files or a raw XML String.
 
Method Summary
 DSFilter addFileSourceFilter(java.lang.String forPath)
          When building a graph programatically, this method avoids the nesessity to know what source filter to use for a specific file type.
static DSGraph createFilterGraph(int flags, java.beans.PropertyChangeListener pcl)
          creates an "empty" graph that the application can add filters to manually
static JavaSourceGraph createJavaSourceGraph(int flags, int width, int height, float fps, java.lang.String renderFile, DSFilterInfo videoCompressor, boolean preview, java.beans.PropertyChangeListener pcl)
          Deprecated. method, use the nine or eleven arguments createJavaSourceGraph versions with srcFilter flags instead.
static JavaSourceGraph createJavaSourceGraph(int renderFlags, int srcFlags, int width, int height, float fps, java.lang.String renderFile, DSFilterInfo videoCompressor, boolean preview, java.beans.PropertyChangeListener pcl)
          creates a graph that uses the dsj_JavaSource filter.
 int getDuration()
          Returns graph duration if known, expressed in milliseconds
 int getTime()
          Returns current playback position in milliseconds.
 CompressedJavaSource insertCompressedSourceFilter(int flags, DSMediaType dsmt, Source src)
          Inserts the CompressedJavaSource filter and establishes communication between it and the java-side Source subclass.
 JavaSourceFilter insertJavaAudioSource(int sampleSize, int channels, float sampleRate, int flags, DSFilterInfo audioCodec, java.lang.String renderFile)
          Inserts and configures the dsj_JavaAudioSource DirectShow filter and establishes communication with it.
The returned filter will support the audio related methods in JavaSourceFilter.
 JavaSourceFilter insertJavaSourceFilter(int width, int height, float frameRate, int flags)
          Inserts and configures the DSJ_JavaSource DirectShow filter and establishes communication with it.
 void playRange(int from, int to)
          Equivalent for DSMovie.setSelection(...) & setPlaySelection(true) - only useful when the DSGraph object this is called upon has some kind of "movie-like" setup with a known duration.
 void requestProgress()
          If your graph has exporting capabilities you may use this to request progress notification to the PropertyChangeListener.
 void setGraphRate(float rate)
           
 void setRate(float rate)
          Set the playback rate (-1.0 to 2.0).
 void setTimeValue(int time)
          Set (movie) position to %time (milliseconds)
 boolean setupComplete()
          Call this method when finished with inserting and connecting filters.
 
Methods inherited from class de.humatic.dsj.DSFiltergraph
addColorSpaceConverter, addFilterToGraph, addNotify, addPropertyChangeListener, asComponent, connectDump, connectSink, createDSFiltergraph, dispose, dumpGraph, findFilterByName, findRenderer, flipImage, getActive, getAspectLocked, getAspectRatio, getAudioProperties, getAudioStream, getBitDepth, getData, getDataSize, getDisplaySize, getEffectiveFrameRate, getFrameRate, getFullScreenWindow, getID, getImage, getInfo, getLoop, getMediaDimension, getMinimumSize, getOutFlags, getPan, getPreferredSize, getRate, getRendererControls, getVolume, getYUVType, goFullScreen, graphChanged, hasMediaOfType, insertFilter, insertOverlayFilter, insertSampleAccessFilter, insertTransInPlaceFilter, isFullScreen, isSubGraph, leaveFullScreen, listFilters, lockAspectRatio, paint, pause, play, queryCapability, redraw, register, reloadFilter, removeFilter, removeNotify, removePropertyChangeListener, removeSink, setAudioRenderer, setAviExportOptions, setBounds, setClockSource, setEvent, setLoop, setPan, setPreferredSize, setVolume, step, stop, tearDown, update
 
Methods inherited from class java.awt.Canvas
createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DSGraph

public DSGraph(java.lang.String path,
               int flags,
               java.beans.PropertyChangeListener pcl)
        throws DSJException
Creates a DSGraph from either GraphEdit .grf or .xgr files or a raw XML String.

Throws:
DSJException

DSGraph

public DSGraph(java.io.InputStream inStream,
               int flags,
               java.beans.PropertyChangeListener pcl)
        throws java.lang.Exception
Creates a DSGraph from XML read from the given InputStream. It is in the application's responsibility to ensure, that the supplied data is valid xgr. dsj will only perform minimal validity checks and will not attempt to rebuild errorous documents before trying to build the filtergraph.

Throws:
java.lang.Exception
Method Detail

createFilterGraph

public static DSGraph createFilterGraph(int flags,
                                        java.beans.PropertyChangeListener pcl)
creates an "empty" graph that the application can add filters to manually


createJavaSourceGraph

public static JavaSourceGraph createJavaSourceGraph(int flags,
                                                    int width,
                                                    int height,
                                                    float fps,
                                                    java.lang.String renderFile,
                                                    DSFilterInfo videoCompressor,
                                                    boolean preview,
                                                    java.beans.PropertyChangeListener pcl)
Deprecated. method, use the nine or eleven arguments createJavaSourceGraph versions with srcFilter flags instead.


createJavaSourceGraph

public static JavaSourceGraph createJavaSourceGraph(int renderFlags,
                                                    int srcFlags,
                                                    int width,
                                                    int height,
                                                    float fps,
                                                    java.lang.String renderFile,
                                                    DSFilterInfo videoCompressor,
                                                    boolean preview,
                                                    java.beans.PropertyChangeListener pcl)
creates a graph that uses the dsj_JavaSource filter. With %renderfile set to null this will run display only


setupComplete

public boolean setupComplete()
Call this method when finished with inserting and connecting filters.


playRange

public void playRange(int from,
                      int to)
Equivalent for DSMovie.setSelection(...) & setPlaySelection(true) - only useful when the DSGraph object this is called upon has some kind of "movie-like" setup with a known duration. Will not currently handle range requests for Source subclasses.
To reset to full timerange call with %to set to -1.


getDuration

public int getDuration()
Description copied from class: DSFiltergraph
Returns graph duration if known, expressed in milliseconds

Overrides:
getDuration in class DSFiltergraph

getTime

public int getTime()
            throws DSJException
Description copied from class: DSFiltergraph
Returns current playback position in milliseconds.

Overrides:
getTime in class DSFiltergraph
Throws:
DSJException

setTimeValue

public void setTimeValue(int time)
                  throws DSJException
Description copied from class: DSFiltergraph
Set (movie) position to %time (milliseconds)

Overrides:
setTimeValue in class DSFiltergraph
Throws:
DSJException

setRate

public void setRate(float rate)
             throws DSJException
Description copied from class: DSFiltergraph
Set the playback rate (-1.0 to 2.0). Use this to start and stop playback (1.0 is normal speed 0 stops. Most DirectShow Filters will not allow negative rates (playing backwards)).

Overrides:
setRate in class DSFiltergraph
Throws:
DSJException

setGraphRate

public void setGraphRate(float rate)
                  throws DSJException
Throws:
DSJException

requestProgress

public void requestProgress()
If your graph has exporting capabilities you may use this to request progress notification to the PropertyChangeListener. Does nothing if the graph has no filewriting part. When loading xgr files containing a file writing node or when connecting a file sink this will be called internally, but event generation may not necessarily start when you piece together filters manually.


addFileSourceFilter

public DSFilter addFileSourceFilter(java.lang.String forPath)
When building a graph programatically, this method avoids the nesessity to know what source filter to use for a specific file type. It basically uses the same code that DSMovie uses when rendering a file, but does not build the filtergraph. Be aware that the returned filter may have two outputs, as some source filters contain splitters.


insertJavaSourceFilter

public JavaSourceFilter insertJavaSourceFilter(int width,
                                               int height,
                                               float frameRate,
                                               int flags)
                                        throws java.lang.IllegalArgumentException
Inserts and configures the DSJ_JavaSource DirectShow filter and establishes communication with it. The flags parameter determines the operation mode of the filter (see constants in JavaSourceFilter). The returned filter will support the video related methods in JavaSourceFilter.

Throws:
java.lang.IllegalArgumentException

insertJavaAudioSource

public JavaSourceFilter insertJavaAudioSource(int sampleSize,
                                              int channels,
                                              float sampleRate,
                                              int flags,
                                              DSFilterInfo audioCodec,
                                              java.lang.String renderFile)
                                       throws DSJException
Inserts and configures the dsj_JavaAudioSource DirectShow filter and establishes communication with it.
The returned filter will support the audio related methods in JavaSourceFilter.

Throws:
DSJException

insertCompressedSourceFilter

public CompressedJavaSource insertCompressedSourceFilter(int flags,
                                                         DSMediaType dsmt,
                                                         Source src)
                                                  throws DSJException
Inserts the CompressedJavaSource filter and establishes communication between it and the java-side Source subclass. The type of the returned filter is determined by the DSMediaType argument, which is also used to configure the DirectShow media types on the filter's outputs. The DSMediaType should therefore be complete as possible.

Throws:
DSJException