ICameraService.h revision d1176ef16677b6c94fb893edb6a864cdccc0b190
1/*
2 * 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 */
16
17#ifndef ANDROID_HARDWARE_ICAMERASERVICE_H
18#define ANDROID_HARDWARE_ICAMERASERVICE_H
19
20#include <utils/RefBase.h>
21#include <binder/IInterface.h>
22#include <binder/Parcel.h>
23
24namespace android {
25
26class ICamera;
27class ICameraClient;
28class IProCameraUser;
29class IProCameraCallbacks;
30class ICameraServiceListener;
31class ICameraDeviceUser;
32class ICameraDeviceCallbacks;
33class CameraMetadata;
34class VendorTagDescriptor;
35
36class ICameraService : public IInterface
37{
38public:
39    /**
40     * Keep up-to-date with ICameraService.aidl in frameworks/base
41     */
42    enum {
43        GET_NUMBER_OF_CAMERAS = IBinder::FIRST_CALL_TRANSACTION,
44        GET_CAMERA_INFO,
45        CONNECT,
46        CONNECT_PRO,
47        CONNECT_DEVICE,
48        ADD_LISTENER,
49        REMOVE_LISTENER,
50        GET_CAMERA_CHARACTERISTICS,
51        GET_CAMERA_VENDOR_TAG_DESCRIPTOR,
52    };
53
54    enum {
55        USE_CALLING_UID = -1
56    };
57
58public:
59    DECLARE_META_INTERFACE(CameraService);
60
61    virtual int32_t  getNumberOfCameras() = 0;
62    virtual status_t getCameraInfo(int cameraId,
63                                          struct CameraInfo* cameraInfo) = 0;
64
65    virtual status_t getCameraCharacteristics(int cameraId,
66                                              CameraMetadata* cameraInfo) = 0;
67
68    virtual status_t getCameraVendorTagDescriptor(sp<VendorTagDescriptor>& desc) = 0;
69
70    // Returns 'OK' if operation succeeded
71    // - Errors: ALREADY_EXISTS if the listener was already added
72    virtual status_t addListener(const sp<ICameraServiceListener>& listener)
73                                                                            = 0;
74    // Returns 'OK' if operation succeeded
75    // - Errors: BAD_VALUE if specified listener was not in the listener list
76    virtual status_t removeListener(const sp<ICameraServiceListener>& listener)
77                                                                            = 0;
78    /**
79     * clientPackageName and clientUid are used for permissions checking.  if
80     * clientUid == USE_CALLING_UID, then the calling UID is used instead. Only
81     * trusted callers can set a clientUid other than USE_CALLING_UID.
82     */
83    virtual status_t connect(const sp<ICameraClient>& cameraClient,
84            int cameraId,
85            const String16& clientPackageName,
86            int clientUid,
87            /*out*/
88            sp<ICamera>& device) = 0;
89
90    virtual status_t connectPro(const sp<IProCameraCallbacks>& cameraCb,
91            int cameraId,
92            const String16& clientPackageName,
93            int clientUid,
94            /*out*/
95            sp<IProCameraUser>& device) = 0;
96
97    virtual status_t connectDevice(
98            const sp<ICameraDeviceCallbacks>& cameraCb,
99            int cameraId,
100            const String16& clientPackageName,
101            int clientUid,
102            /*out*/
103            sp<ICameraDeviceUser>& device) = 0;
104};
105
106// ----------------------------------------------------------------------------
107
108class BnCameraService: public BnInterface<ICameraService>
109{
110public:
111    virtual status_t    onTransact( uint32_t code,
112                                    const Parcel& data,
113                                    Parcel* reply,
114                                    uint32_t flags = 0);
115};
116
117}; // namespace android
118
119#endif
120