blob: e35c3a4445078bc27bec3316ab1081fea36fb7f6 [file] [log] [blame]
Mathias Agopian3cf61352010-02-09 17:46:37 -08001/*
2 * Copyright (C) 2008 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_HARDWARE_ICAMERA_H
18#define ANDROID_HARDWARE_ICAMERA_H
19
20#include <utils/RefBase.h>
21#include <binder/IInterface.h>
22#include <binder/Parcel.h>
Mathias Agopian3cf61352010-02-09 17:46:37 -080023#include <binder/IMemory.h>
24#include <utils/String8.h>
25#include <camera/Camera.h>
26
27namespace android {
28
29class ICameraClient;
Andy McFadden8ba01022012-12-18 09:46:54 -080030class IGraphicBufferProducer;
Mathias Agopiandf712ea2012-02-25 18:48:35 -080031class Surface;
Mathias Agopian3cf61352010-02-09 17:46:37 -080032
33class ICamera: public IInterface
34{
Igor Murashkinbef3f232013-05-30 17:47:38 -070035 /**
36 * Keep up-to-date with ICamera.aidl in frameworks/base
37 */
Mathias Agopian3cf61352010-02-09 17:46:37 -080038public:
Chien-Yu Chen8cca0752015-11-13 15:28:48 -080039 enum {
40 // Pass real YUV data in video buffers through ICameraClient.dataCallbackTimestamp().
41 VIDEO_BUFFER_MODE_DATA_CALLBACK_YUV = 0,
42 // Pass metadata in video buffers through ICameraClient.dataCallbackTimestamp().
43 VIDEO_BUFFER_MODE_DATA_CALLBACK_METADATA = 1,
44 // Pass video buffers through IGraphicBufferProducer set with setVideoTarget().
45 VIDEO_BUFFER_MODE_BUFFER_QUEUE = 2,
46 };
47
Mathias Agopian3cf61352010-02-09 17:46:37 -080048 DECLARE_META_INTERFACE(Camera);
49
50 virtual void disconnect() = 0;
51
52 // connect new client with existing camera remote
53 virtual status_t connect(const sp<ICameraClient>& client) = 0;
54
55 // prevent other processes from using this ICamera interface
56 virtual status_t lock() = 0;
57
58 // allow other processes to use this ICamera interface
59 virtual status_t unlock() = 0;
60
Andy McFadden8ba01022012-12-18 09:46:54 -080061 // pass the buffered IGraphicBufferProducer to the camera service
Eino-Ville Talvala1ce7c342013-08-21 13:57:21 -070062 virtual status_t setPreviewTarget(
Andy McFadden8ba01022012-12-18 09:46:54 -080063 const sp<IGraphicBufferProducer>& bufferProducer) = 0;
Jamie Gennisbfa33aa2010-12-20 11:51:31 -080064
Mathias Agopian3cf61352010-02-09 17:46:37 -080065 // set the preview callback flag to affect how the received frames from
Eino-Ville Talvala3ee35502013-04-02 15:45:11 -070066 // preview are handled. Enabling preview callback flags disables any active
67 // preview callback surface set by setPreviewCallbackTarget().
Mathias Agopian3cf61352010-02-09 17:46:37 -080068 virtual void setPreviewCallbackFlag(int flag) = 0;
Eino-Ville Talvala3ee35502013-04-02 15:45:11 -070069 // set a buffer interface to use for client-received preview frames instead
70 // of preview callback buffers. Passing a valid interface here disables any
71 // active preview callbacks set by setPreviewCallbackFlag(). Passing NULL
72 // disables the use of the callback target.
73 virtual status_t setPreviewCallbackTarget(
74 const sp<IGraphicBufferProducer>& callbackProducer) = 0;
Mathias Agopian3cf61352010-02-09 17:46:37 -080075
Eino-Ville Talvala1ce7c342013-08-21 13:57:21 -070076 // start preview mode, must call setPreviewTarget first
Mathias Agopian3cf61352010-02-09 17:46:37 -080077 virtual status_t startPreview() = 0;
78
79 // stop preview mode
80 virtual void stopPreview() = 0;
81
82 // get preview state
83 virtual bool previewEnabled() = 0;
84
85 // start recording mode
86 virtual status_t startRecording() = 0;
87
88 // stop recording mode
James Donge468ac52011-02-17 16:38:06 -080089 virtual void stopRecording() = 0;
Mathias Agopian3cf61352010-02-09 17:46:37 -080090
91 // get recording state
92 virtual bool recordingEnabled() = 0;
93
94 // release a recording frame
95 virtual void releaseRecordingFrame(const sp<IMemory>& mem) = 0;
96
97 // auto focus
98 virtual status_t autoFocus() = 0;
99
100 // cancel auto focus
101 virtual status_t cancelAutoFocus() = 0;
102
James Donge468ac52011-02-17 16:38:06 -0800103 /*
104 * take a picture.
105 * @param msgType the message type an application selectively turn on/off
106 * on a photo-by-photo basis. The supported message types are:
107 * CAMERA_MSG_SHUTTER, CAMERA_MSG_RAW_IMAGE, CAMERA_MSG_COMPRESSED_IMAGE,
108 * and CAMERA_MSG_POSTVIEW_FRAME. Any other message types will be ignored.
109 */
110 virtual status_t takePicture(int msgType) = 0;
Mathias Agopian3cf61352010-02-09 17:46:37 -0800111
112 // set preview/capture parameters - key/value pairs
113 virtual status_t setParameters(const String8& params) = 0;
114
115 // get preview/capture parameters - key/value pairs
116 virtual String8 getParameters() const = 0;
117
118 // send command to camera driver
119 virtual status_t sendCommand(int32_t cmd, int32_t arg1, int32_t arg2) = 0;
James Donge2ad6732010-10-18 20:42:51 -0700120
Chien-Yu Chen8cca0752015-11-13 15:28:48 -0800121
122 // Tell camera how to pass video buffers. videoBufferMode is one of VIDEO_BUFFER_MODE_*.
123 // Returns OK if the specified video buffer mode is supported. If videoBufferMode is
124 // VIDEO_BUFFER_MODE_BUFFER_QUEUE, setVideoTarget() must be called before starting video
125 // recording.
126 virtual status_t setVideoBufferMode(int32_t videoBufferMode) = 0;
127
128 // Set the video buffer producer for camera to use in VIDEO_BUFFER_MODE_BUFFER_QUEUE mode.
129 virtual status_t setVideoTarget(
130 const sp<IGraphicBufferProducer>& bufferProducer) = 0;
Mathias Agopian3cf61352010-02-09 17:46:37 -0800131};
132
133// ----------------------------------------------------------------------------
134
135class BnCamera: public BnInterface<ICamera>
136{
137public:
138 virtual status_t onTransact( uint32_t code,
139 const Parcel& data,
140 Parcel* reply,
141 uint32_t flags = 0);
142};
143
144}; // namespace android
145
146#endif