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

Commit e538206d authored by James Painter's avatar James Painter Committed by Android (Google) Code Review
Browse files

Camera2: Add a burst mode skeleton.

Bug: 6243944
Change-Id: I7f496ca1051571c68fdd99a6f85bf6a908a4e29a
parent 7ac78325
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -90,6 +90,7 @@ const char CameraParameters::KEY_RECORDING_HINT[] = "recording-hint";
const char CameraParameters::KEY_VIDEO_SNAPSHOT_SUPPORTED[] = "video-snapshot-supported";
const char CameraParameters::KEY_VIDEO_STABILIZATION[] = "video-stabilization";
const char CameraParameters::KEY_VIDEO_STABILIZATION_SUPPORTED[] = "video-stabilization-supported";
const char CameraParameters::KEY_LIGHTFX[] = "light-fx";

const char CameraParameters::TRUE[] = "true";
const char CameraParameters::FALSE[] = "false";
@@ -166,6 +167,10 @@ const char CameraParameters::FOCUS_MODE_EDOF[] = "edof";
const char CameraParameters::FOCUS_MODE_CONTINUOUS_VIDEO[] = "continuous-video";
const char CameraParameters::FOCUS_MODE_CONTINUOUS_PICTURE[] = "continuous-picture";

// Values for light fx settings
const char CameraParameters::LIGHTFX_LOWLIGHT[] = "low-light";
const char CameraParameters::LIGHTFX_HDR[] = "high-dynamic-range";

CameraParameters::CameraParameters()
                : mMap()
{
+12 −2
Original line number Diff line number Diff line
@@ -298,7 +298,7 @@ public:
    // Example value: "42.5". Read only.
    static const char KEY_VERTICAL_VIEW_ANGLE[];
    // Exposure compensation index. 0 means exposure is not adjusted.
    // Example value: "0" or "5". Read/write.
    // Example value: "-5" or "5". Read/write.
    static const char KEY_EXPOSURE_COMPENSATION[];
    // The maximum exposure compensation index (>=0).
    // Example value: "6". Read only.
@@ -307,7 +307,7 @@ public:
    // Example value: "-6". Read only.
    static const char KEY_MIN_EXPOSURE_COMPENSATION[];
    // The exposure compensation step. Exposure compensation index multiply by
    // step eqals to EV. Ex: if exposure compensation index is 6 and step is
    // step eqals to EV. Ex: if exposure compensation index is -6 and step is
    // 0.3333, EV is -2.
    // Example value: "0.333333333" or "0.5". Read only.
    static const char KEY_EXPOSURE_COMPENSATION_STEP[];
@@ -525,6 +525,10 @@ public:
    // stream and record stabilized videos.
    static const char KEY_VIDEO_STABILIZATION_SUPPORTED[];

    // Supported modes for special effects with light.
    // Example values: "lowlight,hdr".
    static const char KEY_LIGHTFX[];

    // Value for KEY_ZOOM_SUPPORTED or KEY_SMOOTH_ZOOM_SUPPORTED.
    static const char TRUE[];
    static const char FALSE[];
@@ -660,6 +664,12 @@ public:
    // other modes.
    static const char FOCUS_MODE_CONTINUOUS_PICTURE[];

    // Values for light special effects
    // Low-light enhancement mode
    static const char LIGHTFX_LOWLIGHT[];
    // High-dynamic range mode
    static const char LIGHTFX_HDR[];

private:
    DefaultKeyedVector<String8,String8>    mMap;
};
+7 −3
Original line number Diff line number Diff line
@@ -17,7 +17,9 @@ LOCAL_SRC_FILES:= \
    camera2/JpegProcessor.cpp \
    camera2/CallbackProcessor.cpp \
    camera2/ZslProcessor.cpp \
    camera2/CaptureSequencer.cpp \
    camera2/BurstCapture.cpp \
    camera2/JpegCompressor.cpp \
    camera2/CaptureSequencer.cpp

LOCAL_SHARED_LIBRARIES:= \
    libui \
@@ -30,10 +32,12 @@ LOCAL_SHARED_LIBRARIES:= \
    libgui \
    libhardware \
    libsync \
    libcamera_metadata
    libcamera_metadata \
    libjpeg

LOCAL_C_INCLUDES += \
    system/media/camera/include
    system/media/camera/include \
    external/jpeg

LOCAL_MODULE:= libcameraservice

+1 −3
Original line number Diff line number Diff line
@@ -25,14 +25,12 @@
#include <gui/SurfaceTextureClient.h>
#include <gui/Surface.h>
#include <media/hardware/MetadataBufferType.h>

#include "Camera2Client.h"
#include "camera2/Parameters.h"

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

namespace android {

using namespace camera2;

static int getCallingPid() {
+112 −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_NDEBUG 0
#define LOG_TAG "BurstCapture"

#include <utils/Log.h>
#include <utils/Trace.h>

#include "BurstCapture.h"

#include "JpegCompressor.h"
#include "../Camera2Client.h"

namespace android {
namespace camera2 {

BurstCapture::BurstCapture(wp<Camera2Client> client, wp<CaptureSequencer> sequencer):
    mCaptureStreamId(NO_STREAM),
    mClient(client),
    mSequencer(sequencer)
{
}

BurstCapture::~BurstCapture() {
}

status_t BurstCapture::start(Vector<CameraMetadata> &metadatas, int32_t firstCaptureId) {
    ALOGE("Not completely implemented");
    return INVALID_OPERATION;
}

void BurstCapture::onFrameAvailable() {
    ALOGV("%s", __FUNCTION__);
    Mutex::Autolock l(mInputMutex);
    if(!mInputChanged) {
        mInputChanged = true;
        mInputSignal.signal();
    }
}

bool BurstCapture::threadLoop() {
    status_t res;
    {
        Mutex::Autolock l(mInputMutex);
        while(!mInputChanged) {
            res = mInputSignal.waitRelative(mInputMutex, kWaitDuration);
            if(res == TIMED_OUT) return true;
        }
        mInputChanged = false;
    }

    do {
        sp<Camera2Client> client = mClient.promote();
        if(client == 0) return false;
        ALOGV("%s: Calling processFrameAvailable()", __FUNCTION__);
        res = processFrameAvailable(client);
    } while(res == OK);

    return true;
}

CpuConsumer::LockedBuffer* BurstCapture::jpegEncode(
    CpuConsumer::LockedBuffer *imgBuffer,
    int quality)
{
    ALOGV("%s", __FUNCTION__);

    CpuConsumer::LockedBuffer *imgEncoded = new CpuConsumer::LockedBuffer;
    uint8_t *data = new uint8_t[ANDROID_JPEG_MAX_SIZE];
    imgEncoded->data = data;
    imgEncoded->width = imgBuffer->width;
    imgEncoded->height = imgBuffer->height;
    imgEncoded->stride = imgBuffer->stride;

    Vector<CpuConsumer::LockedBuffer*> buffers;
    buffers.push_back(imgBuffer);
    buffers.push_back(imgEncoded);

    sp<JpegCompressor> jpeg = new JpegCompressor();
    status_t res = jpeg->start(buffers, 1);

    bool success = jpeg->waitForDone(10 * 1e9);
    if(success) {
        return buffers[1];
    }
    else {
        ALOGE("%s: JPEG encode timed out", __FUNCTION__);
        return NULL;  // TODO: maybe change function return value to status_t
    }
}

status_t BurstCapture::processFrameAvailable(sp<Camera2Client> &client) {
    ALOGE("Not implemented");
    return INVALID_OPERATION;
}

} // namespace camera2
} // namespace android
Loading