1/*
2 * Copyright (C) 2015 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 */
16package android.hardware.camera2.utils;
17
18import android.os.Parcel;
19import android.os.Parcelable;
20import android.hardware.camera2.ICameraDeviceUser;
21
22/**
23 * The status information returned for a successful capture request submission.
24 *
25 * Includes the request ID for the newly submitted capture request, and the
26 * last frame number of either the previous repeating request (for repeating
27 * requests), or of the request(s) just submitted (for single-shot capture).
28 *
29 * @hide
30 */
31public class SubmitInfo implements Parcelable {
32
33    private int mRequestId;
34    private long mLastFrameNumber;
35
36    public SubmitInfo() {
37        mRequestId = -1;
38        mLastFrameNumber = ICameraDeviceUser.NO_IN_FLIGHT_REPEATING_FRAMES;
39    }
40
41    public SubmitInfo(int requestId, long lastFrameNumber) {
42        mRequestId = requestId;
43        mLastFrameNumber = lastFrameNumber;
44    }
45
46    public static final Parcelable.Creator<SubmitInfo> CREATOR =
47            new Parcelable.Creator<SubmitInfo>() {
48        @Override
49        public SubmitInfo createFromParcel(Parcel in) {
50            return new SubmitInfo(in);
51        }
52
53        @Override
54        public SubmitInfo[] newArray(int size) {
55            return new SubmitInfo[size];
56        }
57    };
58
59    private SubmitInfo(Parcel in) {
60        readFromParcel(in);
61    }
62
63    @Override
64    public int describeContents() {
65        return 0;
66    }
67
68    @Override
69    public void writeToParcel(Parcel dest, int flags) {
70        dest.writeInt(mRequestId);
71        dest.writeLong(mLastFrameNumber);
72    }
73
74    public void readFromParcel(Parcel in) {
75        mRequestId = in.readInt();
76        mLastFrameNumber = in.readLong();
77    }
78
79    /**
80     * Return the request ID for the submitted capture request/burst.
81     *
82     * This is used to track the completion status of the requested captures,
83     * and to cancel repeating requests.
84     */
85    public int getRequestId() {
86        return mRequestId;
87    }
88
89    /**
90     * Return the last frame number for the submitted capture request/burst.
91     *
92     * For a repeating request, this is the last frame number of the _prior_
93     * repeating request, to indicate when to fire the sequence completion callback
94     * for the prior repeating request.
95     *
96     * For a single-shot capture, this is the last frame number of _this_
97     * burst, to indicate when to fire the sequence completion callback for the request itself.
98     *
99     * For a repeating request, may be NO_IN_FLIGHT_REPEATING_FRAMES, if no
100     * instances of a prior repeating request were actually issued to the camera device.
101     */
102    public long getLastFrameNumber() {
103        return mLastFrameNumber;
104    }
105
106}
107