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

Commit 61862378 authored by Jayant Chowdhary's avatar Jayant Chowdhary
Browse files

Move session configuration util methods CameraDeviceClient->SessionConfigurationUtils.



Bug: 148329298

Test: builds
Test: Camera CTS has no new failures

Change-Id: I462d2a9162cc4371648f85b2622cc764f36d560e
Signed-off-by: default avatarJayant Chowdhary <jchowdhary@google.com>
parent 6b5fdb53
Loading
Loading
Loading
Loading
+19 −473

File changed.

Preview size limit exceeded, changes collapsed.

+0 −43
Original line number Diff line number Diff line
@@ -204,16 +204,6 @@ public:
    virtual void notifyRequestQueueEmpty();
    virtual void notifyRepeatingRequestError(long lastFrameNumber);

    // utility function to convert AIDL SessionConfiguration to HIDL
    // streamConfiguration. Also checks for validity of SessionConfiguration and
    // returns a non-ok binder::Status if the passed in session configuration
    // isn't valid.
    static binder::Status
    convertToHALStreamCombination(const SessionConfiguration& sessionConfiguration,
            const String8 &cameraId, const CameraMetadata &deviceInfo,
            metadataGetter getMetadata, const std::vector<std::string> &physicalCameraIds,
            hardware::camera::device::V3_4::StreamConfiguration &streamConfiguration,
            bool *earlyExit);
    /**
     * Interface used by independent components of CameraDeviceClient.
     */
@@ -266,18 +256,8 @@ private:

    /** Utility members */
    binder::Status checkPidStatus(const char* checkLocation);
    static binder::Status checkOperatingMode(int operatingMode, const CameraMetadata &staticInfo,
            const String8 &cameraId);
    static binder::Status checkSurfaceType(size_t numBufferProducers, bool deferredConsumer,
            int surfaceType);
    static void mapStreamInfo(const OutputStreamInfo &streamInfo,
            camera3_stream_rotation_t rotation, String8 physicalId,
            hardware::camera::device::V3_4::Stream *stream /*out*/);
    bool enforceRequestPermissions(CameraMetadata& metadata);

    // Find the square of the euclidean distance between two points
    static int64_t euclidDistSquare(int32_t x0, int32_t y0, int32_t x1, int32_t y1);

    // Create an output stream with surface deferred for future.
    binder::Status createDeferredSurfaceStreamLocked(
            const hardware::camera2::params::OutputConfiguration &outputConfiguration,
@@ -288,33 +268,11 @@ private:
    // cases.
    binder::Status setStreamTransformLocked(int streamId);

    // Find the closest dimensions for a given format in available stream configurations with
    // a width <= ROUNDING_WIDTH_CAP
    static const int32_t ROUNDING_WIDTH_CAP = 1920;
    static bool roundBufferDimensionNearest(int32_t width, int32_t height, int32_t format,
            android_dataspace dataSpace, const CameraMetadata& info,
            /*out*/int32_t* outWidth, /*out*/int32_t* outHeight);

    //check if format is not custom format
    static bool isPublicFormat(int32_t format);

    // Create a Surface from an IGraphicBufferProducer. Returns error if
    // IGraphicBufferProducer's property doesn't match with streamInfo
    static binder::Status createSurfaceFromGbp(OutputStreamInfo& streamInfo, bool isStreamInfoValid,
            sp<Surface>& surface, const sp<IGraphicBufferProducer>& gbp, const String8 &cameraId,
            const CameraMetadata &physicalCameraMetadata);


    // Utility method to insert the surface into SurfaceMap
    binder::Status insertGbpLocked(const sp<IGraphicBufferProducer>& gbp,
            /*out*/SurfaceMap* surfaceMap, /*out*/Vector<int32_t>* streamIds,
            /*out*/int32_t*  currentStreamId);

    // Check that the physicalCameraId passed in is spported by the camera
    // device.
    static binder::Status checkPhysicalCameraId(const std::vector<std::string> &physicalCameraIds,
            const String8 &physicalCameraId, const String8 &logicalCameraId);

    // IGraphicsBufferProducer binder -> Stream ID + Surface ID for output streams
    KeyedVector<sp<IBinder>, StreamSurfaceId> mStreamMap;

@@ -346,7 +304,6 @@ private:

    KeyedVector<sp<IBinder>, sp<CompositeStream>> mCompositeStreamMap;

    static const int32_t MAX_SURFACES_PER_STREAM = 4;
    sp<CameraProviderManager> mProviderManager;
};

+478 −5

File changed.

Preview size limit exceeded, changes collapsed.

+42 −0
Original line number Diff line number Diff line
@@ -23,6 +23,9 @@
#include <camera/camera2/SubmitInfo.h>
#include <android/hardware/camera/device/3.4/ICameraDeviceSession.h>

#include <hardware/camera3.h>
#include <device3/Camera3StreamInterface.h>

#include <stdint.h>

namespace android {
@@ -31,6 +34,41 @@ typedef std::function<CameraMetadata (const String8 &)> metadataGetter;

class SessionConfigurationUtils {
public:

    static int64_t euclidDistSquare(int32_t x0, int32_t y0, int32_t x1, int32_t y1);

    // Find the closest dimensions for a given format in available stream configurations with
    // a width <= ROUNDING_WIDTH_CAP
    static bool roundBufferDimensionNearest(int32_t width, int32_t height, int32_t format,
            android_dataspace dataSpace, const CameraMetadata& info,
            /*out*/int32_t* outWidth, /*out*/int32_t* outHeight);

    //check if format is not custom format
    static bool isPublicFormat(int32_t format);

    // Create a Surface from an IGraphicBufferProducer. Returns error if
    // IGraphicBufferProducer's property doesn't match with streamInfo
    static binder::Status createSurfaceFromGbp(
        camera3::OutputStreamInfo& streamInfo, bool isStreamInfoValid,
        sp<Surface>& surface, const sp<IGraphicBufferProducer>& gbp,
        const String8 &cameraId, const CameraMetadata &physicalCameraMetadata);

    static void mapStreamInfo(const camera3::OutputStreamInfo &streamInfo,
            camera3_stream_rotation_t rotation, String8 physicalId,
            hardware::camera::device::V3_4::Stream *stream /*out*/);

    // Check that the physicalCameraId passed in is spported by the camera
    // device.
    static binder::Status checkPhysicalCameraId(
        const std::vector<std::string> &physicalCameraIds, const String8 &physicalCameraId,
        const String8 &logicalCameraId);

    static binder::Status checkSurfaceType(size_t numBufferProducers,
        bool deferredConsumer, int surfaceType);

    static binder::Status checkOperatingMode(int operatingMode,
        const CameraMetadata &staticInfo, const String8 &cameraId);

    // utility function to convert AIDL SessionConfiguration to HIDL
    // streamConfiguration. Also checks for validity of SessionConfiguration and
    // returns a non-ok binder::Status if the passed in session configuration
@@ -41,6 +79,10 @@ public:
            metadataGetter getMetadata, const std::vector<std::string> &physicalCameraIds,
            hardware::camera::device::V3_4::StreamConfiguration &streamConfiguration,
            bool *earlyExit);

    static const int32_t MAX_SURFACES_PER_STREAM = 4;

    static const int32_t ROUNDING_WIDTH_CAP = 1920;
};

} // android