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

Commit ae21e335 authored by Yin-Chia Yeh's avatar Yin-Chia Yeh Committed by Android (Google) Code Review
Browse files

Merge "Camera: plumbing rotation field through"

parents 5a23aa94 b97babb8
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ LOCAL_SRC_FILES:= \
	camera2/ICameraDeviceUser.cpp \
	camera2/ICameraDeviceCallbacks.cpp \
	camera2/CaptureRequest.cpp \
	camera2/OutputConfiguration.cpp \
	ProCamera.cpp \
	CameraBase.cpp \
	CameraUtils.cpp \
+12 −20
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@
#include <gui/Surface.h>
#include <camera/CameraMetadata.h>
#include <camera/camera2/CaptureRequest.h>
#include <camera/camera2/OutputConfiguration.h>

namespace android {

@@ -208,17 +209,16 @@ public:
        return reply.readInt32();
    }

    virtual status_t createStream(
                          const sp<IGraphicBufferProducer>& bufferProducer)
    virtual status_t createStream(const OutputConfiguration& outputConfiguration)
    {
        Parcel data, reply;
        data.writeInterfaceToken(ICameraDeviceUser::getInterfaceDescriptor());

        data.writeInt32(1); // marker that bufferProducer is not null
        data.writeString16(String16("unknown_name")); // name of surface
        sp<IBinder> b(IInterface::asBinder(bufferProducer));
        data.writeStrongBinder(b);

        if (outputConfiguration.getGraphicBufferProducer() != NULL) {
            data.writeInt32(1); // marker that OutputConfiguration is not null. Mimic aidl behavior
            outputConfiguration.writeToParcel(data);
        } else {
            data.writeInt32(0);
        }
        remote()->transact(CREATE_STREAM, data, &reply);

        reply.readExceptionCode();
@@ -394,22 +394,14 @@ status_t BnCameraDeviceUser::onTransact(
        case CREATE_STREAM: {
            CHECK_INTERFACE(ICameraDeviceUser, data, reply);

            sp<IGraphicBufferProducer> bp;
            status_t ret = BAD_VALUE;
            if (data.readInt32() != 0) {
                String16 name = readMaybeEmptyString16(data);
                bp = interface_cast<IGraphicBufferProducer>(
                        data.readStrongBinder());

                ALOGV("%s: CREATE_STREAM: bp = %p, name = %s", __FUNCTION__,
                      bp.get(), String8(name).string());
                OutputConfiguration outputConfiguration(data);
                ret = createStream(outputConfiguration);
            } else {
                ALOGV("%s: CREATE_STREAM: bp = unset, name = unset",
                      __FUNCTION__);
                ALOGE("%s: cannot take an empty OutputConfiguration", __FUNCTION__);
            }

            status_t ret;
            ret = createStream(bp);

            reply->writeNoException();
            ALOGV("%s: CREATE_STREAM: write noException", __FUNCTION__);
            reply->writeInt32(ret);
+79 −0
Original line number Diff line number Diff line
/*
**
** Copyright 2015, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
**     http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/

#define LOG_TAG "OutputConfiguration"
#include <utils/Log.h>

#include <camera/camera2/OutputConfiguration.h>
#include <binder/Parcel.h>

namespace android {


const int OutputConfiguration::INVALID_ROTATION = -1;

// Read empty strings without printing a false error message.
String16 OutputConfiguration::readMaybeEmptyString16(const Parcel& parcel) {
    size_t len;
    const char16_t* str = parcel.readString16Inplace(&len);
    if (str != NULL) {
        return String16(str, len);
    } else {
        return String16();
    }
}

sp<IGraphicBufferProducer> OutputConfiguration::getGraphicBufferProducer() const {
    return mGbp;
}

int OutputConfiguration::getRotation() const {
    return mRotation;
}

OutputConfiguration::OutputConfiguration(const Parcel& parcel) {
    status_t err;
    int rotation = 0;
    if ((err = parcel.readInt32(&rotation)) != OK) {
        ALOGE("%s: Failed to read rotation from parcel", __FUNCTION__);
        mGbp = NULL;
        mRotation = INVALID_ROTATION;
        return;
    }

    String16 name = readMaybeEmptyString16(parcel);
    const sp<IGraphicBufferProducer>& gbp =
            interface_cast<IGraphicBufferProducer>(parcel.readStrongBinder());
    mGbp = gbp;
    mRotation = rotation;

    ALOGV("%s: OutputConfiguration: bp = %p, name = %s", __FUNCTION__,
          gbp.get(), String8(name).string());
}

status_t OutputConfiguration::writeToParcel(Parcel& parcel) const {

    parcel.writeInt32(mRotation);
    parcel.writeString16(String16("unknown_name")); // name of surface
    sp<IBinder> b(IInterface::asBinder(mGbp));
    parcel.writeStrongBinder(b);

    return OK;
}

}; // namespace android
+3 −3
Original line number Diff line number Diff line
@@ -27,9 +27,9 @@ namespace android {

class ICameraDeviceUserClient;
class IGraphicBufferProducer;
class Surface;
class CaptureRequest;
class CameraMetadata;
class OutputConfiguration;

enum {
    NO_IN_FLIGHT_REPEATING_FRAMES = -1,
@@ -100,8 +100,8 @@ public:
    virtual status_t        endConfigure() = 0;

    virtual status_t        deleteStream(int streamId) = 0;
    virtual status_t        createStream(
            const sp<IGraphicBufferProducer>& bufferProducer) = 0;

    virtual status_t        createStream(const OutputConfiguration& outputConfiguration) = 0;

    // Create a request object from a template.
    virtual status_t        createDefaultRequest(int templateId,
+51 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2015 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef ANDROID_HARDWARE_CAMERA2_OUTPUTCONFIGURATION_H
#define ANDROID_HARDWARE_CAMERA2_OUTPUTCONFIGURATION_H

#include <utils/RefBase.h>
#include <gui/IGraphicBufferProducer.h>

namespace android {

class Surface;

class OutputConfiguration : public virtual RefBase {
public:

    static const int INVALID_ROTATION;
    sp<IGraphicBufferProducer> getGraphicBufferProducer() const;
    int                        getRotation() const;

    /**
     * Keep impl up-to-date with OutputConfiguration.java in frameworks/base
     */
    status_t                   writeToParcel(Parcel& parcel) const;
    // getGraphicBufferProducer will be NULL if error occurred
    // getRotation will be INVALID_ROTATION if error occurred
    OutputConfiguration(const Parcel& parcel);

private:
    sp<IGraphicBufferProducer> mGbp;
    int                        mRotation;

    // helper function
    static String16 readMaybeEmptyString16(const Parcel& parcel);
};
}; // namespace android

#endif
Loading