|
Copyright 2012-04-26 Werner Randelshofer | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.monte.media.beans.AbstractStateModel
org.monte.screenrecorder.ScreenRecorder
public class ScreenRecorder
A screen recorder written in pure Java.
Captures the screen, the mouse cursor and audio.
This recorder uses four threads. Three capture threads for screen, mouse cursor and audio, and one output thread for the movie writer.
FIXME - This class is a horrible mess.
| Nested Class Summary | |
|---|---|
static class |
ScreenRecorder.State
|
| Field Summary | |
|---|---|
protected int |
audioTrack
Id of the audio track. |
static java.lang.String |
ENCODING_BLACK_CURSOR
"Encoding" for black mouse cursor. |
static java.lang.String |
ENCODING_WHITE_CURSOR
"Encoding" for white mouse cursor. |
protected int |
videoTrack
Id of the video track. |
| Fields inherited from class org.monte.media.beans.AbstractStateModel |
|---|
changeEvent, listenerList |
| Constructor Summary | |
|---|---|
ScreenRecorder(java.awt.GraphicsConfiguration cfg)
Creates a screen recorder. |
|
ScreenRecorder(java.awt.GraphicsConfiguration cfg,
Format fileFormat,
Format screenFormat,
Format mouseFormat,
Format audioFormat)
Creates a screen recorder. |
|
ScreenRecorder(java.awt.GraphicsConfiguration cfg,
java.awt.Rectangle captureArea,
Format fileFormat,
Format screenFormat,
Format mouseFormat,
Format audioFormat)
Creates a screen recorder. |
|
| Method Summary | |
|---|---|
protected java.io.File |
createMovieFile(Format fileFormat)
Creates a file for recording the movie. |
protected void |
createMovieWriter()
|
java.util.List<java.io.File> |
getCreatedMovieFiles()
Returns a list of all files that the screen recorder created. |
ScreenRecorder.State |
getState()
Returns the state of the recorder. |
void |
start()
Starts the screen recorder. |
void |
stop()
Stops the screen recorder. |
protected void |
write(Buffer buf)
Writes a buffer into the movie. |
| Methods inherited from class org.monte.media.beans.AbstractStateModel |
|---|
addChangeListener, fireStateChanged, removeChangeListener |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String ENCODING_BLACK_CURSOR
public static final java.lang.String ENCODING_WHITE_CURSOR
protected int videoTrack
protected int audioTrack
| Constructor Detail |
|---|
public ScreenRecorder(java.awt.GraphicsConfiguration cfg)
throws java.io.IOException,
java.awt.AWTException
cfg - Graphics configuration of the capture screen.
java.io.IOException
java.awt.AWTException
public ScreenRecorder(java.awt.GraphicsConfiguration cfg,
Format fileFormat,
Format screenFormat,
Format mouseFormat,
Format audioFormat)
throws java.io.IOException,
java.awt.AWTException
cfg - Graphics configuration of the capture screen.fileFormat - The file format "AVI" or "QuickTime".screenFormat - The video format for screen capture.mouseFormat - The video format for mouse capture. The EncodingKey
must be ENCODING_BLACK_CURSOR or ENCODING_WHITE_CURSOR. The SampleRateKey can be
independent from the screenFormat. Specify null if you
don't want to capture the mouse cursor.audioFormat - The audio format for audio capture. Specify null
if you don't want audio capture.
java.io.IOException
java.awt.AWTException
public ScreenRecorder(java.awt.GraphicsConfiguration cfg,
java.awt.Rectangle captureArea,
Format fileFormat,
Format screenFormat,
Format mouseFormat,
Format audioFormat)
throws java.io.IOException,
java.awt.AWTException
cfg - Graphics configuration of the capture screen.captureArea - Defines the area of the screen that shall be captured.fileFormat - The file format "AVI" or "QuickTime".screenFormat - The video format for screen capture.mouseFormat - The video format for mouse capture. The EncodingKey
must be ENCODING_BLACK_CURSOR or ENCODING_WHITE_CURSOR. The SampleRateKey can be
independent from the screenFormat. Specify null if you
don't want to capture the mouse cursor.audioFormat - The audio format for audio capture. Specify null
if you don't want audio capture.
java.io.IOException
java.awt.AWTException| Method Detail |
|---|
protected void createMovieWriter()
throws java.io.IOException
java.io.IOExceptionpublic java.util.List<java.io.File> getCreatedMovieFiles()
protected java.io.File createMovieFile(Format fileFormat)
throws java.io.IOException
This implementation creates a file in the users "Video" folder on Windows, or in the users "Movies" folders on Mac OS X.
You can override this method, if you would like to create a movie file at a different location.
fileFormat -
java.io.IOExceptionpublic ScreenRecorder.State getState()
public void start()
throws java.io.IOException
java.io.IOException
public void stop()
throws java.io.IOException
Stopping the screen recorder may take several seconds, because audio capture uses a large capture buffer. Also, the MovieWriter has to finish up a movie file which may take some time depending on the amount of meta-data that needs to be written.
java.io.IOException
protected void write(Buffer buf)
throws java.io.IOException,
java.lang.InterruptedException
The buffer is copied and passed to the writer queue, which is consumed by the writer thread. See method startWriter().
AVI does not support a variable frame rate for the video track. Since we can not capture frames at a fixed frame rate we have to resend the same captured screen multiple times to the writer.
This method is called asynchronously from different threads.
You can override this method if you wish to process the media data.
buf - A buffer with un-encoded media data. If buf.track==videoTrack,
then the buffer contains a BufferedImage in buffer.data
and a Point in buffer.header with the recorded mouse
location. The header is null if the mouse is outside the capture area, or
mouse recording has not been enabled.
java.io.IOException
java.lang.InterruptedException
|
Copyright 2012-04-26 Werner Randelshofer | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||