blob: fb701abc4dd3c6786ac44e332f33389bc32827f3 [file] [log] [blame]
Eino-Ville Talvala61ab9f92012-05-17 10:30:54 -07001/*
2 * Copyright (C) 2012 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_CAMERA2CLIENT_H
18#define ANDROID_SERVERS_CAMERA_CAMERA2CLIENT_H
19
20#include "Camera2Device.h"
21#include "CameraService.h"
Eino-Ville Talvalaf69c70d2012-05-20 15:59:14 -070022#include "camera/CameraParameters.h"
Eino-Ville Talvala61ab9f92012-05-17 10:30:54 -070023
24namespace android {
25
26/**
27 * Implements the android.hardware.camera API on top of
28 * camera device HAL version 2.
29 */
30class Camera2Client : public CameraService::Client
31{
32public:
33 // ICamera interface (see ICamera for details)
34 virtual void disconnect();
35 virtual status_t connect(const sp<ICameraClient>& client);
36 virtual status_t lock();
37 virtual status_t unlock();
38 virtual status_t setPreviewDisplay(const sp<Surface>& surface);
Eino-Ville Talvala6db981c2012-05-21 18:54:30 -070039 virtual status_t setPreviewTexture(
40 const sp<ISurfaceTexture>& surfaceTexture);
Eino-Ville Talvala61ab9f92012-05-17 10:30:54 -070041 virtual void setPreviewCallbackFlag(int flag);
42 virtual status_t startPreview();
43 virtual void stopPreview();
44 virtual bool previewEnabled();
45 virtual status_t storeMetaDataInBuffers(bool enabled);
46 virtual status_t startRecording();
47 virtual void stopRecording();
48 virtual bool recordingEnabled();
49 virtual void releaseRecordingFrame(const sp<IMemory>& mem);
50 virtual status_t autoFocus();
51 virtual status_t cancelAutoFocus();
52 virtual status_t takePicture(int msgType);
53 virtual status_t setParameters(const String8& params);
54 virtual String8 getParameters() const;
55 virtual status_t sendCommand(int32_t cmd, int32_t arg1, int32_t arg2);
56
57 // Interface used by CameraService
58 Camera2Client(const sp<CameraService>& cameraService,
59 const sp<ICameraClient>& cameraClient,
Eino-Ville Talvala61ab9f92012-05-17 10:30:54 -070060 int cameraId,
61 int cameraFacing,
62 int clientPid);
63 ~Camera2Client();
64
Eino-Ville Talvalaf69c70d2012-05-20 15:59:14 -070065 status_t initialize(camera_module_t *module);
66
Eino-Ville Talvala61ab9f92012-05-17 10:30:54 -070067 virtual status_t dump(int fd, const Vector<String16>& args);
68
69private:
Eino-Ville Talvala6db981c2012-05-21 18:54:30 -070070 // Number of zoom steps to simulate
71 static const unsigned int NUM_ZOOM_STEPS = 10;
72 // Used with mPreviewStreamId
73 static const int NO_PREVIEW_STREAM = -1;
74
75 enum {
76 NOT_INITIALIZED,
77 STOPPED,
78 WAITING_FOR_PREVIEW_WINDOW,
79 PREVIEW
80 } mState;
81
Eino-Ville Talvalaf69c70d2012-05-20 15:59:14 -070082 sp<Camera2Device> mDevice;
Eino-Ville Talvala61ab9f92012-05-17 10:30:54 -070083
Eino-Ville Talvala6db981c2012-05-21 18:54:30 -070084 CameraParameters *mParams;
85
86 sp<IBinder> mPreviewSurface;
87 int mPreviewStreamId;
88 camera_metadata_t *mPreviewRequest;
89
90 status_t setPreviewWindow(const sp<IBinder>& binder,
91 const sp<ANativeWindow>& window);
92
Eino-Ville Talvalaf69c70d2012-05-20 15:59:14 -070093 // Convert static camera info from a camera2 device to the
94 // old API parameter map.
95 status_t buildDefaultParameters();
Eino-Ville Talvala61ab9f92012-05-17 10:30:54 -070096
Eino-Ville Talvala6db981c2012-05-21 18:54:30 -070097 // Update preview request based on mParams
98 status_t updatePreviewRequest();
Eino-Ville Talvala61ab9f92012-05-17 10:30:54 -070099};
100
101}; // namespace android
102
103#endif