dLife Home Page

dlife.vision
Class VideoSource

java.lang.Object
  extended by java.util.Observable
      extended by dlife.vision.VideoSource
Direct Known Subclasses:
DLifeVisionServerVideoSource, ImageSequenceVideoSource, ImageVideoSource

public abstract class VideoSource
extends Observable

A VideoSource provides BufferedImages captured from some video source and methods for controlling the flow of video (e.g. play/stop etc...). There may be VideoSource implementations for movie files, live Internet streams, single images, collections of images, etc...

Each time a new frame of video is available the VideoSource notifies all of its Observers. In practice the Camera that was created using the VideoSource will be the Observer on the VideoSource. When notified the Camera handles everything necessary to filter and display the image.

Version:
Jun 25, 2009
Author:
Grant Braught, Dickinson College

Field Summary
protected  boolean loop
           
 
Constructor Summary
VideoSource()
          Construct a new VideoSource.
 
Method Summary
abstract  boolean canLoop()
          Returns true if this VideoSource can be repeated in a loop.
abstract  boolean canPause()
          Returns true if this VideoSource can, in its current state, be paused.
abstract  boolean canPlay()
          Returns true if this VideoSource can, in its current state, be played.
abstract  boolean canRewind()
          Returns true if this VideoSource can, in its current state, be rewound.
abstract  boolean canSeek()
          Returns true if this VideoSource, in its current state, can seek (i.e.
abstract  boolean canStepBackward()
          Returns true if this VideoSource can, in its current state, be rewound frame by frame.
abstract  boolean canStepForward()
          Returns true if this VideoSource can, in its current state, be advanced frame by frame.
abstract  void connect()
          Perform the steps necessary to connect this VideoSource.
abstract  void disconnect()
          Perform the steps necessary to disconnect this VideoSource.
abstract  VideoSourceGUI getGUI()
          Get the VideoPlayerGUI that will control the VideoSource.
abstract  int getHeight()
          Get the height of the video associated with this VideoSource.
abstract  int getSeekLocation()
          Get the current seek location of this VideoSource.
abstract  BufferedImage getVideoFrame()
          Returns a BufferedImage containing the most recent frame of video from the VideoSource.
abstract  int getWidth()
          Get the width of the video associated with this VideoSource.
 boolean isLooping()
          Returns true or false indicating whether or not this VideoSource is currently set to loop or not.
abstract  void pause()
          Stops this VideoSource.
abstract  void play()
          Starts this VideoSource.
abstract  void rewind()
          Rewinds this VideoSource.
abstract  void seek(int location)
          Seek this VideoSource to the specified location.
 boolean setLoop(boolean loop)
          Set this VideoSource to loop if it is able to be looped.
abstract  void stepBackward()
          Steps this VideoSource one frame backward.
abstract  void stepForward()
          Steps this VideoSource one frame forward.
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

loop

protected boolean loop
Constructor Detail

VideoSource

public VideoSource()
Construct a new VideoSource. The new VideoSource will be set to loop if it is able to loop (i.e. canLoop returns true). All newly constructed VideoSources should not be playing (i.e. paused). When passed to a Camera the Camera will start the VideoSource when it is ready.

Method Detail

connect

public abstract void connect()
                      throws VideoSourceConnectionException
Perform the steps necessary to connect this VideoSource. For example, this method may load images from files, may open a movie file or may connect to a source of streaming video.

Throws:
VideoSourceConnectionException - if unable to connect the VideoSource.

disconnect

public abstract void disconnect()
                         throws VideoSourceConnectionException
Perform the steps necessary to disconnect this VideoSource. This may include closing a movie file or disconnecting from a source of streaming video.

Throws:
VideoSourceConnectionException - if unable to disconnect the VideoSource.

getGUI

public abstract VideoSourceGUI getGUI()
Get the VideoPlayerGUI that will control the VideoSource.

Returns:
a VideoPlayerGUI for controlling the VideoSource.

getVideoFrame

public abstract BufferedImage getVideoFrame()
Returns a BufferedImage containing the most recent frame of video from the VideoSource. This method returns null if there is no video frame available (including before the VideoSource is connected).

Returns:
the most recent frame of video or null if no frame is available.

play

public abstract void play()
Starts this VideoSource. When playing the VideoSource captures frames and notify the Observers each time a new frame is available.


pause

public abstract void pause()
Stops this VideoSource. When paused the VideoSource does not capture any new frames. If the VideoSource is a live source then pausing will cause frames to be lost during the pause.


rewind

public abstract void rewind()
Rewinds this VideoSource. If it makes sense for the VideoSource to be rewound then this method will return it to the first frame.


stepForward

public abstract void stepForward()
Steps this VideoSource one frame forward. For static VideoSources (e.g. movies or images) this method advances to the next frame. For live VideoSources this method will grab the current frame.


stepBackward

public abstract void stepBackward()
Steps this VideoSource one frame backward. For static VideoSources (e.g. movies or images) this method steps back to the previous frame. Typically this method will not be operational for live VideoSources.


seek

public abstract void seek(int location)
Seek this VideoSource to the specified location. The location is returned as a percentage of the whole video from the start. E.g. a location of 25 is 1/4 of the way into the video.

Parameters:
location - the location to which to seek.

getSeekLocation

public abstract int getSeekLocation()
Get the current seek location of this VideoSource. The location is specified as a percentage of the whole video from the start. E.g. a location of 25 is 1/4 of the way into the video.

Returns:
the current seek location or -1 if this VideoSource cannot seek.

setLoop

public boolean setLoop(boolean loop)
Set this VideoSource to loop if it is able to be looped. A VideoSource that is looping will restart each time it reaches the end.

This method invokes canLoop to check if the VideoSource can be looped. If it can it is set to loop or not depending upon the parameter value. If this VideoSource cannot loop then it is set to not loop.

Parameters:
loop - indicates whether the VideoSource should loop.
Returns:
true or false indicating whether or not the VidoeSource will loop.

isLooping

public boolean isLooping()
Returns true or false indicating whether or not this VideoSource is currently set to loop or not.

Returns:
whether or not this VideoSource is looping.

canPlay

public abstract boolean canPlay()
Returns true if this VideoSource can, in its current state, be played. When this method returns true the play button will be enabled.

Returns:
true if this VideoSource can be played, false otherwise.

canPause

public abstract boolean canPause()
Returns true if this VideoSource can, in its current state, be paused. When this method returns true the pause button will be enabled.

Returns:
true if this VideoSource can be paused, false otherwise.

canRewind

public abstract boolean canRewind()
Returns true if this VideoSource can, in its current state, be rewound. When this method returns true the rewind button will be enabled.

Returns:
true if this VideoSource can be rewound, false otherwise.

canStepForward

public abstract boolean canStepForward()
Returns true if this VideoSource can, in its current state, be advanced frame by frame. When this method returns true the step forward button will be enabled.

Returns:
true if this VideoSource can step forward, false otherwise.

canStepBackward

public abstract boolean canStepBackward()
Returns true if this VideoSource can, in its current state, be rewound frame by frame. When this method returns true the step backward button will be enabled.

Returns:
true if this VideoSource can step backward, false otherwise.

canLoop

public abstract boolean canLoop()
Returns true if this VideoSource can be repeated in a loop. If this method returns true, the "loop" control will be enabled.

Returns:
true if this VideoSource can be looped, false otherwise.

canSeek

public abstract boolean canSeek()
Returns true if this VideoSource, in its current state, can seek (i.e. can jump to a random location in the video.) When this method returns true the seek bar will be enabled.

Returns:
true if this VideoSource can seek, false otherwise.

getWidth

public abstract int getWidth()
Get the width of the video associated with this VideoSource.

Returns:
the width of the video or -1 if the VideoSource is not connected.

getHeight

public abstract int getHeight()
Get the height of the video associated with this VideoSource.

Returns:
the height of the video or -1 if the VideoSoure is not connected.

dLife Home Page