2012-09-04 18:01:56 -07:00
|
|
|
/* 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/. */
|
|
|
|
|
|
|
|
#ifndef DOM_CAMERA_ICAMERACONTROL_H
|
|
|
|
#define DOM_CAMERA_ICAMERACONTROL_H
|
|
|
|
|
2014-02-14 14:41:07 -08:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "nsISupportsImpl.h"
|
2012-09-04 18:01:56 -07:00
|
|
|
|
2014-04-14 12:04:24 -07:00
|
|
|
struct DeviceStorageFileDescriptor;
|
2014-01-16 17:01:43 -08:00
|
|
|
|
2014-02-14 14:41:07 -08:00
|
|
|
class nsIFile;
|
|
|
|
|
2012-09-04 18:01:56 -07:00
|
|
|
namespace mozilla {
|
|
|
|
|
2014-02-14 14:41:07 -08:00
|
|
|
class CameraControlListener;
|
2012-10-23 15:30:28 -07:00
|
|
|
class RecorderProfileManager;
|
2012-09-04 18:01:56 -07:00
|
|
|
|
2014-02-14 14:41:07 -08:00
|
|
|
// XXXmikeh - In some future patch this should move into the ICameraControl
|
|
|
|
// class as well, and the names updated to the 'k'-style;
|
|
|
|
// e.g. kParamPreviewSize, etc.
|
|
|
|
enum {
|
|
|
|
// current settings
|
|
|
|
CAMERA_PARAM_PREVIEWSIZE,
|
|
|
|
CAMERA_PARAM_PREVIEWFORMAT,
|
|
|
|
CAMERA_PARAM_PREVIEWFRAMERATE,
|
|
|
|
CAMERA_PARAM_VIDEOSIZE,
|
|
|
|
CAMERA_PARAM_PICTURE_SIZE,
|
|
|
|
CAMERA_PARAM_PICTURE_FILEFORMAT,
|
|
|
|
CAMERA_PARAM_PICTURE_ROTATION,
|
|
|
|
CAMERA_PARAM_PICTURE_LOCATION,
|
|
|
|
CAMERA_PARAM_PICTURE_DATETIME,
|
|
|
|
CAMERA_PARAM_EFFECT,
|
|
|
|
CAMERA_PARAM_WHITEBALANCE,
|
|
|
|
CAMERA_PARAM_SCENEMODE,
|
|
|
|
CAMERA_PARAM_FLASHMODE,
|
|
|
|
CAMERA_PARAM_FOCUSMODE,
|
|
|
|
CAMERA_PARAM_ZOOM,
|
|
|
|
CAMERA_PARAM_METERINGAREAS,
|
|
|
|
CAMERA_PARAM_FOCUSAREAS,
|
|
|
|
CAMERA_PARAM_FOCALLENGTH,
|
|
|
|
CAMERA_PARAM_FOCUSDISTANCENEAR,
|
|
|
|
CAMERA_PARAM_FOCUSDISTANCEOPTIMUM,
|
|
|
|
CAMERA_PARAM_FOCUSDISTANCEFAR,
|
|
|
|
CAMERA_PARAM_EXPOSURECOMPENSATION,
|
|
|
|
CAMERA_PARAM_THUMBNAILSIZE,
|
|
|
|
CAMERA_PARAM_THUMBNAILQUALITY,
|
|
|
|
CAMERA_PARAM_SENSORANGLE,
|
2014-03-06 22:00:43 -08:00
|
|
|
CAMERA_PARAM_ISOMODE,
|
2014-04-09 08:53:41 -07:00
|
|
|
CAMERA_PARAM_LUMINANCE,
|
2014-04-16 18:46:36 -07:00
|
|
|
CAMERA_PARAM_SCENEMODE_HDR_RETURNNORMALPICTURE,
|
2014-02-14 14:41:07 -08:00
|
|
|
|
|
|
|
// supported features
|
|
|
|
CAMERA_PARAM_SUPPORTED_PREVIEWSIZES,
|
|
|
|
CAMERA_PARAM_SUPPORTED_PICTURESIZES,
|
|
|
|
CAMERA_PARAM_SUPPORTED_VIDEOSIZES,
|
|
|
|
CAMERA_PARAM_SUPPORTED_PICTUREFORMATS,
|
|
|
|
CAMERA_PARAM_SUPPORTED_WHITEBALANCES,
|
|
|
|
CAMERA_PARAM_SUPPORTED_SCENEMODES,
|
|
|
|
CAMERA_PARAM_SUPPORTED_EFFECTS,
|
|
|
|
CAMERA_PARAM_SUPPORTED_FLASHMODES,
|
|
|
|
CAMERA_PARAM_SUPPORTED_FOCUSMODES,
|
|
|
|
CAMERA_PARAM_SUPPORTED_MAXFOCUSAREAS,
|
|
|
|
CAMERA_PARAM_SUPPORTED_MAXMETERINGAREAS,
|
|
|
|
CAMERA_PARAM_SUPPORTED_MINEXPOSURECOMPENSATION,
|
|
|
|
CAMERA_PARAM_SUPPORTED_MAXEXPOSURECOMPENSATION,
|
|
|
|
CAMERA_PARAM_SUPPORTED_EXPOSURECOMPENSATIONSTEP,
|
|
|
|
CAMERA_PARAM_SUPPORTED_ZOOM,
|
|
|
|
CAMERA_PARAM_SUPPORTED_ZOOMRATIOS,
|
2014-04-09 08:52:10 -07:00
|
|
|
CAMERA_PARAM_SUPPORTED_MAXDETECTEDFACES,
|
2014-03-06 22:00:43 -08:00
|
|
|
CAMERA_PARAM_SUPPORTED_JPEG_THUMBNAIL_SIZES,
|
|
|
|
CAMERA_PARAM_SUPPORTED_ISOMODES
|
2014-02-14 14:41:07 -08:00
|
|
|
};
|
|
|
|
|
2012-09-04 18:01:56 -07:00
|
|
|
class ICameraControl
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(ICameraControl)
|
|
|
|
|
2014-02-14 14:41:07 -08:00
|
|
|
static nsresult GetNumberOfCameras(int32_t& aDeviceCount);
|
|
|
|
static nsresult GetCameraName(uint32_t aDeviceNum, nsCString& aDeviceName);
|
|
|
|
static nsresult GetListOfCameras(nsTArray<nsString>& aList);
|
|
|
|
|
|
|
|
enum Mode {
|
|
|
|
kUnspecifiedMode,
|
|
|
|
kPictureMode,
|
|
|
|
kVideoMode,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Size {
|
|
|
|
uint32_t width;
|
|
|
|
uint32_t height;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Region {
|
|
|
|
int32_t top;
|
|
|
|
int32_t left;
|
|
|
|
int32_t bottom;
|
|
|
|
int32_t right;
|
|
|
|
uint32_t weight;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Position {
|
2014-04-09 08:52:10 -07:00
|
|
|
double latitude;
|
|
|
|
double longitude;
|
|
|
|
double altitude;
|
|
|
|
double timestamp;
|
2014-02-14 14:41:07 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct StartRecordingOptions {
|
|
|
|
uint32_t rotation;
|
|
|
|
uint32_t maxFileSizeBytes;
|
|
|
|
uint32_t maxVideoLengthMs;
|
2014-04-09 08:53:41 -07:00
|
|
|
bool autoEnableLowLightTorch;
|
2014-02-14 14:41:07 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Configuration {
|
|
|
|
Mode mMode;
|
|
|
|
Size mPreviewSize;
|
|
|
|
nsString mRecorderProfile;
|
|
|
|
};
|
2014-04-09 08:52:10 -07:00
|
|
|
|
|
|
|
struct Point
|
|
|
|
{
|
|
|
|
int32_t x;
|
|
|
|
int32_t y;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Face {
|
|
|
|
uint32_t id;
|
|
|
|
uint32_t score;
|
|
|
|
Region bound;
|
|
|
|
bool hasLeftEye;
|
|
|
|
Point leftEye;
|
|
|
|
bool hasRightEye;
|
|
|
|
Point rightEye;
|
|
|
|
bool hasMouth;
|
|
|
|
Point mouth;
|
|
|
|
};
|
|
|
|
|
2014-02-19 20:18:52 -08:00
|
|
|
static already_AddRefed<ICameraControl> Create(uint32_t aCameraId);
|
|
|
|
|
|
|
|
virtual nsresult Start(const Configuration* aInitialConfig = nullptr) = 0;
|
|
|
|
virtual nsresult Stop() = 0;
|
|
|
|
|
2014-02-14 14:41:07 -08:00
|
|
|
virtual nsresult SetConfiguration(const Configuration& aConfig) = 0;
|
|
|
|
|
|
|
|
virtual void AddListener(CameraControlListener* aListener) = 0;
|
|
|
|
virtual void RemoveListener(CameraControlListener* aListener) = 0;
|
|
|
|
|
|
|
|
virtual nsresult StartPreview() = 0;
|
|
|
|
virtual nsresult StopPreview() = 0;
|
2014-04-15 12:46:40 -07:00
|
|
|
virtual nsresult AutoFocus() = 0;
|
2014-02-14 14:41:07 -08:00
|
|
|
virtual nsresult TakePicture() = 0;
|
|
|
|
virtual nsresult StartRecording(DeviceStorageFileDescriptor *aFileDescriptor,
|
|
|
|
const StartRecordingOptions* aOptions = nullptr) = 0;
|
2012-09-04 18:01:56 -07:00
|
|
|
virtual nsresult StopRecording() = 0;
|
2014-04-09 08:52:10 -07:00
|
|
|
virtual nsresult StartFaceDetection() = 0;
|
|
|
|
virtual nsresult StopFaceDetection() = 0;
|
2014-04-15 12:46:40 -07:00
|
|
|
virtual nsresult ResumeContinuousFocus() = 0;
|
2012-09-04 18:01:56 -07:00
|
|
|
|
|
|
|
virtual nsresult Set(uint32_t aKey, const nsAString& aValue) = 0;
|
|
|
|
virtual nsresult Get(uint32_t aKey, nsAString& aValue) = 0;
|
|
|
|
virtual nsresult Set(uint32_t aKey, double aValue) = 0;
|
2014-02-14 14:41:07 -08:00
|
|
|
virtual nsresult Get(uint32_t aKey, double& aValue) = 0;
|
|
|
|
virtual nsresult Set(uint32_t aKey, int32_t aValue) = 0;
|
|
|
|
virtual nsresult Get(uint32_t aKey, int32_t& aValue) = 0;
|
|
|
|
virtual nsresult Set(uint32_t aKey, int64_t aValue) = 0;
|
|
|
|
virtual nsresult Get(uint32_t aKey, int64_t& aValue) = 0;
|
|
|
|
virtual nsresult Set(uint32_t aKey, const Size& aValue) = 0;
|
|
|
|
virtual nsresult Get(uint32_t aKey, Size& aValue) = 0;
|
|
|
|
virtual nsresult Set(uint32_t aKey, const nsTArray<Region>& aRegions) = 0;
|
|
|
|
virtual nsresult Get(uint32_t aKey, nsTArray<Region>& aRegions) = 0;
|
|
|
|
|
|
|
|
virtual nsresult SetLocation(const Position& aLocation) = 0;
|
|
|
|
|
|
|
|
virtual nsresult Get(uint32_t aKey, nsTArray<Size>& aSizes) = 0;
|
|
|
|
virtual nsresult Get(uint32_t aKey, nsTArray<nsString>& aValues) = 0;
|
|
|
|
virtual nsresult Get(uint32_t aKey, nsTArray<double>& aValues) = 0;
|
|
|
|
|
2012-10-23 15:30:28 -07:00
|
|
|
virtual already_AddRefed<RecorderProfileManager> GetRecorderProfileManager() = 0;
|
|
|
|
virtual uint32_t GetCameraId() = 0;
|
2012-09-04 18:01:56 -07:00
|
|
|
|
2012-09-30 17:37:47 -07:00
|
|
|
virtual void Shutdown() = 0;
|
|
|
|
|
2012-09-04 18:01:56 -07:00
|
|
|
protected:
|
|
|
|
virtual ~ICameraControl() { }
|
2014-02-14 14:41:07 -08:00
|
|
|
|
|
|
|
friend class ICameraControlParameterSetAutoEnter;
|
|
|
|
|
|
|
|
virtual void BeginBatchParameterSet() = 0;
|
|
|
|
virtual void EndBatchParameterSet() = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Helper class to make it easy to update a batch of camera parameters;
|
|
|
|
// the parameters are applied atomically when this object goes out of
|
|
|
|
// scope.
|
|
|
|
class ICameraControlParameterSetAutoEnter
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ICameraControlParameterSetAutoEnter(ICameraControl* aCameraControl)
|
|
|
|
: mCameraControl(aCameraControl)
|
|
|
|
{
|
|
|
|
mCameraControl->BeginBatchParameterSet();
|
|
|
|
}
|
|
|
|
virtual ~ICameraControlParameterSetAutoEnter()
|
|
|
|
{
|
|
|
|
mCameraControl->EndBatchParameterSet();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
nsRefPtr<ICameraControl> mCameraControl;
|
2012-09-04 18:01:56 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // DOM_CAMERA_ICAMERACONTROL_H
|