blob: ee39d52b2afe026a12230104612a546e60ad8625 [file] [log] [blame]
Mathias Agopian65ab4712010-07-14 17:59:35 -07001/*
Ruben Brunkd1176ef2014-02-21 10:51:38 -08002 * Copyright (C) 2008 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 */
Mathias Agopian65ab4712010-07-14 17:59:35 -070016
17#ifndef ANDROID_SERVERS_CAMERA_CAMERASERVICE_H
18#define ANDROID_SERVERS_CAMERA_CAMERASERVICE_H
19
Igor Murashkin634a5152013-02-20 17:15:11 -080020#include <utils/Vector.h>
Ruben Brunkb2119af2014-05-09 19:57:56 -070021#include <utils/KeyedVector.h>
Eino-Ville Talvalaceb388d2013-02-19 10:40:14 -080022#include <binder/AppOpsManager.h>
Mathias Agopian5462fc92010-07-14 18:41:18 -070023#include <binder/BinderService.h>
Eino-Ville Talvalaceb388d2013-02-19 10:40:14 -080024#include <binder/IAppOpsCallback.h>
Mathias Agopian65ab4712010-07-14 17:59:35 -070025#include <camera/ICameraService.h>
Iliyan Malchev8951a972011-04-14 16:55:59 -070026#include <hardware/camera.h>
Mathias Agopian65ab4712010-07-14 17:59:35 -070027
Igor Murashkinc073ba52013-02-26 14:32:34 -080028#include <camera/ICamera.h>
29#include <camera/ICameraClient.h>
30#include <camera/IProCameraUser.h>
31#include <camera/IProCameraCallbacks.h>
Eino-Ville Talvala7b82efe2013-07-25 17:12:35 -070032#include <camera/camera2/ICameraDeviceUser.h>
33#include <camera/camera2/ICameraDeviceCallbacks.h>
Ruben Brunkd1176ef2014-02-21 10:51:38 -080034#include <camera/VendorTagDescriptor.h>
Jianing Weicb0652e2014-03-12 18:29:36 -070035#include <camera/CaptureResult.h>
Ruben Brunkb2119af2014-05-09 19:57:56 -070036#include <camera/CameraParameters.h>
Igor Murashkinc073ba52013-02-26 14:32:34 -080037
Igor Murashkinbfc99152013-02-27 12:55:20 -080038#include <camera/ICameraServiceListener.h>
39
Mathias Agopian65ab4712010-07-14 17:59:35 -070040/* This needs to be increased if we can have more cameras */
41#define MAX_CAMERAS 2
42
43namespace android {
44
Eino-Ville Talvala5e08d602012-05-16 14:59:25 -070045extern volatile int32_t gLogLevel;
46
Mathias Agopian65ab4712010-07-14 17:59:35 -070047class MemoryHeapBase;
48class MediaPlayer;
49
Mathias Agopian5462fc92010-07-14 18:41:18 -070050class CameraService :
51 public BinderService<CameraService>,
Igor Murashkinecf17e82012-10-02 16:05:11 -070052 public BnCameraService,
Igor Murashkincba2c162013-03-20 15:56:31 -070053 public IBinder::DeathRecipient,
54 public camera_module_callbacks_t
Mathias Agopian65ab4712010-07-14 17:59:35 -070055{
Mathias Agopian5462fc92010-07-14 18:41:18 -070056 friend class BinderService<CameraService>;
Mathias Agopian65ab4712010-07-14 17:59:35 -070057public:
Eino-Ville Talvala5e08d602012-05-16 14:59:25 -070058 class Client;
Igor Murashkin634a5152013-02-20 17:15:11 -080059 class BasicClient;
60
61 // Implementation of BinderService<T>
Mathias Agopian5462fc92010-07-14 18:41:18 -070062 static char const* getServiceName() { return "media.camera"; }
Mathias Agopian65ab4712010-07-14 17:59:35 -070063
64 CameraService();
65 virtual ~CameraService();
66
Igor Murashkin634a5152013-02-20 17:15:11 -080067 /////////////////////////////////////////////////////////////////////
Igor Murashkincba2c162013-03-20 15:56:31 -070068 // HAL Callbacks
69 virtual void onDeviceStatusChanged(int cameraId,
70 int newStatus);
71
72 /////////////////////////////////////////////////////////////////////
Igor Murashkin634a5152013-02-20 17:15:11 -080073 // ICameraService
Mathias Agopian65ab4712010-07-14 17:59:35 -070074 virtual int32_t getNumberOfCameras();
75 virtual status_t getCameraInfo(int cameraId,
76 struct CameraInfo* cameraInfo);
Zhijun He2b59be82013-09-25 10:14:30 -070077 virtual status_t getCameraCharacteristics(int cameraId,
78 CameraMetadata* cameraInfo);
Ruben Brunkd1176ef2014-02-21 10:51:38 -080079 virtual status_t getCameraVendorTagDescriptor(/*out*/ sp<VendorTagDescriptor>& desc);
Eino-Ville Talvalaceb388d2013-02-19 10:40:14 -080080
Ruben Brunk0f61d8f2013-08-08 13:07:18 -070081 virtual status_t connect(const sp<ICameraClient>& cameraClient, int cameraId,
82 const String16& clientPackageName, int clientUid,
83 /*out*/
84 sp<ICamera>& device);
85
86 virtual status_t connectPro(const sp<IProCameraCallbacks>& cameraCb,
87 int cameraId, const String16& clientPackageName, int clientUid,
88 /*out*/
89 sp<IProCameraUser>& device);
90
91 virtual status_t connectDevice(
Igor Murashkine7ee7632013-06-11 18:10:18 -070092 const sp<ICameraDeviceCallbacks>& cameraCb,
93 int cameraId,
94 const String16& clientPackageName,
Ruben Brunk0f61d8f2013-08-08 13:07:18 -070095 int clientUid,
96 /*out*/
97 sp<ICameraDeviceUser>& device);
Mathias Agopian65ab4712010-07-14 17:59:35 -070098
Igor Murashkinbfc99152013-02-27 12:55:20 -080099 virtual status_t addListener(const sp<ICameraServiceListener>& listener);
100 virtual status_t removeListener(
101 const sp<ICameraServiceListener>& listener);
102
Igor Murashkin634a5152013-02-20 17:15:11 -0800103 // Extra permissions checks
Mathias Agopian65ab4712010-07-14 17:59:35 -0700104 virtual status_t onTransact(uint32_t code, const Parcel& data,
105 Parcel* reply, uint32_t flags);
Igor Murashkin634a5152013-02-20 17:15:11 -0800106
107 virtual status_t dump(int fd, const Vector<String16>& args);
108
109 /////////////////////////////////////////////////////////////////////
110 // Client functionality
111 virtual void removeClientByRemote(const wp<IBinder>& remoteBinder);
Mathias Agopian65ab4712010-07-14 17:59:35 -0700112
113 enum sound_kind {
114 SOUND_SHUTTER = 0,
115 SOUND_RECORDING = 1,
116 NUM_SOUNDS
117 };
118
119 void loadSound();
120 void playSound(sound_kind kind);
121 void releaseSound();
122
Igor Murashkin98e24722013-06-19 19:51:04 -0700123 /////////////////////////////////////////////////////////////////////
124 // CameraDeviceFactory functionality
125 int getDeviceVersion(int cameraId, int* facing = NULL);
126
Igor Murashkin634a5152013-02-20 17:15:11 -0800127
128 /////////////////////////////////////////////////////////////////////
129 // CameraClient functionality
130
131 // returns plain pointer of client. Note that mClientLock should be acquired to
132 // prevent the client from destruction. The result can be NULL.
Igor Murashkine7ee7632013-06-11 18:10:18 -0700133 virtual BasicClient* getClientByIdUnsafe(int cameraId);
Igor Murashkin634a5152013-02-20 17:15:11 -0800134 virtual Mutex* getClientLockById(int cameraId);
135
136 class BasicClient : public virtual RefBase {
137 public:
138 virtual status_t initialize(camera_module_t *module) = 0;
139
140 virtual void disconnect() = 0;
141
Igor Murashkine7ee7632013-06-11 18:10:18 -0700142 // because we can't virtually inherit IInterface, which breaks
143 // virtual inheritance
144 virtual sp<IBinder> asBinderWrapper() = 0;
145
Igor Murashkine6800ce2013-03-04 17:25:57 -0800146 // Return the remote callback binder object (e.g. IProCameraCallbacks)
Igor Murashkine7ee7632013-06-11 18:10:18 -0700147 sp<IBinder> getRemote() {
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800148 return mRemoteBinder;
Igor Murashkin634a5152013-02-20 17:15:11 -0800149 }
150
Igor Murashkine7ee7632013-06-11 18:10:18 -0700151 virtual status_t dump(int fd, const Vector<String16>& args) = 0;
152
Igor Murashkin634a5152013-02-20 17:15:11 -0800153 protected:
154 BasicClient(const sp<CameraService>& cameraService,
155 const sp<IBinder>& remoteCallback,
Eino-Ville Talvalaceb388d2013-02-19 10:40:14 -0800156 const String16& clientPackageName,
Igor Murashkin634a5152013-02-20 17:15:11 -0800157 int cameraId,
158 int cameraFacing,
159 int clientPid,
Eino-Ville Talvalaceb388d2013-02-19 10:40:14 -0800160 uid_t clientUid,
Igor Murashkin634a5152013-02-20 17:15:11 -0800161 int servicePid);
162
163 virtual ~BasicClient();
164
165 // the instance is in the middle of destruction. When this is set,
166 // the instance should not be accessed from callback.
167 // CameraService's mClientLock should be acquired to access this.
168 // - subclasses should set this to true in their destructors.
169 bool mDestructionStarted;
170
171 // these are initialized in the constructor.
172 sp<CameraService> mCameraService; // immutable after constructor
173 int mCameraId; // immutable after constructor
174 int mCameraFacing; // immutable after constructor
Eino-Ville Talvalaceb388d2013-02-19 10:40:14 -0800175 const String16 mClientPackageName;
Igor Murashkin634a5152013-02-20 17:15:11 -0800176 pid_t mClientPid;
Eino-Ville Talvalaceb388d2013-02-19 10:40:14 -0800177 uid_t mClientUid; // immutable after constructor
Igor Murashkin634a5152013-02-20 17:15:11 -0800178 pid_t mServicePid; // immutable after constructor
179
180 // - The app-side Binder interface to receive callbacks from us
Igor Murashkine7ee7632013-06-11 18:10:18 -0700181 sp<IBinder> mRemoteBinder; // immutable after constructor
Eino-Ville Talvalaceb388d2013-02-19 10:40:14 -0800182
183 // permissions management
184 status_t startCameraOps();
185 status_t finishCameraOps();
186
187 // Notify client about a fatal error
Jianing Weicb0652e2014-03-12 18:29:36 -0700188 virtual void notifyError(
189 ICameraDeviceCallbacks::CameraErrorCode errorCode,
190 const CaptureResultExtras& resultExtras) = 0;
Eino-Ville Talvalaceb388d2013-02-19 10:40:14 -0800191 private:
192 AppOpsManager mAppOpsManager;
193
194 class OpsCallback : public BnAppOpsCallback {
195 public:
196 OpsCallback(wp<BasicClient> client);
197 virtual void opChanged(int32_t op, const String16& packageName);
198
199 private:
200 wp<BasicClient> mClient;
201
202 }; // class OpsCallback
203
204 sp<OpsCallback> mOpsCallback;
205 // Track whether startCameraOps was called successfully, to avoid
206 // finishing what we didn't start.
207 bool mOpsActive;
208
209 // IAppOpsCallback interface, indirected through opListener
210 virtual void opChanged(int32_t op, const String16& packageName);
211 }; // class BasicClient
Igor Murashkin634a5152013-02-20 17:15:11 -0800212
213 class Client : public BnCamera, public BasicClient
Eino-Ville Talvala5e08d602012-05-16 14:59:25 -0700214 {
215 public:
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800216 typedef ICameraClient TCamCallbacks;
217
Eino-Ville Talvala5e08d602012-05-16 14:59:25 -0700218 // ICamera interface (see ICamera for details)
219 virtual void disconnect();
220 virtual status_t connect(const sp<ICameraClient>& client) = 0;
221 virtual status_t lock() = 0;
222 virtual status_t unlock() = 0;
Eino-Ville Talvala1ce7c342013-08-21 13:57:21 -0700223 virtual status_t setPreviewTarget(const sp<IGraphicBufferProducer>& bufferProducer)=0;
Eino-Ville Talvala5e08d602012-05-16 14:59:25 -0700224 virtual void setPreviewCallbackFlag(int flag) = 0;
Eino-Ville Talvala3ee35502013-04-02 15:45:11 -0700225 virtual status_t setPreviewCallbackTarget(
226 const sp<IGraphicBufferProducer>& callbackProducer) = 0;
Eino-Ville Talvala5e08d602012-05-16 14:59:25 -0700227 virtual status_t startPreview() = 0;
228 virtual void stopPreview() = 0;
229 virtual bool previewEnabled() = 0;
230 virtual status_t storeMetaDataInBuffers(bool enabled) = 0;
231 virtual status_t startRecording() = 0;
232 virtual void stopRecording() = 0;
233 virtual bool recordingEnabled() = 0;
234 virtual void releaseRecordingFrame(const sp<IMemory>& mem) = 0;
235 virtual status_t autoFocus() = 0;
236 virtual status_t cancelAutoFocus() = 0;
237 virtual status_t takePicture(int msgType) = 0;
238 virtual status_t setParameters(const String8& params) = 0;
239 virtual String8 getParameters() const = 0;
240 virtual status_t sendCommand(int32_t cmd, int32_t arg1, int32_t arg2) = 0;
241
242 // Interface used by CameraService
243 Client(const sp<CameraService>& cameraService,
244 const sp<ICameraClient>& cameraClient,
Eino-Ville Talvalaceb388d2013-02-19 10:40:14 -0800245 const String16& clientPackageName,
Eino-Ville Talvala5e08d602012-05-16 14:59:25 -0700246 int cameraId,
247 int cameraFacing,
Igor Murashkinecf17e82012-10-02 16:05:11 -0700248 int clientPid,
Eino-Ville Talvalaceb388d2013-02-19 10:40:14 -0800249 uid_t clientUid,
Igor Murashkinecf17e82012-10-02 16:05:11 -0700250 int servicePid);
Eino-Ville Talvala5e08d602012-05-16 14:59:25 -0700251 ~Client();
252
253 // return our camera client
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800254 const sp<ICameraClient>& getRemoteCallback() {
255 return mRemoteCallback;
Eino-Ville Talvala5e08d602012-05-16 14:59:25 -0700256 }
257
Igor Murashkine7ee7632013-06-11 18:10:18 -0700258 virtual sp<IBinder> asBinderWrapper() {
259 return asBinder();
260 }
261
Eino-Ville Talvala5e08d602012-05-16 14:59:25 -0700262 protected:
263 static Mutex* getClientLockFromCookie(void* user);
264 // convert client from cookie. Client lock should be acquired before getting Client.
265 static Client* getClientFromCookie(void* user);
266
Jianing Weicb0652e2014-03-12 18:29:36 -0700267 virtual void notifyError(ICameraDeviceCallbacks::CameraErrorCode errorCode,
268 const CaptureResultExtras& resultExtras);
Eino-Ville Talvalaceb388d2013-02-19 10:40:14 -0800269
Igor Murashkin634a5152013-02-20 17:15:11 -0800270 // Initialized in constructor
Eino-Ville Talvala5e08d602012-05-16 14:59:25 -0700271
Igor Murashkin634a5152013-02-20 17:15:11 -0800272 // - The app-side Binder interface to receive callbacks from us
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800273 sp<ICameraClient> mRemoteCallback;
Eino-Ville Talvalaceb388d2013-02-19 10:40:14 -0800274
275 }; // class Client
Igor Murashkin634a5152013-02-20 17:15:11 -0800276
277 class ProClient : public BnProCameraUser, public BasicClient {
278 public:
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800279 typedef IProCameraCallbacks TCamCallbacks;
280
Igor Murashkin634a5152013-02-20 17:15:11 -0800281 ProClient(const sp<CameraService>& cameraService,
282 const sp<IProCameraCallbacks>& remoteCallback,
Eino-Ville Talvalaceb388d2013-02-19 10:40:14 -0800283 const String16& clientPackageName,
Igor Murashkin634a5152013-02-20 17:15:11 -0800284 int cameraId,
285 int cameraFacing,
286 int clientPid,
Eino-Ville Talvalaceb388d2013-02-19 10:40:14 -0800287 uid_t clientUid,
Igor Murashkin634a5152013-02-20 17:15:11 -0800288 int servicePid);
289
290 virtual ~ProClient();
291
292 const sp<IProCameraCallbacks>& getRemoteCallback() {
293 return mRemoteCallback;
294 }
295
Igor Murashkin634a5152013-02-20 17:15:11 -0800296 /***
297 IProCamera implementation
298 ***/
Igor Murashkine6800ce2013-03-04 17:25:57 -0800299 virtual status_t connect(const sp<IProCameraCallbacks>& callbacks)
300 = 0;
301 virtual status_t exclusiveTryLock() = 0;
302 virtual status_t exclusiveLock() = 0;
303 virtual status_t exclusiveUnlock() = 0;
Igor Murashkin634a5152013-02-20 17:15:11 -0800304
Igor Murashkine6800ce2013-03-04 17:25:57 -0800305 virtual bool hasExclusiveLock() = 0;
Igor Murashkin634a5152013-02-20 17:15:11 -0800306
307 // Note that the callee gets a copy of the metadata.
308 virtual int submitRequest(camera_metadata_t* metadata,
Igor Murashkine6800ce2013-03-04 17:25:57 -0800309 bool streaming = false) = 0;
310 virtual status_t cancelRequest(int requestId) = 0;
Igor Murashkin634a5152013-02-20 17:15:11 -0800311
Igor Murashkinbfc99152013-02-27 12:55:20 -0800312 // Callbacks from camera service
Igor Murashkine6800ce2013-03-04 17:25:57 -0800313 virtual void onExclusiveLockStolen() = 0;
Igor Murashkinbfc99152013-02-27 12:55:20 -0800314
Igor Murashkin634a5152013-02-20 17:15:11 -0800315 protected:
Jianing Weicb0652e2014-03-12 18:29:36 -0700316 virtual void notifyError(ICameraDeviceCallbacks::CameraErrorCode errorCode,
317 const CaptureResultExtras& resultExtras);
Eino-Ville Talvala5e08d602012-05-16 14:59:25 -0700318
Eino-Ville Talvalaceb388d2013-02-19 10:40:14 -0800319 sp<IProCameraCallbacks> mRemoteCallback;
320 }; // class ProClient
Eino-Ville Talvala5e08d602012-05-16 14:59:25 -0700321
Mathias Agopian65ab4712010-07-14 17:59:35 -0700322private:
Igor Murashkin634a5152013-02-20 17:15:11 -0800323
324 // Delay-load the Camera HAL module
325 virtual void onFirstRef();
326
Igor Murashkine6800ce2013-03-04 17:25:57 -0800327 // Step 1. Check if we can connect, before we acquire the service lock.
Ruben Brunk0f61d8f2013-08-08 13:07:18 -0700328 status_t validateConnect(int cameraId,
Igor Murashkine6800ce2013-03-04 17:25:57 -0800329 /*inout*/
330 int& clientUid) const;
331
332 // Step 2. Check if we can connect, after we acquire the service lock.
333 bool canConnectUnsafe(int cameraId,
334 const String16& clientPackageName,
335 const sp<IBinder>& remoteCallback,
336 /*out*/
Igor Murashkine7ee7632013-06-11 18:10:18 -0700337 sp<BasicClient> &client);
Igor Murashkine6800ce2013-03-04 17:25:57 -0800338
339 // When connection is successful, initialize client and track its death
Ruben Brunk0f61d8f2013-08-08 13:07:18 -0700340 status_t connectFinishUnsafe(const sp<BasicClient>& client,
Igor Murashkine7ee7632013-06-11 18:10:18 -0700341 const sp<IBinder>& remoteCallback);
Igor Murashkine6800ce2013-03-04 17:25:57 -0800342
Igor Murashkin634a5152013-02-20 17:15:11 -0800343 virtual sp<BasicClient> getClientByRemote(const wp<IBinder>& cameraClient);
344
Mathias Agopian65ab4712010-07-14 17:59:35 -0700345 Mutex mServiceLock;
Igor Murashkine7ee7632013-06-11 18:10:18 -0700346 // either a Client or CameraDeviceClient
347 wp<BasicClient> mClient[MAX_CAMERAS]; // protected by mServiceLock
Keun young Parkd8973a72012-03-28 14:13:09 -0700348 Mutex mClientLock[MAX_CAMERAS]; // prevent Client destruction inside callbacks
Mathias Agopian65ab4712010-07-14 17:59:35 -0700349 int mNumberOfCameras;
350
Igor Murashkin634a5152013-02-20 17:15:11 -0800351 typedef wp<ProClient> weak_pro_client_ptr;
352 Vector<weak_pro_client_ptr> mProClientList[MAX_CAMERAS];
353
Igor Murashkinecf17e82012-10-02 16:05:11 -0700354 // needs to be called with mServiceLock held
Igor Murashkine7ee7632013-06-11 18:10:18 -0700355 sp<BasicClient> findClientUnsafe(const wp<IBinder>& cameraClient, int& outIndex);
Igor Murashkin634a5152013-02-20 17:15:11 -0800356 sp<ProClient> findProClientUnsafe(
357 const wp<IBinder>& cameraCallbacksRemote);
Igor Murashkinecf17e82012-10-02 16:05:11 -0700358
Mathias Agopian65ab4712010-07-14 17:59:35 -0700359 // atomics to record whether the hardware is allocated to some client.
360 volatile int32_t mBusy[MAX_CAMERAS];
361 void setCameraBusy(int cameraId);
362 void setCameraFree(int cameraId);
363
364 // sounds
Chih-Chung Changff4f55c2011-10-17 19:03:12 +0800365 MediaPlayer* newMediaPlayer(const char *file);
366
Mathias Agopian65ab4712010-07-14 17:59:35 -0700367 Mutex mSoundLock;
368 sp<MediaPlayer> mSoundPlayer[NUM_SOUNDS];
369 int mSoundRef; // reference count (release all MediaPlayer when 0)
370
Iliyan Malchev8951a972011-04-14 16:55:59 -0700371 camera_module_t *mModule;
Igor Murashkinecf17e82012-10-02 16:05:11 -0700372
Igor Murashkinbfc99152013-02-27 12:55:20 -0800373 Vector<sp<ICameraServiceListener> >
374 mListenerList;
375
376 // guard only mStatusList and the broadcasting of ICameraServiceListener
Igor Murashkincba2c162013-03-20 15:56:31 -0700377 mutable Mutex mStatusMutex;
Igor Murashkinbfc99152013-02-27 12:55:20 -0800378 ICameraServiceListener::Status
379 mStatusList[MAX_CAMERAS];
380
Igor Murashkincba2c162013-03-20 15:56:31 -0700381 // Read the current status (locks mStatusMutex)
382 ICameraServiceListener::Status
383 getStatus(int cameraId) const;
384
Igor Murashkin93747b92013-05-01 15:42:20 -0700385 typedef Vector<ICameraServiceListener::Status> StatusVector;
Igor Murashkinbfc99152013-02-27 12:55:20 -0800386 // Broadcast the new status if it changed (locks the service mutex)
387 void updateStatus(
388 ICameraServiceListener::Status status,
Igor Murashkin93747b92013-05-01 15:42:20 -0700389 int32_t cameraId,
390 const StatusVector *rejectSourceStates = NULL);
Igor Murashkinbfc99152013-02-27 12:55:20 -0800391
Igor Murashkinecf17e82012-10-02 16:05:11 -0700392 // IBinder::DeathRecipient implementation
Igor Murashkinbfc99152013-02-27 12:55:20 -0800393 virtual void binderDied(const wp<IBinder> &who);
Igor Murashkin634a5152013-02-20 17:15:11 -0800394
395 // Helpers
Igor Murashkinbfc99152013-02-27 12:55:20 -0800396
397 bool isValidCameraId(int cameraId);
Ruben Brunkd1176ef2014-02-21 10:51:38 -0800398
399 bool setUpVendorTags();
Ruben Brunkb2119af2014-05-09 19:57:56 -0700400
401 /**
402 * A mapping of camera ids to CameraParameters returned by that camera device.
403 *
404 * This cache is used to generate CameraCharacteristic metadata when using
405 * the HAL1 shim.
406 */
407 KeyedVector<int, CameraParameters> mShimParams;
408
409 /**
410 * Initialize and cache the metadata used by the HAL1 shim for a given cameraId.
411 *
412 * Returns OK on success, or a negative error code.
413 */
414 status_t initializeShimMetadata(int cameraId);
415
416 /**
417 * Generate the CameraCharacteristics metadata required by the Camera2 API
418 * from the available HAL1 CameraParameters and CameraInfo.
419 *
420 * Returns OK on success, or a negative error code.
421 */
422 status_t generateShimMetadata(int cameraId, /*out*/CameraMetadata* cameraInfo);
423
424 /**
425 * Connect a new camera client. This should only be used while holding the
426 * mutex for mServiceLock.
427 *
428 * Returns OK on success, or a negative error code.
429 */
430 status_t connectHelperLocked(const sp<ICameraClient>& cameraClient,
431 int cameraId,
432 const String16& clientPackageName,
433 int clientUid,
434 int callingPid,
435 /*out*/
436 sp<Client>& client);
Mathias Agopian65ab4712010-07-14 17:59:35 -0700437};
438
439} // namespace android
440
441#endif