Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c8cb3092 authored by Eino-Ville Talvala's avatar Eino-Ville Talvala Committed by Android (Google) Code Review
Browse files

Merge "Camera service: Add skeleton support for camera2 devices."

parents 7de245bf 61ab9f93
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -8,7 +8,9 @@ include $(CLEAR_VARS)

LOCAL_SRC_FILES:=               \
    CameraService.cpp \
    CameraClient.cpp
    CameraClient.cpp \
    Camera2Client.cpp \
    Camera2Device.cpp

LOCAL_SHARED_LIBRARIES:= \
    libui \
@@ -21,6 +23,9 @@ LOCAL_SHARED_LIBRARIES:= \
    libgui \
    libhardware

LOCAL_C_INCLUDES += \
    system/media/camera/include

LOCAL_MODULE:= libcameraservice

include $(BUILD_SHARED_LIBRARY)
+153 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2012 The Android Open Source Project
 *
 * 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.
 */

#define LOG_TAG "Camera2Client"
//#define LOG_NDEBUG 0

#include <cutils/properties.h>
#include <gui/SurfaceTextureClient.h>
#include <gui/Surface.h>

#include "Camera2Client.h"

namespace android {

#define ALOG1(...) ALOGD_IF(gLogLevel >= 1, __VA_ARGS__);
#define ALOG2(...) ALOGD_IF(gLogLevel >= 2, __VA_ARGS__);

#define ALOG1_ENTRY {       \
    int callingPid = getCallingPid(); \
    ALOG1("%s: E (pid %d, id %d) ", __FUNCTION__, \
            callingPid, mCameraId);      \
}

static int getCallingPid() {
    return IPCThreadState::self()->getCallingPid();
}

static int getCallingUid() {
    return IPCThreadState::self()->getCallingUid();
}

// Interface used by CameraService

Camera2Client::Camera2Client(const sp<CameraService>& cameraService,
        const sp<ICameraClient>& cameraClient,
        const sp<Camera2Device>& device,
        int cameraId,
        int cameraFacing,
        int clientPid):
        Client(cameraService, cameraClient,
                cameraId, cameraFacing, clientPid) {
    int callingPid = getCallingPid();
    ALOG1("%s: E (pid %d, id %d)", __FUNCTION__, callingPid, cameraId);
    ALOG1_ENTRY;

}

Camera2Client::~Camera2Client() {
}

status_t Camera2Client::dump(int fd, const Vector<String16>& args) {
    return BAD_VALUE;
}

// ICamera interface

void Camera2Client::disconnect() {
    CameraService::Client::disconnect();
}

status_t Camera2Client::connect(const sp<ICameraClient>& client) {
    return BAD_VALUE;
}

status_t Camera2Client::lock() {
    return BAD_VALUE;
}

status_t Camera2Client::unlock() {
    return BAD_VALUE;
}

status_t Camera2Client::setPreviewDisplay(const sp<Surface>& surface) {
    return BAD_VALUE;
}

status_t Camera2Client::setPreviewTexture(const sp<ISurfaceTexture>& surfaceTexture) {
    return BAD_VALUE;
}

void Camera2Client::setPreviewCallbackFlag(int flag) {

}

status_t Camera2Client::startPreview() {
    return BAD_VALUE;
}

void Camera2Client::stopPreview() {

}

bool Camera2Client::previewEnabled() {
    return false;
}

status_t Camera2Client::storeMetaDataInBuffers(bool enabled) {
    return BAD_VALUE;
}

status_t Camera2Client::startRecording() {
    return BAD_VALUE;
}

void Camera2Client::stopRecording() {
}

bool Camera2Client::recordingEnabled() {
    return BAD_VALUE;
}

void Camera2Client::releaseRecordingFrame(const sp<IMemory>& mem) {

}

status_t Camera2Client::autoFocus() {
    return BAD_VALUE;
}

status_t Camera2Client::cancelAutoFocus() {
    return BAD_VALUE;
}

status_t Camera2Client::takePicture(int msgType) {
    return BAD_VALUE;
}

status_t Camera2Client::setParameters(const String8& params) {
    return BAD_VALUE;
}
String8 Camera2Client::getParameters() const {
    return String8();
}

status_t Camera2Client::sendCommand(int32_t cmd, int32_t arg1, int32_t arg2) {
    return BAD_VALUE;
}


} // namespace android
+73 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2012 The Android Open Source Project
 *
 * 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.
 */

#ifndef ANDROID_SERVERS_CAMERA_CAMERA2CLIENT_H
#define ANDROID_SERVERS_CAMERA_CAMERA2CLIENT_H

#include "Camera2Device.h"
#include "CameraService.h"

namespace android {

/**
 * Implements the android.hardware.camera API on top of
 * camera device HAL version 2.
 */
class Camera2Client : public CameraService::Client
{
public:
    // ICamera interface (see ICamera for details)
    virtual void            disconnect();
    virtual status_t        connect(const sp<ICameraClient>& client);
    virtual status_t        lock();
    virtual status_t        unlock();
    virtual status_t        setPreviewDisplay(const sp<Surface>& surface);
    virtual status_t        setPreviewTexture(const sp<ISurfaceTexture>& surfaceTexture);
    virtual void            setPreviewCallbackFlag(int flag);
    virtual status_t        startPreview();
    virtual void            stopPreview();
    virtual bool            previewEnabled();
    virtual status_t        storeMetaDataInBuffers(bool enabled);
    virtual status_t        startRecording();
    virtual void            stopRecording();
    virtual bool            recordingEnabled();
    virtual void            releaseRecordingFrame(const sp<IMemory>& mem);
    virtual status_t        autoFocus();
    virtual status_t        cancelAutoFocus();
    virtual status_t        takePicture(int msgType);
    virtual status_t        setParameters(const String8& params);
    virtual String8         getParameters() const;
    virtual status_t        sendCommand(int32_t cmd, int32_t arg1, int32_t arg2);

    // Interface used by CameraService
    Camera2Client(const sp<CameraService>& cameraService,
            const sp<ICameraClient>& cameraClient,
            const sp<Camera2Device>& device,
            int cameraId,
            int cameraFacing,
            int clientPid);
    ~Camera2Client();

    virtual status_t dump(int fd, const Vector<String16>& args);

private:


};

}; // namespace android

#endif
+66 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2012 The Android Open Source Project
 *
 * 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.
 */

#define LOG_TAG "Camera2Device"
//#define LOG_NDEBUG 0

#include <utils/Log.h>
#include "Camera2Device.h"

namespace android {

Camera2Device::Camera2Device(const char *name):
        mName(name),
        mDevice(NULL)
{

}

Camera2Device::~Camera2Device()
{
    if (mDevice) {
        status_t res;
        res = mDevice->common.close(&mDevice->common);
        if (res != OK) {
            ALOGE("Could not close camera2 %s: %s (%d)",
                    mName, strerror(-res), res);
        }
    }
}

status_t Camera2Device::initialize(hw_module_t *module)
{
    status_t res;
    res = module->methods->open(module, mName,
            reinterpret_cast<hw_device_t**>(&mDevice));

    if (res != OK) {
        ALOGE("Could not open camera %s: %s (%d)", mName, strerror(-res), res);
        return res;
    }

    if (mDevice->common.version != CAMERA_DEVICE_API_VERSION_2_0) {
        ALOGE("Could not open camera %s: "
                "Camera device is not version 2.0, reports %x instead",
                mName, mDevice->common.version);
        return BAD_VALUE;
    }

    return OK;
}


}; // namespace android
+42 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2012 The Android Open Source Project
 *
 * 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.
 */

#ifndef ANDROID_SERVERS_CAMERA_CAMERA2DEVICE_H
#define ANDROID_SERVERS_CAMERA_CAMERA2DEVICE_H

#include <utils/RefBase.h>
#include <utils/Errors.h>
#include "hardware/camera2.h"

namespace android {

class Camera2Device : public virtual RefBase {
  public:
    Camera2Device(const char *name);

    ~Camera2Device();

    status_t initialize(hw_module_t *module);
  private:

    const char *mName;
    camera2_device_t *mDevice;

};

}; // namespace android

#endif
Loading