danger.video
Class Recorder

java.lang.Object
  extended by danger.video.Recorder


public class Recorder
extends Object

This class provides the api for capturing a 3GP video file. Use the factory method getInstance(danger.system.CameraDevice) to create an instance of this class.

Since:
4.5

Nested Class Summary
static interface Recorder.Errors
          Status values returned in the data field of the Event handed to #start.
 
Field Summary
static int FILE_STATUS
          Value passed in callback Event.what indicating the status of the recorded file in the filesystem
static int RECORDING_FINISHED
          Value passed in callback Event.what when recording phase is finished
 
Method Summary
 void abortRecording()
          Stop video capture and delete the file.
 int getAvailableFileRecordSeconds(MountPoint volume)
          Return the available time in seconds that can be recorded to this volume given the current record parameters.
 int getAvailableFileRecordSeconds(MountPoint volume, int format, int frameRate)
          Return the available time in seconds that can be recorded to this volume given these record parameters.
 CameraDevice getCameraDevice()
          Return the CameraDevice associated with this Recorder object
 int getCurrentDuration()
          Of the currently recording video, get the number of milliseconds captured so far.
static Recorder getInstance(CameraDevice device)
          return an instance of the Recorder class.
 int getMaxDuration()
          Return the value set by the previous call to setMaxDuration.
 boolean isPreviewing()
          Return true if recorder is currently previwing video.
 boolean isRecordingActive()
          Return true if recorder is currently capturing video, even if capture is paused.
 boolean isRecordingPaused()
          Return true betwen calls to pause and resume.
 void pauseRecording()
          Pause video capture.
 void resumeRecording()
          Resume video capture.
 void setCaptureView(VideoCaptureView captureView)
          Register the component which will monitor the captured video.
 void setMaxDuration(int maxDuration)
          Set the max duration in milliseconds that will be recorded.
 void startPreview()
          Start previewing the video stream
 void startRecording(String filePath, Event completedEvent)
          Start video capture.
 void stopPreview()
          Stop previewing the video stream
 void stopRecording()
          Stop video capture and close the file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RECORDING_FINISHED

public static final int RECORDING_FINISHED
Value passed in callback Event.what when recording phase is finished

See Also:
Constant Field Values

FILE_STATUS

public static final int FILE_STATUS
Value passed in callback Event.what indicating the status of the recorded file in the filesystem

See Also:
Constant Field Values
Method Detail

getInstance

public static final Recorder getInstance(CameraDevice device)
                                  throws VideoException
return an instance of the Recorder class.

Parameters:
device - Camera device to attach to. Use null to specify the default device unless you need to control the camera device power state yourself.
Throws:
VideoException - if video recording is not implemented.

startPreview

public void startPreview()
Start previewing the video stream


stopPreview

public void stopPreview()
Stop previewing the video stream


startRecording

public void startRecording(String filePath,
                           Event completedEvent)
Start video capture.

Parameters:
filePath - filename name including path (i.e. '/removable0/recorded.3gp').
completedEvent - event that is sent once when initial recording (capture) completes, stops, or fails, and again whenever the status of the captured file in the filesystem changes. The status may change more than once, with a new event for each change.
Throws:
IllegalArgumentException - if filePath is null.

stopRecording

public void stopRecording()
Stop video capture and close the file.


isRecordingActive

public boolean isRecordingActive()
Return true if recorder is currently capturing video, even if capture is paused.

Returns:
- recording state

isPreviewing

public boolean isPreviewing()
Return true if recorder is currently previwing video.

Returns:
- previewing state

abortRecording

public void abortRecording()
Stop video capture and delete the file.


pauseRecording

public void pauseRecording()
Pause video capture.


resumeRecording

public void resumeRecording()
Resume video capture. The resulting video will have no time gap.


isRecordingPaused

public boolean isRecordingPaused()
Return true betwen calls to pause and resume.

Returns:
- paused state

getMaxDuration

public int getMaxDuration()
Return the value set by the previous call to setMaxDuration.

Returns:
- max length in millisecons

setMaxDuration

public void setMaxDuration(int maxDuration)
                    throws IllegalStateException
Set the max duration in milliseconds that will be recorded.

Parameters:
maxDuration - - max amount of record time in milliseconds
Throws:
IllegalStateException - - if the Recorder is in recording mode

getCurrentDuration

public int getCurrentDuration()
Of the currently recording video, get the number of milliseconds captured so far.

Returns:
- number of milliseconds of video saved so far.

getAvailableFileRecordSeconds

public int getAvailableFileRecordSeconds(MountPoint volume)
Return the available time in seconds that can be recorded to this volume given the current record parameters.

Parameters:
volume - - The MountPoint to be queried for free space.
Returns:
time - in seconds available for recording.
Throws:
IllegalArgumentException - if volumePath is null.

getAvailableFileRecordSeconds

public int getAvailableFileRecordSeconds(MountPoint volume,
                                         int format,
                                         int frameRate)
Return the available time in seconds that can be recorded to this volume given these record parameters.

Parameters:
volume - - The MountPoint to be queried for free space.
format - - record encoding. Ignored for this release -- always H263 64Kb/s
frameRate - - must be between 10 and 30.
channels - - currently only 1 is supported.
Returns:
time - in seconds available for recording.
Throws:
IllegalArgumentException - if parameter values are invalid or volumePath is null.

getCameraDevice

public CameraDevice getCameraDevice()
Return the CameraDevice associated with this Recorder object


setCaptureView

public void setCaptureView(VideoCaptureView captureView)
Register the component which will monitor the captured video.

Parameters:
captureView - the VideoCaptureView to update when each new captured frame is available.