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

Commit 7e88dc68 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes from topic "dynamic_depth"

* changes:
  Camera: Link dynamically to Depth photo library
  Camera: Add DepthCompositeStream
  Camera: Add support for dynamic depth if possible
parents a3cd8681 cbf174b5
Loading
Loading
Loading
Loading
+77 −0
Original line number Diff line number Diff line
@@ -5549,6 +5549,73 @@ typedef enum acamera_metadata_tag {
    ACAMERA_DEPTH_AVAILABLE_RECOMMENDED_DEPTH_STREAM_CONFIGURATIONS = 
                                                                // int32[n*5]
            ACAMERA_DEPTH_START + 5,
    /**
     * <p>The available dynamic depth dataspace stream
     * configurations that this camera device supports
     * (i.e. format, width, height, output/input stream).</p>
     *
     * <p>Type: int32[n*4] (acamera_metadata_enum_android_depth_available_dynamic_depth_stream_configurations_t)</p>
     *
     * <p>This tag may appear in:
     * <ul>
     *   <li>ACameraMetadata from ACameraManager_getCameraCharacteristics</li>
     * </ul></p>
     *
     * <p>These are output stream configurations for use with
     * dataSpace DYNAMIC_DEPTH. The configurations are
     * listed as <code>(format, width, height, input?)</code> tuples.</p>
     * <p>Only devices that support depth output for at least
     * the HAL_PIXEL_FORMAT_Y16 dense depth map along with
     * HAL_PIXEL_FORMAT_BLOB with the same size or size with
     * the same aspect ratio can have dynamic depth dataspace
     * stream configuration. ACAMERA_DEPTH_DEPTH_IS_EXCLUSIVE also
     * needs to be set to FALSE.</p>
     *
     * @see ACAMERA_DEPTH_DEPTH_IS_EXCLUSIVE
     */
    ACAMERA_DEPTH_AVAILABLE_DYNAMIC_DEPTH_STREAM_CONFIGURATIONS = 
                                                                // int32[n*4] (acamera_metadata_enum_android_depth_available_dynamic_depth_stream_configurations_t)
            ACAMERA_DEPTH_START + 6,
    /**
     * <p>This lists the minimum frame duration for each
     * format/size combination for dynamic depth output streams.</p>
     *
     * <p>Type: int64[4*n]</p>
     *
     * <p>This tag may appear in:
     * <ul>
     *   <li>ACameraMetadata from ACameraManager_getCameraCharacteristics</li>
     * </ul></p>
     *
     * <p>This should correspond to the frame duration when only that
     * stream is active, with all processing (typically in android.*.mode)
     * set to either OFF or FAST.</p>
     * <p>When multiple streams are used in a request, the minimum frame
     * duration will be max(individual stream min durations).</p>
     * <p>The minimum frame duration of a stream (of a particular format, size)
     * is the same regardless of whether the stream is input or output.</p>
     */
    ACAMERA_DEPTH_AVAILABLE_DYNAMIC_DEPTH_MIN_FRAME_DURATIONS = // int64[4*n]
            ACAMERA_DEPTH_START + 7,
    /**
     * <p>This lists the maximum stall duration for each
     * output format/size combination for dynamic depth streams.</p>
     *
     * <p>Type: int64[4*n]</p>
     *
     * <p>This tag may appear in:
     * <ul>
     *   <li>ACameraMetadata from ACameraManager_getCameraCharacteristics</li>
     * </ul></p>
     *
     * <p>A stall duration is how much extra time would get added
     * to the normal minimum frame duration for a repeating request
     * that has streams with non-zero stall.</p>
     * <p>All dynamic depth output streams may have a nonzero stall
     * duration.</p>
     */
    ACAMERA_DEPTH_AVAILABLE_DYNAMIC_DEPTH_STALL_DURATIONS =     // int64[4*n]
            ACAMERA_DEPTH_START + 8,
    ACAMERA_DEPTH_END,

    /**
@@ -8246,6 +8313,16 @@ typedef enum acamera_metadata_enum_acamera_depth_depth_is_exclusive {

} acamera_metadata_enum_android_depth_depth_is_exclusive_t;

// ACAMERA_DEPTH_AVAILABLE_DYNAMIC_DEPTH_STREAM_CONFIGURATIONS
typedef enum acamera_metadata_enum_acamera_depth_available_dynamic_depth_stream_configurations {
    ACAMERA_DEPTH_AVAILABLE_DYNAMIC_DEPTH_STREAM_CONFIGURATIONS_OUTPUT
                                                                      = 0,

    ACAMERA_DEPTH_AVAILABLE_DYNAMIC_DEPTH_STREAM_CONFIGURATIONS_INPUT
                                                                      = 1,

} acamera_metadata_enum_android_depth_available_dynamic_depth_stream_configurations_t;


// ACAMERA_LOGICAL_MULTI_CAMERA_SENSOR_SYNC_TYPE
typedef enum acamera_metadata_enum_acamera_logical_multi_camera_sensor_sync_type {
+41 −0
Original line number Diff line number Diff line
@@ -39,6 +39,8 @@ cc_library_shared {
        "api1/client2/CaptureSequencer.cpp",
        "api1/client2/ZslProcessor.cpp",
        "api2/CameraDeviceClient.cpp",
        "api2/CompositeStream.cpp",
        "api2/DepthCompositeStream.cpp",
        "device1/CameraHardwareInterface.cpp",
        "device3/Camera3Device.cpp",
        "device3/Camera3Stream.cpp",
@@ -65,6 +67,7 @@ cc_library_shared {
    ],

    shared_libs: [
        "libdl",
        "libui",
        "liblog",
        "libutilscallstack",
@@ -108,6 +111,8 @@ cc_library_shared {
        "system/media/private/camera/include",
        "frameworks/native/include/media/openmax",
        "frameworks/av/media/ndk",
        "external/dynamic_depth/includes",
        "external/dynamic_depth/internal",
    ],

    export_include_dirs: ["."],
@@ -116,6 +121,42 @@ cc_library_shared {
        "-Wall",
        "-Wextra",
        "-Werror",
        "-Wno-ignored-qualifiers",
    ],

}

cc_library_shared {
    name: "libdepthphoto",

    srcs: [
        "common/DepthPhotoProcessor.cpp",
    ],

    shared_libs: [
        "libimage_io",
        "libdynamic_depth",
        "libxml2",
        "liblog",
        "libutilscallstack",
        "libutils",
        "libcutils",
        "libjpeg",
        "libmemunreachable",
    ],

    include_dirs: [
        "external/dynamic_depth/includes",
        "external/dynamic_depth/internal",
    ],

    export_include_dirs: ["."],

    cflags: [
        "-Wall",
        "-Wextra",
        "-Werror",
        "-Wno-ignored-qualifiers",
    ],

}
+4 −0
Original line number Diff line number Diff line
@@ -62,6 +62,10 @@ void JpegProcessor::onFrameAvailable(const BufferItem& /*item*/) {
    }
}

void JpegProcessor::onBufferRequestForFrameNumber(uint64_t /*frameNumber*/, int /*streamId*/) {
    // Intentionally left empty
}

void JpegProcessor::onBufferAcquired(const BufferInfo& /*bufferInfo*/) {
    // Intentionally left empty
}
+5 −1
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@
#include <gui/CpuConsumer.h>

#include "camera/CameraMetadata.h"
#include "device3/Camera3StreamBufferListener.h"

namespace android {

@@ -53,12 +54,16 @@ class JpegProcessor:
    // Camera3StreamBufferListener implementation
    void onBufferAcquired(const BufferInfo& bufferInfo) override;
    void onBufferReleased(const BufferInfo& bufferInfo) override;
    void onBufferRequestForFrameNumber(uint64_t frameNumber, int streamId) override;

    status_t updateStream(const Parameters &params);
    status_t deleteStream();
    int getStreamId() const;

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

    static size_t findJpegSize(uint8_t* jpegBuffer, size_t maxSize);

  private:
    static const nsecs_t kWaitDuration = 10000000; // 10 ms
    wp<CameraDeviceBase> mDevice;
@@ -82,7 +87,6 @@ class JpegProcessor:
    virtual bool threadLoop();

    status_t processNewCapture(bool captureSuccess);
    size_t findJpegSize(uint8_t* jpegBuffer, size_t maxSize);

};

+100 −8
Original line number Diff line number Diff line
@@ -33,6 +33,8 @@

#include <camera_metadata_hidden.h>

#include "DepthCompositeStream.h"

// Convenience methods for constructing binder::Status objects for error returns

#define STATUS_ERROR(errorCode, errorString) \
@@ -143,6 +145,7 @@ binder::Status CameraDeviceClient::submitRequest(

binder::Status CameraDeviceClient::insertGbpLocked(const sp<IGraphicBufferProducer>& gbp,
        SurfaceMap* outSurfaceMap, Vector<int32_t>* outputStreamIds, int32_t *currentStreamId) {
    int compositeIdx;
    int idx = mStreamMap.indexOfKey(IInterface::asBinder(gbp));

    // Trying to submit request with surface that wasn't created
@@ -152,6 +155,11 @@ binder::Status CameraDeviceClient::insertGbpLocked(const sp<IGraphicBufferProduc
                __FUNCTION__, mCameraIdStr.string());
        return STATUS_ERROR(CameraService::ERROR_ILLEGAL_ARGUMENT,
                "Request targets Surface that is not part of current capture session");
    } else if ((compositeIdx = mCompositeStreamMap.indexOfKey(IInterface::asBinder(gbp)))
            != NAME_NOT_FOUND) {
        mCompositeStreamMap.valueAt(compositeIdx)->insertGbp(outSurfaceMap, outputStreamIds,
                currentStreamId);
        return binder::Status::ok();
    }

    const StreamSurfaceId& streamSurfaceId = mStreamMap.valueAt(idx);
@@ -489,6 +497,17 @@ binder::Status CameraDeviceClient::endConfigure(int operatingMode,
                mCameraIdStr.string(), strerror(-err), err);
        ALOGE("%s: %s", __FUNCTION__, msg.string());
        res = STATUS_ERROR(CameraService::ERROR_INVALID_OPERATION, msg.string());
    } else {
        for (size_t i = 0; i < mCompositeStreamMap.size(); ++i) {
            err = mCompositeStreamMap.valueAt(i)->configureStream();
            if (err != OK ) {
                String8 msg = String8::format("Camera %s: Error configuring composite "
                        "streams: %s (%d)", mCameraIdStr.string(), strerror(-err), err);
                ALOGE("%s: %s", __FUNCTION__, msg.string());
                res = STATUS_ERROR(CameraService::ERROR_INVALID_OPERATION, msg.string());
                break;
            }
        }
    }

    return res;
@@ -692,8 +711,35 @@ binder::Status CameraDeviceClient::isSessionConfigurationSupported(
                return res;

            if (!isStreamInfoValid) {
                mapStreamInfo(streamInfo, static_cast<camera3_stream_rotation_t> (it.getRotation()),
                if (camera3::DepthCompositeStream::isDepthCompositeStream(surface)) {
                    // We need to take in to account that composite streams can have
                    // additional internal camera streams.
                    std::vector<OutputStreamInfo> compositeStreams;
                    ret = camera3::DepthCompositeStream::getCompositeStreamInfo(streamInfo,
                            mDevice->info(), &compositeStreams);
                    if (ret != OK) {
                        String8 msg = String8::format(
                                "Camera %s: Failed adding depth composite streams: %s (%d)",
                                mCameraIdStr.string(), strerror(-ret), ret);
                        ALOGE("%s: %s", __FUNCTION__, msg.string());
                        return STATUS_ERROR(CameraService::ERROR_ILLEGAL_ARGUMENT, msg.string());
                    }

                    if (compositeStreams.size() > 1) {
                        streamCount += compositeStreams.size() - 1;
                        streamConfiguration.streams.resize(streamCount);
                    }

                    for (const auto& compositeStream : compositeStreams) {
                        mapStreamInfo(compositeStream,
                                static_cast<camera3_stream_rotation_t> (it.getRotation()),
                                physicalCameraId, &streamConfiguration.streams[streamIdx++]);
                    }
                } else {
                    mapStreamInfo(streamInfo,
                            static_cast<camera3_stream_rotation_t> (it.getRotation()),
                            physicalCameraId, &streamConfiguration.streams[streamIdx++]);
                }
                isStreamInfoValid = true;
            }
        }
@@ -743,6 +789,7 @@ binder::Status CameraDeviceClient::deleteStream(int streamId) {
    bool isInput = false;
    std::vector<sp<IBinder>> surfaces;
    ssize_t dIndex = NAME_NOT_FOUND;
    ssize_t compositeIndex  = NAME_NOT_FOUND;

    if (mInputStream.configured && mInputStream.id == streamId) {
        isInput = true;
@@ -762,6 +809,13 @@ binder::Status CameraDeviceClient::deleteStream(int streamId) {
            }
        }

        for (size_t i = 0; i < mCompositeStreamMap.size(); ++i) {
            if (streamId == mCompositeStreamMap.valueAt(i)->getStreamId()) {
                compositeIndex = i;
                break;
            }
        }

        if (surfaces.empty() && dIndex == NAME_NOT_FOUND) {
            String8 msg = String8::format("Camera %s: Invalid stream ID (%d) specified, no such"
                    " stream created yet", mCameraIdStr.string(), streamId);
@@ -791,6 +845,19 @@ binder::Status CameraDeviceClient::deleteStream(int streamId) {
            if (dIndex != NAME_NOT_FOUND) {
                mDeferredStreams.removeItemsAt(dIndex);
            }

            if (compositeIndex != NAME_NOT_FOUND) {
                status_t ret;
                if ((ret = mCompositeStreamMap.valueAt(compositeIndex)->deleteStream())
                        != OK) {
                    String8 msg = String8::format("Camera %s: Unexpected error %s (%d) when "
                            "deleting composite stream %d", mCameraIdStr.string(), strerror(-err), err,
                            streamId);
                    ALOGE("%s: %s", __FUNCTION__, msg.string());
                    res = STATUS_ERROR(CameraService::ERROR_INVALID_OPERATION, msg.string());
                }
                mCompositeStreamMap.removeItemsAt(compositeIndex);
            }
        }
    }

@@ -870,11 +937,25 @@ binder::Status CameraDeviceClient::createStream(

    int streamId = camera3::CAMERA3_STREAM_ID_INVALID;
    std::vector<int> surfaceIds;
    if (!camera3::DepthCompositeStream::isDepthCompositeStream(surfaces[0])) {
        err = mDevice->createStream(surfaces, deferredConsumer, streamInfo.width,
                streamInfo.height, streamInfo.format, streamInfo.dataSpace,
                static_cast<camera3_stream_rotation_t>(outputConfiguration.getRotation()),
                &streamId, physicalCameraId, &surfaceIds, outputConfiguration.getSurfaceSetID(),
                isShared);
    } else {
        sp<CompositeStream> compositeStream = new camera3::DepthCompositeStream(mDevice,
                getRemoteCallback());
        err = compositeStream->createStream(surfaces, deferredConsumer, streamInfo.width,
                streamInfo.height, streamInfo.format,
                static_cast<camera3_stream_rotation_t>(outputConfiguration.getRotation()),
                &streamId, physicalCameraId, &surfaceIds, outputConfiguration.getSurfaceSetID(),
                isShared);
        if (err == OK) {
            mCompositeStreamMap.add(IInterface::asBinder(surfaces[0]->getIGraphicBufferProducer()),
                    compositeStream);
        }
    }

    if (err != OK) {
        res = STATUS_ERROR_FMT(CameraService::ERROR_INVALID_OPERATION,
@@ -1808,7 +1889,14 @@ void CameraDeviceClient::notifyError(int32_t errorCode,
    // Thread safe. Don't bother locking.
    sp<hardware::camera2::ICameraDeviceCallbacks> remoteCb = getRemoteCallback();

    if (remoteCb != 0) {
    // Composites can have multiple internal streams. Error notifications coming from such internal
    // streams may need to remain within camera service.
    bool skipClientNotification = false;
    for (size_t i = 0; i < mCompositeStreamMap.size(); i++) {
        skipClientNotification |= mCompositeStreamMap.valueAt(i)->onError(errorCode, resultExtras);
    }

    if ((remoteCb != 0) && (!skipClientNotification)) {
        remoteCb->onDeviceError(errorCode, resultExtras);
    }
}
@@ -1901,6 +1989,10 @@ void CameraDeviceClient::onResultAvailable(const CaptureResult& result) {
        remoteCb->onResultReceived(result.mMetadata, result.mResultExtras,
                result.mPhysicalMetadatas);
    }

    for (size_t i = 0; i < mCompositeStreamMap.size(); i++) {
        mCompositeStreamMap.valueAt(i)->onResultAvailable(result);
    }
}

binder::Status CameraDeviceClient::checkPidStatus(const char* checkLocation) {
Loading