• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 package android.hardware.camera2.marshal.impl;
17 
18 import android.hardware.camera2.marshal.Marshaler;
19 import android.hardware.camera2.marshal.MarshalQueryable;
20 import android.hardware.camera2.params.HighSpeedVideoConfiguration;
21 import android.hardware.camera2.utils.TypeReference;
22 
23 import static android.hardware.camera2.impl.CameraMetadataNative.*;
24 import static android.hardware.camera2.marshal.MarshalHelpers.*;
25 
26 import java.nio.ByteBuffer;
27 
28 /**
29  * Marshaler for {@code android.control.availableHighSpeedVideoConfigurations} custom class
30  * {@link HighSpeedVideoConfiguration}
31  *
32  * <p>Data is stored as {@code (width, height, fpsMin, fpsMax)} tuples (int32).</p>
33  */
34 public class MarshalQueryableHighSpeedVideoConfiguration
35         implements MarshalQueryable<HighSpeedVideoConfiguration> {
36     private static final int SIZE = SIZEOF_INT32 * 5;
37 
38     private class MarshalerHighSpeedVideoConfiguration
39             extends Marshaler<HighSpeedVideoConfiguration> {
MarshalerHighSpeedVideoConfiguration( TypeReference<HighSpeedVideoConfiguration> typeReference, int nativeType)40         protected MarshalerHighSpeedVideoConfiguration(
41                 TypeReference<HighSpeedVideoConfiguration> typeReference,
42                 int nativeType) {
43             super(MarshalQueryableHighSpeedVideoConfiguration.this, typeReference, nativeType);
44         }
45 
46         @Override
marshal(HighSpeedVideoConfiguration value, ByteBuffer buffer)47         public void marshal(HighSpeedVideoConfiguration value, ByteBuffer buffer) {
48             buffer.putInt(value.getWidth());
49             buffer.putInt(value.getHeight());
50             buffer.putInt(value.getFpsMin());
51             buffer.putInt(value.getFpsMax());
52             buffer.putInt(value.getBatchSizeMax());
53         }
54 
55         @Override
unmarshal(ByteBuffer buffer)56         public HighSpeedVideoConfiguration unmarshal(ByteBuffer buffer) {
57             int width = buffer.getInt();
58             int height = buffer.getInt();
59             int fpsMin = buffer.getInt();
60             int fpsMax = buffer.getInt();
61             int batchSizeMax = buffer.getInt();
62 
63             return new HighSpeedVideoConfiguration(width, height, fpsMin, fpsMax, batchSizeMax);
64         }
65 
66         @Override
getNativeSize()67         public int getNativeSize() {
68             return SIZE;
69         }
70 
71     }
72 
73     @Override
createMarshaler( TypeReference<HighSpeedVideoConfiguration> managedType, int nativeType)74     public Marshaler<HighSpeedVideoConfiguration> createMarshaler(
75             TypeReference<HighSpeedVideoConfiguration> managedType, int nativeType) {
76         return new MarshalerHighSpeedVideoConfiguration(managedType, nativeType);
77     }
78 
79     @Override
isTypeMappingSupported(TypeReference<HighSpeedVideoConfiguration> managedType, int nativeType)80     public boolean isTypeMappingSupported(TypeReference<HighSpeedVideoConfiguration> managedType,
81             int nativeType) {
82         return nativeType == TYPE_INT32 &&
83                 managedType.getType().equals(HighSpeedVideoConfiguration.class);
84     }
85 }
86