BurstHolder.java revision 0fd198ad89ec9c600bb1761b10d938146c28bb98
1/* 2 * Copyright (C) 2014 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.camera2.legacy; 18 19import android.hardware.camera2.CaptureRequest; 20import android.hardware.camera2.impl.CameraMetadataNative; 21import android.util.Log; 22import android.view.Surface; 23 24import java.util.ArrayList; 25import java.util.Collection; 26import java.util.List; 27 28/** 29 * Immutable container for a burst of capture results. 30 */ 31public class BurstHolder { 32 private static final String TAG = "BurstHolder"; 33 private final ArrayList<RequestHolder.Builder> mRequestBuilders; 34 private final boolean mRepeating; 35 private final int mRequestId; 36 37 /** 38 * Immutable container for a burst of capture results. 39 * 40 * @param requestId id of the burst request. 41 * @param repeating true if this burst is repeating. 42 * @param requests a {@link List} of {@link CaptureRequest}s in this burst. 43 * @param jpegSurfaceIds a {@link Collection} of IDs for the surfaces that have jpeg outputs. 44 */ 45 public BurstHolder(int requestId, boolean repeating, List<CaptureRequest> requests, 46 Collection<Long> jpegSurfaceIds) { 47 mRequestBuilders = new ArrayList<>(); 48 int i = 0; 49 for (CaptureRequest r : requests) { 50 mRequestBuilders.add(new RequestHolder.Builder(requestId, /*subsequenceId*/i, 51 /*request*/r, repeating, jpegSurfaceIds)); 52 ++i; 53 } 54 mRepeating = repeating; 55 mRequestId = requestId; 56 } 57 58 /** 59 * Get the id of this request. 60 */ 61 public int getRequestId() { 62 return mRequestId; 63 } 64 65 /** 66 * Return true if this repeating. 67 */ 68 public boolean isRepeating() { 69 return mRepeating; 70 } 71 72 /** 73 * Return the number of requests in this burst sequence. 74 */ 75 public int getNumberOfRequests() { 76 return mRequestBuilders.size(); 77 } 78 79 /** 80 * Create a list of {@link RequestHolder} objects encapsulating the requests in this burst. 81 * 82 * @param frameNumber the starting framenumber for this burst. 83 * @return the list of {@link RequestHolder} objects. 84 */ 85 public List<RequestHolder> produceRequestHolders(long frameNumber) { 86 ArrayList<RequestHolder> holders = new ArrayList<RequestHolder>(); 87 int i = 0; 88 for (RequestHolder.Builder b : mRequestBuilders) { 89 holders.add(b.build(frameNumber + i)); 90 ++i; 91 } 92 return holders; 93 } 94} 95