mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 986024 - expose resumeContinuousFocus() method to DOM/JS, r=bz,dhylands
This commit is contained in:
parent
a552cf4209
commit
558352928c
@ -284,12 +284,15 @@ CameraControlImpl::OnError(CameraControlListener::CameraErrorContext aContext,
|
||||
"StartCamera",
|
||||
"StopCamera",
|
||||
"AutoFocus",
|
||||
"StartFaceDetection",
|
||||
"StopFaceDetection",
|
||||
"TakePicture",
|
||||
"StartRecording",
|
||||
"StopRecording",
|
||||
"SetConfiguration",
|
||||
"StartPreview",
|
||||
"StopPreview",
|
||||
"ResumeContinuousFocus",
|
||||
"Unspecified"
|
||||
};
|
||||
if (static_cast<unsigned int>(aError) < sizeof(error) / sizeof(error[0]) &&
|
||||
@ -414,30 +417,25 @@ CameraControlImpl::SetConfiguration(const Configuration& aConfig)
|
||||
}
|
||||
|
||||
nsresult
|
||||
CameraControlImpl::AutoFocus(bool aCancelExistingCall)
|
||||
CameraControlImpl::AutoFocus()
|
||||
{
|
||||
class Message : public ControlMessage
|
||||
{
|
||||
public:
|
||||
Message(CameraControlImpl* aCameraControl,
|
||||
CameraControlListener::CameraErrorContext aContext,
|
||||
bool aCancelExistingCall)
|
||||
CameraControlListener::CameraErrorContext aContext)
|
||||
: ControlMessage(aCameraControl, aContext)
|
||||
, mCancelExistingCall(aCancelExistingCall)
|
||||
{ }
|
||||
|
||||
nsresult
|
||||
RunImpl() MOZ_OVERRIDE
|
||||
{
|
||||
return mCameraControl->AutoFocusImpl(mCancelExistingCall);
|
||||
return mCameraControl->AutoFocusImpl();
|
||||
}
|
||||
|
||||
protected:
|
||||
bool mCancelExistingCall;
|
||||
};
|
||||
|
||||
return mCameraThread->Dispatch(
|
||||
new Message(this, CameraControlListener::kInAutoFocus, aCancelExistingCall), NS_DISPATCH_NORMAL);
|
||||
new Message(this, CameraControlListener::kInAutoFocus), NS_DISPATCH_NORMAL);
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -611,6 +609,28 @@ CameraControlImpl::StopPreview()
|
||||
new Message(this, CameraControlListener::kInStopPreview), NS_DISPATCH_NORMAL);
|
||||
}
|
||||
|
||||
nsresult
|
||||
CameraControlImpl::ResumeContinuousFocus()
|
||||
{
|
||||
class Message : public ControlMessage
|
||||
{
|
||||
public:
|
||||
Message(CameraControlImpl* aCameraControl,
|
||||
CameraControlListener::CameraErrorContext aContext)
|
||||
: ControlMessage(aCameraControl, aContext)
|
||||
{ }
|
||||
|
||||
nsresult
|
||||
RunImpl() MOZ_OVERRIDE
|
||||
{
|
||||
return mCameraControl->ResumeContinuousFocusImpl();
|
||||
}
|
||||
};
|
||||
|
||||
return mCameraThread->Dispatch(
|
||||
new Message(this, CameraControlListener::kInResumeContinuousFocus), NS_DISPATCH_NORMAL);
|
||||
}
|
||||
|
||||
nsresult
|
||||
CameraControlImpl::Stop()
|
||||
{
|
||||
|
@ -42,13 +42,14 @@ public:
|
||||
virtual nsresult SetConfiguration(const Configuration& aConfig) MOZ_OVERRIDE;
|
||||
virtual nsresult StartPreview() MOZ_OVERRIDE;
|
||||
virtual nsresult StopPreview() MOZ_OVERRIDE;
|
||||
virtual nsresult AutoFocus(bool aCancelExistingCall) MOZ_OVERRIDE;
|
||||
virtual nsresult AutoFocus() MOZ_OVERRIDE;
|
||||
virtual nsresult StartFaceDetection() MOZ_OVERRIDE;
|
||||
virtual nsresult StopFaceDetection() MOZ_OVERRIDE;
|
||||
virtual nsresult TakePicture() MOZ_OVERRIDE;
|
||||
virtual nsresult StartRecording(DeviceStorageFileDescriptor* aFileDescriptor,
|
||||
const StartRecordingOptions* aOptions) MOZ_OVERRIDE;
|
||||
virtual nsresult StopRecording() MOZ_OVERRIDE;
|
||||
virtual nsresult ResumeContinuousFocus() MOZ_OVERRIDE;
|
||||
|
||||
already_AddRefed<RecorderProfileManager> GetRecorderProfileManager();
|
||||
uint32_t GetCameraId() { return mCameraId; }
|
||||
@ -102,13 +103,14 @@ protected:
|
||||
virtual nsresult SetConfigurationImpl(const Configuration& aConfig) = 0;
|
||||
virtual nsresult StartPreviewImpl() = 0;
|
||||
virtual nsresult StopPreviewImpl() = 0;
|
||||
virtual nsresult AutoFocusImpl(bool aCancelExistingCall) = 0;
|
||||
virtual nsresult AutoFocusImpl() = 0;
|
||||
virtual nsresult StartFaceDetectionImpl() = 0;
|
||||
virtual nsresult StopFaceDetectionImpl() = 0;
|
||||
virtual nsresult TakePictureImpl() = 0;
|
||||
virtual nsresult StartRecordingImpl(DeviceStorageFileDescriptor* aFileDescriptor,
|
||||
const StartRecordingOptions* aOptions) = 0;
|
||||
virtual nsresult StopRecordingImpl() = 0;
|
||||
virtual nsresult ResumeContinuousFocusImpl() = 0;
|
||||
virtual nsresult PushParametersImpl() = 0;
|
||||
virtual nsresult PullParametersImpl() = 0;
|
||||
virtual already_AddRefed<RecorderProfileManager> GetRecorderProfileManagerImpl() = 0;
|
||||
|
@ -95,6 +95,7 @@ public:
|
||||
kInSetConfiguration,
|
||||
kInStartPreview,
|
||||
kInStopPreview,
|
||||
kInResumeContinuousFocus,
|
||||
kInUnspecified
|
||||
};
|
||||
enum CameraError
|
||||
|
@ -844,6 +844,29 @@ nsDOMCameraControl::SetConfiguration(const CameraConfiguration& aConfiguration,
|
||||
aRv = mCameraControl->SetConfiguration(config);
|
||||
}
|
||||
|
||||
class ImmediateErrorCallback : public nsRunnable
|
||||
{
|
||||
public:
|
||||
ImmediateErrorCallback(CameraErrorCallback* aCallback, const nsAString& aMessage)
|
||||
: mCallback(aCallback)
|
||||
, mMessage(aMessage)
|
||||
{ }
|
||||
|
||||
NS_IMETHODIMP
|
||||
Run()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
ErrorResult ignored;
|
||||
mCallback->Call(mMessage, ignored);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
protected:
|
||||
nsRefPtr<CameraErrorCallback> mCallback;
|
||||
nsString mMessage;
|
||||
};
|
||||
|
||||
|
||||
void
|
||||
nsDOMCameraControl::AutoFocus(CameraAutoFocusCallback& aOnSuccess,
|
||||
const Optional<OwningNonNull<CameraErrorCallback> >& aOnError,
|
||||
@ -851,17 +874,16 @@ nsDOMCameraControl::AutoFocus(CameraAutoFocusCallback& aOnSuccess,
|
||||
{
|
||||
MOZ_ASSERT(mCameraControl);
|
||||
|
||||
nsRefPtr<CameraAutoFocusCallback> cb = mAutoFocusOnSuccessCb.forget();
|
||||
bool cancel = false;
|
||||
nsRefPtr<CameraAutoFocusCallback> cb = mAutoFocusOnSuccessCb;
|
||||
if (cb) {
|
||||
// we have a callback, which means we're already in the process of
|
||||
// auto-focusing--cancel the old callback
|
||||
nsRefPtr<CameraErrorCallback> ecb = mAutoFocusOnErrorCb.forget();
|
||||
if (ecb) {
|
||||
ErrorResult ignored;
|
||||
ecb->Call(NS_LITERAL_STRING("Interrupted"), ignored);
|
||||
if (aOnError.WasPassed()) {
|
||||
// There is already a call to AutoFocus() in progress, abort this new one
|
||||
// and invoke the error callback (if one was passed in).
|
||||
NS_DispatchToMainThread(new ImmediateErrorCallback(&aOnError.Value(),
|
||||
NS_LITERAL_STRING("AutoFocusAlreadyInProgress")));
|
||||
}
|
||||
cancel = true;
|
||||
aRv = NS_ERROR_FAILURE;
|
||||
return;
|
||||
}
|
||||
|
||||
mAutoFocusOnSuccessCb = &aOnSuccess;
|
||||
@ -870,7 +892,7 @@ nsDOMCameraControl::AutoFocus(CameraAutoFocusCallback& aOnSuccess,
|
||||
mAutoFocusOnErrorCb = &aOnError.Value();
|
||||
}
|
||||
|
||||
aRv = mCameraControl->AutoFocus(cancel);
|
||||
aRv = mCameraControl->AutoFocus();
|
||||
}
|
||||
|
||||
void
|
||||
@ -897,11 +919,11 @@ nsDOMCameraControl::TakePicture(const CameraPictureOptions& aOptions,
|
||||
|
||||
nsRefPtr<CameraTakePictureCallback> cb = mTakePictureOnSuccessCb;
|
||||
if (cb) {
|
||||
// There is already a call to TakePicture() in progress, abort this one and
|
||||
// invoke the error callback (if one was passed in).
|
||||
if (aOnError.WasPassed()) {
|
||||
ErrorResult ignored;
|
||||
aOnError.Value().Call(NS_LITERAL_STRING("TakePictureAlreadyInProgress"), ignored);
|
||||
// There is already a call to TakePicture() in progress, abort this new
|
||||
// one and invoke the error callback (if one was passed in).
|
||||
NS_DispatchToMainThread(new ImmediateErrorCallback(&aOnError.Value(),
|
||||
NS_LITERAL_STRING("TakePictureAlreadyInProgress")));
|
||||
}
|
||||
aRv = NS_ERROR_FAILURE;
|
||||
return;
|
||||
@ -958,6 +980,13 @@ nsDOMCameraControl::ReleaseHardware(const Optional<OwningNonNull<CameraReleaseCa
|
||||
aRv = mCameraControl->Stop();
|
||||
}
|
||||
|
||||
void
|
||||
nsDOMCameraControl::ResumeContinuousFocus(ErrorResult& aRv)
|
||||
{
|
||||
MOZ_ASSERT(mCameraControl);
|
||||
aRv = mCameraControl->ResumeContinuousFocus();
|
||||
}
|
||||
|
||||
void
|
||||
nsDOMCameraControl::Shutdown()
|
||||
{
|
||||
|
@ -128,6 +128,7 @@ public:
|
||||
void ReleaseHardware(const dom::Optional<dom::OwningNonNull<dom::CameraReleaseCallback> >& aOnSuccess,
|
||||
const dom::Optional<dom::OwningNonNull<dom::CameraErrorCallback> >& aOnError,
|
||||
ErrorResult& aRv);
|
||||
void ResumeContinuousFocus(ErrorResult& aRv);
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
|
||||
|
||||
|
@ -58,19 +58,20 @@ public:
|
||||
protected:
|
||||
~FallbackCameraControl();
|
||||
|
||||
virtual nsresult StartPreviewImpl() { return NS_ERROR_FAILURE; }
|
||||
virtual nsresult StopPreviewImpl() { return NS_ERROR_FAILURE; }
|
||||
virtual nsresult AutoFocusImpl(bool aCancelExistingCall) { return NS_ERROR_FAILURE; }
|
||||
virtual nsresult StartFaceDetectionImpl() { return NS_ERROR_FAILURE; }
|
||||
virtual nsresult StopFaceDetectionImpl() { return NS_ERROR_FAILURE; }
|
||||
virtual nsresult TakePictureImpl() { return NS_ERROR_FAILURE; }
|
||||
virtual nsresult StartPreviewImpl() MOZ_OVERRIDE { return NS_ERROR_FAILURE; }
|
||||
virtual nsresult StopPreviewImpl() MOZ_OVERRIDE { return NS_ERROR_FAILURE; }
|
||||
virtual nsresult AutoFocusImpl() MOZ_OVERRIDE { return NS_ERROR_FAILURE; }
|
||||
virtual nsresult StartFaceDetectionImpl() MOZ_OVERRIDE { return NS_ERROR_FAILURE; }
|
||||
virtual nsresult StopFaceDetectionImpl() MOZ_OVERRIDE { return NS_ERROR_FAILURE; }
|
||||
virtual nsresult TakePictureImpl() MOZ_OVERRIDE { return NS_ERROR_FAILURE; }
|
||||
virtual nsresult StartRecordingImpl(DeviceStorageFileDescriptor* aFileDescriptor,
|
||||
const StartRecordingOptions* aOptions = nullptr)
|
||||
const StartRecordingOptions* aOptions = nullptr) MOZ_OVERRIDE
|
||||
{ return NS_ERROR_FAILURE; }
|
||||
virtual nsresult StopRecordingImpl() { return NS_ERROR_FAILURE; }
|
||||
virtual nsresult PushParametersImpl() { return NS_ERROR_FAILURE; }
|
||||
virtual nsresult PullParametersImpl() { return NS_ERROR_FAILURE; }
|
||||
virtual already_AddRefed<RecorderProfileManager> GetRecorderProfileManagerImpl() { return nullptr; }
|
||||
virtual nsresult StopRecordingImpl() MOZ_OVERRIDE { return NS_ERROR_FAILURE; }
|
||||
virtual nsresult ResumeContinuousFocusImpl() MOZ_OVERRIDE { return NS_ERROR_FAILURE; }
|
||||
virtual nsresult PushParametersImpl() MOZ_OVERRIDE { return NS_ERROR_FAILURE; }
|
||||
virtual nsresult PullParametersImpl() MOZ_OVERRIDE { return NS_ERROR_FAILURE; }
|
||||
virtual already_AddRefed<RecorderProfileManager> GetRecorderProfileManagerImpl() MOZ_OVERRIDE { return nullptr; }
|
||||
|
||||
private:
|
||||
FallbackCameraControl(const FallbackCameraControl&) MOZ_DELETE;
|
||||
|
@ -564,15 +564,12 @@ nsGonkCameraControl::PausePreview()
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGonkCameraControl::AutoFocusImpl(bool aCancelExistingCall)
|
||||
nsGonkCameraControl::AutoFocusImpl()
|
||||
{
|
||||
MOZ_ASSERT(NS_GetCurrentThread() == mCameraThread);
|
||||
RETURN_IF_NO_CAMERA_HW();
|
||||
if (aCancelExistingCall) {
|
||||
if (mCameraHw.get()) {
|
||||
mCameraHw->CancelAutoFocus();
|
||||
}
|
||||
}
|
||||
|
||||
DOM_CAMERA_LOGI("Starting auto focus\n");
|
||||
|
||||
if (mCameraHw->AutoFocus() != OK) {
|
||||
return NS_ERROR_FAILURE;
|
||||
@ -1045,6 +1042,23 @@ nsGonkCameraControl::StopRecordingImpl()
|
||||
return NS_DispatchToMainThread(new RecordingComplete(mVideoFile), NS_DISPATCH_NORMAL);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGonkCameraControl::ResumeContinuousFocusImpl()
|
||||
{
|
||||
MOZ_ASSERT(NS_GetCurrentThread() == mCameraThread);
|
||||
RETURN_IF_NO_CAMERA_HW();
|
||||
|
||||
DOM_CAMERA_LOGI("Resuming continuous autofocus\n");
|
||||
|
||||
// see
|
||||
// http://developer.android.com/reference/android/hardware/Camera.Parameters.html#FOCUS_MODE_CONTINUOUS_PICTURE
|
||||
if (NS_WARN_IF(mCameraHw->CancelAutoFocus() != OK)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsGonkCameraControl::OnAutoFocusComplete(bool aSuccess)
|
||||
{
|
||||
|
@ -105,13 +105,14 @@ protected:
|
||||
|
||||
virtual nsresult StartPreviewImpl() MOZ_OVERRIDE;
|
||||
virtual nsresult StopPreviewImpl() MOZ_OVERRIDE;
|
||||
virtual nsresult AutoFocusImpl(bool aCancelExistingCall) MOZ_OVERRIDE;
|
||||
virtual nsresult AutoFocusImpl() MOZ_OVERRIDE;
|
||||
virtual nsresult StartFaceDetectionImpl() MOZ_OVERRIDE;
|
||||
virtual nsresult StopFaceDetectionImpl() MOZ_OVERRIDE;
|
||||
virtual nsresult TakePictureImpl() MOZ_OVERRIDE;
|
||||
virtual nsresult StartRecordingImpl(DeviceStorageFileDescriptor* aFileDescriptor,
|
||||
const StartRecordingOptions* aOptions = nullptr) MOZ_OVERRIDE;
|
||||
virtual nsresult StopRecordingImpl() MOZ_OVERRIDE;
|
||||
virtual nsresult ResumeContinuousFocusImpl() MOZ_OVERRIDE;
|
||||
virtual nsresult PushParametersImpl() MOZ_OVERRIDE;
|
||||
virtual nsresult PullParametersImpl() MOZ_OVERRIDE;
|
||||
virtual already_AddRefed<RecorderProfileManager> GetRecorderProfileManagerImpl() MOZ_OVERRIDE;
|
||||
|
@ -292,11 +292,11 @@ GonkCameraHardware::AutoFocus()
|
||||
return mCamera->autoFocus();
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
GonkCameraHardware::CancelAutoFocus()
|
||||
{
|
||||
DOM_CAMERA_LOGI("%s\n", __func__);
|
||||
mCamera->cancelAutoFocus();
|
||||
return mCamera->cancelAutoFocus();
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -78,7 +78,7 @@ public:
|
||||
virtual int GetSensorOrientation(uint32_t aType = RAW_SENSOR_ORIENTATION);
|
||||
|
||||
virtual int AutoFocus();
|
||||
virtual void CancelAutoFocus();
|
||||
virtual int CancelAutoFocus();
|
||||
virtual int StartFaceDetection();
|
||||
virtual int StopFaceDetection();
|
||||
virtual int TakePicture();
|
||||
|
@ -152,13 +152,14 @@ public:
|
||||
|
||||
virtual nsresult StartPreview() = 0;
|
||||
virtual nsresult StopPreview() = 0;
|
||||
virtual nsresult AutoFocus(bool aCancelExistingCall) = 0;
|
||||
virtual nsresult AutoFocus() = 0;
|
||||
virtual nsresult TakePicture() = 0;
|
||||
virtual nsresult StartRecording(DeviceStorageFileDescriptor *aFileDescriptor,
|
||||
const StartRecordingOptions* aOptions = nullptr) = 0;
|
||||
virtual nsresult StopRecording() = 0;
|
||||
virtual nsresult StartFaceDetection() = 0;
|
||||
virtual nsresult StopFaceDetection() = 0;
|
||||
virtual nsresult ResumeContinuousFocus() = 0;
|
||||
|
||||
virtual nsresult Set(uint32_t aKey, const nsAString& aValue) = 0;
|
||||
virtual nsresult Get(uint32_t aKey, nsAString& aValue) = 0;
|
||||
|
@ -334,6 +334,20 @@ interface CameraControl : MediaStream
|
||||
void setConfiguration(optional CameraConfiguration configuration,
|
||||
optional CameraSetConfigurationCallback onSuccess,
|
||||
optional CameraErrorCallback onError);
|
||||
|
||||
/* if focusMode is set to either 'continuous-picture' or 'continuous-video',
|
||||
then calling autoFocus() will trigger its onSuccess callback immediately
|
||||
if the camera was either successfully focused, or if no focus could be
|
||||
acquired; if the focus acquisition is still in progress, the onSuccess
|
||||
callback will be invoked later, its argument indicating success or
|
||||
failure.
|
||||
|
||||
once autoFocus() is called with a continuous autofocus mode set, the
|
||||
continuous autofocus process is stopped and focus is locked in the
|
||||
current state until this method is called.
|
||||
*/
|
||||
[Throws]
|
||||
void resumeContinuousFocus();
|
||||
};
|
||||
|
||||
/* The coordinates of a point, relative to the camera sensor, of the center of
|
||||
|
Loading…
Reference in New Issue
Block a user