dom/camera/ICameraControl.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
michael@0 3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 #ifndef DOM_CAMERA_ICAMERACONTROL_H
michael@0 6 #define DOM_CAMERA_ICAMERACONTROL_H
michael@0 7
michael@0 8 #include "nsCOMPtr.h"
michael@0 9 #include "nsString.h"
michael@0 10 #include "nsAutoPtr.h"
michael@0 11 #include "nsISupportsImpl.h"
michael@0 12
michael@0 13 struct DeviceStorageFileDescriptor;
michael@0 14
michael@0 15 class nsIFile;
michael@0 16
michael@0 17 namespace mozilla {
michael@0 18
michael@0 19 class CameraControlListener;
michael@0 20 class RecorderProfileManager;
michael@0 21
michael@0 22 // XXXmikeh - In some future patch this should move into the ICameraControl
michael@0 23 // class as well, and the names updated to the 'k'-style;
michael@0 24 // e.g. kParamPreviewSize, etc.
michael@0 25 enum {
michael@0 26 // current settings
michael@0 27 CAMERA_PARAM_PREVIEWSIZE,
michael@0 28 CAMERA_PARAM_PREVIEWFORMAT,
michael@0 29 CAMERA_PARAM_PREVIEWFRAMERATE,
michael@0 30 CAMERA_PARAM_VIDEOSIZE,
michael@0 31 CAMERA_PARAM_PICTURE_SIZE,
michael@0 32 CAMERA_PARAM_PICTURE_FILEFORMAT,
michael@0 33 CAMERA_PARAM_PICTURE_ROTATION,
michael@0 34 CAMERA_PARAM_PICTURE_LOCATION,
michael@0 35 CAMERA_PARAM_PICTURE_DATETIME,
michael@0 36 CAMERA_PARAM_EFFECT,
michael@0 37 CAMERA_PARAM_WHITEBALANCE,
michael@0 38 CAMERA_PARAM_SCENEMODE,
michael@0 39 CAMERA_PARAM_FLASHMODE,
michael@0 40 CAMERA_PARAM_FOCUSMODE,
michael@0 41 CAMERA_PARAM_ZOOM,
michael@0 42 CAMERA_PARAM_METERINGAREAS,
michael@0 43 CAMERA_PARAM_FOCUSAREAS,
michael@0 44 CAMERA_PARAM_FOCALLENGTH,
michael@0 45 CAMERA_PARAM_FOCUSDISTANCENEAR,
michael@0 46 CAMERA_PARAM_FOCUSDISTANCEOPTIMUM,
michael@0 47 CAMERA_PARAM_FOCUSDISTANCEFAR,
michael@0 48 CAMERA_PARAM_EXPOSURECOMPENSATION,
michael@0 49 CAMERA_PARAM_THUMBNAILSIZE,
michael@0 50 CAMERA_PARAM_THUMBNAILQUALITY,
michael@0 51 CAMERA_PARAM_SENSORANGLE,
michael@0 52 CAMERA_PARAM_ISOMODE,
michael@0 53 CAMERA_PARAM_LUMINANCE,
michael@0 54 CAMERA_PARAM_SCENEMODE_HDR_RETURNNORMALPICTURE,
michael@0 55
michael@0 56 // supported features
michael@0 57 CAMERA_PARAM_SUPPORTED_PREVIEWSIZES,
michael@0 58 CAMERA_PARAM_SUPPORTED_PICTURESIZES,
michael@0 59 CAMERA_PARAM_SUPPORTED_VIDEOSIZES,
michael@0 60 CAMERA_PARAM_SUPPORTED_PICTUREFORMATS,
michael@0 61 CAMERA_PARAM_SUPPORTED_WHITEBALANCES,
michael@0 62 CAMERA_PARAM_SUPPORTED_SCENEMODES,
michael@0 63 CAMERA_PARAM_SUPPORTED_EFFECTS,
michael@0 64 CAMERA_PARAM_SUPPORTED_FLASHMODES,
michael@0 65 CAMERA_PARAM_SUPPORTED_FOCUSMODES,
michael@0 66 CAMERA_PARAM_SUPPORTED_MAXFOCUSAREAS,
michael@0 67 CAMERA_PARAM_SUPPORTED_MAXMETERINGAREAS,
michael@0 68 CAMERA_PARAM_SUPPORTED_MINEXPOSURECOMPENSATION,
michael@0 69 CAMERA_PARAM_SUPPORTED_MAXEXPOSURECOMPENSATION,
michael@0 70 CAMERA_PARAM_SUPPORTED_EXPOSURECOMPENSATIONSTEP,
michael@0 71 CAMERA_PARAM_SUPPORTED_ZOOM,
michael@0 72 CAMERA_PARAM_SUPPORTED_ZOOMRATIOS,
michael@0 73 CAMERA_PARAM_SUPPORTED_MAXDETECTEDFACES,
michael@0 74 CAMERA_PARAM_SUPPORTED_JPEG_THUMBNAIL_SIZES,
michael@0 75 CAMERA_PARAM_SUPPORTED_ISOMODES
michael@0 76 };
michael@0 77
michael@0 78 class ICameraControl
michael@0 79 {
michael@0 80 public:
michael@0 81 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(ICameraControl)
michael@0 82
michael@0 83 static nsresult GetNumberOfCameras(int32_t& aDeviceCount);
michael@0 84 static nsresult GetCameraName(uint32_t aDeviceNum, nsCString& aDeviceName);
michael@0 85 static nsresult GetListOfCameras(nsTArray<nsString>& aList);
michael@0 86
michael@0 87 enum Mode {
michael@0 88 kUnspecifiedMode,
michael@0 89 kPictureMode,
michael@0 90 kVideoMode,
michael@0 91 };
michael@0 92
michael@0 93 struct Size {
michael@0 94 uint32_t width;
michael@0 95 uint32_t height;
michael@0 96 };
michael@0 97
michael@0 98 struct Region {
michael@0 99 int32_t top;
michael@0 100 int32_t left;
michael@0 101 int32_t bottom;
michael@0 102 int32_t right;
michael@0 103 uint32_t weight;
michael@0 104 };
michael@0 105
michael@0 106 struct Position {
michael@0 107 double latitude;
michael@0 108 double longitude;
michael@0 109 double altitude;
michael@0 110 double timestamp;
michael@0 111 };
michael@0 112
michael@0 113 struct StartRecordingOptions {
michael@0 114 uint32_t rotation;
michael@0 115 uint32_t maxFileSizeBytes;
michael@0 116 uint32_t maxVideoLengthMs;
michael@0 117 bool autoEnableLowLightTorch;
michael@0 118 };
michael@0 119
michael@0 120 struct Configuration {
michael@0 121 Mode mMode;
michael@0 122 Size mPreviewSize;
michael@0 123 nsString mRecorderProfile;
michael@0 124 };
michael@0 125
michael@0 126 struct Point
michael@0 127 {
michael@0 128 int32_t x;
michael@0 129 int32_t y;
michael@0 130 };
michael@0 131
michael@0 132 struct Face {
michael@0 133 uint32_t id;
michael@0 134 uint32_t score;
michael@0 135 Region bound;
michael@0 136 bool hasLeftEye;
michael@0 137 Point leftEye;
michael@0 138 bool hasRightEye;
michael@0 139 Point rightEye;
michael@0 140 bool hasMouth;
michael@0 141 Point mouth;
michael@0 142 };
michael@0 143
michael@0 144 static already_AddRefed<ICameraControl> Create(uint32_t aCameraId);
michael@0 145
michael@0 146 virtual nsresult Start(const Configuration* aInitialConfig = nullptr) = 0;
michael@0 147 virtual nsresult Stop() = 0;
michael@0 148
michael@0 149 virtual nsresult SetConfiguration(const Configuration& aConfig) = 0;
michael@0 150
michael@0 151 virtual void AddListener(CameraControlListener* aListener) = 0;
michael@0 152 virtual void RemoveListener(CameraControlListener* aListener) = 0;
michael@0 153
michael@0 154 virtual nsresult StartPreview() = 0;
michael@0 155 virtual nsresult StopPreview() = 0;
michael@0 156 virtual nsresult AutoFocus() = 0;
michael@0 157 virtual nsresult TakePicture() = 0;
michael@0 158 virtual nsresult StartRecording(DeviceStorageFileDescriptor *aFileDescriptor,
michael@0 159 const StartRecordingOptions* aOptions = nullptr) = 0;
michael@0 160 virtual nsresult StopRecording() = 0;
michael@0 161 virtual nsresult StartFaceDetection() = 0;
michael@0 162 virtual nsresult StopFaceDetection() = 0;
michael@0 163 virtual nsresult ResumeContinuousFocus() = 0;
michael@0 164
michael@0 165 virtual nsresult Set(uint32_t aKey, const nsAString& aValue) = 0;
michael@0 166 virtual nsresult Get(uint32_t aKey, nsAString& aValue) = 0;
michael@0 167 virtual nsresult Set(uint32_t aKey, double aValue) = 0;
michael@0 168 virtual nsresult Get(uint32_t aKey, double& aValue) = 0;
michael@0 169 virtual nsresult Set(uint32_t aKey, int32_t aValue) = 0;
michael@0 170 virtual nsresult Get(uint32_t aKey, int32_t& aValue) = 0;
michael@0 171 virtual nsresult Set(uint32_t aKey, int64_t aValue) = 0;
michael@0 172 virtual nsresult Get(uint32_t aKey, int64_t& aValue) = 0;
michael@0 173 virtual nsresult Set(uint32_t aKey, const Size& aValue) = 0;
michael@0 174 virtual nsresult Get(uint32_t aKey, Size& aValue) = 0;
michael@0 175 virtual nsresult Set(uint32_t aKey, const nsTArray<Region>& aRegions) = 0;
michael@0 176 virtual nsresult Get(uint32_t aKey, nsTArray<Region>& aRegions) = 0;
michael@0 177
michael@0 178 virtual nsresult SetLocation(const Position& aLocation) = 0;
michael@0 179
michael@0 180 virtual nsresult Get(uint32_t aKey, nsTArray<Size>& aSizes) = 0;
michael@0 181 virtual nsresult Get(uint32_t aKey, nsTArray<nsString>& aValues) = 0;
michael@0 182 virtual nsresult Get(uint32_t aKey, nsTArray<double>& aValues) = 0;
michael@0 183
michael@0 184 virtual already_AddRefed<RecorderProfileManager> GetRecorderProfileManager() = 0;
michael@0 185 virtual uint32_t GetCameraId() = 0;
michael@0 186
michael@0 187 virtual void Shutdown() = 0;
michael@0 188
michael@0 189 protected:
michael@0 190 virtual ~ICameraControl() { }
michael@0 191
michael@0 192 friend class ICameraControlParameterSetAutoEnter;
michael@0 193
michael@0 194 virtual void BeginBatchParameterSet() = 0;
michael@0 195 virtual void EndBatchParameterSet() = 0;
michael@0 196 };
michael@0 197
michael@0 198 // Helper class to make it easy to update a batch of camera parameters;
michael@0 199 // the parameters are applied atomically when this object goes out of
michael@0 200 // scope.
michael@0 201 class ICameraControlParameterSetAutoEnter
michael@0 202 {
michael@0 203 public:
michael@0 204 ICameraControlParameterSetAutoEnter(ICameraControl* aCameraControl)
michael@0 205 : mCameraControl(aCameraControl)
michael@0 206 {
michael@0 207 mCameraControl->BeginBatchParameterSet();
michael@0 208 }
michael@0 209 virtual ~ICameraControlParameterSetAutoEnter()
michael@0 210 {
michael@0 211 mCameraControl->EndBatchParameterSet();
michael@0 212 }
michael@0 213
michael@0 214 protected:
michael@0 215 nsRefPtr<ICameraControl> mCameraControl;
michael@0 216 };
michael@0 217
michael@0 218 } // namespace mozilla
michael@0 219
michael@0 220 #endif // DOM_CAMERA_ICAMERACONTROL_H

mercurial