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

Commit 5612422f authored by Changyeon Jo's avatar Changyeon Jo Committed by Android (Google) Code Review
Browse files

Merge changes from topic "evs_next"

* changes:
  Implement getPhysicalCameraInfo() method
  Update EVS VTS test cases
  Fix EVS frame handler for VTS
  Fix EVS VTS test cases
  Prerequsite changes for EVS multi-camera support
parents 5598f53d 6caf74b0
Loading
Loading
Loading
Loading
+33 −10
Original line number Diff line number Diff line
@@ -33,6 +33,23 @@ interface IEvsCamera extends @1.0::IEvsCamera {
     */
    getCameraInfo_1_1() generates (CameraDesc info);

    /**
     * Returns the description of the physical camera device that backs this
     * logical camera.
     *
     * If a requested device does not either exist or back this logical device,
     * this method returns a null camera descriptor.  And, if this is called on
     * a physical camera device, this method is the same as getCameraInfo_1_1()
     * method if a given device ID is matched.  Otherwise, this will return a
     * null camera descriptor.
     *
     * @param  deviceId Physical camera device identifier string.
     * @return info     The description of a member physical camera device.
     *                  This must be the same value as reported by
     *                  EvsEnumerator::getCameraList_1_1().
     */
    getPhysicalCameraInfo(string deviceId) generates (CameraDesc info);

    /**
     * Requests to pause EVS camera stream events.
     *
@@ -51,7 +68,7 @@ interface IEvsCamera extends @1.0::IEvsCamera {
    resumeVideoStream() generates (EvsResult result);

    /**
     * Returns a frame that was delivered by to the IEvsCameraStream.
     * Returns frame that were delivered by to the IEvsCameraStream.
     *
     * When done consuming a frame delivered to the IEvsCameraStream
     * interface, it must be returned to the IEvsCamera for reuse.
@@ -59,10 +76,10 @@ interface IEvsCamera extends @1.0::IEvsCamera {
     * as one), and if the supply is exhausted, no further frames may be
     * delivered until a buffer is returned.
     *
     * @param  buffer A buffer to be returned.
     * @param  buffer Buffers to be returned.
     * @return result Return EvsResult::OK if this call is successful.
     */
    doneWithFrame_1_1(BufferDesc buffer) generates (EvsResult result);
    doneWithFrame_1_1(vec<BufferDesc> buffer) generates (EvsResult result);

    /**
     * Requests to be a master client.
@@ -127,8 +144,13 @@ interface IEvsCamera extends @1.0::IEvsCamera {
        generates (int32_t min, int32_t max, int32_t step);

    /**
     * Requests to set a camera parameter.  Only a request from the master
     * client will be processed successfully.
     * Requests to set a camera parameter.
     *
     * Only a request from the master client will be processed successfully.
     * When this method is called on a logical camera device, it will be forwarded
     * to each physical device and, if it fails to program any physical device,
     * it will return an error code with the same number of effective values as
     * the number of backing camera devices.
     *
     * @param  id             The identifier of camera parameter, CameraParam enum.
     *         value          A desired parameter value.
@@ -138,21 +160,22 @@ interface IEvsCamera extends @1.0::IEvsCamera {
     *                        parameter is not supported.
     *                        EvsResult::UNDERLYING_SERVICE_ERROR if it fails to
     *                        program a value by any other reason.
     *         effectiveValue A programmed parameter value.  This may differ
     *         effectiveValue Programmed parameter values.  This may differ
     *                        from what the client gives if, for example, the
     *                        driver does not support a target parameter.
     */
    setIntParameter(CameraParam id, int32_t value)
        generates (EvsResult result, int32_t effectiveValue);
        generates (EvsResult result, vec<int32_t> effectiveValue);

    /**
     * Retrieves a value of given camera parameter.
     * Retrieves values of given camera parameter.
     *
     * @param  id     The identifier of camera parameter, CameraParam enum.
     * @return result EvsResult::OK if it succeeds to read a parameter.
     *                EvsResult::INVALID_ARG if either a requested parameter is
     *                not supported.
     *         value  A value of requested camera parameter.
     *         value  Values of requested camera parameter, the same number of
     *                values as backing camera devices.
     */
    getIntParameter(CameraParam id) generates(EvsResult result, int32_t value);
    getIntParameter(CameraParam id) generates(EvsResult result, vec<int32_t> value);
};
+10 −5
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ package android.hardware.automotive.evs@1.1;

import @1.0::IEvsCameraStream;
import @1.1::BufferDesc;
import @1.1::EvsEvent;
import @1.1::EvsEventDesc;

/**
 * Implemented on client side to receive asynchronous streaming event deliveries.
@@ -26,7 +26,7 @@ import @1.1::EvsEvent;
interface IEvsCameraStream extends @1.0::IEvsCameraStream {

    /**
     * Receives calls from the HAL each time a video frame is ready for inspection.
     * Receives calls from the HAL each time video frames is ready for inspection.
     * Buffer handles received by this method must be returned via calls to
     * IEvsCamera::doneWithFrame_1_1(). When the video stream is stopped via a call
     * to IEvsCamera::stopVideoStream(), this callback may continue to happen for
@@ -35,14 +35,19 @@ interface IEvsCameraStream extends @1.0::IEvsCameraStream {
     * event must be delivered.  No further frame deliveries may happen
     * thereafter.
     *
     * @param buffer a buffer descriptor of a delivered image frame.
     * A camera device will deliver the same number of frames as number of
     * backing physical camera devices; it means, a physical camera device
     * sends always a single frame and a logical camera device sends multiple
     * frames as many as number of backing physical camera devices.
     *
     * @param buffer Buffer descriptors of delivered image frames.
     */
    oneway deliverFrame_1_1(BufferDesc buffer);
    oneway deliverFrame_1_1(vec<BufferDesc> buffer);

    /**
     * Receives calls from the HAL each time an event happens.
     *
     * @param  event EVS event with possible event information.
     */
    oneway notify(EvsEvent event);
    oneway notify(EvsEventDesc event);
};
+1 −1
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@ cc_binary {
    shared_libs: [
        "android.hardware.automotive.evs@1.0",
        "android.hardware.automotive.evs@1.1",
        "android.hardware.camera.device@3.2",
        "android.hardware.camera.device@3.3",
        "libbase",
        "libbinder",
        "liblog",
+102 −77
Original line number Diff line number Diff line
@@ -42,55 +42,32 @@ void ConfigManager::readCameraInfo(const XMLElement * const aCameraElem) {
    while (curElem != nullptr) {
        if (!strcmp(curElem->Name(), "group")) {
            /* camera group identifier */
            const char *group_id = curElem->FindAttribute("group_id")->Value();

            /* create CameraGroup */
            unique_ptr<ConfigManager::CameraGroup> aCameraGroup(new ConfigManager::CameraGroup());

            /* add a camera device to its group */
            addCameraDevices(curElem->FindAttribute("device_id")->Value(), aCameraGroup);
            const char *id = curElem->FindAttribute("id")->Value();

            /* a list of camera stream configurations */
            const XMLElement *childElem =
                curElem->FirstChildElement("caps")->FirstChildElement("stream");
            while (childElem != nullptr) {
                /* read 5 attributes */
                const XMLAttribute *idAttr     = childElem->FindAttribute("id");
                const XMLAttribute *widthAttr  = childElem->FindAttribute("width");
                const XMLAttribute *heightAttr = childElem->FindAttribute("height");
                const XMLAttribute *fmtAttr    = childElem->FindAttribute("format");
                const XMLAttribute *fpsAttr    = childElem->FindAttribute("framerate");
            /* create a camera group to be filled */
            CameraGroupInfo *aCamera = new CameraGroupInfo();

                const int32_t id = stoi(idAttr->Value());
                int32_t framerate = 0;
                if (fpsAttr != nullptr) {
                    framerate = stoi(fpsAttr->Value());
                }

                int32_t pixFormat;
                if (ConfigManagerUtil::convertToPixelFormat(fmtAttr->Value(),
                                                            pixFormat)) {
                    RawStreamConfiguration cfg = {
                        id,
                        stoi(widthAttr->Value()),
                        stoi(heightAttr->Value()),
                        pixFormat,
                        ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT,
                        framerate
                    };
                    aCameraGroup->streamConfigurations[id] = cfg;
                }

                childElem = childElem->NextSiblingElement("stream");
            /* read camera device information */
            if (!readCameraDeviceInfo(aCamera, curElem)) {
                ALOGW("Failed to read a camera information of %s", id);
                delete aCamera;
                continue;
            }

            /* camera group synchronization */
            const char *sync = curElem->FindAttribute("synchronized")->Value();
            aCameraGroup->synchronized =
                static_cast<bool>(strcmp(sync, "false"));
            if (!strcmp(sync, "CALIBRATED")) {
                aCamera->synchronized =
                    ANDROID_LOGICAL_MULTI_CAMERA_SENSOR_SYNC_TYPE_CALIBRATED;
            } else if (!strcmp(sync, "APPROXIMATE")) {
                aCamera->synchronized =
                    ANDROID_LOGICAL_MULTI_CAMERA_SENSOR_SYNC_TYPE_APPROXIMATE;
            } else {
                aCamera->synchronized = 0; // Not synchronized
            }

            /* add a group to hash map */
            mCameraGroups[group_id] = std::move(aCameraGroup);
            mCameraGroupInfos.insert_or_assign(id, unique_ptr<CameraGroupInfo>(aCamera));
        } else if (!strcmp(curElem->Name(), "device")) {
            /* camera unique identifier */
            const char *id = curElem->FindAttribute("id")->Value();
@@ -98,8 +75,18 @@ void ConfigManager::readCameraInfo(const XMLElement * const aCameraElem) {
            /* camera mount location */
            const char *pos = curElem->FindAttribute("position")->Value();

            /* create a camera device to be filled */
            CameraInfo *aCamera = new CameraInfo();

            /* read camera device information */
            if (!readCameraDeviceInfo(aCamera, curElem)) {
                ALOGW("Failed to read a camera information of %s", id);
                delete aCamera;
                continue;
            }

            /* store read camera module information */
            mCameraInfo[id] = readCameraDeviceInfo(curElem);
            mCameraInfo.insert_or_assign(id, unique_ptr<CameraInfo>(aCamera));

            /* assign a camera device to a position group */
            mCameraPosition[pos].emplace(id);
@@ -113,15 +100,13 @@ void ConfigManager::readCameraInfo(const XMLElement * const aCameraElem) {
}


unique_ptr<ConfigManager::CameraInfo>
ConfigManager::readCameraDeviceInfo(const XMLElement *aDeviceElem) {
    if (aDeviceElem == nullptr) {
        return nullptr;
bool
ConfigManager::readCameraDeviceInfo(CameraInfo *aCamera,
                                    const XMLElement *aDeviceElem) {
    if (aCamera == nullptr || aDeviceElem == nullptr) {
        return false;
    }

    /* create a CameraInfo to be filled */
    unique_ptr<ConfigManager::CameraInfo> aCamera(new ConfigManager::CameraInfo());

    /* size information to allocate camera_metadata_t */
    size_t totalEntries = 0;
    size_t totalDataSize = 0;
@@ -145,14 +130,15 @@ ConfigManager::readCameraDeviceInfo(const XMLElement *aDeviceElem) {
              "allocated memory was not large enough");
    }

    return aCamera;
    return true;
}


size_t ConfigManager::readCameraCapabilities(const XMLElement * const aCapElem,
                                             unique_ptr<ConfigManager::CameraInfo> &aCamera,
size_t
ConfigManager::readCameraCapabilities(const XMLElement * const aCapElem,
                                      CameraInfo *aCamera,
                                      size_t &dataSize) {
    if (aCapElem == nullptr) {
    if (aCapElem == nullptr || aCamera == nullptr) {
        return 0;
    }

@@ -214,7 +200,7 @@ size_t ConfigManager::readCameraCapabilities(const XMLElement * const aCapElem,
                ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT,
                framerate
            };
            aCamera->streamConfigurations[id] = cfg;
            aCamera->streamConfigurations.insert_or_assign(id, cfg);
        }

        curElem = curElem->NextSiblingElement("stream");
@@ -232,10 +218,11 @@ size_t ConfigManager::readCameraCapabilities(const XMLElement * const aCapElem,
}


size_t ConfigManager::readCameraMetadata(const XMLElement * const aParamElem,
                                       unique_ptr<ConfigManager::CameraInfo> &aCamera,
size_t
ConfigManager::readCameraMetadata(const XMLElement * const aParamElem,
                                  CameraInfo *aCamera,
                                  size_t &dataSize) {
    if (aParamElem == nullptr) {
    if (aParamElem == nullptr || aCamera == nullptr) {
        return 0;
    }

@@ -258,8 +245,9 @@ size_t ConfigManager::readCameraMetadata(const XMLElement * const aParamElem,
                                        count
                                   );

                    aCamera->cameraMetadata[tag] =
                        make_pair(make_unique<void *>(data), count);
                    aCamera->cameraMetadata.insert_or_assign(
                        tag, make_pair(make_unique<void *>(data), count)
                    );

                    ++numEntries;
                    dataSize += calculate_camera_metadata_entry_data_size(
@@ -269,6 +257,52 @@ size_t ConfigManager::readCameraMetadata(const XMLElement * const aParamElem,
                    break;
                }

                case ANDROID_REQUEST_AVAILABLE_CAPABILITIES: {
                    camera_metadata_enum_android_request_available_capabilities_t *data =
                        new camera_metadata_enum_android_request_available_capabilities_t[1];
                    if (ConfigManagerUtil::convertToCameraCapability(
                            curElem->FindAttribute("value")->Value(), *data)) {
                                        curElem->FindAttribute("value")->Value(),
                        aCamera->cameraMetadata.insert_or_assign(
                            tag, make_pair(make_unique<void *>(data), 1)
                        );

                        ++numEntries;
                        dataSize += calculate_camera_metadata_entry_data_size(
                                        get_camera_metadata_tag_type(tag), 1
                                    );
                    }
                    break;
                }

                case ANDROID_LOGICAL_MULTI_CAMERA_PHYSICAL_IDS: {
                    /* a comma-separated list of physical camera devices */
                    size_t len = strlen(curElem->FindAttribute("value")->Value());
                    char *data = new char[len + 1];
                    memcpy(data,
                           curElem->FindAttribute("value")->Value(),
                           len * sizeof(char));

                    /* replace commas with null char */
                    char *p = data;
                    while (*p != '\0') {
                        if (*p == ',') {
                            *p = '\0';
                        }
                        ++p;
                    }

                    aCamera->cameraMetadata.insert_or_assign(
                        tag, make_pair(make_unique<void *>(data), len)
                    );

                    ++numEntries;
                    dataSize += calculate_camera_metadata_entry_data_size(
                                    get_camera_metadata_tag_type(tag), len
                                );
                    break;
                }

                default:
                    ALOGW("Parameter %s is not supported",
                          curElem->FindAttribute("name")->Value());
@@ -283,10 +317,11 @@ size_t ConfigManager::readCameraMetadata(const XMLElement * const aParamElem,
}


bool ConfigManager::constructCameraMetadata(unique_ptr<CameraInfo> &aCamera,
bool
ConfigManager::constructCameraMetadata(CameraInfo *aCamera,
                                       const size_t totalEntries,
                                       const size_t totalDataSize) {
    if (!aCamera->allocate(totalEntries, totalDataSize)) {
    if (aCamera == nullptr || !aCamera->allocate(totalEntries, totalDataSize)) {
        ALOGE("Failed to allocate memory for camera metadata");
        return false;
    }
@@ -401,14 +436,14 @@ void ConfigManager::readDisplayInfo(const XMLElement * const aDisplayElem) {
                        ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_INPUT,
                        0   // unused
                    };
                    dpy->streamConfigurations[id] = cfg;
                    dpy->streamConfigurations.insert_or_assign(id, cfg);
                }

                curStream = curStream->NextSiblingElement("stream");
            }
        }

        mDisplayInfo[id] = std::move(dpy);
        mDisplayInfo.insert_or_assign(id, std::move(dpy));
        curDev = curDev->NextSiblingElement("device");
    }

@@ -457,16 +492,6 @@ bool ConfigManager::readConfigDataFromXML() noexcept {
}


void ConfigManager::addCameraDevices(const char *devices,
                                     unique_ptr<CameraGroup> &aGroup) {
    stringstream device_list(devices);
    string token;
    while (getline(device_list, token, ',')) {
        aGroup->devices.emplace(token);
    }
}


std::unique_ptr<ConfigManager> ConfigManager::Create(const char *path) {
    unique_ptr<ConfigManager> cfgMgr(new ConfigManager(path));

+19 −37
Original line number Diff line number Diff line
@@ -82,9 +82,6 @@ public:
        unordered_map<CameraParam,
                      tuple<int32_t, int32_t, int32_t>> controls;

        /* List of supported frame rates */
        unordered_set<int32_t> frameRates;

        /*
         * List of supported output stream configurations; each array stores
         * format, width, height, and direction values in the order.
@@ -102,21 +99,15 @@ public:
        camera_metadata_t *characteristics;
    };

    class CameraGroup {
    class CameraGroupInfo : public CameraInfo {
    public:
        CameraGroup() {}
        CameraGroupInfo() {}

        /* ID of member camera devices */
        unordered_set<string> devices;

        /* The capture operation of member camera devices are synchronized */
        bool synchronized = false;

        /*
         * List of stream configurations that are supposed by all camera devices
         * in this group.
         */
        unordered_map<int32_t, RawStreamConfiguration> streamConfigurations;
    };

    class SystemInfo {
@@ -165,11 +156,11 @@ public:
    /*
     * Return a list of cameras
     *
     * @return CameraGroup
     * @return CameraGroupInfo
     *         A pointer to a camera group identified by a given id.
     */
    unique_ptr<CameraGroup>& getCameraGroup(const string& gid) {
        return mCameraGroups[gid];
    unique_ptr<CameraGroupInfo>& getCameraGroupInfo(const string& gid) {
        return mCameraGroupInfos[gid];
    }


@@ -203,8 +194,8 @@ private:
    /* Internal data structure for camera device information */
    unordered_map<string, unique_ptr<DisplayInfo>> mDisplayInfo;

    /* Camera groups are stored in <groud id, CameraGroup> hash map */
    unordered_map<string, unique_ptr<CameraGroup>> mCameraGroups;
    /* Camera groups are stored in <groud id, CameraGroupInfo> hash map */
    unordered_map<string, unique_ptr<CameraGroupInfo>> mCameraGroupInfos;

    /*
     * Camera positions are stored in <position, camera id set> hash map.
@@ -253,16 +244,19 @@ private:
    /*
     * read camera device information
     *
     * @param  aDeviceElem
     * @param  aCamera
     *         A pointer to CameraInfo that will be completed by this
     *         method.
     *         aDeviceElem
     *         A pointer to "device" XML element that contains camera module
     *         capability info and its characteristics.
     *
     * @return unique_ptr<CameraInfo>
     *         A pointer to CameraInfo class that contains camera module
     *         capability and characteristics.  Please note that this transfers
     *         the ownership of created CameraInfo to the caller.
     * @return bool
     *         Return false upon any failure in reading and processing camera
     *         device information.
     */
    unique_ptr<CameraInfo> readCameraDeviceInfo(const XMLElement *aDeviceElem);
    bool readCameraDeviceInfo(CameraInfo *aCamera,
                              const XMLElement *aDeviceElem);

    /*
     * read camera metadata
@@ -280,7 +274,7 @@ private:
     *         Number of camera metadata entries
     */
    size_t readCameraCapabilities(const XMLElement * const aCapElem,
                                  unique_ptr<CameraInfo> &aCamera,
                                  CameraInfo *aCamera,
                                  size_t &dataSize);

    /*
@@ -298,7 +292,7 @@ private:
     *         Number of camera metadata entries
     */
    size_t readCameraMetadata(const XMLElement * const aParamElem,
                              unique_ptr<CameraInfo> &aCamera,
                              CameraInfo *aCamera,
                              size_t &dataSize);

    /*
@@ -316,21 +310,9 @@ private:
     *         or its size is not large enough to add all found camera metadata
     *         entries.
     */
    bool constructCameraMetadata(unique_ptr<CameraInfo> &aCamera,
    bool constructCameraMetadata(CameraInfo *aCamera,
                                 const size_t totalEntries,
                                 const size_t totalDataSize);

    /*
     * parse a comma-separated list of camera devices and add them to
     * CameraGroup.
     *
     * @param  devices
     *         A comma-separated list of camera device identifiers.
     * @param  aGroup
     *         Camera group which cameras will be added to.
     */
    void addCameraDevices(const char *devices,
                          unique_ptr<CameraGroup> &aGroup);
};
#endif // CONFIG_MANAGER_H
Loading