15d4fb6accab3bcbe737d52747c328de5cc092d02Puneet Lall/*
25d4fb6accab3bcbe737d52747c328de5cc092d02Puneet Lall * Copyright (C) 2014 The Android Open Source Project
35d4fb6accab3bcbe737d52747c328de5cc092d02Puneet Lall *
45d4fb6accab3bcbe737d52747c328de5cc092d02Puneet Lall * Licensed under the Apache License, Version 2.0 (the "License");
55d4fb6accab3bcbe737d52747c328de5cc092d02Puneet Lall * you may not use this file except in compliance with the License.
65d4fb6accab3bcbe737d52747c328de5cc092d02Puneet Lall * You may obtain a copy of the License at
75d4fb6accab3bcbe737d52747c328de5cc092d02Puneet Lall *
85d4fb6accab3bcbe737d52747c328de5cc092d02Puneet Lall *      http://www.apache.org/licenses/LICENSE-2.0
95d4fb6accab3bcbe737d52747c328de5cc092d02Puneet Lall *
105d4fb6accab3bcbe737d52747c328de5cc092d02Puneet Lall * Unless required by applicable law or agreed to in writing, software
115d4fb6accab3bcbe737d52747c328de5cc092d02Puneet Lall * distributed under the License is distributed on an "AS IS" BASIS,
125d4fb6accab3bcbe737d52747c328de5cc092d02Puneet Lall * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
135d4fb6accab3bcbe737d52747c328de5cc092d02Puneet Lall * See the License for the specific language governing permissions and
145d4fb6accab3bcbe737d52747c328de5cc092d02Puneet Lall * limitations under the License.
155d4fb6accab3bcbe737d52747c328de5cc092d02Puneet Lall */
169c94ab32a69a1ad3642a0f1e38e68bcfd97d3511Puneet Lall
179c94ab32a69a1ad3642a0f1e38e68bcfd97d3511Puneet Lallpackage com.android.camera.one.v2.commands;
185d4fb6accab3bcbe737d52747c328de5cc092d02Puneet Lall
195d4fb6accab3bcbe737d52747c328de5cc092d02Puneet Lallimport android.hardware.camera2.CameraAccessException;
205d4fb6accab3bcbe737d52747c328de5cc092d02Puneet Lall
219c94ab32a69a1ad3642a0f1e38e68bcfd97d3511Puneet Lallimport com.android.camera.one.v2.camera2proxy.CameraCaptureSessionClosedException;
2212f608f3d2089439a108788a1908941eea4277b9Puneet Lallimport com.android.camera.one.v2.core.ResourceAcquisitionFailedException;
239c94ab32a69a1ad3642a0f1e38e68bcfd97d3511Puneet Lall
245d4fb6accab3bcbe737d52747c328de5cc092d02Puneet Lall/**
2512f608f3d2089439a108788a1908941eea4277b9Puneet Lall * A generic camera command which may take an arbitrary, indefinite amount of
2612f608f3d2089439a108788a1908941eea4277b9Puneet Lall * time to execute. Camera commands typically interact with the camera device,
2712f608f3d2089439a108788a1908941eea4277b9Puneet Lall * capture session, image reader, and other resources.
2812f608f3d2089439a108788a1908941eea4277b9Puneet Lall * <p>
2912f608f3d2089439a108788a1908941eea4277b9Puneet Lall * When shutting down, it is critical that commands gracefully exit when these
3012f608f3d2089439a108788a1908941eea4277b9Puneet Lall * resources are no longer available.
315d4fb6accab3bcbe737d52747c328de5cc092d02Puneet Lall */
325d4fb6accab3bcbe737d52747c328de5cc092d02Puneet Lallpublic interface CameraCommand {
339c94ab32a69a1ad3642a0f1e38e68bcfd97d3511Puneet Lall    /**
349c94ab32a69a1ad3642a0f1e38e68bcfd97d3511Puneet Lall     * @throws InterruptedException If interrupted while executing the command.
359c94ab32a69a1ad3642a0f1e38e68bcfd97d3511Puneet Lall     * @throws CameraAccessException If the camera is not available when
369c94ab32a69a1ad3642a0f1e38e68bcfd97d3511Puneet Lall     *             accessed by the command.
3712f608f3d2089439a108788a1908941eea4277b9Puneet Lall     * @throws CameraCaptureSessionClosedException If the capture session was
3812f608f3d2089439a108788a1908941eea4277b9Puneet Lall     *             closed and not available when accessed by the command.
3912f608f3d2089439a108788a1908941eea4277b9Puneet Lall     * @throws ResourceAcquisitionFailedException If various non-camera
4012f608f3d2089439a108788a1908941eea4277b9Puneet Lall     *             resources required for the command to execute could not be
4112f608f3d2089439a108788a1908941eea4277b9Puneet Lall     *             acquired, either because they do not exist, or things are
4212f608f3d2089439a108788a1908941eea4277b9Puneet Lall     *             being shut down. For example, a command may throw this if it
4312f608f3d2089439a108788a1908941eea4277b9Puneet Lall     *             failed to allocate logical space in a shared image reader
4412f608f3d2089439a108788a1908941eea4277b9Puneet Lall     *             because the image reader is being closed, or because the
4512f608f3d2089439a108788a1908941eea4277b9Puneet Lall     *             requested space was greater than the capacity of the image
4612f608f3d2089439a108788a1908941eea4277b9Puneet Lall     *             reader.
479c94ab32a69a1ad3642a0f1e38e68bcfd97d3511Puneet Lall     */
489c94ab32a69a1ad3642a0f1e38e68bcfd97d3511Puneet Lall    public void run() throws InterruptedException, CameraAccessException,
4912f608f3d2089439a108788a1908941eea4277b9Puneet Lall            CameraCaptureSessionClosedException, ResourceAcquisitionFailedException;
505d4fb6accab3bcbe737d52747c328de5cc092d02Puneet Lall}
51