Camera: Switch camera2 to auto-gen C++ binder interfaces
- Move camera service AIDL files to frameworks/av
- Build C++ interface stubs with AIDL tools
- Add necessary native-side parcelables and update existing ones
- Remove manually-written stubs, rearrange remaining manual stubs
- Adjust implementations to work with auto-generated stubs
- Adjust method signatures for auto-gen differences
- Add rich error messages using binder::Status
Bug: 25091611
Change-Id: I6f69f34b9d1a3f8d1fb7db87357363f8fa8483ff
diff --git a/include/camera/camera2/CaptureRequest.h b/include/camera/camera2/CaptureRequest.h
index 1dd15c4..c989f26 100644
--- a/include/camera/camera2/CaptureRequest.h
+++ b/include/camera/camera2/CaptureRequest.h
@@ -19,15 +19,17 @@
#include <utils/RefBase.h>
#include <utils/Vector.h>
+#include <binder/Parcelable.h>
#include <camera/CameraMetadata.h>
namespace android {
class Surface;
-struct CaptureRequest : public RefBase {
-public:
+namespace hardware {
+namespace camera2 {
+struct CaptureRequest : public Parcelable {
CameraMetadata mMetadata;
Vector<sp<Surface> > mSurfaceList;
bool mIsReprocess;
@@ -35,9 +37,20 @@
/**
* Keep impl up-to-date with CaptureRequest.java in frameworks/base
*/
- status_t readFromParcel(Parcel* parcel);
- status_t writeToParcel(Parcel* parcel) const;
+ status_t readFromParcel(const Parcel* parcel) override;
+ status_t writeToParcel(Parcel* parcel) const override;
};
-}; // namespace android
+
+} // namespace camera2
+} // namespace hardware
+
+struct CaptureRequest :
+ public RefBase, public hardware::camera2::CaptureRequest {
+ public:
+ // Same as android::hardware::camera2::CaptureRequest, except that you can
+ // put this in an sp<>
+};
+
+} // namespace android
#endif
diff --git a/include/camera/camera2/ICameraDeviceCallbacks.h b/include/camera/camera2/ICameraDeviceCallbacks.h
deleted file mode 100644
index c57b39f..0000000
--- a/include/camera/camera2/ICameraDeviceCallbacks.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (C) 2013 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_PHOTOGRAPHY_CALLBACKS_H
-#define ANDROID_HARDWARE_PHOTOGRAPHY_CALLBACKS_H
-
-#include <utils/RefBase.h>
-#include <binder/IInterface.h>
-#include <binder/Parcel.h>
-#include <binder/IMemory.h>
-#include <utils/Timers.h>
-#include <system/camera.h>
-
-#include <camera/CaptureResult.h>
-
-namespace android {
-class CameraMetadata;
-
-
-class ICameraDeviceCallbacks : public IInterface
-{
- /**
- * Keep up-to-date with ICameraDeviceCallbacks.aidl in frameworks/base
- */
-public:
- DECLARE_META_INTERFACE(CameraDeviceCallbacks);
-
- /**
- * Error codes for CAMERA_MSG_ERROR
- */
- enum CameraErrorCode {
- ERROR_CAMERA_INVALID_ERROR = -1, // To indicate all invalid error codes
- ERROR_CAMERA_DISCONNECTED = 0,
- ERROR_CAMERA_DEVICE = 1,
- ERROR_CAMERA_SERVICE = 2,
- ERROR_CAMERA_REQUEST = 3,
- ERROR_CAMERA_RESULT = 4,
- ERROR_CAMERA_BUFFER = 5,
- };
-
- // One way
- virtual void onDeviceError(CameraErrorCode errorCode,
- const CaptureResultExtras& resultExtras) = 0;
-
- // One way
- virtual void onDeviceIdle() = 0;
-
- // One way
- virtual void onCaptureStarted(const CaptureResultExtras& resultExtras,
- int64_t timestamp) = 0;
-
- // One way
- virtual void onResultReceived(const CameraMetadata& metadata,
- const CaptureResultExtras& resultExtras) = 0;
-
- // One way
- virtual void onPrepared(int streamId) = 0;
-};
-
-// ----------------------------------------------------------------------------
-
-class BnCameraDeviceCallbacks : public BnInterface<ICameraDeviceCallbacks>
-{
-public:
- virtual status_t onTransact( uint32_t code,
- const Parcel& data,
- Parcel* reply,
- uint32_t flags = 0);
-};
-
-}; // namespace android
-
-#endif
diff --git a/include/camera/camera2/ICameraDeviceUser.h b/include/camera/camera2/ICameraDeviceUser.h
deleted file mode 100644
index 4d8eb53..0000000
--- a/include/camera/camera2/ICameraDeviceUser.h
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Copyright (C) 2013 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_PHOTOGRAPHY_ICAMERADEVICEUSER_H
-#define ANDROID_HARDWARE_PHOTOGRAPHY_ICAMERADEVICEUSER_H
-
-#include <binder/IInterface.h>
-#include <binder/Parcel.h>
-#include <utils/List.h>
-
-struct camera_metadata;
-
-namespace android {
-
-class ICameraDeviceUserClient;
-class IGraphicBufferProducer;
-class CaptureRequest;
-class CameraMetadata;
-class OutputConfiguration;
-
-enum {
- NO_IN_FLIGHT_REPEATING_FRAMES = -1,
-};
-
-class ICameraDeviceUser : public IInterface
-{
- /**
- * Keep up-to-date with ICameraDeviceUser.aidl in frameworks/base
- */
-public:
- DECLARE_META_INTERFACE(CameraDeviceUser);
-
- virtual void disconnect() = 0;
-
- /**
- * Request Handling
- **/
-
- /**
- * For streaming requests, output lastFrameNumber is the last frame number
- * of the previous repeating request.
- * For non-streaming requests, output lastFrameNumber is the expected last
- * frame number of the current request.
- */
- virtual int submitRequest(sp<CaptureRequest> request,
- bool streaming = false,
- /*out*/
- int64_t* lastFrameNumber = NULL) = 0;
-
- /**
- * For streaming requests, output lastFrameNumber is the last frame number
- * of the previous repeating request.
- * For non-streaming requests, output lastFrameNumber is the expected last
- * frame number of the current request.
- */
- virtual int submitRequestList(List<sp<CaptureRequest> > requestList,
- bool streaming = false,
- /*out*/
- int64_t* lastFrameNumber = NULL) = 0;
-
- /**
- * Output lastFrameNumber is the last frame number of the previous repeating request.
- */
- virtual status_t cancelRequest(int requestId,
- /*out*/
- int64_t* lastFrameNumber = NULL) = 0;
-
- /**
- * Begin the device configuration.
- *
- * <p>
- * beginConfigure must be called before any call to deleteStream, createStream,
- * or endConfigure. It is not valid to call this when the device is not idle.
- * <p>
- */
- virtual status_t beginConfigure() = 0;
-
- /**
- * End the device configuration.
- *
- * <p>
- * endConfigure must be called after stream configuration is complete (i.e. after
- * a call to beginConfigure and subsequent createStream/deleteStream calls). This
- * must be called before any requests can be submitted.
- * <p>
- */
- virtual status_t endConfigure(bool isConstrainedHighSpeed = false) = 0;
-
- virtual status_t deleteStream(int streamId) = 0;
-
- virtual status_t createStream(const OutputConfiguration& outputConfiguration) = 0;
-
- /**
- * Create an input stream of width, height, and format (one of
- * HAL_PIXEL_FORMAT_*)
- *
- * Return stream ID if it's a non-negative value. status_t if it's a
- * negative value.
- */
- virtual status_t createInputStream(int width, int height, int format) = 0;
-
- // get the buffer producer of the input stream
- virtual status_t getInputBufferProducer(
- sp<IGraphicBufferProducer> *producer) = 0;
-
- // Create a request object from a template.
- virtual status_t createDefaultRequest(int templateId,
- /*out*/
- CameraMetadata* request) = 0;
- // Get static camera metadata
- virtual status_t getCameraInfo(/*out*/
- CameraMetadata* info) = 0;
-
- // Wait until all the submitted requests have finished processing
- virtual status_t waitUntilIdle() = 0;
-
- /**
- * Flush all pending and in-progress work as quickly as possible.
- * Output lastFrameNumber is the last frame number of the previous repeating request.
- */
- virtual status_t flush(/*out*/
- int64_t* lastFrameNumber = NULL) = 0;
-
- /**
- * Preallocate buffers for a given output stream asynchronously.
- */
- virtual status_t prepare(int streamId) = 0;
-
- /**
- * Preallocate up to maxCount buffers for a given output stream asynchronously.
- */
- virtual status_t prepare2(int maxCount, int streamId) = 0;
-
- /**
- * Free all unused buffers for a given output stream.
- */
- virtual status_t tearDown(int streamId) = 0;
-
-};
-
-// ----------------------------------------------------------------------------
-
-class BnCameraDeviceUser: public BnInterface<ICameraDeviceUser>
-{
-public:
- virtual status_t onTransact( uint32_t code,
- const Parcel& data,
- Parcel* reply,
- uint32_t flags = 0);
-};
-
-}; // namespace android
-
-#endif
diff --git a/include/camera/camera2/OutputConfiguration.h b/include/camera/camera2/OutputConfiguration.h
index 137d98c..72a3753 100644
--- a/include/camera/camera2/OutputConfiguration.h
+++ b/include/camera/camera2/OutputConfiguration.h
@@ -18,12 +18,17 @@
#define ANDROID_HARDWARE_CAMERA2_OUTPUTCONFIGURATION_H
#include <gui/IGraphicBufferProducer.h>
+#include <binder/Parcelable.h>
namespace android {
class Surface;
-class OutputConfiguration {
+namespace hardware {
+namespace camera2 {
+namespace params {
+
+class OutputConfiguration : public android::Parcelable {
public:
static const int INVALID_ROTATION;
@@ -35,9 +40,18 @@
/**
* Keep impl up-to-date with OutputConfiguration.java in frameworks/base
*/
- status_t writeToParcel(Parcel& parcel) const;
+ virtual status_t writeToParcel(Parcel* parcel) const override;
+
+ virtual status_t readFromParcel(const Parcel* parcel) override;
+
+ // getGraphicBufferProducer will be NULL
+ // getRotation will be INVALID_ROTATION
+ // getSurfaceSetID will be INVALID_SET_ID
+ OutputConfiguration();
+
// getGraphicBufferProducer will be NULL if error occurred
// getRotation will be INVALID_ROTATION if error occurred
+ // getSurfaceSetID will be INVALID_SET_ID if error occurred
OutputConfiguration(const Parcel& parcel);
OutputConfiguration(sp<IGraphicBufferProducer>& gbp, int rotation,
@@ -45,7 +59,8 @@
bool operator == (const OutputConfiguration& other) const {
return (mGbp == other.mGbp &&
- mRotation == other.mRotation);
+ mRotation == other.mRotation &&
+ mSurfaceSetID == other.mSurfaceSetID);
}
bool operator != (const OutputConfiguration& other) const {
return !(*this == other);
@@ -53,6 +68,9 @@
bool operator < (const OutputConfiguration& other) const {
if (*this == other) return false;
if (mGbp != other.mGbp) return mGbp < other.mGbp;
+ if (mSurfaceSetID != other.mSurfaceSetID) {
+ return mSurfaceSetID < other.mSurfaceSetID;
+ }
return mRotation < other.mRotation;
}
bool operator > (const OutputConfiguration& other) const {
@@ -64,8 +82,15 @@
int mRotation;
int mSurfaceSetID;
// helper function
- static String16 readMaybeEmptyString16(const Parcel& parcel);
+ static String16 readMaybeEmptyString16(const Parcel* parcel);
};
+} // namespace params
+} // namespace camera2
+} // namespace hardware
+
+
+using hardware::camera2::params::OutputConfiguration;
+
}; // namespace android
#endif
diff --git a/include/camera/camera2/SubmitInfo.h b/include/camera/camera2/SubmitInfo.h
new file mode 100644
index 0000000..3b47b32
--- /dev/null
+++ b/include/camera/camera2/SubmitInfo.h
@@ -0,0 +1,44 @@
+/*
+ * 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_UTIL_SUBMITINFO_H
+#define ANDROID_HARDWARE_CAMERA2_UTIL_SUBMITINFO_H
+
+#include <binder/Parcel.h>
+#include <binder/Parcelable.h>
+
+namespace android {
+namespace hardware {
+namespace camera2 {
+namespace utils {
+
+struct SubmitInfo : public android::Parcelable {
+public:
+
+ int32_t mRequestId;
+ int64_t mLastFrameNumber;
+
+ virtual status_t writeToParcel(Parcel *parcel) const override;
+ virtual status_t readFromParcel(const Parcel* parcel) override;
+
+};
+
+} // namespace utils
+} // namespace camera2
+} // namespace hardware
+} // namespace android
+
+#endif