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