2013-07-07 00:55:10 +04:00
|
|
|
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*/
|
|
|
|
|
|
|
|
interface CameraCapabilities;
|
|
|
|
interface GetCameraCallback;
|
|
|
|
interface CameraErrorCallback;
|
|
|
|
interface CameraShutterCallback;
|
|
|
|
interface CameraClosedCallback;
|
|
|
|
interface CameraRecorderStateChange;
|
|
|
|
interface CameraAutoFocusCallback;
|
|
|
|
interface CameraTakePictureCallback;
|
|
|
|
interface CameraPreviewStateChange;
|
|
|
|
interface CameraPreviewStreamCallback;
|
|
|
|
interface CameraStartRecordingCallback;
|
|
|
|
interface CameraReleaseCallback;
|
|
|
|
|
|
|
|
/*
|
|
|
|
attributes here affect the preview, any pictures taken, and/or
|
|
|
|
any video recorded by the camera.
|
|
|
|
*/
|
|
|
|
interface CameraControl {
|
|
|
|
readonly attribute CameraCapabilities capabilities;
|
|
|
|
|
|
|
|
/* one of the values chosen from capabilities.effects;
|
|
|
|
default is "none" */
|
|
|
|
[Throws]
|
|
|
|
attribute DOMString effect;
|
|
|
|
|
|
|
|
/* one of the values chosen from capabilities.whiteBalanceModes;
|
|
|
|
default is "auto" */
|
|
|
|
[Throws]
|
|
|
|
attribute DOMString whiteBalanceMode;
|
|
|
|
|
|
|
|
/* one of the values chosen from capabilities.sceneModes;
|
|
|
|
default is "auto" */
|
|
|
|
[Throws]
|
|
|
|
attribute DOMString sceneMode;
|
|
|
|
|
|
|
|
/* one of the values chosen from capabilities.flashModes;
|
|
|
|
default is "auto" */
|
|
|
|
[Throws]
|
|
|
|
attribute DOMString flashMode;
|
|
|
|
|
|
|
|
/* one of the values chosen from capabilities.focusModes;
|
|
|
|
default is "auto", if supported, or "fixed" */
|
|
|
|
[Throws]
|
|
|
|
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 */
|
|
|
|
[Throws]
|
|
|
|
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. */
|
|
|
|
[Throws]
|
|
|
|
attribute any 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. */
|
|
|
|
[Throws]
|
|
|
|
attribute any focusAreas;
|
|
|
|
|
|
|
|
/* focal length in millimetres */
|
|
|
|
[Throws]
|
|
|
|
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. */
|
|
|
|
[Throws]
|
|
|
|
readonly attribute double focusDistanceNear;
|
|
|
|
[Throws]
|
|
|
|
readonly attribute double focusDistanceOptimum;
|
|
|
|
[Throws]
|
|
|
|
readonly attribute unrestricted 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. */
|
|
|
|
[Throws]
|
|
|
|
void setExposureCompensation(optional double compensation);
|
|
|
|
[Throws]
|
|
|
|
readonly attribute unrestricted double exposureCompensation;
|
|
|
|
|
|
|
|
/* the function to call on the camera's shutter event, to trigger
|
|
|
|
a shutter sound and/or a visual shutter indicator. */
|
|
|
|
[Throws]
|
|
|
|
attribute CameraShutterCallback? onShutter;
|
|
|
|
|
|
|
|
/* the function to call when the camera hardware is closed
|
|
|
|
by the underlying framework, e.g. when another app makes a more
|
|
|
|
recent call to get the camera. */
|
|
|
|
[Throws]
|
|
|
|
attribute CameraClosedCallback? onClosed;
|
|
|
|
|
|
|
|
/* the function to call when the recorder changes state, either because
|
|
|
|
the recording process encountered an error, or because one of the
|
|
|
|
recording limits (see CameraStartRecordingOptions) was reached. */
|
|
|
|
[Throws]
|
|
|
|
attribute CameraRecorderStateChange? onRecorderStateChange;
|
|
|
|
attribute CameraPreviewStateChange? onPreviewStateChange;
|
|
|
|
|
|
|
|
/* tell the camera to attempt to focus the image */
|
|
|
|
[Throws]
|
|
|
|
void autoFocus(CameraAutoFocusCallback onSuccess, optional CameraErrorCallback 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). */
|
|
|
|
[Throws]
|
|
|
|
void takePicture(CameraPictureOptions aOptions,
|
|
|
|
CameraTakePictureCallback onSuccess,
|
|
|
|
optional CameraErrorCallback onError);
|
|
|
|
|
|
|
|
/* get a media stream to be used as a camera viewfinder in video mode;
|
|
|
|
'aOptions' is an CameraRecorderOptions object. */
|
|
|
|
[Throws]
|
2013-10-11 20:02:41 +04:00
|
|
|
void getPreviewStreamVideoMode(CameraRecorderOptions aOptions, CameraPreviewStreamCallback onSuccess, optional CameraErrorCallback onError);
|
2013-07-07 00:55:10 +04:00
|
|
|
|
|
|
|
/* start recording video; 'aOptions' is a
|
|
|
|
CameraStartRecordingOptions object. */
|
|
|
|
[Throws]
|
2013-10-11 20:02:41 +04:00
|
|
|
void startRecording(CameraStartRecordingOptions aOptions, DeviceStorage storageArea, DOMString filename, CameraStartRecordingCallback onSuccess, optional CameraErrorCallback onError);
|
2013-07-07 00:55:10 +04:00
|
|
|
|
|
|
|
/* stop precording video. */
|
|
|
|
[Throws]
|
|
|
|
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,
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
[Throws]
|
|
|
|
void getPreviewStream(any aOptions, CameraPreviewStreamCallback onSuccess, optional CameraErrorCallback onError);
|
|
|
|
|
|
|
|
/* call in or after the takePicture() onSuccess callback to
|
|
|
|
resume the camera preview stream. */
|
|
|
|
[Throws]
|
|
|
|
void resumePreview();
|
|
|
|
|
|
|
|
/* release the camera so that other applications can use it; you should
|
|
|
|
probably call this whenever the camera is not longer in the foreground
|
|
|
|
(depending on your usage model).
|
|
|
|
|
|
|
|
the callbacks are optional, unless you really need to know when
|
|
|
|
the hardware is ultimately released.
|
|
|
|
|
|
|
|
once this is called, the camera control object is to be considered
|
|
|
|
defunct; a new instance will need to be created to access the camera. */
|
|
|
|
[Throws]
|
|
|
|
void release(optional CameraReleaseCallback onSuccess, optional CameraErrorCallback onError);
|
|
|
|
};
|
2013-10-11 20:02:41 +04:00
|
|
|
/* These properties affect the actual video recording, e.g.
|
|
|
|
{
|
|
|
|
rotation: 0,
|
|
|
|
maxFileSizeBytes: 1024 * 1024,
|
|
|
|
maxVideoLengthMs: 0
|
|
|
|
}
|
|
|
|
|
|
|
|
'rotation' is the degrees clockwise to rotate the recorded video; if
|
|
|
|
this options is not supported, it will be ignored; if this option is
|
|
|
|
missing, the default is 0.
|
|
|
|
|
|
|
|
'maxFileSizeBytes' is the maximum size in bytes to which the recorded
|
|
|
|
video file will be allowed to grow.
|
|
|
|
|
|
|
|
'maxVideoLengthMs' is the maximum length in milliseconds to which the
|
|
|
|
recorded video will be allowed to grow.
|
|
|
|
|
|
|
|
if either 'maxFileSizeBytes' or 'maxVideoLengthMs' is missing, zero,
|
|
|
|
or negative, that limit will be disabled.
|
|
|
|
*/
|
|
|
|
dictionary CameraStartRecordingOptions
|
|
|
|
{
|
|
|
|
long rotation = 0;
|
|
|
|
long long maxFileSizeBytes = 0;
|
|
|
|
long long maxVideoLengthMs = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* These properties affect the video recording preview, e.g.
|
|
|
|
{
|
|
|
|
profile: "1080p",
|
|
|
|
rotation: 0
|
|
|
|
}
|
|
|
|
|
|
|
|
'profile' is one of the profiles returned by
|
|
|
|
nsICameraCapabilities.recorderProfiles'; if this profile is missing,
|
|
|
|
an arbitrary profile will be chosen.
|
|
|
|
|
|
|
|
'rotation' is the degrees clockwise to rotate the preview; if
|
|
|
|
this option is not supported, it will be ignored; if this option
|
|
|
|
is missing, the default is 0.
|
|
|
|
*/
|
|
|
|
dictionary CameraRecorderOptions
|
|
|
|
{
|
|
|
|
DOMString profile = "";
|
|
|
|
long rotation = 0;
|
|
|
|
};
|