mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Bug 1062387 - Part 3. Implement Gonk wrappers for JS camera driver. r=mikeh
This commit is contained in:
parent
3cd2fd3ac9
commit
2f0b8c72c1
@ -37,8 +37,8 @@ DOMCameraDetectedFace::Constructor(const GlobalObject& aGlobal,
|
||||
const dom::CameraDetectedFaceInit& aFace,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
nsCOMPtr<nsISupports> s = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
nsRefPtr<DOMCameraDetectedFace> face = new DOMCameraDetectedFace(s, aFace);
|
||||
nsRefPtr<DOMCameraDetectedFace> face =
|
||||
new DOMCameraDetectedFace(aGlobal.GetAsSupports(), aFace);
|
||||
return face.forget();
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2014 Mozilla Foundation
|
||||
* Copyright (C) 2012-2015 Mozilla Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -221,18 +221,23 @@ GonkCameraHardware::Init()
|
||||
sp<GonkCameraHardware>
|
||||
GonkCameraHardware::Connect(mozilla::nsGonkCameraControl* aTarget, uint32_t aCameraId)
|
||||
{
|
||||
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 18
|
||||
sp<Camera> camera = Camera::connect(aCameraId, /* clientPackageName */String16("gonk.camera"), Camera::USE_CALLING_UID);
|
||||
#else
|
||||
sp<Camera> camera = Camera::connect(aCameraId);
|
||||
#endif
|
||||
|
||||
if (camera.get() == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
sp<Camera> camera;
|
||||
|
||||
nsCString test;
|
||||
CameraPreferences::GetPref("camera.control.test.enabled", test);
|
||||
|
||||
if (!test.EqualsASCII("hardware")) {
|
||||
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 18
|
||||
camera = Camera::connect(aCameraId, /* clientPackageName */String16("gonk.camera"), Camera::USE_CALLING_UID);
|
||||
#else
|
||||
camera = Camera::connect(aCameraId);
|
||||
#endif
|
||||
|
||||
if (camera.get() == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
sp<GonkCameraHardware> cameraHardware;
|
||||
if (test.EqualsASCII("hardware")) {
|
||||
NS_WARNING("Using test Gonk hardware layer");
|
||||
@ -257,8 +262,10 @@ GonkCameraHardware::Close()
|
||||
DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, (void*)this);
|
||||
|
||||
mClosing = true;
|
||||
mCamera->stopPreview();
|
||||
mCamera->disconnect();
|
||||
if (mCamera.get()) {
|
||||
mCamera->stopPreview();
|
||||
mCamera->disconnect();
|
||||
}
|
||||
if (mNativeWindow.get()) {
|
||||
mNativeWindow->abandon();
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2013-2014 Mozilla Foundation
|
||||
* Copyright (C) 2013-2015 Mozilla Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -18,59 +18,55 @@
|
||||
#define DOM_CAMERA_TESTGONKCAMERAHARDWARE_H
|
||||
|
||||
#include "GonkCameraHwMgr.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsIDOMEventListener.h"
|
||||
#include "mozilla/CondVar.h"
|
||||
|
||||
namespace android {
|
||||
namespace mozilla {
|
||||
|
||||
class TestGonkCameraHardware : public android::GonkCameraHardware
|
||||
{
|
||||
public:
|
||||
virtual nsresult Init() MOZ_OVERRIDE;
|
||||
virtual int AutoFocus() MOZ_OVERRIDE;
|
||||
virtual int StartFaceDetection() MOZ_OVERRIDE;
|
||||
virtual int StopFaceDetection() MOZ_OVERRIDE;
|
||||
virtual int TakePicture() MOZ_OVERRIDE;
|
||||
virtual void CancelTakePicture() MOZ_OVERRIDE;
|
||||
virtual int StartPreview() MOZ_OVERRIDE;
|
||||
virtual void StopPreview() MOZ_OVERRIDE;
|
||||
virtual int PushParameters(const mozilla::GonkCameraParameters& aParams) MOZ_OVERRIDE;
|
||||
virtual nsresult PullParameters(mozilla::GonkCameraParameters& aParams) MOZ_OVERRIDE;
|
||||
virtual int StartRecording() MOZ_OVERRIDE;
|
||||
virtual int StopRecording() MOZ_OVERRIDE;
|
||||
virtual int SetListener(const sp<GonkCameraListener>& aListener) MOZ_OVERRIDE;
|
||||
virtual int StoreMetaDataInBuffers(bool aEnabled) MOZ_OVERRIDE;
|
||||
|
||||
virtual int
|
||||
PushParameters(const CameraParameters& aParams) MOZ_OVERRIDE
|
||||
{
|
||||
return GonkCameraHardware::PushParameters(aParams);
|
||||
}
|
||||
|
||||
virtual void
|
||||
PullParameters(CameraParameters& aParams) MOZ_OVERRIDE
|
||||
{
|
||||
GonkCameraHardware::PullParameters(aParams);
|
||||
}
|
||||
virtual int PushParameters(const android::CameraParameters& aParams) MOZ_OVERRIDE;
|
||||
virtual void PullParameters(android::CameraParameters& aParams) MOZ_OVERRIDE;
|
||||
|
||||
TestGonkCameraHardware(mozilla::nsGonkCameraControl* aTarget,
|
||||
uint32_t aCameraId,
|
||||
const sp<Camera>& aCamera);
|
||||
virtual ~TestGonkCameraHardware();
|
||||
|
||||
virtual nsresult Init() MOZ_OVERRIDE;
|
||||
const android::sp<android::Camera>& aCamera);
|
||||
|
||||
protected:
|
||||
const nsCString TestCase();
|
||||
const nsCString GetExtraParameters();
|
||||
bool IsTestCaseInternal(const char* aTest, const char* aFile, int aLine);
|
||||
int TestCaseError(int aDefaultError);
|
||||
virtual ~TestGonkCameraHardware();
|
||||
|
||||
int StartAutoFocusMoving(bool aIsMoving);
|
||||
void InjectFakeSystemFailure();
|
||||
class ControlMessage;
|
||||
class PushParametersDelegate;
|
||||
class PullParametersDelegate;
|
||||
|
||||
nsresult WaitWhileRunningOnMainThread(nsRefPtr<ControlMessage> aRunnable);
|
||||
|
||||
nsCOMPtr<nsIDOMEventListener> mDomListener;
|
||||
nsCOMPtr<nsIThread> mCameraThread;
|
||||
mozilla::Mutex mMutex;
|
||||
mozilla::CondVar mCondVar;
|
||||
nsresult mStatus;
|
||||
|
||||
private:
|
||||
TestGonkCameraHardware(const TestGonkCameraHardware&) = delete;
|
||||
TestGonkCameraHardware& operator=(const TestGonkCameraHardware&) = delete;
|
||||
};
|
||||
|
||||
#define IsTestCase(test) IsTestCaseInternal((test), __FILE__, __LINE__)
|
||||
|
||||
} // namespace android
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // DOM_CAMERA_TESTGONKCAMERAHARDWARE_H
|
||||
|
Loading…
Reference in New Issue
Block a user