Camera2Client.h revision f69c70ded4316ea3ee504ac779bd024433ed4ef7
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"
22#include "camera/CameraParameters.h"
23
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);
39    virtual status_t        setPreviewTexture(const sp<ISurfaceTexture>& surfaceTexture);
40    virtual void            setPreviewCallbackFlag(int flag);
41    virtual status_t        startPreview();
42    virtual void            stopPreview();
43    virtual bool            previewEnabled();
44    virtual status_t        storeMetaDataInBuffers(bool enabled);
45    virtual status_t        startRecording();
46    virtual void            stopRecording();
47    virtual bool            recordingEnabled();
48    virtual void            releaseRecordingFrame(const sp<IMemory>& mem);
49    virtual status_t        autoFocus();
50    virtual status_t        cancelAutoFocus();
51    virtual status_t        takePicture(int msgType);
52    virtual status_t        setParameters(const String8& params);
53    virtual String8         getParameters() const;
54    virtual status_t        sendCommand(int32_t cmd, int32_t arg1, int32_t arg2);
55
56    // Interface used by CameraService
57    Camera2Client(const sp<CameraService>& cameraService,
58            const sp<ICameraClient>& cameraClient,
59            int cameraId,
60            int cameraFacing,
61            int clientPid);
62    ~Camera2Client();
63
64    status_t initialize(camera_module_t *module);
65
66    virtual status_t dump(int fd, const Vector<String16>& args);
67
68private:
69    CameraParameters *mParams;
70    sp<Camera2Device> mDevice;
71
72    // Convert static camera info from a camera2 device to the
73    // old API parameter map.
74    status_t buildDefaultParameters();
75
76    // Free parameters for mapping from new to old HAL
77    static const unsigned int kNumZoomSteps = 10;
78};
79
80}; // namespace android
81
82#endif
83