com.googlecode.android_scripting.facade
Class WebCamFacade

java.lang.Object
  extended by com.googlecode.android_scripting.jsonrpc.RpcReceiver
      extended by com.googlecode.android_scripting.facade.WebCamFacade

@RpcMinSdk(value=8)
public class WebCamFacade
extends RpcReceiver

Manages access to camera streaming.

Usage Notes


webCamStart and webCamStop are used to start and stop an Mpeg stream on a given port. webcamAdjustQuality is used to ajust the quality of the streaming video.
cameraStartPreview is used to get access to the camera preview screen. It will generate "preview" events as images become available.
The preview has two modes: data or file. If you pass a non-blank, writable file path to the cameraStartPreview it will store jpg images in that folder. It is up to the caller to clean up these files after the fact. If no file element is provided, the event will include the image data as a base64 encoded string.

Event details


The data element of the preview event will be a map, with the following elements defined.
Note that "filename", "error" and "data" are mutual exclusive.

The webcam and preview modes use the same resources, so you can't use them both at the same time. Stop one mode before starting the other.

Author:
Damon Kohler (damonkohler@gmail.com) (probably), Robbie Matthews (rjmatthews62@gmail.com)

Constructor Summary
WebCamFacade(FacadeManager manager)
           
 
Method Summary
 boolean cameraStartPreview(java.lang.Integer resolutionLevel, java.lang.Integer jpegQuality, java.lang.String filepath)
           
 void cameraStopPreview()
           
 void shutdown()
          Invoked when the receiver is shut down.
 void webcamAdjustQuality(java.lang.Integer resolutionLevel, java.lang.Integer jpegQuality)
           
 java.net.InetSocketAddress webcamStart(java.lang.Integer resolutionLevel, java.lang.Integer jpegQuality, java.lang.Integer port)
           
 void webcamStop()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WebCamFacade

public WebCamFacade(FacadeManager manager)
Method Detail

webcamStart

@Rpc(description="Starts an MJPEG stream and returns a Tuple of address and port for the stream.")
public java.net.InetSocketAddress webcamStart(@RpcParameter(name="resolutionLevel",description="increasing this number provides higher resolution")@RpcDefault(value="0")
                                                             java.lang.Integer resolutionLevel,
                                                             @RpcParameter(name="jpegQuality",description="a number from 0-100")@RpcDefault(value="20")
                                                             java.lang.Integer jpegQuality,
                                                             @RpcParameter(name="port",description="If port is specified, the webcam service will bind to port, otherwise it will pick any available port.")@RpcDefault(value="0")
                                                             java.lang.Integer port)
                                       throws java.lang.Exception
Throws:
java.lang.Exception

webcamAdjustQuality

@Rpc(description="Adjusts the quality of the webcam stream while it is running.")
public void webcamAdjustQuality(@RpcParameter(name="resolutionLevel",description="increasing this number provides higher resolution")@RpcDefault(value="0")
                                               java.lang.Integer resolutionLevel,
                                               @RpcParameter(name="jpegQuality",description="a number from 0-100")@RpcDefault(value="20")
                                               java.lang.Integer jpegQuality)
                         throws java.lang.Exception
Throws:
java.lang.Exception

webcamStop

@Rpc(description="Stops the webcam stream.")
public void webcamStop()

cameraStartPreview

@Rpc(description="Start Preview Mode. Throws \'preview\' events.",
     returns="True if successful")
public boolean cameraStartPreview(@RpcParameter(name="resolutionLevel",description="increasing this number provides higher resolution")@RpcDefault(value="0")
                                                        java.lang.Integer resolutionLevel,
                                                        @RpcParameter(name="jpegQuality",description="a number from 0-100")@RpcDefault(value="20")
                                                        java.lang.Integer jpegQuality,
                                                        @RpcParameter(name="filepath",description="Path to store jpeg files.")@RpcOptional
                                                        java.lang.String filepath)
                           throws java.lang.InterruptedException
Throws:
java.lang.InterruptedException

cameraStopPreview

@Rpc(description="Stop the preview mode.")
public void cameraStopPreview()

shutdown

public void shutdown()
Description copied from class: RpcReceiver
Invoked when the receiver is shut down.

Specified by:
shutdown in class RpcReceiver