Home | History | Annotate | Download | only in camera2proxy
      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 com.android.camera.one.v2.camera2proxy;
     18 
     19 import android.hardware.camera2.CaptureRequest;
     20 import android.view.Surface;
     21 
     22 /**
     23  * Wraps {@link android.hardware.camera2.CaptureRequest.Builder} with a mockable
     24  * interface.
     25  */
     26 public class CaptureRequestBuilderProxy {
     27     private final CaptureRequest.Builder mBuilder;
     28 
     29     public CaptureRequestBuilderProxy(CaptureRequest.Builder builder) {
     30         mBuilder = builder;
     31     }
     32 
     33     /**
     34      * See {@link CaptureRequest.Builder#addTarget}.
     35      */
     36     public void addTarget(Surface outputTarget) {
     37         mBuilder.addTarget(outputTarget);
     38     }
     39 
     40     /**
     41      * See {@link CaptureRequest.Builder#build}.
     42      */
     43     public CaptureRequest build() {
     44         return mBuilder.build();
     45     }
     46 
     47     /**
     48      * See {@link CaptureRequest.Builder#get}.
     49      */
     50     public <T> T get(CaptureRequest.Key<T> key) throws IllegalArgumentException {
     51         return mBuilder.get(key);
     52     }
     53 
     54     /**
     55      * See {@link CaptureRequest.Builder#removeTarget}.
     56      */
     57     public void removeTarget(Surface outputTarget) {
     58         mBuilder.removeTarget(outputTarget);
     59     }
     60 
     61     /**
     62      * See {@link CaptureRequest.Builder#set}.
     63      */
     64     public <T> void set(CaptureRequest.Key<T> key, T value) {
     65         mBuilder.set(key, value);
     66     }
     67 
     68     /**
     69      * See {@link CaptureRequest.Builder#setTag}.
     70      */
     71     public void setTag(Object tag) {
     72         mBuilder.setTag(tag);
     73     }
     74 }
     75