de.humatic.dsj
Class DSStreamBufferGraph

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

public class DSStreamBufferGraph
extends DSFiltergraph

DSStreamBufferGraph tries to wrap the DirectShow StreamBufferEngine.
The StreamBufferEngine has been introduced in Windows XP Service Pack 1. You can not create DSStreamBufferGraph instances on older Windows versions!

A StreamBuffer graph consists of two separate filtergraphs. One is capturing data from a MPEG2 or DV CaptureDevice, a BDA compliant DVB receiver or from (MPEG2 or DV) file. It permanently records captured data into a number of backing files set up as a ring buffer (see: setupEnvironment()). The second filtergraph reads from the backing files and previews their data. This principle enables so called time shifting. You can "rewind" or pause live captured content and resume viewing at a later point. You can also "start recording in the past".
For details on SBE buffer and time concepts, please refer to the native documentation on msdn.

All playback and display methods that DSStreamBufferGraph inherits from DSFiltergraph refer to the preview part of the StreamBuffer setup. To control the capture part use the methods in StreamBufferSource and its subclasses.
As the preview branch of the StreamBufferEngine usually outputs MPEG2, a system that wants to decode and display its data must be equipped with MPEG decoders. Like with all dsj classes, that work on MPEG2, you may specify decoders by either using the extended constructor or entering preferred decoders into the dsj.xml setup file.

Windows 7 note: The StreamBufferEngine2 is not implemented yet, this class can not create and handle the WTV format.

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
DSStreamBufferGraph(int flags, StreamBufferSource sbs, DSFilterInfo mpegDecoder, DSFilterInfo audioDecoder, java.beans.PropertyChangeListener pcl)
           
DSStreamBufferGraph(int flags, StreamBufferSource sbs, java.beans.PropertyChangeListener pcl)
           
 
Method Summary
 void controlSourceGraph(int[] params)
          Called from StreamBufferSource subclasses, not to be used by application code, which should instead use StreamBufferSource.controlSource with the parameters supported by the subclass.
static StreamBufferSource createNonStandardSource(int type, DSFilterInfo info, DSFilterInfo audioInfo, int dvFlags)
           
static StreamBufferSource createSource(int type, DSFilterInfo info, int flags)
           
 java.lang.String getCaptureFile()
           
 int getContentDuration()
          Returns total available content time in ringbuffer, that is: content end - content start.
 int getContentEnd()
          Returns time of the latest available content in the ringbuffer.
 int getContentStart()
          Returns time of the earliest available content in the ringbuffer.
 int getContentTime()
           
 int getState()
           
static DSFilterInfo[][] getStreamBufferSourceDevices(int type, boolean mpeg_dv)
          Performs a capture device query and optionally returns only devices that are directly compliant with the StreamBufferEngine, i.e.
 void record()
          Toggles recording when capture file has been set This overridden DSFiltergraph method will create content recordings.
 void referenceRecord(int msecIn, int msecOut)
          This method will create reference recordings.
 void setCaptureFile(java.lang.String filePath)
          Sets the file both record() and referenceRecord() will write to.
 void setTimeValue(int time)
          Set (movie) position to %time (milliseconds)
static void setupEnvironment(java.lang.String tempDir, int fileCount, int fileDurationInSeconds)
          Sets up the backing files for the StreamBuffer engine.
 
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, getDuration, getEffectiveFrameRate, getFrameRate, getFullScreenWindow, getID, getImage, getInfo, getLoop, getMediaDimension, getMinimumSize, getOutFlags, getPan, getPreferredSize, getRate, getRendererControls, getTime, 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, setRate, 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

DSStreamBufferGraph

public DSStreamBufferGraph(int flags,
                           StreamBufferSource sbs,
                           java.beans.PropertyChangeListener pcl)
                    throws DSJException
Throws:
DSJException

DSStreamBufferGraph

public DSStreamBufferGraph(int flags,
                           StreamBufferSource sbs,
                           DSFilterInfo mpegDecoder,
                           DSFilterInfo audioDecoder,
                           java.beans.PropertyChangeListener pcl)
                    throws DSJException
Throws:
DSJException
Method Detail

getContentStart

public int getContentStart()
Returns time of the earliest available content in the ringbuffer. This starts at zero and increases as ringbuffer files get deleted.


getContentEnd

public int getContentEnd()
Returns time of the latest available content in the ringbuffer. This increses from zero onward.


getContentDuration

public int getContentDuration()
Returns total available content time in ringbuffer, that is: content end - content start. Will initially increse, but not exceed the total ringbuffer length (as returned by getDuration()).


getContentTime

public int getContentTime()

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

setCaptureFile

public void setCaptureFile(java.lang.String filePath)
                    throws DSJException
Sets the file both record() and referenceRecord() will write to.

Throws:
DSJException

getCaptureFile

public java.lang.String getCaptureFile()

record

public void record()
            throws DSJException
Toggles recording when capture file has been set This overridden DSFiltergraph method will create content recordings.

Throws:
DSJException

referenceRecord

public void referenceRecord(int msecIn,
                            int msecOut)
                     throws DSJException
This method will create reference recordings. It produces a stub file only and all data remains in the StreamBufferEngine's backing files. Reference recordings can start (and end) in the past. A value of 0 for either in or out will perform a start or stop immediately. A value of -1 will make this parameter be ignored, i.e. referenceRecord(-10000, -1) would start recording 10 seconds in the past and wait for another call to referenceRecord with a non -1 out parameter to stop recording.
The native APIs behind this are undergoing significant changes, this method is not fully functional on Windows 7 and Vista.

Throws:
DSJException

getState

public int getState()

getStreamBufferSourceDevices

public static DSFilterInfo[][] getStreamBufferSourceDevices(int type,
                                                            boolean mpeg_dv)
Performs a capture device query and optionally returns only devices that are directly compliant with the StreamBufferEngine, i.e. the returnd DSFilterInfo[] will contain only MPEG2 and/or DV devices. With the boolean parameter set to false, this does the same as DSCapture.queryDevices().


createSource

public static StreamBufferSource createSource(int type,
                                              DSFilterInfo info,
                                              int flags)

createNonStandardSource

public static StreamBufferSource createNonStandardSource(int type,
                                                         DSFilterInfo info,
                                                         DSFilterInfo audioInfo,
                                                         int dvFlags)

controlSourceGraph

public void controlSourceGraph(int[] params)
Called from StreamBufferSource subclasses, not to be used by application code, which should instead use StreamBufferSource.controlSource with the parameters supported by the subclass.


setupEnvironment

public static void setupEnvironment(java.lang.String tempDir,
                                    int fileCount,
                                    int fileDurationInSeconds)
Sets up the backing files for the StreamBuffer engine. Theoretically this never needs to be called, dsj will work with reasonable default file-count (8) and sizes (300 sec) in C:\\User\\tmp. However, you may want to keep your C:\\ drive clean. Settings made here will be stored in the registry and will be persistant (no need to call this on every run, but changeable at any time). If you want to change backing file characteristics do so before initializing DSStreamBufferGraph itself (or it will not take effect until the next initialization).