From 7b82efe7a376c882f8f938e1c41b8311a8cdda4a Mon Sep 17 00:00:00 2001 From: Eino-Ville Talvala Date: Thu, 25 Jul 2013 17:12:35 -0700 Subject: Camera: Rename new API to camera2, rearrange camera service - Support API rename from photography to camera2 - Reorganize camera service files - API support files to api1/, api2/, api_pro/ - HAL device support files into device{1,2,3}/ - Common files into common/ - Camera service remains at top-level Change-Id: Ie474c12536f543832fba0a2dc936ac4fd39fe6a9 --- .../libcameraservice/api2/CameraDeviceClient.h | 141 +++++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 services/camera/libcameraservice/api2/CameraDeviceClient.h (limited to 'services/camera/libcameraservice/api2/CameraDeviceClient.h') diff --git a/services/camera/libcameraservice/api2/CameraDeviceClient.h b/services/camera/libcameraservice/api2/CameraDeviceClient.h new file mode 100644 index 0000000..21d633c --- /dev/null +++ b/services/camera/libcameraservice/api2/CameraDeviceClient.h @@ -0,0 +1,141 @@ +/* + * 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_SERVERS_CAMERA_PHOTOGRAPHY_CAMERADEVICECLIENT_H +#define ANDROID_SERVERS_CAMERA_PHOTOGRAPHY_CAMERADEVICECLIENT_H + +#include +#include + +#include "CameraService.h" +#include "common/FrameProcessorBase.h" +#include "common/Camera2ClientBase.h" + +namespace android { + +struct CameraDeviceClientBase : + public CameraService::BasicClient, public BnCameraDeviceUser +{ + typedef ICameraDeviceCallbacks TCamCallbacks; + + const sp& getRemoteCallback() { + return mRemoteCallback; + } + +protected: + CameraDeviceClientBase(const sp& cameraService, + const sp& remoteCallback, + const String16& clientPackageName, + int cameraId, + int cameraFacing, + int clientPid, + uid_t clientUid, + int servicePid); + + virtual void notifyError(); + + sp mRemoteCallback; +}; + +/** + * Implements the binder ICameraDeviceUser API, + * meant for HAL3-public implementation of + * android.hardware.photography.CameraDevice + */ +class CameraDeviceClient : + public Camera2ClientBase, + public camera2::FrameProcessorBase::FilteredListener +{ +public: + /** + * ICameraDeviceUser interface (see ICameraDeviceUser for details) + */ + + // Note that the callee gets a copy of the metadata. + virtual int submitRequest(sp request, + bool streaming = false); + virtual status_t cancelRequest(int requestId); + + // Returns -EBUSY if device is not idle + virtual status_t deleteStream(int streamId); + + virtual status_t createStream( + int width, + int height, + int format, + const sp& bufferProducer); + + // Create a request object from a template. + virtual status_t createDefaultRequest(int templateId, + /*out*/ + CameraMetadata* request); + + // Get the static metadata for the camera + // -- Caller owns the newly allocated metadata + virtual status_t getCameraInfo(/*out*/CameraMetadata* info); + + // Wait until all the submitted requests have finished processing + virtual status_t waitUntilIdle(); + /** + * Interface used by CameraService + */ + + CameraDeviceClient(const sp& cameraService, + const sp& remoteCallback, + const String16& clientPackageName, + int cameraId, + int cameraFacing, + int clientPid, + uid_t clientUid, + int servicePid); + virtual ~CameraDeviceClient(); + + virtual status_t initialize(camera_module_t *module); + + virtual status_t dump(int fd, const Vector& args); + + /** + * Interface used by independent components of CameraDeviceClient. + */ +protected: + /** FilteredListener implementation **/ + virtual void onFrameAvailable(int32_t frameId, + const CameraMetadata& frame); + virtual void detachDevice(); + +private: + /** ICameraDeviceUser interface-related private members */ + + /** Preview callback related members */ + sp mFrameProcessor; + static const int32_t FRAME_PROCESSOR_LISTENER_MIN_ID = 0; + static const int32_t FRAME_PROCESSOR_LISTENER_MAX_ID = 0x7fffffffL; + + /** Utility members */ + bool enforceRequestPermissions(CameraMetadata& metadata); + + // IGraphicsBufferProducer binder -> Stream ID + KeyedVector, int> mStreamMap; + + // Stream ID + Vector mStreamingRequestList; + + int32_t mRequestIdCounter; +}; + +}; // namespace android + +#endif -- cgit v1.1 From abaa51d3ca31f0eda99e1d271e6dc64c877dbf58 Mon Sep 17 00:00:00 2001 From: Eino-Ville Talvala Date: Wed, 14 Aug 2013 11:37:00 -0700 Subject: Camera2: Add flush support - On HAL2 devices, fall back to wait until idle - On HAL3 devices, call HAL flush method Bug: 9758581 Change-Id: Ie1c570a15f6590a1ee6c271e3b989c48079b468a --- services/camera/libcameraservice/api2/CameraDeviceClient.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'services/camera/libcameraservice/api2/CameraDeviceClient.h') diff --git a/services/camera/libcameraservice/api2/CameraDeviceClient.h b/services/camera/libcameraservice/api2/CameraDeviceClient.h index 21d633c..c6b6336 100644 --- a/services/camera/libcameraservice/api2/CameraDeviceClient.h +++ b/services/camera/libcameraservice/api2/CameraDeviceClient.h @@ -89,6 +89,10 @@ public: // Wait until all the submitted requests have finished processing virtual status_t waitUntilIdle(); + + // Flush all active and pending requests as fast as possible + virtual status_t flush(); + /** * Interface used by CameraService */ -- cgit v1.1 From f8b2a6f7dea06234c7966798d9363d2d236488a6 Mon Sep 17 00:00:00 2001 From: Igor Murashkin Date: Tue, 17 Sep 2013 17:03:28 -0700 Subject: camera2: Tell all streams to ignore global device UI rotation - Also use android.sensor.orientation to set the right transform flags automatically. Bug: 10804238 Change-Id: I10caf8331f19e107c461696963cc10f597c91d83 --- services/camera/libcameraservice/api2/CameraDeviceClient.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'services/camera/libcameraservice/api2/CameraDeviceClient.h') diff --git a/services/camera/libcameraservice/api2/CameraDeviceClient.h b/services/camera/libcameraservice/api2/CameraDeviceClient.h index c6b6336..b490924 100644 --- a/services/camera/libcameraservice/api2/CameraDeviceClient.h +++ b/services/camera/libcameraservice/api2/CameraDeviceClient.h @@ -120,6 +120,9 @@ protected: const CameraMetadata& frame); virtual void detachDevice(); + // Calculate the ANativeWindow transform from android.sensor.orientation + status_t getRotationTransformLocked(/*out*/int32_t* transform); + private: /** ICameraDeviceUser interface-related private members */ -- cgit v1.1 From f1e98d857ec377f2c9b916073d40732e6ebb7ced Mon Sep 17 00:00:00 2001 From: Eino-Ville Talvala Date: Fri, 6 Sep 2013 09:32:43 -0700 Subject: Camera API 2, Device 2/3: Implement idle and shutter callbacks - Update callback Binder interface - Rename frameId to be requestId to be consistent and disambiguate from frameNumber. - Implement shutter callback from HAL2/3 notify() - Add in-flight tracking to HAL2 - Add requestId to in-flight tracking - Report requestId from shutter callback - Implement idle callback from HAL3 process_capture_result - Add new idle tracker thread - Update all idle waiting to use the tracker - Add reporting from request thread, all streams to tracker - Remove existing idle waiting infrastructure Bug: 10549462 Change-Id: I867bfc248e3848c50e71527e3561fe92dc037958 --- services/camera/libcameraservice/api2/CameraDeviceClient.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'services/camera/libcameraservice/api2/CameraDeviceClient.h') diff --git a/services/camera/libcameraservice/api2/CameraDeviceClient.h b/services/camera/libcameraservice/api2/CameraDeviceClient.h index b490924..b9c16aa 100644 --- a/services/camera/libcameraservice/api2/CameraDeviceClient.h +++ b/services/camera/libcameraservice/api2/CameraDeviceClient.h @@ -45,8 +45,6 @@ protected: uid_t clientUid, int servicePid); - virtual void notifyError(); - sp mRemoteCallback; }; @@ -112,11 +110,19 @@ public: virtual status_t dump(int fd, const Vector& args); /** + * Device listener interface + */ + + virtual void notifyIdle(); + virtual void notifyError(); + virtual void notifyShutter(int requestId, nsecs_t timestamp); + + /** * Interface used by independent components of CameraDeviceClient. */ protected: /** FilteredListener implementation **/ - virtual void onFrameAvailable(int32_t frameId, + virtual void onFrameAvailable(int32_t requestId, const CameraMetadata& frame); virtual void detachDevice(); -- cgit v1.1