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_DOMCAMERACONTROL_H
|
|
|
|
#define DOM_CAMERA_DOMCAMERACONTROL_H
|
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2014-02-14 05:27:44 -08:00
|
|
|
#include "nsIDOMEventListener.h"
|
|
|
|
#include "DictionaryHelpers.h"
|
2012-09-04 18:01:56 -07:00
|
|
|
#include "ICameraControl.h"
|
2014-02-14 05:27:44 -08:00
|
|
|
#include "DOMCameraPreview.h"
|
|
|
|
#include "nsIDOMCameraManager.h"
|
2012-09-04 18:01:56 -07:00
|
|
|
#include "CameraCommon.h"
|
2012-12-11 02:14:06 -08:00
|
|
|
#include "AudioChannelAgent.h"
|
2013-06-17 08:59:53 -07:00
|
|
|
#include "nsProxyRelease.h"
|
2013-10-23 04:11:18 -07:00
|
|
|
#include "nsHashPropertyBag.h"
|
2014-01-16 17:01:43 -08:00
|
|
|
#include "DeviceStorage.h"
|
2012-09-04 18:01:56 -07:00
|
|
|
|
2013-07-06 13:55:10 -07:00
|
|
|
class nsDOMDeviceStorage;
|
|
|
|
class nsPIDOMWindow;
|
|
|
|
|
2012-09-04 18:01:56 -07:00
|
|
|
namespace mozilla {
|
2013-07-06 13:55:10 -07:00
|
|
|
namespace dom {
|
2014-02-14 05:27:44 -08:00
|
|
|
class CameraPictureOptions;
|
|
|
|
template<typename T> class Optional;
|
2013-07-06 13:55:10 -07:00
|
|
|
}
|
|
|
|
class ErrorResult;
|
2012-09-04 18:01:56 -07:00
|
|
|
|
|
|
|
// Main camera control.
|
2014-02-14 05:27:44 -08:00
|
|
|
class nsDOMCameraControl MOZ_FINAL : public nsIDOMEventListener,
|
|
|
|
public nsWrapperCache
|
2012-09-04 18:01:56 -07:00
|
|
|
{
|
|
|
|
public:
|
2014-02-14 05:27:44 -08:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_NSIDOMEVENTLISTENER
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsDOMCameraControl)
|
|
|
|
|
|
|
|
nsDOMCameraControl(uint32_t aCameraId, nsIThread* aCameraThread,
|
|
|
|
nsICameraGetCameraCallback* onSuccess,
|
|
|
|
nsICameraErrorCallback* onError, nsPIDOMWindow* aWindow);
|
|
|
|
nsresult Result(nsresult aResult,
|
|
|
|
const nsMainThreadPtrHandle<nsICameraGetCameraCallback>& onSuccess,
|
|
|
|
const nsMainThreadPtrHandle<nsICameraErrorCallback>& onError,
|
|
|
|
uint64_t aWindowId);
|
2013-05-02 04:59:58 -07:00
|
|
|
nsRefPtr<ICameraControl> GetNativeCameraControl();
|
2012-09-30 17:37:47 -07:00
|
|
|
|
|
|
|
void Shutdown();
|
2012-09-04 18:01:56 -07:00
|
|
|
|
2013-07-06 13:55:10 -07:00
|
|
|
nsPIDOMWindow* GetParentObject() const { return mWindow; }
|
|
|
|
|
2014-02-14 05:27:44 -08:00
|
|
|
// WebIDL
|
|
|
|
nsICameraCapabilities* Capabilities();
|
2013-07-06 13:55:10 -07:00
|
|
|
void GetEffect(nsString& aEffect, ErrorResult& aRv);
|
|
|
|
void SetEffect(const nsAString& aEffect, ErrorResult& aRv);
|
|
|
|
void GetWhiteBalanceMode(nsString& aMode, ErrorResult& aRv);
|
|
|
|
void SetWhiteBalanceMode(const nsAString& aMode, ErrorResult& aRv);
|
|
|
|
void GetSceneMode(nsString& aMode, ErrorResult& aRv);
|
|
|
|
void SetSceneMode(const nsAString& aMode, ErrorResult& aRv);
|
|
|
|
void GetFlashMode(nsString& aMode, ErrorResult& aRv);
|
|
|
|
void SetFlashMode(const nsAString& aMode, ErrorResult& aRv);
|
|
|
|
void GetFocusMode(nsString& aMode, ErrorResult& aRv);
|
|
|
|
void SetFocusMode(const nsAString& aMode, ErrorResult& aRv);
|
|
|
|
double GetZoom(ErrorResult& aRv);
|
|
|
|
void SetZoom(double aZoom, ErrorResult& aRv);
|
|
|
|
JS::Value GetMeteringAreas(JSContext* aCx, ErrorResult& aRv);
|
|
|
|
void SetMeteringAreas(JSContext* aCx, JS::Handle<JS::Value> aAreas, ErrorResult& aRv);
|
|
|
|
JS::Value GetFocusAreas(JSContext* aCx, ErrorResult& aRv);
|
|
|
|
void SetFocusAreas(JSContext* aCx, JS::Handle<JS::Value> aAreas, ErrorResult& aRv);
|
2013-10-30 12:41:08 -07:00
|
|
|
JS::Value GetPictureSize(JSContext* aCx, ErrorResult& aRv);
|
|
|
|
void SetPictureSize(JSContext* aCx, JS::Handle<JS::Value> aSize, ErrorResult& aRv);
|
|
|
|
JS::Value GetThumbnailSize(JSContext* aCx, ErrorResult& aRv);
|
|
|
|
void SetThumbnailSize(JSContext* aCx, JS::Handle<JS::Value> aSize, ErrorResult& aRv);
|
2013-07-06 13:55:10 -07:00
|
|
|
double GetFocalLength(ErrorResult& aRv);
|
|
|
|
double GetFocusDistanceNear(ErrorResult& aRv);
|
|
|
|
double GetFocusDistanceOptimum(ErrorResult& aRv);
|
|
|
|
double GetFocusDistanceFar(ErrorResult& aRv);
|
|
|
|
void SetExposureCompensation(const dom::Optional<double>& aCompensation, ErrorResult& aRv);
|
|
|
|
double GetExposureCompensation(ErrorResult& aRv);
|
2013-12-06 06:47:29 -08:00
|
|
|
int32_t SensorAngle();
|
2014-02-14 05:27:44 -08:00
|
|
|
already_AddRefed<nsICameraShutterCallback> GetOnShutter(ErrorResult& aRv);
|
|
|
|
void SetOnShutter(nsICameraShutterCallback* aCb, ErrorResult& aRv);
|
|
|
|
already_AddRefed<nsICameraClosedCallback> GetOnClosed(ErrorResult& aRv);
|
|
|
|
void SetOnClosed(nsICameraClosedCallback* aCb, ErrorResult& aRv);
|
|
|
|
already_AddRefed<nsICameraRecorderStateChange> GetOnRecorderStateChange(ErrorResult& aRv);
|
|
|
|
void SetOnRecorderStateChange(nsICameraRecorderStateChange* aCb, ErrorResult& aRv);
|
|
|
|
void AutoFocus(nsICameraAutoFocusCallback* aOnSuccess, const dom::Optional<nsICameraErrorCallback*>& aOnErro, ErrorResult& aRvr);
|
|
|
|
void TakePicture(JSContext* aCx, const dom::CameraPictureOptions& aOptions,
|
|
|
|
nsICameraTakePictureCallback* onSuccess,
|
|
|
|
const dom::Optional<nsICameraErrorCallback* >& onError,
|
2013-07-06 13:55:10 -07:00
|
|
|
ErrorResult& aRv);
|
2014-02-14 05:27:44 -08:00
|
|
|
already_AddRefed<nsICameraPreviewStateChange> GetOnPreviewStateChange() const;
|
|
|
|
void SetOnPreviewStateChange(nsICameraPreviewStateChange* aOnStateChange);
|
|
|
|
void GetPreviewStreamVideoMode(JSContext* cx, JS::Handle<JS::Value> aOptions, nsICameraPreviewStreamCallback* onSuccess, const dom::Optional<nsICameraErrorCallback* >& onError, ErrorResult& aRv);
|
|
|
|
void StartRecording(JSContext* cx, JS::Handle<JS::Value> aOptions, nsDOMDeviceStorage& storageArea, const nsAString& filename, nsICameraStartRecordingCallback* onSuccess, const dom::Optional<nsICameraErrorCallback* >& onError, ErrorResult& aRv);
|
2013-07-06 13:55:10 -07:00
|
|
|
void StopRecording(ErrorResult& aRv);
|
2014-02-14 05:27:44 -08:00
|
|
|
void GetPreviewStream(JSContext* cx, JS::Handle<JS::Value> aOptions, nsICameraPreviewStreamCallback* onSuccess, const dom::Optional<nsICameraErrorCallback* >& onError, ErrorResult& aRv);
|
2013-07-06 13:55:10 -07:00
|
|
|
void ResumePreview(ErrorResult& aRv);
|
2014-02-14 05:27:44 -08:00
|
|
|
void ReleaseHardware(const dom::Optional<nsICameraReleaseCallback* >& onSuccess, const dom::Optional<nsICameraErrorCallback* >& onError, ErrorResult& aRv);
|
2013-07-06 13:55:10 -07:00
|
|
|
|
2012-09-04 18:01:56 -07:00
|
|
|
protected:
|
|
|
|
virtual ~nsDOMCameraControl();
|
|
|
|
|
2014-02-14 05:27:44 -08:00
|
|
|
private:
|
|
|
|
nsDOMCameraControl(const nsDOMCameraControl&) MOZ_DELETE;
|
|
|
|
nsDOMCameraControl& operator=(const nsDOMCameraControl&) MOZ_DELETE;
|
2012-09-04 18:01:56 -07:00
|
|
|
|
2014-02-14 05:27:44 -08:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
|
2013-11-25 22:22:22 -08:00
|
|
|
nsresult NotifyRecordingStatusChange(const nsString& aMsg);
|
2013-07-06 13:55:10 -07:00
|
|
|
|
2014-02-14 05:27:44 -08:00
|
|
|
mozilla::idl::CameraStartRecordingOptions mOptions;
|
2014-02-13 21:28:57 -08:00
|
|
|
nsRefPtr<DeviceStorageFileDescriptor> mDSFileDescriptor;
|
2014-02-14 05:27:44 -08:00
|
|
|
nsCOMPtr<nsICameraStartRecordingCallback> mOnSuccessCb;
|
|
|
|
nsCOMPtr<nsICameraErrorCallback> mOnErrorCb;
|
2014-02-13 21:28:57 -08:00
|
|
|
|
2014-02-14 05:27:44 -08:00
|
|
|
protected:
|
|
|
|
/* additional members */
|
|
|
|
nsRefPtr<ICameraControl> mCameraControl; // non-DOM camera control
|
|
|
|
nsCOMPtr<nsICameraCapabilities> mDOMCapabilities;
|
|
|
|
// An agent used to join audio channel service.
|
|
|
|
nsCOMPtr<nsIAudioChannelAgent> mAudioChannelAgent;
|
|
|
|
nsCOMPtr<nsPIDOMWindow> mWindow;
|
2012-09-04 18:01:56 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // DOM_CAMERA_DOMCAMERACONTROL_H
|