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

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

Merge changes from topic "offlineProc-framework"

* changes:
  Camera: Various offline processing fixes
  Camera: some patchs for offline processing
parents f030d4e3 faa4bde9
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -66,7 +66,7 @@ FrameProcessor::~FrameProcessor() {
}
}


bool FrameProcessor::processSingleFrame(CaptureResult &frame,
bool FrameProcessor::processSingleFrame(CaptureResult &frame,
                                        const sp<CameraDeviceBase> &device) {
                                        const sp<FrameProducer> &device) {


    sp<Camera2Client> client = mClient.promote();
    sp<Camera2Client> client = mClient.promote();
    if (!client.get()) {
    if (!client.get()) {
+2 −1
Original line number Original line Diff line number Diff line
@@ -24,6 +24,7 @@
#include <utils/List.h>
#include <utils/List.h>
#include <camera/CameraMetadata.h>
#include <camera/CameraMetadata.h>


#include "common/CameraDeviceBase.h"
#include "common/FrameProcessorBase.h"
#include "common/FrameProcessorBase.h"


struct camera_frame_metadata;
struct camera_frame_metadata;
@@ -54,7 +55,7 @@ class FrameProcessor : public FrameProcessorBase {
    void processNewFrames(const sp<Camera2Client> &client);
    void processNewFrames(const sp<Camera2Client> &client);


    virtual bool processSingleFrame(CaptureResult &frame,
    virtual bool processSingleFrame(CaptureResult &frame,
                                    const sp<CameraDeviceBase> &device);
                                    const sp<FrameProducer> &device);


    status_t processFaceDetect(const CameraMetadata &frame,
    status_t processFaceDetect(const CameraMetadata &frame,
            const sp<Camera2Client> &client);
            const sp<Camera2Client> &client);
+13 −12
Original line number Original line Diff line number Diff line
@@ -117,8 +117,8 @@ status_t CameraDeviceClient::initializeImpl(TProviderPtr providerPtr, const Stri
    threadName = String8::format("CDU-%s-FrameProc", mCameraIdStr.string());
    threadName = String8::format("CDU-%s-FrameProc", mCameraIdStr.string());
    mFrameProcessor->run(threadName.string());
    mFrameProcessor->run(threadName.string());


    mFrameProcessor->registerListener(FRAME_PROCESSOR_LISTENER_MIN_ID,
    mFrameProcessor->registerListener(camera2::FrameProcessorBase::FRAME_PROCESSOR_LISTENER_MIN_ID,
                                      FRAME_PROCESSOR_LISTENER_MAX_ID,
                                      camera2::FrameProcessorBase::FRAME_PROCESSOR_LISTENER_MAX_ID,
                                      /*listener*/this,
                                      /*listener*/this,
                                      /*sendPartials*/true);
                                      /*sendPartials*/true);


@@ -526,6 +526,7 @@ binder::Status CameraDeviceClient::endConfigure(int operatingMode,
            // streams are also supported.
            // streams are also supported.
            std::vector<int> internalStreams;
            std::vector<int> internalStreams;
            mCompositeStreamMap.valueAt(i)->insertCompositeStreamIds(&internalStreams);
            mCompositeStreamMap.valueAt(i)->insertCompositeStreamIds(&internalStreams);
            offlineStreamIds->erase(
                    std::remove_if(offlineStreamIds->begin(), offlineStreamIds->end(),
                    std::remove_if(offlineStreamIds->begin(), offlineStreamIds->end(),
                    [&internalStreams] (int streamId) {
                    [&internalStreams] (int streamId) {
                        auto it = std::find(internalStreams.begin(), internalStreams.end(),
                        auto it = std::find(internalStreams.begin(), internalStreams.end(),
@@ -535,8 +536,7 @@ binder::Status CameraDeviceClient::endConfigure(int operatingMode,
                            return true;
                            return true;
                        }
                        }


                        return false;
                        return false;}), offlineStreamIds->end());
                    });
            if (internalStreams.empty()) {
            if (internalStreams.empty()) {
                offlineStreamIds->push_back(mCompositeStreamMap.valueAt(i)->getStreamId());
                offlineStreamIds->push_back(mCompositeStreamMap.valueAt(i)->getStreamId());
            }
            }
@@ -818,7 +818,7 @@ binder::Status CameraDeviceClient::isSessionConfigurationSupported(
    }
    }
    hardware::camera::device::V3_4::StreamConfiguration streamConfiguration;
    hardware::camera::device::V3_4::StreamConfiguration streamConfiguration;
    bool earlyExit = false;
    bool earlyExit = false;
    metadataGetter getMetadata = [this](const String8 &id) {return mDevice->info(id);};
    metadataGetter getMetadata = [this](const String8 &id) {return mDevice->infoPhysical(id);};
    std::vector<std::string> physicalCameraIds;
    std::vector<std::string> physicalCameraIds;
    mProviderManager->isLogicalCamera(mCameraIdStr.string(), &physicalCameraIds);
    mProviderManager->isLogicalCamera(mCameraIdStr.string(), &physicalCameraIds);
    res = convertToHALStreamCombination(sessionConfiguration, mCameraIdStr,
    res = convertToHALStreamCombination(sessionConfiguration, mCameraIdStr,
@@ -1010,7 +1010,7 @@ binder::Status CameraDeviceClient::createStream(


        sp<Surface> surface;
        sp<Surface> surface;
        res = createSurfaceFromGbp(streamInfo, isStreamInfoValid, surface, bufferProducer,
        res = createSurfaceFromGbp(streamInfo, isStreamInfoValid, surface, bufferProducer,
                mCameraIdStr, mDevice->info(physicalCameraId));
                mCameraIdStr, mDevice->infoPhysical(physicalCameraId));


        if (!res.isOk())
        if (!res.isOk())
            return res;
            return res;
@@ -1314,7 +1314,7 @@ binder::Status CameraDeviceClient::updateOutputConfiguration(int streamId,
        OutputStreamInfo outInfo;
        OutputStreamInfo outInfo;
        sp<Surface> surface;
        sp<Surface> surface;
        res = createSurfaceFromGbp(outInfo, /*isStreamInfoValid*/ false, surface,
        res = createSurfaceFromGbp(outInfo, /*isStreamInfoValid*/ false, surface,
                newOutputsMap.valueAt(i), mCameraIdStr, mDevice->info(physicalCameraId));
                newOutputsMap.valueAt(i), mCameraIdStr, mDevice->infoPhysical(physicalCameraId));
        if (!res.isOk())
        if (!res.isOk())
            return res;
            return res;


@@ -1897,7 +1897,7 @@ binder::Status CameraDeviceClient::finalizeOutputConfigurations(int32_t streamId


        sp<Surface> surface;
        sp<Surface> surface;
        res = createSurfaceFromGbp(mStreamInfoMap[streamId], true /*isStreamInfoValid*/,
        res = createSurfaceFromGbp(mStreamInfoMap[streamId], true /*isStreamInfoValid*/,
                surface, bufferProducer, mCameraIdStr, mDevice->info(physicalId));
                surface, bufferProducer, mCameraIdStr, mDevice->infoPhysical(physicalId));


        if (!res.isOk())
        if (!res.isOk())
            return res;
            return res;
@@ -2005,7 +2005,8 @@ binder::Status CameraDeviceClient::switchToOffline(
        return STATUS_ERROR(CameraService::ERROR_ILLEGAL_ARGUMENT, msg.string());
        return STATUS_ERROR(CameraService::ERROR_ILLEGAL_ARGUMENT, msg.string());
    }
    }


    std::vector<int32_t> offlineStreamIds(offlineOutputIds.size());
    std::vector<int32_t> offlineStreamIds;
    offlineStreamIds.reserve(offlineOutputIds.size());
    KeyedVector<sp<IBinder>, sp<CompositeStream>> offlineCompositeStreamMap;
    KeyedVector<sp<IBinder>, sp<CompositeStream>> offlineCompositeStreamMap;
    for (const auto& streamId : offlineOutputIds) {
    for (const auto& streamId : offlineOutputIds) {
        ssize_t index = mConfiguredOutputs.indexOfKey(streamId);
        ssize_t index = mConfiguredOutputs.indexOfKey(streamId);
@@ -2206,8 +2207,8 @@ void CameraDeviceClient::detachDevice() {


    ALOGV("Camera %s: Stopping processors", mCameraIdStr.string());
    ALOGV("Camera %s: Stopping processors", mCameraIdStr.string());


    mFrameProcessor->removeListener(FRAME_PROCESSOR_LISTENER_MIN_ID,
    mFrameProcessor->removeListener(camera2::FrameProcessorBase::FRAME_PROCESSOR_LISTENER_MIN_ID,
                                    FRAME_PROCESSOR_LISTENER_MAX_ID,
                                    camera2::FrameProcessorBase::FRAME_PROCESSOR_LISTENER_MAX_ID,
                                    /*listener*/this);
                                    /*listener*/this);
    mFrameProcessor->requestExit();
    mFrameProcessor->requestExit();
    ALOGV("Camera %s: Waiting for threads", mCameraIdStr.string());
    ALOGV("Camera %s: Waiting for threads", mCameraIdStr.string());
+0 −2
Original line number Original line Diff line number Diff line
@@ -258,8 +258,6 @@ private:


    /** Preview callback related members */
    /** Preview callback related members */
    sp<camera2::FrameProcessorBase> mFrameProcessor;
    sp<camera2::FrameProcessorBase> mFrameProcessor;
    static const int32_t FRAME_PROCESSOR_LISTENER_MIN_ID = 0;
    static const int32_t FRAME_PROCESSOR_LISTENER_MAX_ID = 0x7fffffffL;


    std::vector<int32_t> mSupportedPhysicalRequestKeys;
    std::vector<int32_t> mSupportedPhysicalRequestKeys;


+19 −1
Original line number Original line Diff line number Diff line
@@ -41,6 +41,16 @@ status_t CameraOfflineSessionClient::initialize(sp<CameraProviderManager>, const
        return NO_INIT;
        return NO_INIT;
    }
    }


    String8 threadName;
    mFrameProcessor = new camera2::FrameProcessorBase(mOfflineSession);
    threadName = String8::format("Offline-%s-FrameProc", mCameraIdStr.string());
    mFrameProcessor->run(threadName.string());

    mFrameProcessor->registerListener(camera2::FrameProcessorBase::FRAME_PROCESSOR_LISTENER_MIN_ID,
                                      camera2::FrameProcessorBase::FRAME_PROCESSOR_LISTENER_MAX_ID,
                                      /*listener*/this,
                                      /*sendPartials*/true);

    wp<NotificationListener> weakThis(this);
    wp<NotificationListener> weakThis(this);
    res = mOfflineSession->initialize(weakThis);
    res = mOfflineSession->initialize(weakThis);
    if (res != OK) {
    if (res != OK) {
@@ -62,7 +72,7 @@ status_t CameraOfflineSessionClient::dump(int fd, const Vector<String16>& args)
    return BasicClient::dump(fd, args);
    return BasicClient::dump(fd, args);
}
}


status_t CameraOfflineSessionClient::dumpClient(int fd, const Vector<String16>& /*args*/) {
status_t CameraOfflineSessionClient::dumpClient(int fd, const Vector<String16>& args) {
    String8 result;
    String8 result;


    result = "  Offline session dump:\n";
    result = "  Offline session dump:\n";
@@ -74,6 +84,8 @@ status_t CameraOfflineSessionClient::dumpClient(int fd, const Vector<String16>&
        return NO_ERROR;
        return NO_ERROR;
    }
    }


    mFrameProcessor->dump(fd, args);

    auto res = mOfflineSession->dump(fd);
    auto res = mOfflineSession->dump(fd);
    if (res != OK) {
    if (res != OK) {
        result = String8::format("   Error dumping offline session: %s (%d)",
        result = String8::format("   Error dumping offline session: %s (%d)",
@@ -108,6 +120,12 @@ binder::Status CameraOfflineSessionClient::disconnect() {
        remote->unlinkToDeath(sCameraService);
        remote->unlinkToDeath(sCameraService);
    }
    }


    mFrameProcessor->removeListener(camera2::FrameProcessorBase::FRAME_PROCESSOR_LISTENER_MIN_ID,
                                    camera2::FrameProcessorBase::FRAME_PROCESSOR_LISTENER_MAX_ID,
                                    /*listener*/this);
    mFrameProcessor->requestExit();
    mFrameProcessor->join();

    finishCameraOps();
    finishCameraOps();
    ALOGI("%s: Disconnected client for offline camera %s for PID %d", __FUNCTION__,
    ALOGI("%s: Disconnected client for offline camera %s for PID %d", __FUNCTION__,
            mCameraIdStr.string(), mClientPid);
            mCameraIdStr.string(), mClientPid);
Loading