ICameraService.h revision e1445da74730473a66a3ae8414e940aebfe6585d
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            /*out*/
64            struct CameraInfo* cameraInfo) = 0;
65
66    virtual status_t getCameraCharacteristics(int cameraId,
67            /*out*/
68            CameraMetadata* cameraInfo) = 0;
69
70    virtual status_t getCameraVendorTagDescriptor(
71            /*out*/
72            sp<VendorTagDescriptor>& desc) = 0;
73
74    // Returns 'OK' if operation succeeded
75    // - Errors: ALREADY_EXISTS if the listener was already added
76    virtual status_t addListener(const sp<ICameraServiceListener>& listener)
77                                                                            = 0;
78    // Returns 'OK' if operation succeeded
79    // - Errors: BAD_VALUE if specified listener was not in the listener list
80    virtual status_t removeListener(const sp<ICameraServiceListener>& listener)
81                                                                            = 0;
82    /**
83     * clientPackageName and clientUid are used for permissions checking.  if
84     * clientUid == USE_CALLING_UID, then the calling UID is used instead. Only
85     * trusted callers can set a clientUid other than USE_CALLING_UID.
86     */
87    virtual status_t connect(const sp<ICameraClient>& cameraClient,
88            int cameraId,
89            const String16& clientPackageName,
90            int clientUid,
91            /*out*/
92            sp<ICamera>& device) = 0;
93
94    virtual status_t connectPro(const sp<IProCameraCallbacks>& cameraCb,
95            int cameraId,
96            const String16& clientPackageName,
97            int clientUid,
98            /*out*/
99            sp<IProCameraUser>& device) = 0;
100
101    virtual status_t connectDevice(
102            const sp<ICameraDeviceCallbacks>& cameraCb,
103            int cameraId,
104            const String16& clientPackageName,
105            int clientUid,
106            /*out*/
107            sp<ICameraDeviceUser>& device) = 0;
108};
109
110// ----------------------------------------------------------------------------
111
112class BnCameraService: public BnInterface<ICameraService>
113{
114public:
115    virtual status_t    onTransact( uint32_t code,
116                                    const Parcel& data,
117                                    Parcel* reply,
118                                    uint32_t flags = 0);
119};
120
121}; // namespace android
122
123#endif
124