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

Commit 63d2f56b authored by Jayant Chowdhary's avatar Jayant Chowdhary Committed by Android (Google) Code Review
Browse files

Merge "cameraserver: Fix HIDL vs AIDL CameraBlobId discrepancy; Move HIDL into...

Merge "cameraserver: Fix HIDL vs AIDL CameraBlobId discrepancy; Move HIDL into seperate source files." into tm-dev
parents 2ea87cb7 c67af1bd
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@
#include <android_media_Utils.h>
#include <private/android/AHardwareBufferHelpers.h>
#include <utils/Log.h>
#include "hardware/camera3.h"

using namespace android;

@@ -375,8 +374,8 @@ AImage::getJpegSize() const {
    uint8_t* jpegBuffer = mLockedBuffer->data;

    // First check for JPEG transport header at the end of the buffer
    uint8_t* header = jpegBuffer + (width - sizeof(struct camera3_jpeg_blob));
    struct camera3_jpeg_blob* blob = (struct camera3_jpeg_blob*)(header);
    uint8_t* header = jpegBuffer + (width - sizeof(struct camera3_jpeg_blob_v2));
    struct camera3_jpeg_blob_v2* blob = (struct camera3_jpeg_blob_v2*)(header);
    if (blob->jpeg_blob_id == CAMERA3_JPEG_BLOB_ID) {
        size = blob->jpeg_size;
        ALOGV("%s: Jpeg size = %d", __FUNCTION__, size);
+1 −0
Original line number Diff line number Diff line
@@ -100,6 +100,7 @@ cc_library_shared {
        "utils/CameraTraces.cpp",
        "utils/AutoConditionLock.cpp",
        "utils/SessionConfigurationUtils.cpp",
        "utils/SessionConfigurationUtilsHidl.cpp",
        "utils/SessionStatsBuilder.cpp",
        "utils/TagMonitor.cpp",
        "utils/LatencyHistogram.cpp",
+10 −5
Original line number Diff line number Diff line
@@ -20,6 +20,9 @@

#include <netinet/in.h>

#include <aidl/android/hardware/camera/device/CameraBlob.h>
#include <aidl/android/hardware/camera/device/CameraBlobId.h>

#include <binder/MemoryBase.h>
#include <binder/MemoryHeapBase.h>
#include <utils/Log.h>
@@ -36,6 +39,8 @@ namespace android {
namespace camera2 {

using android::camera3::CAMERA_STREAM_ROTATION_0;
using aidl::android::hardware::camera::device::CameraBlob;
using aidl::android::hardware::camera::device::CameraBlobId;

JpegProcessor::JpegProcessor(
    sp<Camera2Client> client,
@@ -350,11 +355,11 @@ size_t JpegProcessor::findJpegSize(uint8_t* jpegBuffer, size_t maxSize) {
    size_t size;

    // First check for JPEG transport header at the end of the buffer
    uint8_t *header = jpegBuffer + (maxSize - sizeof(struct camera2_jpeg_blob));
    struct camera2_jpeg_blob *blob = (struct camera2_jpeg_blob*)(header);
    if (blob->jpeg_blob_id == CAMERA2_JPEG_BLOB_ID) {
        size = blob->jpeg_size;
        if (size > 0 && size <= maxSize - sizeof(struct camera2_jpeg_blob)) {
    uint8_t *header = jpegBuffer + (maxSize - sizeof(CameraBlob));
    CameraBlob *blob = (CameraBlob*)(header);
    if (blob->blobId == CameraBlobId::JPEG) {
        size = blob->blobSizeBytes;
        if (size > 0 && size <= maxSize - sizeof(CameraBlob)) {
            // Verify SOI and EOI markers
            size_t offset = size - MARKER_LENGTH;
            uint8_t *end = jpegBuffer + offset;
+0 −35
Original line number Diff line number Diff line
@@ -117,41 +117,6 @@ protected:
    // Composite streams should behave accordingly.
    void enableErrorState();

    // Utility class to lock and unlock a GraphicBuffer
    class GraphicBufferLocker {
    public:
        GraphicBufferLocker(sp<GraphicBuffer> buffer) : _buffer(buffer) {}

        status_t lockAsync(void** dstBuffer, int fenceFd) {
            if (_buffer == nullptr) return BAD_VALUE;

            status_t res = OK;
            if (!_locked) {
                status_t res =  _buffer->lockAsync(GRALLOC_USAGE_SW_WRITE_OFTEN,
                        dstBuffer, fenceFd);
                if (res == OK) {
                    _locked = true;
                }
            }
            return res;
        }

        ~GraphicBufferLocker() {
            if (_locked && _buffer != nullptr) {
                auto res = _buffer->unlock();
                if (res != OK) {
                    ALOGE("%s: Error trying to unlock buffer: %s (%d)", __FUNCTION__,
                            strerror(-res), res);
                }
            }
        }

    private:
        sp<GraphicBuffer> _buffer;
        bool _locked = false;
    };


    wp<CameraDeviceBase>   mDevice;
    wp<camera3::StatusTracker> mStatusTracker;
    wp<hardware::camera2::ICameraDeviceCallbacks> mRemoteCallback;
+11 −5
Original line number Diff line number Diff line
@@ -18,6 +18,9 @@
#define ATRACE_TAG ATRACE_TAG_CAMERA
//#define LOG_NDEBUG 0

#include <aidl/android/hardware/camera/device/CameraBlob.h>
#include <aidl/android/hardware/camera/device/CameraBlobId.h>

#include "api1/client2/JpegProcessor.h"
#include "common/CameraProviderManager.h"
#include "utils/SessionConfigurationUtils.h"
@@ -30,6 +33,9 @@
namespace android {
namespace camera3 {

using aidl::android::hardware::camera::device::CameraBlob;
using aidl::android::hardware::camera::device::CameraBlobId;

DepthCompositeStream::DepthCompositeStream(sp<CameraDeviceBase> device,
        wp<hardware::camera2::ICameraDeviceCallbacks> cb) :
        CompositeStream(device, cb),
@@ -367,7 +373,7 @@ status_t DepthCompositeStream::processInputFrame(nsecs_t ts, const InputFrame &i
        return res;
    }

    size_t finalJpegSize = actualJpegSize + sizeof(struct camera_jpeg_blob);
    size_t finalJpegSize = actualJpegSize + sizeof(CameraBlob);
    if (finalJpegSize > finalJpegBufferSize) {
        ALOGE("%s: Final jpeg buffer not large enough for the jpeg blob header", __FUNCTION__);
        outputANW->cancelBuffer(mOutputSurface.get(), anb, /*fence*/ -1);
@@ -383,10 +389,10 @@ status_t DepthCompositeStream::processInputFrame(nsecs_t ts, const InputFrame &i

    ALOGV("%s: Final jpeg size: %zu", __func__, finalJpegSize);
    uint8_t* header = static_cast<uint8_t *> (dstBuffer) +
        (gb->getWidth() - sizeof(struct camera_jpeg_blob));
    struct camera_jpeg_blob *blob = reinterpret_cast<struct camera_jpeg_blob*> (header);
    blob->jpeg_blob_id = CAMERA_JPEG_BLOB_ID;
    blob->jpeg_size = actualJpegSize;
        (gb->getWidth() - sizeof(CameraBlob));
    CameraBlob *blob = reinterpret_cast<CameraBlob*> (header);
    blob->blobId = CameraBlobId::JPEG;
    blob->blobSizeBytes = actualJpegSize;
    outputANW->queueBuffer(mOutputSurface.get(), anb, /*fence*/ -1);

    return res;
Loading