blob: d4a7a3c1d84e5cadca93afe07db995e0f6fb8a59 [file] [log] [blame]
Eino-Ville Talvalab2675542012-12-12 13:29:45 -08001/*
2 * Copyright (C) 2013 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
17package android.hardware.photography;
18
Igor Murashkin70725502013-06-25 20:27:06 +000019import android.os.Parcel;
20import android.os.Parcelable;
Eino-Ville Talvalab2675542012-12-12 13:29:45 -080021import android.view.Surface;
22
Igor Murashkin70725502013-06-25 20:27:06 +000023import java.util.HashSet;
Eino-Ville Talvalab2675542012-12-12 13:29:45 -080024
25
26/**
27 * <p>All the settings required to capture a single image from the image sensor.</p>
28 *
29 * <p>Contains the configuration for the capture hardware (sensor, lens, flash),
30 * the processing pipeline, the control algorithms, and the output buffers.</p>
31 *
32 * <p>CaptureRequests can be created by calling
33 * {@link CameraDevice#createCaptureRequest}</p>
34 *
35 * <p>CaptureRequests are given to {@link CameraDevice#capture} or
36 * {@link CameraDevice#setRepeatingRequest} to capture images from a camera.</p>
37 *
38 * <p>Each request can specify a different subset of target Surfaces for the
39 * camera to send the captured data to. All the surfaces used in a request must
40 * be part of the surface list given to the last call to
41 * {@link CameraDevice#configureOutputs}.</p>
42 *
43 * <p>For example, a request meant for repeating preview might only include the
44 * Surface for the preview SurfaceView or SurfaceTexture, while a
45 * high-resolution still capture would also include a Surface from a ImageReader
46 * configured for high-resolution JPEG images.</p>
47 *
48 * @see CameraDevice#capture
49 * @see CameraDevice#setRepeatingRequest
50 * @see CameraDevice#createRequest
51 */
Igor Murashkin70725502013-06-25 20:27:06 +000052public final class CaptureRequest extends CameraMetadata implements Parcelable {
53
54 private final Object mLock = new Object();
55 private final HashSet<Surface> mSurfaceSet = new HashSet<Surface>();
Eino-Ville Talvalab2675542012-12-12 13:29:45 -080056
57 /**
58 * The exposure time for this capture, in nanoseconds.
59 */
Igor Murashkin70725502013-06-25 20:27:06 +000060 public static final Key<Long> SENSOR_EXPOSURE_TIME =
Igor Murashkinb519cc52013-07-02 11:23:44 -070061 new Key<Long>("android.sensor.exposureTime", Long.TYPE);
Eino-Ville Talvalab2675542012-12-12 13:29:45 -080062
63 /**
64 * The sensor sensitivity (gain) setting for this camera.
65 * This is represented as an ISO sensitivity value
66 */
Igor Murashkin70725502013-06-25 20:27:06 +000067 public static final Key<Integer> SENSOR_SENSITIVITY =
Igor Murashkinb519cc52013-07-02 11:23:44 -070068 new Key<Integer>("android.sensor.sensitivity", Integer.TYPE);
Eino-Ville Talvalab2675542012-12-12 13:29:45 -080069
70 // Many more settings
71
Igor Murashkin70725502013-06-25 20:27:06 +000072 /**
73 * @hide
74 */
75 public CaptureRequest() {
Eino-Ville Talvalab2675542012-12-12 13:29:45 -080076 }
77
78 /**
79 * <p>Add a surface to the list of targets for this request</p>
80 *
81 * <p>The Surface added must be one of the surfaces included in the last
82 * call to {@link CameraDevice#configureOutputs}.</p>
Igor Murashkin70725502013-06-25 20:27:06 +000083 *
84 * <p>Adding a target more than once has no effect.</p>
85 *
86 * @param outputTarget surface to use as an output target for this request
Eino-Ville Talvalab2675542012-12-12 13:29:45 -080087 */
88 public void addTarget(Surface outputTarget) {
Igor Murashkin70725502013-06-25 20:27:06 +000089 synchronized (mLock) {
90 mSurfaceSet.add(outputTarget);
91 }
Eino-Ville Talvalab2675542012-12-12 13:29:45 -080092 }
93
94 /**
95 * <p>Remove a surface from the list of targets for this request.</p>
Igor Murashkin70725502013-06-25 20:27:06 +000096 *
97 * <p>Removing a target that is not currently added has no effect.</p>
98 *
99 * @param outputTarget surface to use as an output target for this request
Eino-Ville Talvalab2675542012-12-12 13:29:45 -0800100 */
101 public void removeTarget(Surface outputTarget) {
Igor Murashkin70725502013-06-25 20:27:06 +0000102 synchronized (mLock) {
103 mSurfaceSet.remove(outputTarget);
104 }
105 }
106
107 public static final Parcelable.Creator<CaptureRequest> CREATOR =
108 new Parcelable.Creator<CaptureRequest>() {
109 @Override
110 public CaptureRequest createFromParcel(Parcel in) {
111 CaptureRequest request = new CaptureRequest();
112 request.readFromParcel(in);
113 return request;
114 }
115
116 @Override
117 public CaptureRequest[] newArray(int size) {
118 return new CaptureRequest[size];
119 }
120 };
121
122 /**
123 * Expand this object from a Parcel.
124 * @param in The parcel from which the object should be read
125 */
126 @Override
127 public void readFromParcel(Parcel in) {
128 synchronized (mLock) {
129 super.readFromParcel(in);
130
131 mSurfaceSet.clear();
132
133 Parcelable[] parcelableArray = in.readParcelableArray(Surface.class.getClassLoader());
134
135 if (parcelableArray == null) {
136 return;
137 }
138
139 for (Parcelable p : parcelableArray) {
140 Surface s = (Surface) p;
141 mSurfaceSet.add(s);
142 }
143 }
144 }
145
146 @Override
147 public void writeToParcel(Parcel dest, int flags) {
148 synchronized (mLock) {
149 super.writeToParcel(dest, flags);
150
151 dest.writeParcelableArray(mSurfaceSet.toArray(new Surface[mSurfaceSet.size()]), flags);
152 }
Eino-Ville Talvalab2675542012-12-12 13:29:45 -0800153 }
154
155}