зеркало из https://github.com/mozilla/gecko-dev.git
bug 899210 - convert camera control to WebIDL r=bz
This commit is contained in:
Родитель
53890c2c91
Коммит
54fb4bac29
|
@ -612,7 +612,7 @@ MediaEngineWebRTCVideoSource::AllocImpl() {
|
|||
mCameraThread,
|
||||
this,
|
||||
this,
|
||||
mWindowId);
|
||||
nsGlobalWindow::GetInnerWindowWithId(mWindowId));
|
||||
mCameraManager->Register(mDOMCameraControl);
|
||||
}
|
||||
|
||||
|
@ -662,7 +662,7 @@ MediaEngineWebRTCVideoSource::SnapshotImpl() {
|
|||
|
||||
// nsICameraGetCameraCallback
|
||||
nsresult
|
||||
MediaEngineWebRTCVideoSource::HandleEvent(nsICameraControl* camera) {
|
||||
MediaEngineWebRTCVideoSource::HandleEvent(nsISupports* /* unused */) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
ReentrantMonitorAutoEnter sync(mCallbackMonitor);
|
||||
mNativeCameraControl = static_cast<nsGonkCameraControl*>(mDOMCameraControl->GetNativeCameraControl().get());
|
||||
|
|
|
@ -554,8 +554,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
|||
EVENTTARGET_SCRIPTABLE_FLAGS)
|
||||
#endif
|
||||
|
||||
NS_DEFINE_CLASSINFO_DATA(CameraControl, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(CameraCapabilities, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
|
||||
|
@ -1432,10 +1430,6 @@ nsDOMClassInfo::Init()
|
|||
DOM_CLASSINFO_MAP_END
|
||||
#endif
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(CameraControl, nsICameraControl)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsICameraControl)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(CameraCapabilities, nsICameraCapabilities)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsICameraCapabilities)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
|
|
@ -140,7 +140,6 @@ DOMCI_CLASS(FMRadio)
|
|||
DOMCI_CLASS(BluetoothDevice)
|
||||
#endif
|
||||
|
||||
DOMCI_CLASS(CameraControl)
|
||||
DOMCI_CLASS(CameraCapabilities)
|
||||
|
||||
DOMCI_CLASS(LockedFile)
|
||||
|
|
|
@ -176,6 +176,14 @@ DOMInterfaces = {
|
|||
'headerFile': 'CallsList.h',
|
||||
},
|
||||
|
||||
'CameraControl': {
|
||||
'nativeType': 'mozilla::nsDOMCameraControl',
|
||||
'headerFile': 'DOMCameraControl.h',
|
||||
'binaryNames': {
|
||||
"release": "ReleaseHardware"
|
||||
}
|
||||
},
|
||||
|
||||
'CameraManager': {
|
||||
'nativeType': 'nsDOMCameraManager',
|
||||
'headerFile': 'DOMCameraManager.h'
|
||||
|
@ -1815,3 +1823,13 @@ addExternalIface('XULCommandDispatcher')
|
|||
addExternalIface('DataTransfer', notflattened=True)
|
||||
addExternalIface('GetCameraCallback', nativeType='nsICameraGetCameraCallback', headerFile='nsIDOMCameraManager.h')
|
||||
addExternalIface('CameraErrorCallback', nativeType='nsICameraErrorCallback', headerFile='nsIDOMCameraManager.h')
|
||||
addExternalIface('CameraCapabilities', nativeType='nsICameraCapabilities', headerFile='nsIDOMCameraManager.h')
|
||||
addExternalIface('CameraAutoFocusCallback', nativeType='nsICameraAutoFocusCallback', headerFile='nsIDOMCameraManager.h')
|
||||
addExternalIface('CameraShutterCallback', nativeType='nsICameraShutterCallback', headerFile='nsIDOMCameraManager.h')
|
||||
addExternalIface('CameraClosedCallback', nativeType='nsICameraClosedCallback', headerFile='nsIDOMCameraManager.h')
|
||||
addExternalIface('CameraTakePictureCallback', nativeType='nsICameraTakePictureCallback', headerFile='nsIDOMCameraManager.h')
|
||||
addExternalIface('CameraReleaseCallback', nativeType='nsICameraReleaseCallback', headerFile='nsIDOMCameraManager.h')
|
||||
addExternalIface('CameraStartRecordingCallback', nativeType='nsICameraStartRecordingCallback', headerFile='nsIDOMCameraManager.h')
|
||||
addExternalIface('CameraPreviewStateChange', nativeType='nsICameraPreviewStateChange', headerFile='nsIDOMCameraManager.h')
|
||||
addExternalIface('CameraPreviewStreamCallback', nativeType='nsICameraPreviewStreamCallback', headerFile='nsIDOMCameraManager.h')
|
||||
addExternalIface('CameraRecorderStateChange', nativeType='nsICameraRecorderStateChange', headerFile='nsIDOMCameraManager.h')
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
#include "nsDOMClassInfo.h"
|
||||
#include "jsapi.h"
|
||||
#include "nsThread.h"
|
||||
#include "DeviceStorage.h"
|
||||
#include "mozilla/dom/CameraControlBinding.h"
|
||||
#include "mozilla/dom/ContentChild.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "mozilla/unused.h"
|
||||
|
@ -23,15 +25,11 @@
|
|||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
DOMCI_DATA(CameraControl, nsICameraControl)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_1(nsDOMCameraControl,
|
||||
mDOMCapabilities)
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_2(nsDOMCameraControl, mDOMCapabilities, mWindow)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsDOMCameraControl)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_ENTRY(nsICameraControl)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CameraControl)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDOMCameraControl)
|
||||
|
@ -42,235 +40,242 @@ nsDOMCameraControl::~nsDOMCameraControl()
|
|||
DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
|
||||
}
|
||||
|
||||
/* readonly attribute nsICameraCapabilities capabilities; */
|
||||
NS_IMETHODIMP
|
||||
nsDOMCameraControl::GetCapabilities(nsICameraCapabilities** aCapabilities)
|
||||
JSObject*
|
||||
nsDOMCameraControl::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
|
||||
{
|
||||
return CameraControlBinding::Wrap(aCx, aScope, this);
|
||||
}
|
||||
|
||||
nsICameraCapabilities*
|
||||
nsDOMCameraControl::Capabilities()
|
||||
{
|
||||
if (!mDOMCapabilities) {
|
||||
mDOMCapabilities = new DOMCameraCapabilities(mCameraControl);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsICameraCapabilities> capabilities = mDOMCapabilities;
|
||||
capabilities.forget(aCapabilities);
|
||||
return NS_OK;
|
||||
return mDOMCapabilities;
|
||||
}
|
||||
|
||||
/* attribute DOMString effect; */
|
||||
NS_IMETHODIMP
|
||||
nsDOMCameraControl::GetEffect(nsAString& aEffect)
|
||||
void
|
||||
nsDOMCameraControl::GetEffect(nsString& aEffect, ErrorResult& aRv)
|
||||
{
|
||||
return mCameraControl->Get(CAMERA_PARAM_EFFECT, aEffect);
|
||||
aRv = mCameraControl->Get(CAMERA_PARAM_EFFECT, aEffect);
|
||||
}
|
||||
NS_IMETHODIMP
|
||||
nsDOMCameraControl::SetEffect(const nsAString& aEffect)
|
||||
void
|
||||
nsDOMCameraControl::SetEffect(const nsAString& aEffect, ErrorResult& aRv)
|
||||
{
|
||||
return mCameraControl->Set(CAMERA_PARAM_EFFECT, aEffect);
|
||||
aRv = mCameraControl->Set(CAMERA_PARAM_EFFECT, aEffect);
|
||||
}
|
||||
|
||||
/* attribute DOMString whiteBalanceMode; */
|
||||
NS_IMETHODIMP
|
||||
nsDOMCameraControl::GetWhiteBalanceMode(nsAString& aWhiteBalanceMode)
|
||||
void
|
||||
nsDOMCameraControl::GetWhiteBalanceMode(nsString& aWhiteBalanceMode, ErrorResult& aRv)
|
||||
{
|
||||
return mCameraControl->Get(CAMERA_PARAM_WHITEBALANCE, aWhiteBalanceMode);
|
||||
aRv = mCameraControl->Get(CAMERA_PARAM_WHITEBALANCE, aWhiteBalanceMode);
|
||||
}
|
||||
NS_IMETHODIMP
|
||||
nsDOMCameraControl::SetWhiteBalanceMode(const nsAString& aWhiteBalanceMode)
|
||||
void
|
||||
nsDOMCameraControl::SetWhiteBalanceMode(const nsAString& aWhiteBalanceMode, ErrorResult& aRv)
|
||||
{
|
||||
return mCameraControl->Set(CAMERA_PARAM_WHITEBALANCE, aWhiteBalanceMode);
|
||||
aRv = mCameraControl->Set(CAMERA_PARAM_WHITEBALANCE, aWhiteBalanceMode);
|
||||
}
|
||||
|
||||
/* attribute DOMString sceneMode; */
|
||||
NS_IMETHODIMP
|
||||
nsDOMCameraControl::GetSceneMode(nsAString& aSceneMode)
|
||||
void
|
||||
nsDOMCameraControl::GetSceneMode(nsString& aSceneMode, ErrorResult& aRv)
|
||||
{
|
||||
return mCameraControl->Get(CAMERA_PARAM_SCENEMODE, aSceneMode);
|
||||
aRv = mCameraControl->Get(CAMERA_PARAM_SCENEMODE, aSceneMode);
|
||||
}
|
||||
NS_IMETHODIMP
|
||||
nsDOMCameraControl::SetSceneMode(const nsAString& aSceneMode)
|
||||
void
|
||||
nsDOMCameraControl::SetSceneMode(const nsAString& aSceneMode, ErrorResult& aRv)
|
||||
{
|
||||
return mCameraControl->Set(CAMERA_PARAM_SCENEMODE, aSceneMode);
|
||||
aRv = mCameraControl->Set(CAMERA_PARAM_SCENEMODE, aSceneMode);
|
||||
}
|
||||
|
||||
/* attribute DOMString flashMode; */
|
||||
NS_IMETHODIMP
|
||||
nsDOMCameraControl::GetFlashMode(nsAString& aFlashMode)
|
||||
void
|
||||
nsDOMCameraControl::GetFlashMode(nsString& aFlashMode, ErrorResult& aRv)
|
||||
{
|
||||
return mCameraControl->Get(CAMERA_PARAM_FLASHMODE, aFlashMode);
|
||||
aRv = mCameraControl->Get(CAMERA_PARAM_FLASHMODE, aFlashMode);
|
||||
}
|
||||
NS_IMETHODIMP
|
||||
nsDOMCameraControl::SetFlashMode(const nsAString& aFlashMode)
|
||||
void
|
||||
nsDOMCameraControl::SetFlashMode(const nsAString& aFlashMode, ErrorResult& aRv)
|
||||
{
|
||||
return mCameraControl->Set(CAMERA_PARAM_FLASHMODE, aFlashMode);
|
||||
aRv = mCameraControl->Set(CAMERA_PARAM_FLASHMODE, aFlashMode);
|
||||
}
|
||||
|
||||
/* attribute DOMString focusMode; */
|
||||
NS_IMETHODIMP
|
||||
nsDOMCameraControl::GetFocusMode(nsAString& aFocusMode)
|
||||
void
|
||||
nsDOMCameraControl::GetFocusMode(nsString& aFocusMode, ErrorResult& aRv)
|
||||
{
|
||||
return mCameraControl->Get(CAMERA_PARAM_FOCUSMODE, aFocusMode);
|
||||
aRv = mCameraControl->Get(CAMERA_PARAM_FOCUSMODE, aFocusMode);
|
||||
}
|
||||
NS_IMETHODIMP
|
||||
nsDOMCameraControl::SetFocusMode(const nsAString& aFocusMode)
|
||||
void
|
||||
nsDOMCameraControl::SetFocusMode(const nsAString& aFocusMode, ErrorResult& aRv)
|
||||
{
|
||||
return mCameraControl->Set(CAMERA_PARAM_FOCUSMODE, aFocusMode);
|
||||
aRv = mCameraControl->Set(CAMERA_PARAM_FOCUSMODE, aFocusMode);
|
||||
}
|
||||
|
||||
/* attribute double zoom; */
|
||||
NS_IMETHODIMP
|
||||
nsDOMCameraControl::GetZoom(double* aZoom)
|
||||
double
|
||||
nsDOMCameraControl::GetZoom(ErrorResult& aRv)
|
||||
{
|
||||
return mCameraControl->Get(CAMERA_PARAM_ZOOM, aZoom);
|
||||
double zoom;
|
||||
aRv = mCameraControl->Get(CAMERA_PARAM_ZOOM, &zoom);
|
||||
return zoom;
|
||||
}
|
||||
NS_IMETHODIMP
|
||||
nsDOMCameraControl::SetZoom(double aZoom)
|
||||
|
||||
void
|
||||
nsDOMCameraControl::SetZoom(double aZoom, ErrorResult& aRv)
|
||||
{
|
||||
return mCameraControl->Set(CAMERA_PARAM_ZOOM, aZoom);
|
||||
aRv = mCameraControl->Set(CAMERA_PARAM_ZOOM, aZoom);
|
||||
}
|
||||
|
||||
/* attribute jsval meteringAreas; */
|
||||
NS_IMETHODIMP
|
||||
nsDOMCameraControl::GetMeteringAreas(JSContext* cx, JS::Value* aMeteringAreas)
|
||||
JS::Value
|
||||
nsDOMCameraControl::GetMeteringAreas(JSContext* cx, ErrorResult& aRv)
|
||||
{
|
||||
return mCameraControl->Get(cx, CAMERA_PARAM_METERINGAREAS, aMeteringAreas);
|
||||
}
|
||||
NS_IMETHODIMP
|
||||
nsDOMCameraControl::SetMeteringAreas(JSContext* cx, const JS::Value& aMeteringAreas)
|
||||
{
|
||||
return mCameraControl->SetMeteringAreas(cx, aMeteringAreas);
|
||||
JS::Rooted<JS::Value> areas(cx);
|
||||
aRv = mCameraControl->Get(cx, CAMERA_PARAM_METERINGAREAS, areas.address());
|
||||
return areas;
|
||||
}
|
||||
|
||||
/* attribute jsval focusAreas; */
|
||||
NS_IMETHODIMP
|
||||
nsDOMCameraControl::GetFocusAreas(JSContext* cx, JS::Value* aFocusAreas)
|
||||
void
|
||||
nsDOMCameraControl::SetMeteringAreas(JSContext* cx, JS::Handle<JS::Value> aMeteringAreas, ErrorResult& aRv)
|
||||
{
|
||||
return mCameraControl->Get(cx, CAMERA_PARAM_FOCUSAREAS, aFocusAreas);
|
||||
}
|
||||
NS_IMETHODIMP
|
||||
nsDOMCameraControl::SetFocusAreas(JSContext* cx, const JS::Value& aFocusAreas)
|
||||
{
|
||||
return mCameraControl->SetFocusAreas(cx, aFocusAreas);
|
||||
aRv = mCameraControl->SetMeteringAreas(cx, aMeteringAreas);
|
||||
}
|
||||
|
||||
/* readonly attribute double focalLength; */
|
||||
NS_IMETHODIMP
|
||||
nsDOMCameraControl::GetFocalLength(double* aFocalLength)
|
||||
JS::Value
|
||||
nsDOMCameraControl::GetFocusAreas(JSContext* cx, ErrorResult& aRv)
|
||||
{
|
||||
return mCameraControl->Get(CAMERA_PARAM_FOCALLENGTH, aFocalLength);
|
||||
JS::Rooted<JS::Value> value(cx);
|
||||
aRv = mCameraControl->Get(cx, CAMERA_PARAM_FOCUSAREAS, value.address());
|
||||
return value;
|
||||
}
|
||||
void
|
||||
nsDOMCameraControl::SetFocusAreas(JSContext* cx, JS::Handle<JS::Value> aFocusAreas, ErrorResult& aRv)
|
||||
{
|
||||
aRv = mCameraControl->SetFocusAreas(cx, aFocusAreas);
|
||||
}
|
||||
|
||||
/* readonly attribute double focusDistanceNear; */
|
||||
NS_IMETHODIMP
|
||||
nsDOMCameraControl::GetFocusDistanceNear(double* aFocusDistanceNear)
|
||||
double
|
||||
nsDOMCameraControl::GetFocalLength(ErrorResult& aRv)
|
||||
{
|
||||
return mCameraControl->Get(CAMERA_PARAM_FOCUSDISTANCENEAR, aFocusDistanceNear);
|
||||
double focalLength;
|
||||
aRv = mCameraControl->Get(CAMERA_PARAM_FOCALLENGTH, &focalLength);
|
||||
return focalLength;
|
||||
}
|
||||
|
||||
/* readonly attribute double focusDistanceOptimum; */
|
||||
NS_IMETHODIMP
|
||||
nsDOMCameraControl::GetFocusDistanceOptimum(double* aFocusDistanceOptimum)
|
||||
double
|
||||
nsDOMCameraControl::GetFocusDistanceNear(ErrorResult& aRv)
|
||||
{
|
||||
return mCameraControl->Get(CAMERA_PARAM_FOCUSDISTANCEOPTIMUM, aFocusDistanceOptimum);
|
||||
double distance;
|
||||
aRv = mCameraControl->Get(CAMERA_PARAM_FOCUSDISTANCENEAR, &distance);
|
||||
return distance;
|
||||
}
|
||||
|
||||
/* readonly attribute double focusDistanceFar; */
|
||||
NS_IMETHODIMP
|
||||
nsDOMCameraControl::GetFocusDistanceFar(double* aFocusDistanceFar)
|
||||
double
|
||||
nsDOMCameraControl::GetFocusDistanceOptimum(ErrorResult& aRv)
|
||||
{
|
||||
return mCameraControl->Get(CAMERA_PARAM_FOCUSDISTANCEFAR, aFocusDistanceFar);
|
||||
double distance;
|
||||
aRv = mCameraControl->Get(CAMERA_PARAM_FOCUSDISTANCEOPTIMUM, &distance);
|
||||
return distance;
|
||||
}
|
||||
|
||||
/* void setExposureCompensation (const JS::Value& aCompensation, JSContext* cx); */
|
||||
NS_IMETHODIMP
|
||||
nsDOMCameraControl::SetExposureCompensation(const JS::Value& aCompensation, JSContext* cx)
|
||||
double
|
||||
nsDOMCameraControl::GetFocusDistanceFar(ErrorResult& aRv)
|
||||
{
|
||||
if (aCompensation.isNullOrUndefined()) {
|
||||
double distance;
|
||||
aRv = mCameraControl->Get(CAMERA_PARAM_FOCUSDISTANCEFAR, &distance);
|
||||
return distance;
|
||||
}
|
||||
|
||||
void
|
||||
nsDOMCameraControl::SetExposureCompensation(const Optional<double>& aCompensation, ErrorResult& aRv)
|
||||
{
|
||||
if (!aCompensation.WasPassed()) {
|
||||
// use NaN to switch the camera back into auto mode
|
||||
return mCameraControl->Set(CAMERA_PARAM_EXPOSURECOMPENSATION, NAN);
|
||||
aRv = mCameraControl->Set(CAMERA_PARAM_EXPOSURECOMPENSATION, NAN);
|
||||
}
|
||||
|
||||
aRv = mCameraControl->Set(CAMERA_PARAM_EXPOSURECOMPENSATION, aCompensation.Value());
|
||||
}
|
||||
|
||||
double
|
||||
nsDOMCameraControl::GetExposureCompensation(ErrorResult& aRv)
|
||||
{
|
||||
double compensation;
|
||||
if (!JS_ValueToNumber(cx, aCompensation, &compensation)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
return mCameraControl->Set(CAMERA_PARAM_EXPOSURECOMPENSATION, compensation);
|
||||
aRv = mCameraControl->Get(CAMERA_PARAM_EXPOSURECOMPENSATION, &compensation);
|
||||
return compensation;
|
||||
}
|
||||
|
||||
/* readonly attribute double exposureCompensation; */
|
||||
NS_IMETHODIMP
|
||||
nsDOMCameraControl::GetExposureCompensation(double* aExposureCompensation)
|
||||
already_AddRefed<nsICameraShutterCallback>
|
||||
nsDOMCameraControl::GetOnShutter(ErrorResult& aRv)
|
||||
{
|
||||
return mCameraControl->Get(CAMERA_PARAM_EXPOSURECOMPENSATION, aExposureCompensation);
|
||||
nsCOMPtr<nsICameraShutterCallback> cb;
|
||||
aRv = mCameraControl->Get(getter_AddRefs(cb));
|
||||
return cb.forget();
|
||||
}
|
||||
|
||||
/* attribute nsICameraShutterCallback onShutter; */
|
||||
NS_IMETHODIMP
|
||||
nsDOMCameraControl::GetOnShutter(nsICameraShutterCallback** aOnShutter)
|
||||
void
|
||||
nsDOMCameraControl::SetOnShutter(nsICameraShutterCallback* aOnShutter,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
return mCameraControl->Get(aOnShutter);
|
||||
}
|
||||
NS_IMETHODIMP
|
||||
nsDOMCameraControl::SetOnShutter(nsICameraShutterCallback* aOnShutter)
|
||||
{
|
||||
return mCameraControl->Set(aOnShutter);
|
||||
aRv = mCameraControl->Set(aOnShutter);
|
||||
}
|
||||
|
||||
/* attribute nsICameraClosedCallback onClosed; */
|
||||
NS_IMETHODIMP
|
||||
nsDOMCameraControl::GetOnClosed(nsICameraClosedCallback** aOnClosed)
|
||||
already_AddRefed<nsICameraClosedCallback>
|
||||
nsDOMCameraControl::GetOnClosed(ErrorResult& aRv)
|
||||
{
|
||||
return mCameraControl->Get(aOnClosed);
|
||||
}
|
||||
NS_IMETHODIMP
|
||||
nsDOMCameraControl::SetOnClosed(nsICameraClosedCallback* aOnClosed)
|
||||
{
|
||||
return mCameraControl->Set(aOnClosed);
|
||||
nsCOMPtr<nsICameraClosedCallback> onClosed;
|
||||
aRv = mCameraControl->Get(getter_AddRefs(onClosed));
|
||||
return onClosed.forget();
|
||||
}
|
||||
|
||||
/* attribute nsICameraRecorderStateChange onRecorderStateChange; */
|
||||
NS_IMETHODIMP
|
||||
nsDOMCameraControl::GetOnRecorderStateChange(nsICameraRecorderStateChange** aOnRecorderStateChange)
|
||||
void
|
||||
nsDOMCameraControl::SetOnClosed(nsICameraClosedCallback* aOnClosed,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
return mCameraControl->Get(aOnRecorderStateChange);
|
||||
}
|
||||
NS_IMETHODIMP
|
||||
nsDOMCameraControl::SetOnRecorderStateChange(nsICameraRecorderStateChange* aOnRecorderStateChange)
|
||||
{
|
||||
return mCameraControl->Set(aOnRecorderStateChange);
|
||||
aRv = mCameraControl->Set(aOnClosed);
|
||||
}
|
||||
|
||||
/* attribute nsICameraPreviewStateChange onPreviewStateChange; */
|
||||
NS_IMETHODIMP
|
||||
nsDOMCameraControl::GetOnPreviewStateChange(nsICameraPreviewStateChange** aOnPreviewStateChange)
|
||||
already_AddRefed<nsICameraRecorderStateChange>
|
||||
nsDOMCameraControl::GetOnRecorderStateChange(ErrorResult& aRv)
|
||||
{
|
||||
return mCameraControl->Get(aOnPreviewStateChange);
|
||||
}
|
||||
NS_IMETHODIMP
|
||||
nsDOMCameraControl::SetOnPreviewStateChange(nsICameraPreviewStateChange* aOnPreviewStateChange)
|
||||
{
|
||||
return mCameraControl->Set(aOnPreviewStateChange);
|
||||
nsCOMPtr<nsICameraRecorderStateChange> cb;
|
||||
aRv = mCameraControl->Get(getter_AddRefs(cb));
|
||||
return cb.forget();
|
||||
}
|
||||
|
||||
/* [implicit_jscontext] void startRecording (in jsval aOptions, in nsIDOMDeviceStorage storageArea, in DOMString filename, in nsICameraStartRecordingCallback onSuccess, [optional] in nsICameraErrorCallback onError); */
|
||||
NS_IMETHODIMP
|
||||
nsDOMCameraControl::StartRecording(const JS::Value& aOptions, nsIDOMDeviceStorage* storageArea, const nsAString& filename, nsICameraStartRecordingCallback* onSuccess, nsICameraErrorCallback* onError, JSContext* cx)
|
||||
void
|
||||
nsDOMCameraControl::SetOnRecorderStateChange(nsICameraRecorderStateChange* aOnRecorderStateChange,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
NS_ENSURE_TRUE(onSuccess, NS_ERROR_INVALID_ARG);
|
||||
NS_ENSURE_TRUE(storageArea, NS_ERROR_INVALID_ARG);
|
||||
aRv = mCameraControl->Set(aOnRecorderStateChange);
|
||||
}
|
||||
|
||||
void
|
||||
nsDOMCameraControl::StartRecording(JSContext* aCx,
|
||||
JS::Handle<JS::Value> aOptions,
|
||||
nsDOMDeviceStorage& storageArea,
|
||||
const nsAString& filename,
|
||||
nsICameraStartRecordingCallback* onSuccess,
|
||||
const Optional<nsICameraErrorCallback*>& onError,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
MOZ_ASSERT(onSuccess, "no onSuccess handler passed");
|
||||
mozilla::idl::CameraStartRecordingOptions options;
|
||||
|
||||
// Default values, until the dictionary parser can handle them.
|
||||
options.rotation = 0;
|
||||
options.maxFileSizeBytes = 0;
|
||||
options.maxVideoLengthMs = 0;
|
||||
nsresult rv = options.Init(cx, &aOptions);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
aRv = options.Init(aCx, aOptions.address());
|
||||
if (aRv.Failed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
||||
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
|
||||
if (!obs) {
|
||||
NS_WARNING("Could not get the Observer service for CameraControl::StartRecording.");
|
||||
return NS_ERROR_FAILURE;
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return;
|
||||
}
|
||||
|
||||
obs->NotifyObservers(nullptr,
|
||||
|
@ -296,19 +301,21 @@ nsDOMCameraControl::StartRecording(const JS::Value& aOptions, nsIDOMDeviceStorag
|
|||
#endif
|
||||
|
||||
nsCOMPtr<nsIFile> folder;
|
||||
rv = storageArea->GetRootDirectoryForFile(filename, getter_AddRefs(folder));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
return mCameraControl->StartRecording(&options, folder, filename, onSuccess, onError);
|
||||
aRv = storageArea.GetRootDirectoryForFile(filename, getter_AddRefs(folder));
|
||||
if (aRv.Failed()) {
|
||||
return;
|
||||
}
|
||||
aRv = mCameraControl->StartRecording(&options, folder, filename, onSuccess,
|
||||
onError.WasPassed() ? onError.Value() : nullptr);
|
||||
}
|
||||
|
||||
/* void stopRecording (); */
|
||||
NS_IMETHODIMP
|
||||
nsDOMCameraControl::StopRecording()
|
||||
void
|
||||
nsDOMCameraControl::StopRecording(ErrorResult& aRv)
|
||||
{
|
||||
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
|
||||
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
|
||||
if (!obs) {
|
||||
NS_WARNING("Could not get the Observer service for CameraControl::StopRecording.");
|
||||
return NS_ERROR_FAILURE;
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
}
|
||||
|
||||
obs->NotifyObservers(nullptr,
|
||||
|
@ -327,55 +334,71 @@ nsDOMCameraControl::StopRecording()
|
|||
}
|
||||
#endif
|
||||
|
||||
return mCameraControl->StopRecording();
|
||||
aRv = mCameraControl->StopRecording();
|
||||
}
|
||||
|
||||
/* [implicit_jscontext] void getPreviewStream (in jsval aOptions, in nsICameraPreviewStreamCallback onSuccess, [optional] in nsICameraErrorCallback onError); */
|
||||
NS_IMETHODIMP
|
||||
nsDOMCameraControl::GetPreviewStream(const JS::Value& aOptions, nsICameraPreviewStreamCallback* onSuccess, nsICameraErrorCallback* onError, JSContext* cx)
|
||||
void
|
||||
nsDOMCameraControl::GetPreviewStream(JSContext* aCx,
|
||||
JS::Handle<JS::Value> aOptions,
|
||||
nsICameraPreviewStreamCallback* onSuccess,
|
||||
const Optional<nsICameraErrorCallback*>& onError,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
NS_ENSURE_TRUE(onSuccess, NS_ERROR_INVALID_ARG);
|
||||
|
||||
mozilla::idl::CameraSize size;
|
||||
nsresult rv = size.Init(cx, &aOptions);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
aRv = size.Init(aCx, aOptions.address());
|
||||
if (aRv.Failed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
return mCameraControl->GetPreviewStream(size, onSuccess, onError);
|
||||
aRv = mCameraControl->GetPreviewStream(size, onSuccess,
|
||||
onError.WasPassed()
|
||||
? onError.Value() : nullptr);
|
||||
}
|
||||
|
||||
/* void resumePreview(); */
|
||||
NS_IMETHODIMP
|
||||
nsDOMCameraControl::ResumePreview()
|
||||
void
|
||||
nsDOMCameraControl::ResumePreview(ErrorResult& aRv)
|
||||
{
|
||||
return mCameraControl->StartPreview(nullptr);
|
||||
aRv = mCameraControl->StartPreview(nullptr);
|
||||
}
|
||||
|
||||
/* void autoFocus (in nsICameraAutoFocusCallback onSuccess, [optional] in nsICameraErrorCallback onError); */
|
||||
NS_IMETHODIMP
|
||||
nsDOMCameraControl::AutoFocus(nsICameraAutoFocusCallback* onSuccess, nsICameraErrorCallback* onError)
|
||||
already_AddRefed<nsICameraPreviewStateChange>
|
||||
nsDOMCameraControl::GetOnPreviewStateChange() const
|
||||
{
|
||||
NS_ENSURE_TRUE(onSuccess, NS_ERROR_INVALID_ARG);
|
||||
return mCameraControl->AutoFocus(onSuccess, onError);
|
||||
nsCOMPtr<nsICameraPreviewStateChange> cb;
|
||||
mCameraControl->Get(getter_AddRefs(cb));
|
||||
return cb.forget();
|
||||
}
|
||||
|
||||
/* void takePicture (in jsval aOptions, in nsICameraTakePictureCallback onSuccess, [optional] in nsICameraErrorCallback onError); */
|
||||
NS_IMETHODIMP
|
||||
nsDOMCameraControl::TakePicture(const JS::Value& aOptions, nsICameraTakePictureCallback* onSuccess, nsICameraErrorCallback* onError, JSContext* cx)
|
||||
void
|
||||
nsDOMCameraControl::SetOnPreviewStateChange(nsICameraPreviewStateChange* aCb)
|
||||
{
|
||||
NS_ENSURE_TRUE(onSuccess, NS_ERROR_INVALID_ARG);
|
||||
mCameraControl->Set(aCb);
|
||||
}
|
||||
|
||||
RootedDictionary<CameraPictureOptions> options(cx);
|
||||
void
|
||||
nsDOMCameraControl::AutoFocus(nsICameraAutoFocusCallback* onSuccess,
|
||||
const Optional<nsICameraErrorCallback*>& onError,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
aRv = mCameraControl->AutoFocus(onSuccess,
|
||||
onError.WasPassed() ? onError.Value() : nullptr);
|
||||
}
|
||||
|
||||
void
|
||||
nsDOMCameraControl::TakePicture(JSContext* aCx,
|
||||
const CameraPictureOptions& aOptions,
|
||||
nsICameraTakePictureCallback* onSuccess,
|
||||
const Optional<nsICameraErrorCallback*>& aOnError,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
mozilla::idl::CameraSize size;
|
||||
mozilla::idl::CameraPosition pos;
|
||||
|
||||
JS::Rooted<JS::Value> optionVal(cx, aOptions);
|
||||
if (!options.Init(cx, optionVal)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
aRv = size.Init(aCx, &aOptions.mPictureSize);
|
||||
if (aRv.Failed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsresult rv = size.Init(cx, &options.mPictureSize);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
/**
|
||||
* Default values, until the dictionary parser can handle them.
|
||||
* NaN indicates no value provided.
|
||||
|
@ -384,29 +407,45 @@ nsDOMCameraControl::TakePicture(const JS::Value& aOptions, nsICameraTakePictureC
|
|||
pos.longitude = NAN;
|
||||
pos.altitude = NAN;
|
||||
pos.timestamp = NAN;
|
||||
rv = pos.Init(cx, &options.mPosition);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
aRv = pos.Init(aCx, &aOptions.mPosition);
|
||||
if (aRv.Failed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
return mCameraControl->TakePicture(size, options.mRotation, options.mFileFormat, pos, options.mDateTime, onSuccess, onError);
|
||||
nsICameraErrorCallback* onError =
|
||||
aOnError.WasPassed() ? aOnError.Value() : nullptr;
|
||||
aRv = mCameraControl->TakePicture(size, aOptions.mRotation,
|
||||
aOptions.mFileFormat, pos,
|
||||
aOptions.mDateTime, onSuccess, onError);
|
||||
}
|
||||
|
||||
/* [implicit_jscontext] void GetPreviewStreamVideoMode (in jsval aOptions, in nsICameraPreviewStreamCallback onSuccess, [optional] in nsICameraErrorCallback onError); */
|
||||
NS_IMETHODIMP
|
||||
nsDOMCameraControl::GetPreviewStreamVideoMode(const JS::Value& aOptions, nsICameraPreviewStreamCallback* onSuccess, nsICameraErrorCallback* onError, JSContext* cx)
|
||||
void
|
||||
nsDOMCameraControl::GetPreviewStreamVideoMode(JSContext* aCx,
|
||||
JS::Handle<JS::Value> aOptions,
|
||||
nsICameraPreviewStreamCallback* onSuccess,
|
||||
const Optional<nsICameraErrorCallback*>& onError,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
NS_ENSURE_TRUE(onSuccess, NS_ERROR_INVALID_ARG);
|
||||
|
||||
mozilla::idl::CameraRecorderOptions options;
|
||||
nsresult rv = options.Init(cx, &aOptions);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
aRv = options.Init(aCx, aOptions.address());
|
||||
if (aRv.Failed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
return mCameraControl->GetPreviewStreamVideoMode(&options, onSuccess, onError);
|
||||
aRv = mCameraControl->GetPreviewStreamVideoMode(&options, onSuccess,
|
||||
onError.WasPassed()
|
||||
? onError.Value() : nullptr);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMCameraControl::ReleaseHardware(nsICameraReleaseCallback* onSuccess, nsICameraErrorCallback* onError)
|
||||
void
|
||||
nsDOMCameraControl::ReleaseHardware(const Optional<nsICameraReleaseCallback*>& onSuccess,
|
||||
const Optional<nsICameraErrorCallback*>& onError,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
return mCameraControl->ReleaseHardware(onSuccess, onError);
|
||||
aRv =
|
||||
mCameraControl->ReleaseHardware(
|
||||
onSuccess.WasPassed() ? onSuccess.Value() : nullptr,
|
||||
onError.WasPassed() ? onError.Value() : nullptr);
|
||||
}
|
||||
|
||||
class GetCameraResult : public nsRunnable
|
||||
|
|
|
@ -16,19 +16,27 @@
|
|||
#include "AudioChannelAgent.h"
|
||||
#include "nsProxyRelease.h"
|
||||
|
||||
class nsDOMDeviceStorage;
|
||||
class nsPIDOMWindow;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
class CameraPictureOptions;
|
||||
template<typename T> class Optional;
|
||||
}
|
||||
class ErrorResult;
|
||||
|
||||
// Main camera control.
|
||||
class nsDOMCameraControl : public nsICameraControl
|
||||
class nsDOMCameraControl MOZ_FINAL : public nsISupports,
|
||||
public nsWrapperCache
|
||||
{
|
||||
public:
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS(nsDOMCameraControl)
|
||||
NS_DECL_NSICAMERACONTROL
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsDOMCameraControl)
|
||||
|
||||
nsDOMCameraControl(uint32_t aCameraId, nsIThread* aCameraThread,
|
||||
nsICameraGetCameraCallback* onSuccess,
|
||||
nsICameraErrorCallback* onError, uint64_t aWindowId);
|
||||
nsICameraErrorCallback* onError, nsPIDOMWindow* aWindow);
|
||||
nsresult Result(nsresult aResult,
|
||||
const nsMainThreadPtrHandle<nsICameraGetCameraCallback>& onSuccess,
|
||||
const nsMainThreadPtrHandle<nsICameraErrorCallback>& onError,
|
||||
|
@ -37,6 +45,52 @@ public:
|
|||
|
||||
void Shutdown();
|
||||
|
||||
nsPIDOMWindow* GetParentObject() const { return mWindow; }
|
||||
|
||||
// WebIDL
|
||||
nsICameraCapabilities* Capabilities();
|
||||
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);
|
||||
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);
|
||||
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,
|
||||
ErrorResult& aRv);
|
||||
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);
|
||||
void StopRecording(ErrorResult& aRv);
|
||||
void GetPreviewStream(JSContext* cx, JS::Handle<JS::Value> aOptions, nsICameraPreviewStreamCallback* onSuccess, const dom::Optional<nsICameraErrorCallback* >& onError, ErrorResult& aRv);
|
||||
void ResumePreview(ErrorResult& aRv);
|
||||
void ReleaseHardware(const dom::Optional<nsICameraReleaseCallback* >& onSuccess, const dom::Optional<nsICameraErrorCallback* >& onError, ErrorResult& aRv);
|
||||
|
||||
protected:
|
||||
virtual ~nsDOMCameraControl();
|
||||
|
||||
|
@ -44,12 +98,15 @@ private:
|
|||
nsDOMCameraControl(const nsDOMCameraControl&) MOZ_DELETE;
|
||||
nsDOMCameraControl& operator=(const nsDOMCameraControl&) MOZ_DELETE;
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -127,9 +127,9 @@ nsDOMCameraManager::GetCamera(const CameraSelector& aOptions,
|
|||
DOM_CAMERA_LOGT("%s:%d\n", __func__, __LINE__);
|
||||
|
||||
// Creating this object will trigger the onSuccess handler
|
||||
nsCOMPtr<nsDOMCameraControl> cameraControl =
|
||||
nsRefPtr<nsDOMCameraControl> cameraControl =
|
||||
new nsDOMCameraControl(cameraId, mCameraThread,
|
||||
onSuccess, onError.WasPassed() ? onError.Value() : nullptr, mWindowId);
|
||||
onSuccess, onError.WasPassed() ? onError.Value() : nullptr, mWindow);
|
||||
|
||||
Register(cameraControl);
|
||||
}
|
||||
|
|
|
@ -59,8 +59,10 @@ private:
|
|||
* store a reference in the 'mCameraControl' member (which is why it is
|
||||
* defined here).
|
||||
*/
|
||||
nsDOMCameraControl::nsDOMCameraControl(uint32_t aCameraId, nsIThread* aCameraThread, nsICameraGetCameraCallback* onSuccess, nsICameraErrorCallback* onError, uint64_t aWindowId)
|
||||
nsDOMCameraControl::nsDOMCameraControl(uint32_t aCameraId, nsIThread* aCameraThread, nsICameraGetCameraCallback* onSuccess, nsICameraErrorCallback* onError, nsPIDOMWindow* aWindow) :
|
||||
mWindow(aWindow)
|
||||
{
|
||||
MOZ_ASSERT(aWindow, "shouldn't be created with null window!");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -143,9 +143,10 @@ static const char* getKeyText(uint32_t aKey)
|
|||
}
|
||||
|
||||
// nsDOMCameraControl implementation-specific constructor
|
||||
nsDOMCameraControl::nsDOMCameraControl(uint32_t aCameraId, nsIThread* aCameraThread, nsICameraGetCameraCallback* onSuccess, nsICameraErrorCallback* onError, uint64_t aWindowId)
|
||||
: mDOMCapabilities(nullptr)
|
||||
nsDOMCameraControl::nsDOMCameraControl(uint32_t aCameraId, nsIThread* aCameraThread, nsICameraGetCameraCallback* onSuccess, nsICameraErrorCallback* onError, nsPIDOMWindow* aWindow)
|
||||
: mDOMCapabilities(nullptr), mWindow(aWindow)
|
||||
{
|
||||
MOZ_ASSERT(aWindow, "shouldn't be created with null window!");
|
||||
DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
|
||||
|
||||
/**
|
||||
|
@ -160,8 +161,8 @@ nsDOMCameraControl::nsDOMCameraControl(uint32_t aCameraId, nsIThread* aCameraThr
|
|||
* nsDOMCameraControl or memory will leak!
|
||||
*/
|
||||
NS_ADDREF_THIS();
|
||||
nsRefPtr<nsGonkCameraControl> control = new nsGonkCameraControl(aCameraId, aCameraThread, this, onSuccess, onError, aWindowId);
|
||||
control->DispatchInit(this, onSuccess, onError, aWindowId);
|
||||
nsRefPtr<nsGonkCameraControl> control = new nsGonkCameraControl(aCameraId, aCameraThread, this, onSuccess, onError, aWindow->WindowID());
|
||||
control->DispatchInit(this, onSuccess, onError, aWindow->WindowID());
|
||||
mCameraControl = control;
|
||||
}
|
||||
|
||||
|
|
|
@ -217,171 +217,8 @@ interface nsICameraErrorCallback : nsISupports
|
|||
void handleEvent(in DOMString error);
|
||||
};
|
||||
|
||||
/*
|
||||
attributes here affect the preview, any pictures taken, and/or
|
||||
any video recorded by the camera.
|
||||
*/
|
||||
[scriptable, uuid(74dc7f1f-c88f-4774-860b-44aef9de5dc8)]
|
||||
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. */
|
||||
[implicit_jscontext]
|
||||
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. */
|
||||
[implicit_jscontext]
|
||||
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. */
|
||||
[implicit_jscontext]
|
||||
void setExposureCompensation([optional] in jsval 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 nsICameraShutterCallback 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. */
|
||||
attribute nsICameraClosedCallback 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. */
|
||||
attribute nsICameraRecorderStateChange onRecorderStateChange;
|
||||
|
||||
/* the function to call when the preview stream is actually started and
|
||||
stopped; this is usually used to enable and disable the camera UI,
|
||||
since the low-level hardware often does not support taking pictures
|
||||
unless the preview is running. */
|
||||
attribute nsICameraPreviewStateChange onPreviewStateChange;
|
||||
|
||||
/* 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). */
|
||||
[implicit_jscontext]
|
||||
void takePicture(in jsval aOptions, in nsICameraTakePictureCallback onSuccess, [optional] in nsICameraErrorCallback onError);
|
||||
|
||||
/* get a media stream to be used as a camera viewfinder in video mode;
|
||||
'aOptions' is an CameraRecorderOptions object. */
|
||||
[implicit_jscontext]
|
||||
void getPreviewStreamVideoMode(in jsval aOptions, in nsICameraPreviewStreamCallback onSuccess, [optional] in nsICameraErrorCallback onError);
|
||||
|
||||
/* start recording video; 'aOptions' is a
|
||||
CameraStartRecordingOptions object. */
|
||||
[implicit_jscontext]
|
||||
void startRecording(in jsval aOptions, in nsIDOMDeviceStorage storageArea, in DOMString filename, 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);
|
||||
|
||||
/* call in or after the takePicture() onSuccess callback to
|
||||
resume the camera preview stream. */
|
||||
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. */
|
||||
[binaryname(ReleaseHardware)] void release([optional] in nsICameraReleaseCallback onSuccess, [optional] in nsICameraErrorCallback onError);
|
||||
};
|
||||
|
||||
[scriptable, function, uuid(a267afbc-d91c-413a-8de5-0b94aecffa3e)]
|
||||
interface nsICameraGetCameraCallback : nsISupports
|
||||
{
|
||||
void handleEvent(in nsICameraControl camera);
|
||||
void handleEvent(in nsISupports camera);
|
||||
};
|
||||
|
|
|
@ -0,0 +1,195 @@
|
|||
/* -*- 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]
|
||||
void getPreviewStreamVideoMode(any aOptions, CameraPreviewStreamCallback onSuccess, optional CameraErrorCallback onError);
|
||||
|
||||
/* start recording video; 'aOptions' is a
|
||||
CameraStartRecordingOptions object. */
|
||||
[Throws]
|
||||
void startRecording(any aOptions, DeviceStorage storageArea, DOMString filename, CameraStartRecordingCallback onSuccess, optional CameraErrorCallback onError);
|
||||
|
||||
/* 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);
|
||||
};
|
|
@ -19,7 +19,6 @@ interface DummyInterface {
|
|||
void funcDNSLookupDict(optional DNSLookupDict arg);
|
||||
void funcConnStatusDict(optional ConnStatusDict arg);
|
||||
void frameRequestCallback(FrameRequestCallback arg);
|
||||
void CameraPictureOptions(optional CameraPictureOptions arg);
|
||||
void MmsParameters(optional MmsParameters arg);
|
||||
void MmsAttachment(optional MmsAttachment arg);
|
||||
void AsyncScrollEventDetail(optional AsyncScrollEventDetail arg);
|
||||
|
|
|
@ -34,6 +34,7 @@ webidl_files = \
|
|||
BiquadFilterNode.webidl \
|
||||
Blob.webidl \
|
||||
BrowserElementDictionaries.webidl \
|
||||
CameraControl.webidl \
|
||||
CameraManager.webidl \
|
||||
CanvasRenderingContext2D.webidl \
|
||||
CaretPosition.webidl \
|
||||
|
|
Загрузка…
Ссылка в новой задаче