org.jim2mov.core
Class Jim2Mov

java.lang.Object
  extended by org.jim2mov.core.Jim2Mov
All Implemented Interfaces:
javax.media.Controls, javax.media.protocol.PullBufferStream, javax.media.protocol.SourceStream

public class Jim2Mov
extends java.lang.Object
implements javax.media.protocol.PullBufferStream

Wrapper class that allows to create movies. The only requirement is providing the implementation of two simple interfaces

Author:
andre

Field Summary
 
Fields inherited from interface javax.media.protocol.SourceStream
LENGTH_UNKNOWN
 
Constructor Summary
Jim2Mov(ImageProvider ip, MovieInfoProvider mip)
          Creates a new instance of Jim2Mov
Jim2Mov(ImageProvider ip, MovieInfoProvider mip, FrameSavedListener listener)
          Creates a new instance of Jim2Mov
 
Method Summary
 void addFrameSavedListener(FrameSavedListener listener)
          Registers FrameSavedListener to receive events.
 boolean endOfStream()
          Find out if the end of the stream has been reached.
 javax.media.protocol.ContentDescriptor getContentDescriptor()
          Always return ContentDescriptor.RAW
 long getContentLength()
          Always return LENGTH_UNKNOWN.
 java.lang.Object getControl(java.lang.String str)
          No controls are supported.
 java.lang.Object[] getControls()
          Returns a zero length array.
 javax.media.Format getFormat()
          Get the format type of the data that this source stream provides.
 void read(javax.media.Buffer buf)
          Block and read a buffer from the stream.
 void removeFrameSavedListener(FrameSavedListener listener)
          Removes FrameSavedListener from the list of listeners.
 void saveMovie(int type)
          This method saves the movie.
 void saveMovie(java.lang.String descriptor, javax.media.format.VideoFormat vf)
          This method saves the movie, but the video format is given by the caller...
 boolean willReadBlock()
          Find out if data is available now.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Jim2Mov

public Jim2Mov(ImageProvider ip,
               MovieInfoProvider mip)
Creates a new instance of Jim2Mov

Parameters:
ip - Interface which returns the images
mip - Interface which provides information about the movie

Jim2Mov

public Jim2Mov(ImageProvider ip,
               MovieInfoProvider mip,
               FrameSavedListener listener)
Creates a new instance of Jim2Mov

Parameters:
ip - Interface which returns the images
mip - Interface which provides information about the movie
listener - Listener to the frame add events
Method Detail

saveMovie

public void saveMovie(int type)
               throws MovieSaveException
This method saves the movie.

Parameters:
type - The type of movie. You can get the types available in the MovieInfoProvider interface
Throws:
MovieSaveException - If there is any problem saving the movie

saveMovie

public void saveMovie(java.lang.String descriptor,
                      javax.media.format.VideoFormat vf)
               throws MovieSaveException
This method saves the movie, but the video format is given by the caller...

Parameters:
descriptor - The file type descriptor
vf - The video format
Throws:
MovieSaveException - If there is any problem saving the movie

endOfStream

public boolean endOfStream()
Find out if the end of the stream has been reached.

Specified by:
endOfStream in interface javax.media.protocol.SourceStream
Returns:
true if there is no more data.

getContentDescriptor

public javax.media.protocol.ContentDescriptor getContentDescriptor()
Always return ContentDescriptor.RAW

Specified by:
getContentDescriptor in interface javax.media.protocol.SourceStream
Returns:
ContentDescriptor.RAW

getContentLength

public long getContentLength()
Always return LENGTH_UNKNOWN.

Specified by:
getContentLength in interface javax.media.protocol.SourceStream
Returns:
LENGTH_UNKNOWN

getControl

public java.lang.Object getControl(java.lang.String str)
No controls are supported.

Specified by:
getControl in interface javax.media.Controls
Parameters:
str - The control type
Returns:
null

getControls

public java.lang.Object[] getControls()
Returns a zero length array.

Specified by:
getControls in interface javax.media.Controls
Returns:
a zero length array

getFormat

public javax.media.Format getFormat()
Get the format type of the data that this source stream provides.

Specified by:
getFormat in interface javax.media.protocol.PullBufferStream
Returns:
A Format object that describes the data in this stream.

read

public void read(javax.media.Buffer buf)
          throws java.io.IOException
Block and read a buffer from the stream. buffer should be non-null.

Specified by:
read in interface javax.media.protocol.PullBufferStream
Parameters:
buf - The buffer
Throws:
java.io.IOException - Thrown if an error occurs while reading.

willReadBlock

public boolean willReadBlock()
Find out if data is available now. Returns true if a call to read would block for data.

Specified by:
willReadBlock in interface javax.media.protocol.PullBufferStream
Returns:
true if read would block; otherwise returns false.

addFrameSavedListener

public void addFrameSavedListener(FrameSavedListener listener)
Registers FrameSavedListener to receive events.

Parameters:
listener - The listener to register.

removeFrameSavedListener

public void removeFrameSavedListener(FrameSavedListener listener)
Removes FrameSavedListener from the list of listeners.

Parameters:
listener - The listener to remove.