4package org.qtproject.qt.android.multimedia;
6import android.annotation.TargetApi;
7import android.content.Context;
8import android.graphics.ImageFormat;
9import android.graphics.Rect;
10import android.hardware.camera2.CameraCharacteristics;
11import android.hardware.camera2.CameraManager;
12import android.hardware.camera2.CaptureRequest;
13import android.hardware.camera2.params.StreamConfigurationMap;
14import android.media.MediaCodecList;
15import android.media.MediaCodecInfo;
16import android.util.Range;
17import android.util.Size;
18import android.util.Log;
20import java.lang.String;
21import java.util.ArrayList;
22import java.util.HashSet;
25import java.util.WeakHashMap;
29 CameraManager mCameraManager;
30 Map<String, CameraCharacteristics> cache;
33 mCameraManager = (CameraManager)
context.getSystemService(Context.CAMERA_SERVICE);
34 cache =
new WeakHashMap<String, CameraCharacteristics>();
39 if (
cache.containsKey(cameraId))
40 return cache.get(cameraId);
43 CameraCharacteristics cameraCharacteristics = mCameraManager.getCameraCharacteristics(cameraId);
44 cache.put(cameraId, cameraCharacteristics);
45 return cameraCharacteristics;
46 }
catch (Exception e) {
52 static private boolean isSoftwareCodec(String longCodecName) {
53 longCodecName = longCodecName.toLowerCase();
54 return longCodecName.startsWith(
"omx.google.") || longCodecName.startsWith(
"c2.android.")
55 || !(longCodecName.startsWith(
"omx.") || longCodecName.startsWith(
"c2."));
62 static private String[] getHWVideoCodecs(
CODEC expectedType) {
63 MediaCodecList mediaCodecList =
new MediaCodecList(MediaCodecList.REGULAR_CODECS);
64 MediaCodecInfo[] mediaCodecInfo = mediaCodecList.getCodecInfos();
65 Set<String> codecs =
new HashSet<String>();
67 for (MediaCodecInfo codecInfo : mediaCodecInfo) {
69 if (currentType == expectedType && !isSoftwareCodec(codecInfo.getName())) {
70 String[] supportedTypes = codecInfo.getSupportedTypes();
71 for (String
type : supportedTypes) {
72 if (
type.startsWith(
"video/"))
73 codecs.add(
type.substring(6));
77 return codecs.toArray(
new String[codecs.size()]);
85 return mCameraManager.getCameraIdList();
86 }
catch (Exception e) {
94 if (characteristics ==
null)
96 return characteristics.get(CameraCharacteristics.SENSOR_ORIENTATION);
101 if (characteristics ==
null)
103 return characteristics.get(CameraCharacteristics.LENS_FACING);
109 if (characteristics ==
null)
110 return new String[0];
112 Range<Integer>[] ranges = characteristics.get(CameraCharacteristics.CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES);
114 String[] fps =
new String[ranges.length];
125 float maxZoom = 1.0f;
127 if (characteristics !=
null)
128 maxZoom = characteristics.get(CameraCharacteristics.SCALER_AVAILABLE_MAX_DIGITAL_ZOOM);
133 Rect activeArraySize =
new Rect();
135 if (characteristics !=
null)
136 activeArraySize = characteristics.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE);
137 return activeArraySize;
140 static final int maxResolution = 3840*2160;
144 if (characteristics ==
null)
145 return new String[0];
147 StreamConfigurationMap
map = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
148 Size[]
sizes =
map.getOutputSizes(imageFormat);
150 return new String[0];
152 ArrayList<String>
stream =
new ArrayList<>();
159 return stream.toArray(
new String[0]);
165 return CaptureRequest.CONTROL_AE_MODE_ON;
167 return CaptureRequest.CONTROL_AE_MODE_ON_AUTO_FLASH;
169 return CaptureRequest.CONTROL_AE_MODE_ON_ALWAYS_FLASH;
171 return CaptureRequest.CONTROL_AE_MODE_ON_AUTO_FLASH_REDEYE;
173 return CaptureRequest.CONTROL_AE_MODE_ON_EXTERNAL_FLASH;
181 case CaptureRequest.CONTROL_AE_MODE_ON:
183 case CaptureRequest.CONTROL_AE_MODE_ON_AUTO_FLASH:
185 case CaptureRequest.CONTROL_AE_MODE_ON_ALWAYS_FLASH:
187 case CaptureRequest.CONTROL_AE_MODE_ON_AUTO_FLASH_REDEYE:
189 case CaptureRequest.CONTROL_AE_MODE_ON_EXTERNAL_FLASH:
191 case CaptureRequest.CONTROL_AE_MODE_OFF:
200 if (characteristics ==
null)
203 return characteristics.get(CameraCharacteristics.CONTROL_AF_AVAILABLE_MODES);
209 if (characteristics ==
null)
210 return new String[0];
212 int supportedFlashModes[] = characteristics.get(CameraCharacteristics.CONTROL_AE_AVAILABLE_MODES);
213 ArrayList<String> supportedFlashModesList =
new ArrayList<String>();
218 String[]
ret =
new String[ supportedFlashModesList.size() ];
219 return supportedFlashModesList.toArray(
ret);
225 if (characteristics !=
null)
226 ret = characteristics.get(CameraCharacteristics.FLASH_INFO_AVAILABLE);
QMap< QString, QString > map
[6]
QCache< int, Employee > cache
[0]
GLuint GLsizei const GLuint const GLintptr const GLsizeiptr * sizes
char * toString(const MyType &t)
[31]