13cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian/*
23cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian * Copyright (C) 2008 The Android Open Source Project
33cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian *
43cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian * Licensed under the Apache License, Version 2.0 (the "License");
53cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian * you may not use this file except in compliance with the License.
63cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian * You may obtain a copy of the License at
73cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian *
83cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian *      http://www.apache.org/licenses/LICENSE-2.0
93cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian *
103cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian * Unless required by applicable law or agreed to in writing, software
113cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian * distributed under the License is distributed on an "AS IS" BASIS,
123cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
133cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian * See the License for the specific language governing permissions and
143cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian * limitations under the License.
153cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian */
163cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian
173cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian#ifndef ANDROID_HARDWARE_ICAMERA_H
183cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian#define ANDROID_HARDWARE_ICAMERA_H
193cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian
203cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian#include <utils/RefBase.h>
213cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian#include <binder/IInterface.h>
223cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian#include <binder/Parcel.h>
233cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian#include <binder/IMemory.h>
243cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian#include <utils/String8.h>
253cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian#include <camera/Camera.h>
263cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian
273cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopiannamespace android {
283cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian
293cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopianclass ICameraClient;
308ba01021b573889802e67e029225a96f0dfa471aAndy McFaddenclass IGraphicBufferProducer;
31df712ea86e6350f7005a02ab0e1c60c28a343ed0Mathias Agopianclass Surface;
323cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian
333cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopianclass ICamera: public IInterface
343cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian{
35bef3f23f16f2fc575b3f425febcfcc436a7db70fIgor Murashkin    /**
36bef3f23f16f2fc575b3f425febcfcc436a7db70fIgor Murashkin     * Keep up-to-date with ICamera.aidl in frameworks/base
37bef3f23f16f2fc575b3f425febcfcc436a7db70fIgor Murashkin     */
383cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopianpublic:
393cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian    DECLARE_META_INTERFACE(Camera);
403cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian
413cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian    virtual void            disconnect() = 0;
423cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian
433cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian    // connect new client with existing camera remote
443cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian    virtual status_t        connect(const sp<ICameraClient>& client) = 0;
453cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian
463cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian    // prevent other processes from using this ICamera interface
473cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian    virtual status_t        lock() = 0;
483cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian
493cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian    // allow other processes to use this ICamera interface
503cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian    virtual status_t        unlock() = 0;
513cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian
528ba01021b573889802e67e029225a96f0dfa471aAndy McFadden    // pass the buffered IGraphicBufferProducer to the camera service
531ce7c34e67c2cf58dd88c31f36f4bd62e375f7f0Eino-Ville Talvala    virtual status_t        setPreviewTarget(
548ba01021b573889802e67e029225a96f0dfa471aAndy McFadden            const sp<IGraphicBufferProducer>& bufferProducer) = 0;
55bfa33aae4f54c0020a0568b16a3acb7b30b6ca3dJamie Gennis
563cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian    // set the preview callback flag to affect how the received frames from
573ee3550a2f529cbf56d87d8503f59a8f45dccf32Eino-Ville Talvala    // preview are handled. Enabling preview callback flags disables any active
583ee3550a2f529cbf56d87d8503f59a8f45dccf32Eino-Ville Talvala    // preview callback surface set by setPreviewCallbackTarget().
593cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian    virtual void            setPreviewCallbackFlag(int flag) = 0;
603ee3550a2f529cbf56d87d8503f59a8f45dccf32Eino-Ville Talvala    // set a buffer interface to use for client-received preview frames instead
613ee3550a2f529cbf56d87d8503f59a8f45dccf32Eino-Ville Talvala    // of preview callback buffers. Passing a valid interface here disables any
623ee3550a2f529cbf56d87d8503f59a8f45dccf32Eino-Ville Talvala    // active preview callbacks set by setPreviewCallbackFlag(). Passing NULL
633ee3550a2f529cbf56d87d8503f59a8f45dccf32Eino-Ville Talvala    // disables the use of the callback target.
643ee3550a2f529cbf56d87d8503f59a8f45dccf32Eino-Ville Talvala    virtual status_t        setPreviewCallbackTarget(
653ee3550a2f529cbf56d87d8503f59a8f45dccf32Eino-Ville Talvala            const sp<IGraphicBufferProducer>& callbackProducer) = 0;
663cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian
671ce7c34e67c2cf58dd88c31f36f4bd62e375f7f0Eino-Ville Talvala    // start preview mode, must call setPreviewTarget first
683cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian    virtual status_t        startPreview() = 0;
693cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian
703cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian    // stop preview mode
713cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian    virtual void            stopPreview() = 0;
723cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian
733cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian    // get preview state
743cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian    virtual bool            previewEnabled() = 0;
753cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian
763cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian    // start recording mode
773cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian    virtual status_t        startRecording() = 0;
783cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian
793cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian    // stop recording mode
80e468ac57f6e8afc6078c76d4eb1ac327112a3de0James Dong    virtual void            stopRecording() = 0;
813cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian
823cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian    // get recording state
833cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian    virtual bool            recordingEnabled() = 0;
843cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian
853cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian    // release a recording frame
863cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian    virtual void            releaseRecordingFrame(const sp<IMemory>& mem) = 0;
873cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian
883cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian    // auto focus
893cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian    virtual status_t        autoFocus() = 0;
903cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian
913cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian    // cancel auto focus
923cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian    virtual status_t        cancelAutoFocus() = 0;
933cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian
94e468ac57f6e8afc6078c76d4eb1ac327112a3de0James Dong    /*
95e468ac57f6e8afc6078c76d4eb1ac327112a3de0James Dong     * take a picture.
96e468ac57f6e8afc6078c76d4eb1ac327112a3de0James Dong     * @param msgType the message type an application selectively turn on/off
97e468ac57f6e8afc6078c76d4eb1ac327112a3de0James Dong     * on a photo-by-photo basis. The supported message types are:
98e468ac57f6e8afc6078c76d4eb1ac327112a3de0James Dong     * CAMERA_MSG_SHUTTER, CAMERA_MSG_RAW_IMAGE, CAMERA_MSG_COMPRESSED_IMAGE,
99e468ac57f6e8afc6078c76d4eb1ac327112a3de0James Dong     * and CAMERA_MSG_POSTVIEW_FRAME. Any other message types will be ignored.
100e468ac57f6e8afc6078c76d4eb1ac327112a3de0James Dong     */
101e468ac57f6e8afc6078c76d4eb1ac327112a3de0James Dong    virtual status_t        takePicture(int msgType) = 0;
1023cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian
1033cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian    // set preview/capture parameters - key/value pairs
1043cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian    virtual status_t        setParameters(const String8& params) = 0;
1053cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian
1063cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian    // get preview/capture parameters - key/value pairs
1073cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian    virtual String8         getParameters() const = 0;
1083cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian
1093cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian    // send command to camera driver
1103cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian    virtual status_t        sendCommand(int32_t cmd, int32_t arg1, int32_t arg2) = 0;
111e2ad6734eccc4b9ea7857c747ff9469a9c11ba09James Dong
112e2ad6734eccc4b9ea7857c747ff9469a9c11ba09James Dong    // tell the camera hal to store meta data or real YUV data in video buffers.
113e2ad6734eccc4b9ea7857c747ff9469a9c11ba09James Dong    virtual status_t        storeMetaDataInBuffers(bool enabled) = 0;
1143cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian};
1153cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian
1163cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian// ----------------------------------------------------------------------------
1173cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian
1183cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopianclass BnCamera: public BnInterface<ICamera>
1193cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian{
1203cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopianpublic:
1213cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian    virtual status_t    onTransact( uint32_t code,
1223cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian                                    const Parcel& data,
1233cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian                                    Parcel* reply,
1243cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian                                    uint32_t flags = 0);
1253cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian};
1263cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian
1273cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian}; // namespace android
1283cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian
1293cf613507f1e2f7bd932d921a6e222e426fd3be4Mathias Agopian#endif
130