Hi everyone,
Here is the XPIDL for the CameraControl API. It has been updated to incorporate the changes discussed on this thread. Please look it over and let me know if you have any concerns or second thoughts or if I've missed anything.
Thanks!
--Mike.
---------- 8< ----------
#include "domstubs.idl"
#include "nsIDOMMediaStream.idl"
#include "nsIDOMDOMRequest.idl"
#include "nsIDOMFile.idl"
[scriptable, uuid(64196840-0d03-4b65-a955-790f43a4b810)]
interface nsICameraCapabilities : nsISupports
{
/* an array of objects with 'height' and 'width' properties
supported for the preview stream */
readonly attribute jsval previewSizes;
/* an array of objects with 'height' and 'width' properties
supported for picture taking */
readonly attribute jsval pictureSizes;
/* an array of strings, e.g. [ "jpeg", "rgb565" ] */
readonly attribute jsval fileFormats;
/* an array of strings, e.g. [ "auto", "fluorescent", etc. ] */
readonly attribute jsval whiteBalanceModes;
/* an array of strings, e.g. [ "auto", "night", "beach", etc. ] */
readonly attribute jsval sceneModes;
/* an array of strings, e.g. [ "normal", "sepia", "mono", etc. ] */
readonly attribute jsval effects;
/* an array of strings, e.g. [ "auto", "off", "on", etc. ] */
readonly attribute jsval flashModes;
/* an array of strings, e.g. [ "auto", "fixed", "macro", etc. ] */
readonly attribute jsval focusModes;
/* the maximum number of focus areas supported by the camera */
readonly attribute long maxFocusAreas;
/* the minimum supported exposure compensation value */
readonly attribute double minExposureCompensation;
/* the maximum supported exposure compensation value */
readonly attribute double maxExposureCompensation;
/* exposure compensation minimum step-size */
readonly attribute double stepExposureCompensation;
/* the maximum number of metering areas supported by the camera */
readonly attribute long maxMeteringAreas;
/* an array of doubles, e.g. [ 1.0, 1.2, 1.5, 2.0, 3.0, etc. ],
or null if zooming is not supported */
readonly attribute jsval zoomRatios;
/* an array of objects with 'height' and 'width' properties
supported for video recording */
readonly attribute jsval videoSizes;
};
/*
These properties only affect the captured image;
invalid property settings are ignored.
*/
[scriptable, uuid(e127cbfc-bc60-4621-97b3-cb78d2549237)]
interface nsICameraPictureOptions : nsISupports
{
/* an object with a combination of 'height' and 'width' properties
chosen from nsICameraCapabilities.pictureSizes */
attribute jsval pictureSize;
/* one of the file formats chosen from
nsICameraCapabilities.fileFormats */
attribute DOMString fileFormat;
/* the rotation of the image in degrees, from 0 to 270 in
steps of 90; this doesn't affect the image, only the
rotation recorded in the image header.*/
attribute long rotation;
/* an object containing any or all of 'latitude', 'longitude',
'elevation', and 'timestamp', used to record when and where
the image was taken. e.g.
{
latitude: 43.647118,
longitude: -79.3943,
elevation: 500
// timestamp not specified, in this case
}
can be null in the case where position information isn't
available/desired.
'elevation' is in metres; 'timestamp' is UTC, in seconds from
January 1, 1970.
*/
attribute jsval position;
};
[scriptable, function, uuid(0444a687-4bc9-462c-8246-5423f0fe46a4)]
interface nsICameraPreviewStreamCallback : nsISupports
{
void handleEvent(in nsIDOMMediaStream stream);
};
[scriptable, function, uuid(6baa4ac7-9c25-4c48-9bb0-5193b38b9b0a)]
interface nsICameraAutoFocusCallback : nsISupports
{
void handleEvent();
};
[scriptable, function, uuid(17af779e-cb6f-4ca5-890c-06468ff82e4f)]
interface nsICameraTakePictureCallback : nsISupports
{
void handleEvent(in nsIDOMBlob picture);
};
[scriptable, function, uuid(ac43f123-529c-48d3-84dd-ad206b7aca9b)]
interface nsICameraStartRecordingCallback : nsISupports
{
void handleEvent(); /* need to determine parameters */
};
[scriptable, function, uuid(fb80db71-e315-42f0-9ea9-dd3dd312ed70)]
interface nsICameraShutterCallback : nsISupports
{
void handleEvent();
}
[scriptable, function, uuid(a302c6c9-3776-4d1d-a395-f4105d47c3d3)]
interface nsICameraErrorCallback : nsISupports
{
void handleEvent(in nsIDOMError error);
};
/*
attributes here affect the preview, any pictures taken, and/or
any video recorded by the camera.
*/
[scriptable, uuid(3066c884-d2c3-4477-847d-08ea1c2d188a)]
interface nsICameraControl : nsISupports
{
readonly attribute nsICameraCapabilities capabilities;
/* one of the vales chosen from capabilities.effects;
default is "none" */
attribute DOMString effect;
/* one of the values chosen from capabilities.whiteBalanceModes;
default is "auto" */
attribute DOMString whiteBalanceMode;
/* one of the valus chosen from capabilities.sceneModes;
default is "auto" */
attribute DOMString sceneMode;
/* one of the values chosen from capabilities.flashModes;
default is "auto" */
attribute DOMString flashMode;
/* one of the values chosen from capabilities.focusModes;
default is "auto", if supported, or "fixed" */
attribute DOMString focusMode;
/* one of the values chosen from capabilities.zoomRatios; other
values will be rounded to the nearest supported value;
default is 1.0 */
attribute double zoom;
/* an array of one or more objects that define where the
camera will perform light metering, each defining the properties:
{
top: -1000,
left: -1000,
bottom: 1000,
right: 1000,
weight: 1000
}
'top', 'left', 'bottom', and 'right' all range from -1000 at
the top-/leftmost of the sensor to 1000 at the bottom-/rightmost
of the sensor.
objects missing one or more of these properties will be ignored;
if the array contains more than capabilities.maxMeteringAreas,
extra areas will be ignored.
this attribute can be set to null to allow the camera to determine
where to perform light metering. */
attribute jsval meteringAreas;
/* an array of one or more objects that define where the camera will
perform auto-focusing, with the same definition as meteringAreas.
if the array contains more than capabilities.maxFocusAreas, extra
areas will be ignored.
this attribute can be set to null to allow the camera to determine
where to focus. */
attribute jsval focusAreas;
/* focal length in millimetres */
readonly attribute double focalLength;
/* the distances in metres to where the image subject appears to be
in focus. 'focusDistanceOptimum' is where the subject will appear
sharpest; the difference between 'focusDistanceFar' and
'focusDistanceNear' is the image's depth of field.
'focusDistanceFar' may be infinity. */
readonly attribute double focusDistanceNear;
readonly attribute double focusDistanceOptimum;
readonly attribute double focusDistanceFar;
/* 'compensation' is optional, and if missing, will
set the camera to use automatic exposure compensation.
acceptable values must range from minExposureCompensation
to maxExposureCompensation in steps of stepExposureCompensation;
invalid values will be rounded to the nearest valid value. */
void setExposureCompensation([optional] in double compensation);
readonly attribute double exposureCompensation;
/* the function to call on the camera's shutter event, to trigger
a shutter sound and/or a visual shutter indicator. */
attribute nsIShutterCallback onShutter;
/* tell the camera to attempt to focus the image */
void autoFocus(in nsICameraAutoFocusCallback onSuccess, [optional] in nsICameraErrorCallback onError);
/* capture an image and return it as a blob to the 'onSuccess' callback;
if the camera supports it, this may be invoked while the camera is
already recording video.
invoking this function will stop the preview stream, which must be
manually restarted (e.g. by calling .play() on it). */
void takePicture(in nsICameraTakePictureCallback onSuccess, [optional] in nsICameraErrorCallback onError);
/* start recording video; 'aOptions' define the frame size of to
capture, chosen from capabilities.videoSizes, e.g.:
{
width: 640,
height: 480
}
*/
void startRecording(in jsval aOptions, in nsICameraStartRecordingCallback onSuccess, [optional] in nsICameraErrorCallback onError);
/* stop precording video. */
void stopRecording();
/* get a media stream to be used as a camera viewfinder; the options
define the desired frame size of the preview, chosen from
capabilities.previewSizes, e.g.:
{
height: 640,
width: 480,
}
*/
[implicit_jscontext]
void getPreviewStream(in jsval aOptions, in nsICameraPreviewStreamCallback onSuccess, [optional] in nsICameraErrorCallback onError);
};
[scriptable, uuid(671ee624-0336-441a-a24e-26b5319f14ff)]
interface nsICameraManager : nsISupports
{
/* get a camera instance; options will be used to specify which
camera to get from the list returned by getListOfCameras(), e.g.:
{
camera: front
}
*/
[implicit_jscontext]
nsICameraControl getCamera([optional] in jsval aOptions);
/* return a JSON array of camera identifiers, e.g.
[ "front", "back" ]
*/
[implicit_jscontext]
jsval getListOfCameras();
};
> > Wouldn't it make more sense that we have an API on the Camera
> > Control
> > API which returns a preview stream? This way we are staying out of
> > the way for getUserMedia and it can evolve freely.
>