| Igor Murashkin | 985fd30 | 2013-02-20 18:24:43 -0800 | [diff] [blame] | 1 | /* | 
 | 2 |  * Copyright (C) 2013 The Android Open Source Project | 
 | 3 |  * | 
 | 4 |  * Licensed under the Apache License, Version 2.0 (the "License"); | 
 | 5 |  * you may not use this file except in compliance with the License. | 
 | 6 |  * You may obtain a copy of the License at | 
 | 7 |  * | 
 | 8 |  *      http://www.apache.org/licenses/LICENSE-2.0 | 
 | 9 |  * | 
 | 10 |  * Unless required by applicable law or agreed to in writing, software | 
 | 11 |  * distributed under the License is distributed on an "AS IS" BASIS, | 
 | 12 |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
 | 13 |  * See the License for the specific language governing permissions and | 
 | 14 |  * limitations under the License. | 
 | 15 |  */ | 
 | 16 |  | 
 | 17 | #ifndef ANDROID_SERVERS_CAMERA_PROCAMERA2CLIENT_H | 
 | 18 | #define ANDROID_SERVERS_CAMERA_PROCAMERA2CLIENT_H | 
 | 19 |  | 
 | 20 | #include "Camera2Device.h" | 
 | 21 | #include "CameraService.h" | 
| Igor Murashkin | a91537e | 2013-02-21 12:02:29 -0800 | [diff] [blame] | 22 | #include "camera2/ProFrameProcessor.h" | 
| Igor Murashkin | 44cfcf0 | 2013-03-01 16:22:28 -0800 | [diff] [blame^] | 23 | #include "Camera2ClientBase.h" | 
| Igor Murashkin | 985fd30 | 2013-02-20 18:24:43 -0800 | [diff] [blame] | 24 |  | 
 | 25 | namespace android { | 
 | 26 |  | 
 | 27 | class IMemory; | 
 | 28 | /** | 
 | 29 |  * Implements the binder IProCameraUser API, | 
 | 30 |  * meant for HAL2-level private API access. | 
 | 31 |  */ | 
 | 32 | class ProCamera2Client : | 
| Igor Murashkin | 44cfcf0 | 2013-03-01 16:22:28 -0800 | [diff] [blame^] | 33 |         public Camera2ClientBase<CameraService::ProClient>, | 
| Igor Murashkin | a91537e | 2013-02-21 12:02:29 -0800 | [diff] [blame] | 34 |         public camera2::ProFrameProcessor::FilteredListener | 
| Igor Murashkin | 985fd30 | 2013-02-20 18:24:43 -0800 | [diff] [blame] | 35 | { | 
 | 36 | public: | 
 | 37 |     /** | 
 | 38 |      * IProCameraUser interface (see IProCameraUser for details) | 
 | 39 |      */ | 
| Igor Murashkin | 985fd30 | 2013-02-20 18:24:43 -0800 | [diff] [blame] | 40 |     virtual status_t      exclusiveTryLock(); | 
 | 41 |     virtual status_t      exclusiveLock(); | 
 | 42 |     virtual status_t      exclusiveUnlock(); | 
 | 43 |  | 
 | 44 |     virtual bool          hasExclusiveLock(); | 
 | 45 |  | 
 | 46 |     // Note that the callee gets a copy of the metadata. | 
 | 47 |     virtual int           submitRequest(camera_metadata_t* metadata, | 
 | 48 |                                         bool streaming = false); | 
 | 49 |     virtual status_t      cancelRequest(int requestId); | 
 | 50 |  | 
 | 51 |     virtual status_t      requestStream(int streamId); | 
 | 52 |     virtual status_t      cancelStream(int streamId); | 
 | 53 |  | 
| Igor Murashkin | 44cfcf0 | 2013-03-01 16:22:28 -0800 | [diff] [blame^] | 54 |     virtual status_t      createStream( | 
 | 55 |             int width, | 
 | 56 |             int height, | 
 | 57 |             int format, | 
 | 58 |             const sp<IGraphicBufferProducer>& bufferProducer, | 
 | 59 |             /*out*/ | 
 | 60 |             int* streamId); | 
| Igor Murashkin | 985fd30 | 2013-02-20 18:24:43 -0800 | [diff] [blame] | 61 |  | 
 | 62 |     // Create a request object from a template. | 
| Igor Murashkin | 3261fd3 | 2013-02-20 19:02:36 -0800 | [diff] [blame] | 63 |     // -- Caller owns the newly allocated metadata | 
| Igor Murashkin | 985fd30 | 2013-02-20 18:24:43 -0800 | [diff] [blame] | 64 |     virtual status_t      createDefaultRequest(int templateId, | 
 | 65 |                                                /*out*/ | 
 | 66 |                                                camera_metadata** request); | 
 | 67 |  | 
| Igor Murashkin | 7b33a74 | 2013-02-21 13:49:26 -0800 | [diff] [blame] | 68 |     // Get the static metadata for the camera | 
 | 69 |     // -- Caller owns the newly allocated metadata | 
 | 70 |     virtual status_t      getCameraInfo(int cameraId, | 
 | 71 |                                         /*out*/ | 
 | 72 |                                         camera_metadata** info); | 
| Igor Murashkin | 985fd30 | 2013-02-20 18:24:43 -0800 | [diff] [blame] | 73 |  | 
 | 74 |     /** | 
 | 75 |      * Interface used by CameraService | 
 | 76 |      */ | 
 | 77 |  | 
 | 78 |     ProCamera2Client(const sp<CameraService>& cameraService, | 
 | 79 |             const sp<IProCameraCallbacks>& remoteCallback, | 
| Eino-Ville Talvala | ceb388d | 2013-02-19 10:40:14 -0800 | [diff] [blame] | 80 |             const String16& clientPackageName, | 
| Igor Murashkin | 985fd30 | 2013-02-20 18:24:43 -0800 | [diff] [blame] | 81 |             int cameraId, | 
 | 82 |             int cameraFacing, | 
 | 83 |             int clientPid, | 
| Eino-Ville Talvala | ceb388d | 2013-02-19 10:40:14 -0800 | [diff] [blame] | 84 |             uid_t clientUid, | 
| Igor Murashkin | 985fd30 | 2013-02-20 18:24:43 -0800 | [diff] [blame] | 85 |             int servicePid); | 
 | 86 |     virtual ~ProCamera2Client(); | 
 | 87 |  | 
| Igor Murashkin | 44cfcf0 | 2013-03-01 16:22:28 -0800 | [diff] [blame^] | 88 |     virtual status_t      initialize(camera_module_t *module); | 
| Igor Murashkin | 985fd30 | 2013-02-20 18:24:43 -0800 | [diff] [blame] | 89 |  | 
| Igor Murashkin | 44cfcf0 | 2013-03-01 16:22:28 -0800 | [diff] [blame^] | 90 |     virtual status_t      dump(int fd, const Vector<String16>& args); | 
| Igor Murashkin | 985fd30 | 2013-02-20 18:24:43 -0800 | [diff] [blame] | 91 |  | 
| Igor Murashkin | bfc9915 | 2013-02-27 12:55:20 -0800 | [diff] [blame] | 92 |     // Callbacks from camera service | 
 | 93 |     virtual void onExclusiveLockStolen(); | 
 | 94 |  | 
| Igor Murashkin | 985fd30 | 2013-02-20 18:24:43 -0800 | [diff] [blame] | 95 |     /** | 
 | 96 |      * Interface used by independent components of ProCamera2Client. | 
 | 97 |      */ | 
 | 98 |  | 
| Igor Murashkin | a91537e | 2013-02-21 12:02:29 -0800 | [diff] [blame] | 99 | protected: | 
 | 100 |     /** FilteredListener implementation **/ | 
| Igor Murashkin | 44cfcf0 | 2013-03-01 16:22:28 -0800 | [diff] [blame^] | 101 |     virtual void          onFrameAvailable(int32_t frameId, | 
 | 102 |                                            const CameraMetadata& frame); | 
 | 103 |     virtual void          detachDevice(); | 
| Igor Murashkin | a91537e | 2013-02-21 12:02:29 -0800 | [diff] [blame] | 104 |  | 
| Igor Murashkin | 985fd30 | 2013-02-20 18:24:43 -0800 | [diff] [blame] | 105 | private: | 
 | 106 |     /** IProCameraUser interface-related private members */ | 
 | 107 |  | 
| Igor Murashkin | 985fd30 | 2013-02-20 18:24:43 -0800 | [diff] [blame] | 108 |     /** Preview callback related members */ | 
| Igor Murashkin | a91537e | 2013-02-21 12:02:29 -0800 | [diff] [blame] | 109 |     sp<camera2::ProFrameProcessor> mFrameProcessor; | 
 | 110 |     static const int32_t FRAME_PROCESSOR_LISTENER_MIN_ID = 0; | 
 | 111 |     static const int32_t FRAME_PROCESSOR_LISTENER_MAX_ID = 0x7fffffffL; | 
 | 112 |  | 
| Igor Murashkin | 985fd30 | 2013-02-20 18:24:43 -0800 | [diff] [blame] | 113 |     /** Utility members */ | 
 | 114 |  | 
| Igor Murashkin | 985fd30 | 2013-02-20 18:24:43 -0800 | [diff] [blame] | 115 |     // Whether or not we have an exclusive lock on the device | 
 | 116 |     // - if no we can't modify the request queue. | 
 | 117 |     // note that creating/deleting streams we own is still OK | 
 | 118 |     bool mExclusiveLock; | 
| Igor Murashkin | 985fd30 | 2013-02-20 18:24:43 -0800 | [diff] [blame] | 119 | }; | 
 | 120 |  | 
 | 121 | }; // namespace android | 
 | 122 |  | 
 | 123 | #endif |