blob: f69021e96917cc2f37fe2ce5715b84c12305d481 [file] [log] [blame]
Igor Murashkin985fd302013-02-20 18:24:43 -08001/*
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 Murashkina91537e2013-02-21 12:02:29 -080022#include "camera2/ProFrameProcessor.h"
Igor Murashkin44cfcf02013-03-01 16:22:28 -080023#include "Camera2ClientBase.h"
Igor Murashkin985fd302013-02-20 18:24:43 -080024
25namespace android {
26
27class IMemory;
28/**
29 * Implements the binder IProCameraUser API,
30 * meant for HAL2-level private API access.
31 */
32class ProCamera2Client :
Igor Murashkin44cfcf02013-03-01 16:22:28 -080033 public Camera2ClientBase<CameraService::ProClient>,
Igor Murashkina91537e2013-02-21 12:02:29 -080034 public camera2::ProFrameProcessor::FilteredListener
Igor Murashkin985fd302013-02-20 18:24:43 -080035{
36public:
37 /**
38 * IProCameraUser interface (see IProCameraUser for details)
39 */
Igor Murashkin985fd302013-02-20 18:24:43 -080040 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 Murashkin44cfcf02013-03-01 16:22:28 -080054 virtual status_t createStream(
55 int width,
56 int height,
57 int format,
58 const sp<IGraphicBufferProducer>& bufferProducer,
59 /*out*/
60 int* streamId);
Igor Murashkin985fd302013-02-20 18:24:43 -080061
62 // Create a request object from a template.
Igor Murashkin3261fd32013-02-20 19:02:36 -080063 // -- Caller owns the newly allocated metadata
Igor Murashkin985fd302013-02-20 18:24:43 -080064 virtual status_t createDefaultRequest(int templateId,
65 /*out*/
66 camera_metadata** request);
67
Igor Murashkin7b33a742013-02-21 13:49:26 -080068 // 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 Murashkin985fd302013-02-20 18:24:43 -080073
74 /**
75 * Interface used by CameraService
76 */
77
78 ProCamera2Client(const sp<CameraService>& cameraService,
79 const sp<IProCameraCallbacks>& remoteCallback,
Eino-Ville Talvalaceb388d2013-02-19 10:40:14 -080080 const String16& clientPackageName,
Igor Murashkin985fd302013-02-20 18:24:43 -080081 int cameraId,
82 int cameraFacing,
83 int clientPid,
Eino-Ville Talvalaceb388d2013-02-19 10:40:14 -080084 uid_t clientUid,
Igor Murashkin985fd302013-02-20 18:24:43 -080085 int servicePid);
86 virtual ~ProCamera2Client();
87
Igor Murashkin44cfcf02013-03-01 16:22:28 -080088 virtual status_t initialize(camera_module_t *module);
Igor Murashkin985fd302013-02-20 18:24:43 -080089
Igor Murashkin44cfcf02013-03-01 16:22:28 -080090 virtual status_t dump(int fd, const Vector<String16>& args);
Igor Murashkin985fd302013-02-20 18:24:43 -080091
Igor Murashkinbfc99152013-02-27 12:55:20 -080092 // Callbacks from camera service
93 virtual void onExclusiveLockStolen();
94
Igor Murashkin985fd302013-02-20 18:24:43 -080095 /**
96 * Interface used by independent components of ProCamera2Client.
97 */
98
Igor Murashkina91537e2013-02-21 12:02:29 -080099protected:
100 /** FilteredListener implementation **/
Igor Murashkin44cfcf02013-03-01 16:22:28 -0800101 virtual void onFrameAvailable(int32_t frameId,
102 const CameraMetadata& frame);
103 virtual void detachDevice();
Igor Murashkina91537e2013-02-21 12:02:29 -0800104
Igor Murashkin985fd302013-02-20 18:24:43 -0800105private:
106 /** IProCameraUser interface-related private members */
107
Igor Murashkin985fd302013-02-20 18:24:43 -0800108 /** Preview callback related members */
Igor Murashkina91537e2013-02-21 12:02:29 -0800109 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 Murashkin985fd302013-02-20 18:24:43 -0800113 /** Utility members */
114
Igor Murashkin985fd302013-02-20 18:24:43 -0800115 // 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 Murashkin985fd302013-02-20 18:24:43 -0800119};
120
121}; // namespace android
122
123#endif