2012-07-30 14:59:05 -07:00
|
|
|
/*
|
2014-02-19 20:18:52 -08:00
|
|
|
* Copyright (C) 2012-2014 Mozilla Foundation
|
2012-07-30 14:59:05 -07:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2014-02-14 14:41:07 -08:00
|
|
|
#include "GonkCameraHwMgr.h"
|
2014-02-19 20:18:52 -08:00
|
|
|
#include "TestGonkCameraHardware.h"
|
2014-02-14 14:41:07 -08:00
|
|
|
|
2013-03-08 11:43:33 -08:00
|
|
|
#include <binder/IPCThreadState.h>
|
|
|
|
#include <sys/system_properties.h>
|
|
|
|
|
2012-08-17 03:56:55 -07:00
|
|
|
#include "base/basictypes.h"
|
2012-07-30 14:59:05 -07:00
|
|
|
#include "nsDebug.h"
|
2014-03-31 08:24:28 -07:00
|
|
|
#include "mozilla/layers/TextureClient.h"
|
2014-06-19 06:20:49 -07:00
|
|
|
#include "CameraPreferences.h"
|
2014-03-31 08:24:28 -07:00
|
|
|
#include "mozilla/RefPtr.h"
|
2013-03-08 11:43:33 -08:00
|
|
|
#include "GonkCameraControl.h"
|
2012-07-30 14:59:05 -07:00
|
|
|
#include "GonkNativeWindow.h"
|
|
|
|
#include "CameraCommon.h"
|
|
|
|
|
|
|
|
using namespace mozilla;
|
2012-08-17 03:56:55 -07:00
|
|
|
using namespace mozilla::layers;
|
|
|
|
using namespace android;
|
2012-07-30 14:59:05 -07:00
|
|
|
|
2013-03-08 11:43:33 -08:00
|
|
|
GonkCameraHardware::GonkCameraHardware(mozilla::nsGonkCameraControl* aTarget, uint32_t aCameraId, const sp<Camera>& aCamera)
|
|
|
|
: mCameraId(aCameraId)
|
2012-07-30 14:59:05 -07:00
|
|
|
, mClosing(false)
|
|
|
|
, mNumFrames(0)
|
2013-03-08 11:43:33 -08:00
|
|
|
, mCamera(aCamera)
|
2012-07-30 14:59:05 -07:00
|
|
|
, mTarget(aTarget)
|
2013-03-08 11:43:33 -08:00
|
|
|
, mSensorOrientation(0)
|
2012-07-30 14:59:05 -07:00
|
|
|
{
|
2014-02-14 14:41:07 -08:00
|
|
|
DOM_CAMERA_LOGT("%s:%d : this=%p (aTarget=%p)\n", __func__, __LINE__, (void*)this, (void*)aTarget);
|
2012-07-30 14:59:05 -07:00
|
|
|
}
|
|
|
|
|
2014-07-02 16:55:00 -07:00
|
|
|
void
|
|
|
|
GonkCameraHardware::OnRateLimitPreview(bool aLimit)
|
|
|
|
{
|
|
|
|
::OnRateLimitPreview(mTarget, aLimit);
|
|
|
|
}
|
|
|
|
|
2012-08-17 03:56:55 -07:00
|
|
|
void
|
|
|
|
GonkCameraHardware::OnNewFrame()
|
|
|
|
{
|
|
|
|
if (mClosing) {
|
|
|
|
return;
|
|
|
|
}
|
2014-03-31 08:24:28 -07:00
|
|
|
RefPtr<TextureClient> buffer = mNativeWindow->getCurrentBuffer();
|
2013-11-21 13:03:27 -08:00
|
|
|
if (!buffer) {
|
|
|
|
DOM_CAMERA_LOGW("received null frame");
|
|
|
|
return;
|
|
|
|
}
|
2014-02-14 14:41:07 -08:00
|
|
|
OnNewPreviewFrame(mTarget, buffer);
|
2012-08-17 03:56:55 -07:00
|
|
|
}
|
|
|
|
|
2012-07-30 14:59:05 -07:00
|
|
|
// Android data callback
|
|
|
|
void
|
2013-03-08 11:43:33 -08:00
|
|
|
GonkCameraHardware::postData(int32_t aMsgType, const sp<IMemory>& aDataPtr, camera_frame_metadata_t* metadata)
|
2012-07-30 14:59:05 -07:00
|
|
|
{
|
2013-03-08 11:43:33 -08:00
|
|
|
if (mClosing) {
|
2012-07-30 14:59:05 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-03-08 11:43:33 -08:00
|
|
|
switch (aMsgType) {
|
|
|
|
case CAMERA_MSG_PREVIEW_FRAME:
|
|
|
|
// Do nothing
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CAMERA_MSG_COMPRESSED_IMAGE:
|
2013-01-24 10:41:18 -08:00
|
|
|
if (aDataPtr != nullptr) {
|
2014-02-14 14:41:07 -08:00
|
|
|
OnTakePictureComplete(mTarget, static_cast<uint8_t*>(aDataPtr->pointer()), aDataPtr->size());
|
2013-01-24 10:41:18 -08:00
|
|
|
} else {
|
2014-02-14 14:41:07 -08:00
|
|
|
OnTakePictureError(mTarget);
|
2013-01-24 10:41:18 -08:00
|
|
|
}
|
2013-03-08 11:43:33 -08:00
|
|
|
break;
|
|
|
|
|
2014-04-09 08:52:10 -07:00
|
|
|
case CAMERA_MSG_PREVIEW_METADATA:
|
|
|
|
OnFacesDetected(mTarget, metadata);
|
|
|
|
break;
|
|
|
|
|
2013-03-08 11:43:33 -08:00
|
|
|
default:
|
|
|
|
DOM_CAMERA_LOGE("Unhandled data callback event %d\n", aMsgType);
|
|
|
|
break;
|
2012-07-30 14:59:05 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Android notify callback
|
|
|
|
void
|
2013-03-08 11:43:33 -08:00
|
|
|
GonkCameraHardware::notify(int32_t aMsgType, int32_t ext1, int32_t ext2)
|
2012-07-30 14:59:05 -07:00
|
|
|
{
|
2013-03-08 11:43:33 -08:00
|
|
|
if (mClosing) {
|
2012-07-30 14:59:05 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (aMsgType) {
|
|
|
|
case CAMERA_MSG_FOCUS:
|
2014-02-14 14:41:07 -08:00
|
|
|
OnAutoFocusComplete(mTarget, !!ext1);
|
2012-07-30 14:59:05 -07:00
|
|
|
break;
|
|
|
|
|
2014-04-09 08:12:25 -07:00
|
|
|
#if ANDROID_VERSION >= 16
|
|
|
|
case CAMERA_MSG_FOCUS_MOVE:
|
|
|
|
OnAutoFocusMoving(mTarget, !!ext1);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
|
2012-07-30 14:59:05 -07:00
|
|
|
case CAMERA_MSG_SHUTTER:
|
2013-03-08 11:43:33 -08:00
|
|
|
OnShutter(mTarget);
|
2012-07-30 14:59:05 -07:00
|
|
|
break;
|
|
|
|
|
2014-02-14 14:41:07 -08:00
|
|
|
case CAMERA_MSG_ERROR:
|
2014-04-25 13:28:15 -07:00
|
|
|
OnSystemError(mTarget, CameraControlListener::kSystemService, ext1, ext2);
|
2014-02-14 14:41:07 -08:00
|
|
|
break;
|
|
|
|
|
2012-07-30 14:59:05 -07:00
|
|
|
default:
|
|
|
|
DOM_CAMERA_LOGE("Unhandled notify callback event %d\n", aMsgType);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-28 22:30:52 -07:00
|
|
|
void
|
2013-03-08 11:43:33 -08:00
|
|
|
GonkCameraHardware::postDataTimestamp(nsecs_t aTimestamp, int32_t aMsgType, const sp<IMemory>& aDataPtr)
|
2012-09-28 22:30:52 -07:00
|
|
|
{
|
|
|
|
DOM_CAMERA_LOGI("%s",__func__);
|
2013-03-08 11:43:33 -08:00
|
|
|
if (mClosing) {
|
2012-09-28 22:30:52 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-03-08 11:43:33 -08:00
|
|
|
if (mListener.get()) {
|
2012-09-28 22:30:52 -07:00
|
|
|
DOM_CAMERA_LOGI("Listener registered, posting recording frame!");
|
2014-07-03 01:30:00 -07:00
|
|
|
if (!mListener->postDataTimestamp(aTimestamp, aMsgType, aDataPtr)) {
|
|
|
|
DOM_CAMERA_LOGW("Listener unable to process. Drop a recording frame.");
|
|
|
|
mCamera->releaseRecordingFrame(aDataPtr);
|
|
|
|
}
|
2012-09-28 22:30:52 -07:00
|
|
|
} else {
|
|
|
|
DOM_CAMERA_LOGW("No listener was set. Drop a recording frame.");
|
2013-03-08 11:43:33 -08:00
|
|
|
mCamera->releaseRecordingFrame(aDataPtr);
|
2012-09-28 22:30:52 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-19 20:18:52 -08:00
|
|
|
nsresult
|
2012-09-04 18:01:56 -07:00
|
|
|
GonkCameraHardware::Init()
|
2012-07-30 14:59:05 -07:00
|
|
|
{
|
2012-09-04 18:01:56 -07:00
|
|
|
DOM_CAMERA_LOGT("%s: this=%p\n", __func__, (void* )this);
|
2012-07-30 14:59:05 -07:00
|
|
|
|
2013-03-08 11:43:33 -08:00
|
|
|
CameraInfo info;
|
|
|
|
int rv = Camera::getCameraInfo(mCameraId, &info);
|
2012-10-24 17:23:01 -07:00
|
|
|
if (rv != 0) {
|
2013-03-08 11:43:33 -08:00
|
|
|
DOM_CAMERA_LOGE("%s: failed to get CameraInfo mCameraId %d\n", __func__, mCameraId);
|
2014-04-25 13:28:15 -07:00
|
|
|
return NS_ERROR_NOT_INITIALIZED;
|
2013-03-08 11:43:33 -08:00
|
|
|
}
|
|
|
|
|
2012-11-06 19:32:01 -08:00
|
|
|
mRawSensorOrientation = info.orientation;
|
|
|
|
mSensorOrientation = mRawSensorOrientation;
|
2012-10-24 17:23:01 -07:00
|
|
|
|
2014-01-12 18:12:40 -08:00
|
|
|
/**
|
|
|
|
* Non-V4L2-based camera driver adds extra offset onto picture orientation
|
|
|
|
* set by gecko, so we have to adjust it back.
|
|
|
|
*/
|
2012-10-24 17:23:01 -07:00
|
|
|
char propname[PROP_NAME_MAX];
|
|
|
|
char prop[PROP_VALUE_MAX];
|
2012-11-06 19:32:01 -08:00
|
|
|
int offset = 0;
|
2013-03-08 11:43:33 -08:00
|
|
|
snprintf(propname, sizeof(propname), "ro.moz.cam.%d.sensor_offset", mCameraId);
|
2012-10-24 17:23:01 -07:00
|
|
|
if (__system_property_get(propname, prop) > 0) {
|
2012-11-06 19:32:01 -08:00
|
|
|
offset = clamped(atoi(prop), 0, 270);
|
2012-10-24 17:23:01 -07:00
|
|
|
mSensorOrientation += offset;
|
|
|
|
mSensorOrientation %= 360;
|
|
|
|
}
|
2012-11-06 19:32:01 -08:00
|
|
|
DOM_CAMERA_LOGI("Sensor orientation: base=%d, offset=%d, final=%d\n", info.orientation, offset, mSensorOrientation);
|
2012-10-24 17:23:01 -07:00
|
|
|
|
2013-03-27 08:19:10 -07:00
|
|
|
// Disable shutter sound in android CameraService because gaia camera app will play it
|
|
|
|
mCamera->sendCommand(CAMERA_CMD_ENABLE_SHUTTER_SOUND, 0, 0);
|
|
|
|
|
2014-02-24 23:51:46 -08:00
|
|
|
#if defined(MOZ_WIDGET_GONK)
|
|
|
|
|
|
|
|
#if ANDROID_VERSION >= 19
|
2014-05-18 18:52:47 -07:00
|
|
|
mNativeWindow = new GonkNativeWindow(GonkCameraHardware::MIN_UNDEQUEUED_BUFFERS);
|
2014-02-24 23:51:46 -08:00
|
|
|
mCamera->setPreviewTarget(mNativeWindow->getBufferQueue());
|
2014-05-18 18:52:47 -07:00
|
|
|
#elif ANDROID_VERSION >= 17
|
2014-06-07 17:49:50 -07:00
|
|
|
mNativeWindow = new GonkNativeWindow(GonkCameraHardware::MIN_UNDEQUEUED_BUFFERS);
|
2013-09-12 02:40:26 -07:00
|
|
|
mCamera->setPreviewTexture(mNativeWindow->getBufferQueue());
|
|
|
|
#else
|
2014-05-18 18:52:47 -07:00
|
|
|
mNativeWindow = new GonkNativeWindow();
|
2013-03-08 11:43:33 -08:00
|
|
|
mCamera->setPreviewTexture(mNativeWindow);
|
2014-02-24 23:51:46 -08:00
|
|
|
#endif
|
2014-05-18 18:52:47 -07:00
|
|
|
mNativeWindow->setNewFrameCallback(this);
|
|
|
|
mCamera->setListener(this);
|
2014-02-24 23:51:46 -08:00
|
|
|
|
2014-04-09 08:12:25 -07:00
|
|
|
#if ANDROID_VERSION >= 16
|
|
|
|
rv = mCamera->sendCommand(CAMERA_CMD_ENABLE_FOCUS_MOVE_MSG, 1, 0);
|
|
|
|
if (rv != OK) {
|
|
|
|
NS_WARNING("Failed to send command CAMERA_CMD_ENABLE_FOCUS_MOVE_MSG");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-09-12 02:40:26 -07:00
|
|
|
#endif
|
2014-02-19 20:18:52 -08:00
|
|
|
|
|
|
|
return NS_OK;
|
2012-07-30 14:59:05 -07:00
|
|
|
}
|
|
|
|
|
2013-03-08 11:43:33 -08:00
|
|
|
sp<GonkCameraHardware>
|
|
|
|
GonkCameraHardware::Connect(mozilla::nsGonkCameraControl* aTarget, uint32_t aCameraId)
|
2012-07-30 14:59:05 -07:00
|
|
|
{
|
2013-09-12 02:40:26 -07:00
|
|
|
#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 18
|
|
|
|
sp<Camera> camera = Camera::connect(aCameraId, /* clientPackageName */String16("gonk.camera"), Camera::USE_CALLING_UID);
|
|
|
|
#else
|
2013-03-08 11:43:33 -08:00
|
|
|
sp<Camera> camera = Camera::connect(aCameraId);
|
2013-09-12 02:40:26 -07:00
|
|
|
#endif
|
|
|
|
|
2013-03-08 11:43:33 -08:00
|
|
|
if (camera.get() == nullptr) {
|
|
|
|
return nullptr;
|
2012-09-30 17:37:47 -07:00
|
|
|
}
|
2014-02-19 20:18:52 -08:00
|
|
|
|
2014-06-19 06:20:49 -07:00
|
|
|
nsCString test;
|
|
|
|
CameraPreferences::GetPref("camera.control.test.enabled", test);
|
2014-02-19 20:18:52 -08:00
|
|
|
sp<GonkCameraHardware> cameraHardware;
|
|
|
|
if (test.EqualsASCII("hardware")) {
|
|
|
|
NS_WARNING("Using test Gonk hardware layer");
|
|
|
|
cameraHardware = new TestGonkCameraHardware(aTarget, aCameraId, camera);
|
|
|
|
} else {
|
|
|
|
cameraHardware = new GonkCameraHardware(aTarget, aCameraId, camera);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult rv = cameraHardware->Init();
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
DOM_CAMERA_LOGE("Failed to initialize camera hardware (0x%X)\n", rv);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2013-03-08 11:43:33 -08:00
|
|
|
return cameraHardware;
|
2014-02-19 20:18:52 -08:00
|
|
|
}
|
2012-07-30 14:59:05 -07:00
|
|
|
|
|
|
|
void
|
2013-03-08 11:43:33 -08:00
|
|
|
GonkCameraHardware::Close()
|
2012-07-30 14:59:05 -07:00
|
|
|
{
|
2014-02-19 20:18:52 -08:00
|
|
|
DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, (void*)this);
|
2012-07-30 14:59:05 -07:00
|
|
|
|
2013-03-08 11:43:33 -08:00
|
|
|
mClosing = true;
|
|
|
|
mCamera->stopPreview();
|
|
|
|
mCamera->disconnect();
|
|
|
|
if (mNativeWindow.get()) {
|
|
|
|
mNativeWindow->abandon();
|
2013-01-07 04:54:24 -08:00
|
|
|
}
|
2013-03-08 11:43:33 -08:00
|
|
|
mCamera.clear();
|
|
|
|
mNativeWindow.clear();
|
|
|
|
|
|
|
|
// Ensure that ICamera's destructor is actually executed
|
|
|
|
IPCThreadState::self()->flushCommands();
|
2012-07-30 14:59:05 -07:00
|
|
|
}
|
|
|
|
|
2013-03-08 11:43:33 -08:00
|
|
|
GonkCameraHardware::~GonkCameraHardware()
|
2012-07-30 14:59:05 -07:00
|
|
|
{
|
2014-02-19 20:18:52 -08:00
|
|
|
DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, (void*)this);
|
2013-03-08 11:43:33 -08:00
|
|
|
mCamera.clear();
|
|
|
|
mNativeWindow.clear();
|
2012-07-30 14:59:05 -07:00
|
|
|
|
2013-04-17 07:30:44 -07:00
|
|
|
if (mClosing) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-03-08 11:43:33 -08:00
|
|
|
/**
|
|
|
|
* Trigger the OnClosed event; the upper layers can't do anything
|
|
|
|
* with the hardware layer once they receive this event.
|
|
|
|
*/
|
|
|
|
if (mTarget) {
|
|
|
|
OnClosed(mTarget);
|
2012-07-30 14:59:05 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-24 17:23:01 -07:00
|
|
|
int
|
2013-03-08 11:43:33 -08:00
|
|
|
GonkCameraHardware::GetSensorOrientation(uint32_t aType)
|
2012-10-24 17:23:01 -07:00
|
|
|
{
|
2013-03-08 11:43:33 -08:00
|
|
|
DOM_CAMERA_LOGI("%s\n", __func__);
|
|
|
|
|
2012-11-06 19:32:01 -08:00
|
|
|
switch (aType) {
|
|
|
|
case OFFSET_SENSOR_ORIENTATION:
|
2013-03-08 11:43:33 -08:00
|
|
|
return mSensorOrientation;
|
2012-11-06 19:32:01 -08:00
|
|
|
|
|
|
|
case RAW_SENSOR_ORIENTATION:
|
2013-03-08 11:43:33 -08:00
|
|
|
return mRawSensorOrientation;
|
2012-11-06 19:32:01 -08:00
|
|
|
|
|
|
|
default:
|
|
|
|
DOM_CAMERA_LOGE("%s:%d : unknown aType=%d\n", __func__, __LINE__, aType);
|
|
|
|
return 0;
|
|
|
|
}
|
2012-10-24 17:23:01 -07:00
|
|
|
}
|
|
|
|
|
2012-07-30 14:59:05 -07:00
|
|
|
int
|
2013-03-08 11:43:33 -08:00
|
|
|
GonkCameraHardware::AutoFocus()
|
2012-07-30 14:59:05 -07:00
|
|
|
{
|
2013-03-08 11:43:33 -08:00
|
|
|
DOM_CAMERA_LOGI("%s\n", __func__);
|
|
|
|
return mCamera->autoFocus();
|
2012-07-30 14:59:05 -07:00
|
|
|
}
|
|
|
|
|
2014-04-15 12:46:40 -07:00
|
|
|
int
|
2013-03-08 11:43:33 -08:00
|
|
|
GonkCameraHardware::CancelAutoFocus()
|
2012-07-30 14:59:05 -07:00
|
|
|
{
|
2013-03-08 11:43:33 -08:00
|
|
|
DOM_CAMERA_LOGI("%s\n", __func__);
|
2014-04-15 12:46:40 -07:00
|
|
|
return mCamera->cancelAutoFocus();
|
2012-07-30 14:59:05 -07:00
|
|
|
}
|
|
|
|
|
2014-04-09 08:52:10 -07:00
|
|
|
int
|
|
|
|
GonkCameraHardware::StartFaceDetection()
|
|
|
|
{
|
|
|
|
DOM_CAMERA_LOGI("%s\n", __func__);
|
|
|
|
int rv = INVALID_OPERATION;
|
|
|
|
|
|
|
|
#if ANDROID_VERSION >= 15
|
|
|
|
rv = mCamera->sendCommand(CAMERA_CMD_START_FACE_DETECTION, CAMERA_FACE_DETECTION_HW, 0);
|
|
|
|
#endif
|
|
|
|
if (rv != OK) {
|
|
|
|
DOM_CAMERA_LOGE("Start face detection failed with status %d", rv);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
GonkCameraHardware::StopFaceDetection()
|
|
|
|
{
|
|
|
|
DOM_CAMERA_LOGI("%s\n", __func__);
|
|
|
|
int rv = INVALID_OPERATION;
|
|
|
|
|
|
|
|
#if ANDROID_VERSION >= 15
|
|
|
|
rv = mCamera->sendCommand(CAMERA_CMD_STOP_FACE_DETECTION, 0, 0);
|
|
|
|
#endif
|
|
|
|
if (rv != OK) {
|
|
|
|
DOM_CAMERA_LOGE("Stop face detection failed with status %d", rv);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2012-07-30 14:59:05 -07:00
|
|
|
int
|
2013-03-08 11:43:33 -08:00
|
|
|
GonkCameraHardware::TakePicture()
|
2012-07-30 14:59:05 -07:00
|
|
|
{
|
2013-03-08 11:43:33 -08:00
|
|
|
return mCamera->takePicture(CAMERA_MSG_SHUTTER | CAMERA_MSG_COMPRESSED_IMAGE);
|
2012-07-30 14:59:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-03-08 11:43:33 -08:00
|
|
|
GonkCameraHardware::CancelTakePicture()
|
2012-07-30 14:59:05 -07:00
|
|
|
{
|
2013-03-08 11:43:33 -08:00
|
|
|
DOM_CAMERA_LOGW("%s: android::Camera do not provide this capability\n", __func__);
|
2012-07-30 14:59:05 -07:00
|
|
|
}
|
|
|
|
|
2014-02-14 14:41:07 -08:00
|
|
|
int
|
|
|
|
GonkCameraHardware::PushParameters(const GonkCameraParameters& aParams)
|
|
|
|
{
|
|
|
|
const String8 s = aParams.Flatten();
|
|
|
|
return mCamera->setParameters(s);
|
|
|
|
}
|
|
|
|
|
2012-07-30 14:59:05 -07:00
|
|
|
int
|
2013-03-08 11:43:33 -08:00
|
|
|
GonkCameraHardware::PushParameters(const CameraParameters& aParams)
|
2012-07-30 14:59:05 -07:00
|
|
|
{
|
2013-03-08 11:43:33 -08:00
|
|
|
String8 s = aParams.flatten();
|
|
|
|
return mCamera->setParameters(s);
|
2012-07-30 14:59:05 -07:00
|
|
|
}
|
|
|
|
|
2014-02-14 14:41:07 -08:00
|
|
|
nsresult
|
|
|
|
GonkCameraHardware::PullParameters(GonkCameraParameters& aParams)
|
|
|
|
{
|
|
|
|
const String8 s = mCamera->getParameters();
|
|
|
|
return aParams.Unflatten(s);
|
|
|
|
}
|
|
|
|
|
2012-07-30 14:59:05 -07:00
|
|
|
void
|
2013-03-08 11:43:33 -08:00
|
|
|
GonkCameraHardware::PullParameters(CameraParameters& aParams)
|
2012-07-30 14:59:05 -07:00
|
|
|
{
|
2013-03-08 11:43:33 -08:00
|
|
|
const String8 s = mCamera->getParameters();
|
|
|
|
aParams.unflatten(s);
|
2012-07-30 14:59:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
GonkCameraHardware::StartPreview()
|
|
|
|
{
|
2013-03-08 11:43:33 -08:00
|
|
|
DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
|
|
|
|
return mCamera->startPreview();
|
2012-07-30 14:59:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-03-08 11:43:33 -08:00
|
|
|
GonkCameraHardware::StopPreview()
|
2012-07-30 14:59:05 -07:00
|
|
|
{
|
2013-03-08 11:43:33 -08:00
|
|
|
DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
|
2014-02-19 20:18:52 -08:00
|
|
|
mCamera->stopPreview();
|
2012-07-30 14:59:05 -07:00
|
|
|
}
|
2012-09-28 22:30:52 -07:00
|
|
|
|
|
|
|
int
|
2013-03-08 11:43:33 -08:00
|
|
|
GonkCameraHardware::StartRecording()
|
2012-09-28 22:30:52 -07:00
|
|
|
{
|
2013-03-08 11:43:33 -08:00
|
|
|
DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
|
2012-09-28 22:30:52 -07:00
|
|
|
int rv = OK;
|
|
|
|
|
2013-03-08 11:43:33 -08:00
|
|
|
rv = mCamera->startRecording();
|
2012-09-28 22:30:52 -07:00
|
|
|
if (rv != OK) {
|
|
|
|
DOM_CAMERA_LOGE("mHardware->startRecording() failed with status %d", rv);
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2013-03-08 11:43:33 -08:00
|
|
|
GonkCameraHardware::StopRecording()
|
2012-09-28 22:30:52 -07:00
|
|
|
{
|
2013-03-08 11:43:33 -08:00
|
|
|
DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
|
|
|
|
mCamera->stopRecording();
|
2012-09-28 22:30:52 -07:00
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2013-03-08 11:43:33 -08:00
|
|
|
GonkCameraHardware::SetListener(const sp<GonkCameraListener>& aListener)
|
2012-09-28 22:30:52 -07:00
|
|
|
{
|
2013-03-08 11:43:33 -08:00
|
|
|
mListener = aListener;
|
2012-09-28 22:30:52 -07:00
|
|
|
return OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-03-08 11:43:33 -08:00
|
|
|
GonkCameraHardware::ReleaseRecordingFrame(const sp<IMemory>& aFrame)
|
2012-09-28 22:30:52 -07:00
|
|
|
{
|
2013-03-08 11:43:33 -08:00
|
|
|
mCamera->releaseRecordingFrame(aFrame);
|
2012-09-28 22:30:52 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2013-03-08 11:43:33 -08:00
|
|
|
GonkCameraHardware::StoreMetaDataInBuffers(bool aEnabled)
|
2012-09-28 22:30:52 -07:00
|
|
|
{
|
2013-03-08 11:43:33 -08:00
|
|
|
return mCamera->storeMetaDataInBuffers(aEnabled);
|
2012-09-28 22:30:52 -07:00
|
|
|
}
|