Eino-Ville Talvala | 61ab9f9 | 2012-05-17 10:30:54 -0700 | [diff] [blame] | 1 | /* |
| 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 Talvala | f69c70d | 2012-05-20 15:59:14 -0700 | [diff] [blame] | 22 | #include "camera/CameraParameters.h" |
Eino-Ville Talvala | 61ab9f9 | 2012-05-17 10:30:54 -0700 | [diff] [blame] | 23 | |
| 24 | namespace android { |
| 25 | |
| 26 | /** |
| 27 | * Implements the android.hardware.camera API on top of |
| 28 | * camera device HAL version 2. |
| 29 | */ |
| 30 | class Camera2Client : public CameraService::Client |
| 31 | { |
| 32 | public: |
| 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 Talvala | 6db981c | 2012-05-21 18:54:30 -0700 | [diff] [blame^] | 39 | virtual status_t setPreviewTexture( |
| 40 | const sp<ISurfaceTexture>& surfaceTexture); |
Eino-Ville Talvala | 61ab9f9 | 2012-05-17 10:30:54 -0700 | [diff] [blame] | 41 | 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 Talvala | 61ab9f9 | 2012-05-17 10:30:54 -0700 | [diff] [blame] | 60 | int cameraId, |
| 61 | int cameraFacing, |
| 62 | int clientPid); |
| 63 | ~Camera2Client(); |
| 64 | |
Eino-Ville Talvala | f69c70d | 2012-05-20 15:59:14 -0700 | [diff] [blame] | 65 | status_t initialize(camera_module_t *module); |
| 66 | |
Eino-Ville Talvala | 61ab9f9 | 2012-05-17 10:30:54 -0700 | [diff] [blame] | 67 | virtual status_t dump(int fd, const Vector<String16>& args); |
| 68 | |
| 69 | private: |
Eino-Ville Talvala | 6db981c | 2012-05-21 18:54:30 -0700 | [diff] [blame^] | 70 | // 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 Talvala | f69c70d | 2012-05-20 15:59:14 -0700 | [diff] [blame] | 82 | sp<Camera2Device> mDevice; |
Eino-Ville Talvala | 61ab9f9 | 2012-05-17 10:30:54 -0700 | [diff] [blame] | 83 | |
Eino-Ville Talvala | 6db981c | 2012-05-21 18:54:30 -0700 | [diff] [blame^] | 84 | 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 Talvala | f69c70d | 2012-05-20 15:59:14 -0700 | [diff] [blame] | 93 | // Convert static camera info from a camera2 device to the |
| 94 | // old API parameter map. |
| 95 | status_t buildDefaultParameters(); |
Eino-Ville Talvala | 61ab9f9 | 2012-05-17 10:30:54 -0700 | [diff] [blame] | 96 | |
Eino-Ville Talvala | 6db981c | 2012-05-21 18:54:30 -0700 | [diff] [blame^] | 97 | // Update preview request based on mParams |
| 98 | status_t updatePreviewRequest(); |
Eino-Ville Talvala | 61ab9f9 | 2012-05-17 10:30:54 -0700 | [diff] [blame] | 99 | }; |
| 100 | |
| 101 | }; // namespace android |
| 102 | |
| 103 | #endif |