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/Camera.h b/include/camera/Camera.h
index f19d296..b45bbfc 100644
--- a/include/camera/Camera.h
+++ b/include/camera/Camera.h
@@ -18,13 +18,15 @@
#define ANDROID_HARDWARE_CAMERA_H
#include <utils/Timers.h>
+
+#include <android/hardware/ICameraService.h>
+
#include <gui/IGraphicBufferProducer.h>
#include <system/camera.h>
-#include <camera/ICameraClient.h>
#include <camera/ICameraRecordingProxy.h>
#include <camera/ICameraRecordingProxyListener.h>
-#include <camera/ICameraService.h>
-#include <camera/ICamera.h>
+#include <camera/android/hardware/ICamera.h>
+#include <camera/android/hardware/ICameraClient.h>
#include <camera/CameraBase.h>
namespace android {
@@ -48,31 +50,32 @@
template <>
struct CameraTraits<Camera>
{
- typedef CameraListener TCamListener;
- typedef ICamera TCamUser;
- typedef ICameraClient TCamCallbacks;
- typedef status_t (ICameraService::*TCamConnectService)(const sp<ICameraClient>&,
- int, const String16&, int, int,
- /*out*/
- sp<ICamera>&);
+ typedef CameraListener TCamListener;
+ typedef ::android::hardware::ICamera TCamUser;
+ typedef ::android::hardware::ICameraClient TCamCallbacks;
+ typedef ::android::binder::Status(::android::hardware::ICameraService::*TCamConnectService)
+ (const sp<::android::hardware::ICameraClient>&,
+ int, const String16&, int, int,
+ /*out*/
+ sp<::android::hardware::ICamera>*);
static TCamConnectService fnConnectService;
};
class Camera :
public CameraBase<Camera>,
- public BnCameraClient
+ public ::android::hardware::BnCameraClient
{
public:
enum {
- USE_CALLING_UID = ICameraService::USE_CALLING_UID
+ USE_CALLING_UID = ::android::hardware::ICameraService::USE_CALLING_UID
};
enum {
- USE_CALLING_PID = ICameraService::USE_CALLING_PID
+ USE_CALLING_PID = ::android::hardware::ICameraService::USE_CALLING_PID
};
// construct a camera client from an existing remote
- static sp<Camera> create(const sp<ICamera>& camera);
+ static sp<Camera> create(const sp<::android::hardware::ICamera>& camera);
static sp<Camera> connect(int cameraId,
const String16& clientPackageName,
int clientUid, int clientPid);
diff --git a/include/camera/CameraBase.h b/include/camera/CameraBase.h
index d8561ed..0692a27 100644
--- a/include/camera/CameraBase.h
+++ b/include/camera/CameraBase.h
@@ -18,13 +18,18 @@
#define ANDROID_HARDWARE_CAMERA_BASE_H
#include <utils/Mutex.h>
-#include <camera/ICameraService.h>
struct camera_frame_metadata;
namespace android {
-struct CameraInfo {
+namespace hardware {
+
+
+class ICameraService;
+class ICameraServiceListener;
+
+struct CameraInfo : public android::Parcelable {
/**
* The direction that the camera faces to. It should be CAMERA_FACING_BACK
* or CAMERA_FACING_FRONT.
@@ -44,8 +49,17 @@
* right of the screen, the value should be 270.
*/
int orientation;
+
+ virtual status_t writeToParcel(Parcel* parcel) const;
+ virtual status_t readFromParcel(const Parcel* parcel);
+
};
+} // namespace hardware
+
+using hardware::CameraInfo;
+
+
template <typename TCam>
struct CameraTraits {
};
@@ -70,13 +84,13 @@
static status_t getCameraInfo(int cameraId,
/*out*/
- struct CameraInfo* cameraInfo);
+ struct hardware::CameraInfo* cameraInfo);
static status_t addServiceListener(
- const sp<ICameraServiceListener>& listener);
+ const sp<::android::hardware::ICameraServiceListener>& listener);
static status_t removeServiceListener(
- const sp<ICameraServiceListener>& listener);
+ const sp<::android::hardware::ICameraServiceListener>& listener);
sp<TCamUser> remote();
@@ -101,7 +115,7 @@
virtual void binderDied(const wp<IBinder>& who);
// helper function to obtain camera service handle
- static const sp<ICameraService>& getCameraService();
+ static const sp<::android::hardware::ICameraService>& getCameraService();
sp<TCamUser> mCamera;
status_t mStatus;
diff --git a/include/camera/CameraMetadata.h b/include/camera/CameraMetadata.h
index 953d711..db400de 100644
--- a/include/camera/CameraMetadata.h
+++ b/include/camera/CameraMetadata.h
@@ -20,14 +20,14 @@
#include "system/camera_metadata.h"
#include <utils/String8.h>
#include <utils/Vector.h>
+#include <binder/Parcelable.h>
namespace android {
-class Parcel;
/**
* A convenience wrapper around the C-based camera_metadata_t library.
*/
-class CameraMetadata {
+class CameraMetadata: public Parcelable {
public:
/** Creates an empty object; best used when expecting to acquire contents
* from elsewhere */
@@ -186,8 +186,8 @@
*/
// Metadata object is unchanged when reading from parcel fails.
- status_t readFromParcel(Parcel *parcel);
- status_t writeToParcel(Parcel *parcel) const;
+ virtual status_t readFromParcel(const Parcel *parcel) override;
+ virtual status_t writeToParcel(Parcel *parcel) const override;
/**
* Caller becomes the owner of the new metadata
@@ -227,6 +227,15 @@
};
-}; // namespace android
+namespace hardware {
+namespace camera2 {
+namespace impl {
+using ::android::CameraMetadata;
+typedef CameraMetadata CameraMetadataNative;
+}
+}
+}
+
+} // namespace android
#endif
diff --git a/include/camera/CaptureResult.h b/include/camera/CaptureResult.h
index 0be7d6f..ff0e3d3 100644
--- a/include/camera/CaptureResult.h
+++ b/include/camera/CaptureResult.h
@@ -18,15 +18,21 @@
#define ANDROID_HARDWARE_CAPTURERESULT_H
#include <utils/RefBase.h>
+#include <binder/Parcelable.h>
#include <camera/CameraMetadata.h>
+
namespace android {
+namespace hardware {
+namespace camera2 {
+namespace impl {
+
/**
* CaptureResultExtras is a structure to encapsulate various indices for a capture result.
* These indices are framework-internal and not sent to the HAL.
*/
-struct CaptureResultExtras {
+struct CaptureResultExtras : public android::Parcelable {
/**
* An integer to index the request sequence that this result belongs to.
*/
@@ -75,9 +81,14 @@
*/
bool isValid();
- status_t readFromParcel(Parcel* parcel);
- status_t writeToParcel(Parcel* parcel) const;
+ virtual status_t readFromParcel(const Parcel* parcel) override;
+ virtual status_t writeToParcel(Parcel* parcel) const override;
};
+} // namespace impl
+} // namespace camera2
+} // namespace hardware
+
+using hardware::camera2::impl::CaptureResultExtras;
struct CaptureResult : public virtual LightRefBase<CaptureResult> {
CameraMetadata mMetadata;
diff --git a/include/camera/ICameraService.h b/include/camera/ICameraService.h
deleted file mode 100644
index d568b4d..0000000
--- a/include/camera/ICameraService.h
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * Copyright (C) 2008 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_ICAMERASERVICE_H
-#define ANDROID_HARDWARE_ICAMERASERVICE_H
-
-#include <utils/RefBase.h>
-#include <binder/IInterface.h>
-#include <binder/Parcel.h>
-
-namespace android {
-
-class ICamera;
-class ICameraClient;
-class ICameraServiceListener;
-class ICameraDeviceUser;
-class ICameraDeviceCallbacks;
-class CameraMetadata;
-class VendorTagDescriptor;
-class String16;
-
-class ICameraService : public IInterface
-{
-public:
- /**
- * Keep up-to-date with ICameraService.aidl in frameworks/base
- */
- enum {
- GET_NUMBER_OF_CAMERAS = IBinder::FIRST_CALL_TRANSACTION,
- GET_CAMERA_INFO,
- CONNECT,
- CONNECT_DEVICE,
- ADD_LISTENER,
- REMOVE_LISTENER,
- GET_CAMERA_CHARACTERISTICS,
- GET_CAMERA_VENDOR_TAG_DESCRIPTOR,
- GET_LEGACY_PARAMETERS,
- SUPPORTS_CAMERA_API,
- CONNECT_LEGACY,
- SET_TORCH_MODE,
- NOTIFY_SYSTEM_EVENT,
- };
-
- enum {
- USE_CALLING_PID = -1
- };
-
- enum {
- USE_CALLING_UID = -1
- };
-
- enum {
- API_VERSION_1 = 1,
- API_VERSION_2 = 2,
- };
-
- enum {
- CAMERA_TYPE_BACKWARD_COMPATIBLE = 0,
- CAMERA_TYPE_ALL = 1,
- };
-
- enum {
- CAMERA_HAL_API_VERSION_UNSPECIFIED = -1
- };
-
- /**
- * Keep up-to-date with declarations in
- * frameworks/base/services/core/java/com/android/server/camera/CameraService.java
- *
- * These event codes are intended to be used with the notifySystemEvent call.
- */
- enum {
- NO_EVENT = 0,
- USER_SWITCHED,
- };
-
-public:
- DECLARE_META_INTERFACE(CameraService);
-
- // Get the number of cameras that support basic color camera operation
- // (type CAMERA_TYPE_BACKWARD_COMPATIBLE)
- virtual int32_t getNumberOfCameras() = 0;
- // Get the number of cameras of the specified type, one of CAMERA_TYPE_*
- // enums
- virtual int32_t getNumberOfCameras(int cameraType) = 0;
- virtual status_t getCameraInfo(int cameraId,
- /*out*/
- struct CameraInfo* cameraInfo) = 0;
-
- virtual status_t getCameraCharacteristics(int cameraId,
- /*out*/
- CameraMetadata* cameraInfo) = 0;
-
- virtual status_t getCameraVendorTagDescriptor(
- /*out*/
- sp<VendorTagDescriptor>& desc) = 0;
-
- // Returns 'OK' if operation succeeded
- // - Errors: ALREADY_EXISTS if the listener was already added
- virtual status_t addListener(const sp<ICameraServiceListener>& listener)
- = 0;
- // Returns 'OK' if operation succeeded
- // - Errors: BAD_VALUE if specified listener was not in the listener list
- virtual status_t removeListener(const sp<ICameraServiceListener>& listener)
- = 0;
- /**
- * clientPackageName, clientUid, and clientPid are used for permissions checking. If
- * clientUid == USE_CALLING_UID, then the calling UID is used instead. If
- * clientPid == USE_CALLING_PID, then the calling PID is used instead. Only
- * trusted callers can set a clientUid and clientPid other than USE_CALLING_UID and
- * USE_CALLING_UID respectively.
- */
- virtual status_t connect(const sp<ICameraClient>& cameraClient,
- int cameraId,
- const String16& clientPackageName,
- int clientUid,
- int clientPid,
- /*out*/
- sp<ICamera>& device) = 0;
-
- virtual status_t connectDevice(
- const sp<ICameraDeviceCallbacks>& cameraCb,
- int cameraId,
- const String16& clientPackageName,
- int clientUid,
- /*out*/
- sp<ICameraDeviceUser>& device) = 0;
-
- virtual status_t getLegacyParameters(
- int cameraId,
- /*out*/
- String16* parameters) = 0;
-
- /**
- * Returns OK if device supports camera2 api,
- * returns -EOPNOTSUPP if it doesn't.
- */
- virtual status_t supportsCameraApi(
- int cameraId, int apiVersion) = 0;
-
- /**
- * Connect the device as a legacy device for a given HAL version.
- * For halVersion, use CAMERA_API_DEVICE_VERSION_* for a particular
- * version, or CAMERA_HAL_API_VERSION_UNSPECIFIED for a service-selected version.
- */
- virtual status_t connectLegacy(const sp<ICameraClient>& cameraClient,
- int cameraId, int halVersion,
- const String16& clientPackageName,
- int clientUid,
- /*out*/
- sp<ICamera>& device) = 0;
-
- /**
- * Turn on or off a camera's torch mode. Torch mode will be turned off by
- * camera service if the lastest client binder that turns it on dies.
- *
- * return values:
- * 0: on a successful operation.
- * -ENOSYS: the camera device doesn't support this operation. It it returned
- * if and only if android.flash.into.available is false.
- * -EBUSY: the camera device is opened.
- * -EINVAL: camera_id is invalid or clientBinder is NULL when enabling a
- * torch mode.
- */
- virtual status_t setTorchMode(const String16& cameraId, bool enabled,
- const sp<IBinder>& clientBinder) = 0;
-
- /**
- * Notify the camera service of a system event. Should only be called from system_server.
- */
- virtual void notifySystemEvent(int32_t eventId, const int32_t* args, size_t length) = 0;
-};
-
-// ----------------------------------------------------------------------------
-
-class BnCameraService: public BnInterface<ICameraService>
-{
-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/ICameraServiceListener.h b/include/camera/ICameraServiceListener.h
deleted file mode 100644
index 709ff31..0000000
--- a/include/camera/ICameraServiceListener.h
+++ /dev/null
@@ -1,113 +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_ICAMERASERVICE_LISTENER_H
-#define ANDROID_HARDWARE_ICAMERASERVICE_LISTENER_H
-
-#include <utils/RefBase.h>
-#include <binder/IInterface.h>
-#include <binder/Parcel.h>
-#include <hardware/camera_common.h>
-
-namespace android {
-
-class ICameraServiceListener : public IInterface
-{
- /**
- * Keep up-to-date with ICameraServiceListener.aidl in frameworks/base
- */
-public:
-
- /**
- * Initial status will be transmitted with onStatusChange immediately
- * after this listener is added to the service listener list.
- *
- * Allowed transitions:
- *
- * (Any) -> NOT_PRESENT
- * NOT_PRESENT -> PRESENT
- * NOT_PRESENT -> ENUMERATING
- * ENUMERATING -> PRESENT
- * PRESENT -> NOT_AVAILABLE
- * NOT_AVAILABLE -> PRESENT
- *
- * A state will never immediately transition back to itself.
- */
- enum Status {
- // Device physically unplugged
- STATUS_NOT_PRESENT = CAMERA_DEVICE_STATUS_NOT_PRESENT,
- // Device physically has been plugged in
- // and the camera can be used exlusively
- STATUS_PRESENT = CAMERA_DEVICE_STATUS_PRESENT,
- // Device physically has been plugged in
- // but it will not be connect-able until enumeration is complete
- STATUS_ENUMERATING = CAMERA_DEVICE_STATUS_ENUMERATING,
-
- // Camera can be used exclusively
- STATUS_AVAILABLE = STATUS_PRESENT, // deprecated, will be removed
-
- // Camera is in use by another app and cannot be used exclusively
- STATUS_NOT_AVAILABLE = 0x80000000,
-
- // Use to initialize variables only
- STATUS_UNKNOWN = 0xFFFFFFFF,
- };
-
- /**
- * The torch mode status of a camera.
- *
- * Initial status will be transmitted with onTorchStatusChanged immediately
- * after this listener is added to the service listener list.
- *
- * The enums should be set to values matching
- * include/hardware/camera_common.h
- */
- enum TorchStatus {
- // The camera's torch mode has become not available to use via
- // setTorchMode().
- TORCH_STATUS_NOT_AVAILABLE = TORCH_MODE_STATUS_NOT_AVAILABLE,
- // The camera's torch mode is off and available to be turned on via
- // setTorchMode().
- TORCH_STATUS_AVAILABLE_OFF = TORCH_MODE_STATUS_AVAILABLE_OFF,
- // The camera's torch mode is on and available to be turned off via
- // setTorchMode().
- TORCH_STATUS_AVAILABLE_ON = TORCH_MODE_STATUS_AVAILABLE_ON,
-
- // Use to initialize variables only
- TORCH_STATUS_UNKNOWN = 0xFFFFFFFF,
- };
-
- DECLARE_META_INTERFACE(CameraServiceListener);
-
- virtual void onStatusChanged(Status status, int32_t cameraId) = 0;
-
- virtual void onTorchStatusChanged(TorchStatus status, const String16& cameraId) = 0;
-};
-
-// ----------------------------------------------------------------------------
-
-class BnCameraServiceListener : public BnInterface<ICameraServiceListener>
-{
-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/VendorTagDescriptor.h b/include/camera/VendorTagDescriptor.h
index 1758acf..4c1cab6 100644
--- a/include/camera/VendorTagDescriptor.h
+++ b/include/camera/VendorTagDescriptor.h
@@ -16,6 +16,7 @@
#ifndef VENDOR_TAG_DESCRIPTOR_H
+#include <binder/Parcelable.h>
#include <utils/Vector.h>
#include <utils/KeyedVector.h>
#include <utils/String8.h>
@@ -26,18 +27,27 @@
namespace android {
-class Parcel;
+class VendorTagDescriptor;
+
+namespace hardware {
+namespace camera2 {
+namespace params {
/**
* VendorTagDescriptor objects are parcelable containers for the vendor tag
* definitions provided, and are typically used to pass the vendor tag
* information enumerated by the HAL to clients of the camera service.
*/
-class VendorTagDescriptor
- : public LightRefBase<VendorTagDescriptor> {
+class VendorTagDescriptor : public Parcelable {
public:
virtual ~VendorTagDescriptor();
+ VendorTagDescriptor();
+ VendorTagDescriptor(const VendorTagDescriptor& src);
+ VendorTagDescriptor& operator=(const VendorTagDescriptor& rhs);
+
+ void copyFrom(const VendorTagDescriptor& src);
+
/**
* The following 'get*' methods implement the corresponding
* functions defined in
@@ -64,9 +74,9 @@
*
* Returns OK on success, or a negative error code.
*/
- status_t writeToParcel(
+ virtual status_t writeToParcel(
/*out*/
- Parcel* parcel) const;
+ Parcel* parcel) const override;
/**
* Convenience method to get a vector containing all vendor tag
@@ -86,48 +96,14 @@
*/
void dump(int fd, int verbosity, int indentation) const;
- // Static methods:
-
/**
- * Create a VendorTagDescriptor object from the given parcel.
+ * Read values VendorTagDescriptor object from the given parcel.
*
* Returns OK on success, or a negative error code.
*/
- static status_t createFromParcel(const Parcel* parcel,
- /*out*/
- sp<VendorTagDescriptor>& descriptor);
+ virtual status_t readFromParcel(const Parcel* parcel) override;
- /**
- * Create a VendorTagDescriptor object from the given vendor_tag_ops_t
- * struct.
- *
- * Returns OK on success, or a negative error code.
- */
- static status_t createDescriptorFromOps(const vendor_tag_ops_t* vOps,
- /*out*/
- sp<VendorTagDescriptor>& descriptor);
-
- /**
- * Sets the global vendor tag descriptor to use for this process.
- * Camera metadata operations that access vendor tags will use the
- * vendor tag definitions set this way.
- *
- * Returns OK on success, or a negative error code.
- */
- static status_t setAsGlobalVendorTagDescriptor(const sp<VendorTagDescriptor>& desc);
-
- /**
- * Clears the global vendor tag descriptor used by this process.
- */
- static void clearGlobalVendorTagDescriptor();
-
- /**
- * Returns the global vendor tag descriptor used by this process.
- * This will contain NULL if no vendor tags are defined.
- */
- static sp<VendorTagDescriptor> getGlobalVendorTagDescriptor();
protected:
- VendorTagDescriptor();
KeyedVector<String8, KeyedVector<String8, uint32_t>*> mReverseMapping;
KeyedVector<uint32_t, String8> mTagToNameMap;
KeyedVector<uint32_t, uint32_t> mTagToSectionMap; // Value is offset in mSections
@@ -135,11 +111,61 @@
SortedVector<String8> mSections;
// must be int32_t to be compatible with Parcel::writeInt32
int32_t mTagCount;
- private:
+
vendor_tag_ops mVendorOps;
};
+} /* namespace params */
+} /* namespace camera2 */
+} /* namespace hardware */
+
+/**
+ * This version of VendorTagDescriptor must be stored in Android sp<>, and adds support for using it
+ * as a global tag descriptor.
+ *
+ * It's a child class of the basic hardware::camera2::params::VendorTagDescriptor since basic
+ * Parcelable objects cannot require being kept in an sp<> and still work with auto-generated AIDL
+ * interface implementations.
+ */
+class VendorTagDescriptor :
+ public ::android::hardware::camera2::params::VendorTagDescriptor,
+ public LightRefBase<VendorTagDescriptor> {
+
+ public:
+
+ /**
+ * Create a VendorTagDescriptor object from the given vendor_tag_ops_t
+ * struct.
+ *
+ * Returns OK on success, or a negative error code.
+ */
+ static status_t createDescriptorFromOps(const vendor_tag_ops_t* vOps,
+ /*out*/
+ sp<VendorTagDescriptor>& descriptor);
+
+ /**
+ * Sets the global vendor tag descriptor to use for this process.
+ * Camera metadata operations that access vendor tags will use the
+ * vendor tag definitions set this way.
+ *
+ * Returns OK on success, or a negative error code.
+ */
+ static status_t setAsGlobalVendorTagDescriptor(const sp<VendorTagDescriptor>& desc);
+
+ /**
+ * Returns the global vendor tag descriptor used by this process.
+ * This will contain NULL if no vendor tags are defined.
+ */
+ static sp<VendorTagDescriptor> getGlobalVendorTagDescriptor();
+
+ /**
+ * Clears the global vendor tag descriptor used by this process.
+ */
+ static void clearGlobalVendorTagDescriptor();
+
+};
} /* namespace android */
+
#define VENDOR_TAG_DESCRIPTOR_H
#endif /* VENDOR_TAG_DESCRIPTOR_H */
diff --git a/include/camera/ICamera.h b/include/camera/android/hardware/ICamera.h
similarity index 96%
rename from include/camera/ICamera.h
rename to include/camera/android/hardware/ICamera.h
index e35c3a4..322b741 100644
--- a/include/camera/ICamera.h
+++ b/include/camera/android/hardware/ICamera.h
@@ -21,15 +21,18 @@
#include <binder/IInterface.h>
#include <binder/Parcel.h>
#include <binder/IMemory.h>
+#include <binder/Status.h>
#include <utils/String8.h>
-#include <camera/Camera.h>
namespace android {
-class ICameraClient;
class IGraphicBufferProducer;
class Surface;
+namespace hardware {
+
+class ICameraClient;
+
class ICamera: public IInterface
{
/**
@@ -47,7 +50,7 @@
DECLARE_META_INTERFACE(Camera);
- virtual void disconnect() = 0;
+ virtual binder::Status disconnect() = 0;
// connect new client with existing camera remote
virtual status_t connect(const sp<ICameraClient>& client) = 0;
@@ -141,6 +144,7 @@
uint32_t flags = 0);
};
-}; // namespace android
+} // namespace hardware
+} // namespace android
#endif
diff --git a/include/camera/ICameraClient.h b/include/camera/android/hardware/ICameraClient.h
similarity index 93%
rename from include/camera/ICameraClient.h
rename to include/camera/android/hardware/ICameraClient.h
index 1584dba..d7f9a75 100644
--- a/include/camera/ICameraClient.h
+++ b/include/camera/android/hardware/ICameraClient.h
@@ -25,12 +25,10 @@
#include <system/camera.h>
namespace android {
+namespace hardware {
class ICameraClient: public IInterface
{
- /**
- * Keep up-to-date with ICameraClient.aidl in frameworks/base
- */
public:
DECLARE_META_INTERFACE(CameraClient);
@@ -51,6 +49,7 @@
uint32_t flags = 0);
};
-}; // namespace android
+} // namespace hardware
+} // namespace android
#endif
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